[英]How to get the 95% confidence interval in R?
I would like to find the 95% CI for the MLE for my parameter in a function but I have no idea how. 我想在一个函数中为我的参数找到MLE的95%CI,但我不知道如何。
The given function is a power-law distribution with 给定的函数是幂律分布
f(x)=Cx^(-mu), F(X)= CX ^( - 亩),
I calculated the MLE for mu using the bbmle package in R. 我用R中的bbmle包计算了mu的MLE。
Some people on the internet say use profile likelihood to do it but I am not sure how to in R, or other methods which lead to the same results are fine too. 互联网上的一些人说使用配置文件可能性这样做但我不确定如何在R中,或者导致相同结果的其他方法也很好。
Much appreciate and thanks in advance! 非常感谢并提前感谢!
Update: 更新:
load("fakedata500.Rda")
> library(stats4)
> library(bbmle)
> x<-fakedata500
> pl <- function(u){-length(x)*log(u-1)-length(x)*(u-1)*log(min(x))+u*sum(log(x))}
mle1<-mle2(pl, start=list(u=2), data=list(x))
> summary(mle1)
Maximum likelihood estimation
Call:
mle2(minuslogl = pl, start = list(u = 2), data = list(x))
Coefficients:
Estimate Std. Error z value Pr(z)
u 2.00510 0.04495 44.608 < 2.2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
-2 log L: 1300.166
So the estimated mu is 2.00510 and I would like to get the 95% CI of it, it might look nonsense since my started mu was 2 so 2.00510 is very close to it, but I am going to apply this method to other data sets too which I havn't come across yet so really hope to find a way to do it. 所以估计的mu是2.00510,我想获得它的95%CI,它可能看起来无意义,因为我的开始mu是2所以2.00510非常接近它,但我也将这个方法应用于其他数据集我没有遇到过,所以真的希望找到一种方法来做到这一点。
(Converted from a comment.) (从评论转换而来。)
If you're using mle2
from the bbmle
package you should just be able to say confint(mle1)
to get the 95% profile confidence intervals. 如果您正在使用mle2
包中的bbmle
您应该只能说confint(mle1)
来获得95%的配置文件置信区间。 See ?confint.mle2
, or try vignette("mle2",package="bbmle")
and search for "confint" for more information. 请参阅?confint.mle2
,或尝试使用vignette("mle2",package="bbmle")
并搜索“confint”以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.