感谢所有帮助过的人。
- 我联系了我的教授,结果发现我不能将“bbmle”用于不可区分的分布。
- 在这种情况下,log(constant=1/ba) 不可微分以获得最大值。
- 还有另一个名为“ ExtDist ”的 R 包,它为所有分布(到目前为止对我来说,包括统一)输出 MLE 非常好,但不提供它们的标准错误,事实上“bbmle”确实如此
只是为了帮助将来可能偶然发现这篇文章的任何人:
正常,“bbmle”:
#Comparison of mentioned packages
#Example for normal distribution
set.seed(123)
library("bbmle")
x<-rnorm(100,1,3) #mean=1, sd = 3
n<-length(x)
ll<-function(a,b){
-sum(dnorm(x,a,b,log=TRUE))
}
m0<-mle2(ll,start=list(a=1,b=2))
summary(m0)
结果:
Maximum likelihood estimation
Call:
mle2(minuslogl = ll, start = list(a = 1, b = 2))
Coefficients:
Estimate Std. Error z value Pr(z)
a 1.27122 0.27247 4.6655 3.079e-06 ***
b 2.72473 0.19267 14.1421 < 2.2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
-2 log L: 484.2609
正常,“ExtDist”:
library("ExtDist")
m1<-eNormal(X=x,method = "unbiased.MLE")
m1
结果:
Parameters for the Normal distribution.
(found using the unbiased.MLE method.)
Parameter Type Estimate S.E.
mean location 1.271218 0.2738448
sd scale 2.738448 0.1946130
统一,“bbmle”:
#Example for uniform distribution
set.seed(123)
x<-runif(100,1,3) #minimum =1, maximum = 3
range(x) #To know beforehand the original minimum and maximum before the package estimates
[1] 1.00125 2.98854
n<-length(x)
ll<-function(a,b){
-sum(dunif(x,a,b,log=TRUE))
}
m3<-mle2(ll,start=list(a=1,b=2))
Error in optim(par = c(1, 2), fn = function (p) :
initial value in 'vmmin' is not finite
summary(m3)
错误信息:
Error in optim(par = c(1, 2), fn = function (p) :
initial value in 'vmmin' is not finite
统一,“ExtDist”:
m4<-eUniform(X=x,method = "unbiased.MLE")
m4
Parameters for the Uniform distribution.
(found using the numerical.MLE method.)
Parameter Type Estimate
a boundary 1.001245
b boundary 2.988544