简体   繁体   English

如何获得R中的95%置信区间?

[英]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.

相关问题 在R中使用glm(..)获得95%的置信区间 - Get 95% confidence interval with glm(..) in R 如何计算 R 中某个比例的 95% 置信区间? - How to calculate 95% confidence interval for a proportion in R? 如何使用方程式中的95%置信区间在r中使用95%置信区间? - How do I use the 95% confidence interval in r using the equation for a 95% confidence interval? 如何计算R中线性回归模型中斜率的95%置信区间 - How to calculate the 95% confidence interval for the slope in a linear regression model in R 如何获得 ROC 准确率的 95% 置信区间? - How to obtain the 95% confidence interval of accuracy of ROC ? 如何在 R 求和后得到置信区间? - How to get the confidence interval after sum in R? 如何使用R获得函数的置信区间 - How to get the confidence interval for a function using R R如何获得多项logit的置信区间? - R How to get confidence interval for multinominal logit? 如何计算使用 R 中的 CARET 训练的模型的 95% 置信区间? - How to calculate the 95% confidence interval from a model trained using CARET in R? 我怎样才能 plot 我的 LMM 的截距和系数与 R 中的意大利面条图相比具有 95% 的置信区间? - How can I plot the intercept and coefficient of my LMM with 95% confidence interval over spagetti plots in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM