我的工作是绘制函数的可能性。我是这个主题的新手,尤其是在R中。幸运的是,我收到了一些示例代码(针对不同的功能),并且尝试更改一些代码,看看是否可以获得一些结果。
This is the formula sheet for maximum likelihood estimation
这是我到目前为止的代码。
set.seed(4302019)
theta_true <- 2
n <- 30
U <- runif(n)
Y <- theta_true * U ^ (1 / 3)
y <- rbeta(n, U, Y)
theta <- seq(1.9, 2.1, length = 1000)
maxlike <- (theta_true + 1)^n + sum(y)^(theta_true)
plot(theta_true, maxlike, xlab = expression(theta_true),
ylab = expression(L(theta_true)), type = "l", lwd = 3)
theta_mome <- (2 * mean(y) - 1) / (1 - mean(y))
theta_mle <- -n / sum(y) - 1
abline(v = theta_mle, col = "red", lwd = 2)
abline(v = theta_mome, col = "blue", lwd = 2)
abline(v = theta_true, col = "black", lty = 2, lwd = 2)
What I get by running the code above
我应该获得一些具有不同颜色的线条,但是我看不到任何线条!任何帮助将不胜感激。