Maximum likelihood estimate
I. Introduction
Maximum likelihood estimation is an important parameter estimation method of mathematical statistics, but solving the maximum likelihood likelihood function is sometimes very difficult, in the article entitled to a maximum likelihood as an example. To show one yuan to solve the great problems of the likelihood function, and finally attach the code and explain.
Second, the title and deduced
Examples: a life of electronic components (unit: hour) Weibull distribution, the distribution of the probability density function is:
among them
>0,
> 0. Granted the
= 2.5, which has a capacity of 101 sample size is as follows:
97.73,152.86,148.27,86.81,166.78,79.66,95.01,22.24,52.66,150.02
unknown parameters
maximum likelihood estimation.
Answer: Write the title of the log-likelihood function
This problem becomes a matter of maximum points below this function.
The following self with R language function to solve this problem.
Three, R language to solve
Results of operations
# 读入数据
data = c(96.73, 152.86, 148.27, 86.81, 166.78, 79.66,
95.01, 22.24, 52.66, 150.02)
# 自编函数
MLE <- function(a = 2.5, data){
fun <- function(b){
-10*a*log(b)-sum(data)/(b^a)
}
optim(50, fun, method = "CG")$par
}
# 函数调用
> MLE(a = 2.5, data = data)
[1] 86.30949
The end result is 86.309
optim function introduction
This function title is too long, just put the parameters section. Detailed usage reference optim function help documentation.
function (par, fn, gr = NULL, ..., method = c("Nelder-Mead",
"BFGS", "CG", "L-BFGS-B", "SANN",
"Brent"), lower = -Inf, upper = Inf, control = list(),
hessian = FALSE)
Just say here that a parameter method
, usually selected "BFGS", "CG" in two ways.