繁体   English   中英

此代码是否给我置信区间? 95%

[英]Does this code gives me confidence intervals? 95%

我正在运行逻辑回归,并希望确保获得95%的置信区间。 码:

# Dissable scientific notation. 
# From: stackoverflow.com/questions/25946047
options(scipen=999)



###############################################################################


OR_CI_round_number<-5  # How many decimal point to keep after rounding OR and CI.


dfAPI <- haven::read_dta(
  file = "https://stats.idre.ucla.edu/stat/stata/faq/eyestudy.dta") 


dfAPI$carrot<-factor(dfAPI$carrot)
dfAPI$carrot<-relevel(dfAPI$carrot, ref = "1")


glmAPI = glm(lenses ~ carrot, data= dfAPI, family=(binomial(link = "log")))
#glmAPI
#summary(glmAPI)
round(exp(cbind(RR = coef(glmAPI), confint(glmAPI))), OR_CI_round_number)
round(exp(cbind(RR = coef(glmAPI), confint(glmAPI, level = 0.95))), OR_CI_round_number)

结果:

> round(exp(cbind(RR = coef(glmAPI), confint(glmAPI, level = 0.95))), OR_CI_round_number)
Waiting for profiling to be done...
                 RR   2.5 %  97.5 %
(Intercept) 0.41176 0.28349 0.54870
carrot0     1.58601 1.09250 2.40172

> round(exp(cbind(RR = coef(glmAPI), confint(glmAPI))), OR_CI_round_number)
Waiting for profiling to be done...
                 RR   2.5 %  97.5 %
(Intercept) 0.41176 0.28349 0.54870
carrot0     1.58601 1.09250 2.40172

我问的原因是因为我的RR 2.5 % 97.5 % 据我了解,它们表示置信区间为95%的上下边界。 这个对吗?

是的,正确,这些是您的边界,并且显着性水平在2.5%左侧和97.5%右侧都是区域。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM