Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 该代码是否提供了置信区间?95%_R_Glm_Confidence Interval - Fatal编程技术网

R 该代码是否提供了置信区间?95%

R 该代码是否提供了置信区间?95%,r,glm,confidence-interval,R,Glm,Confidence Interval,我正在进行逻辑回归,并希望确保我获得95%的自信间隔。代码: # Dissable scientific notation. # From: stackoverflow.com/questions/25946047 options(scipen=999) ############################################################################### OR_CI_round_number<-5 # How many

我正在进行逻辑回归,并希望确保我获得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)

我问这个问题的原因是因为我得到了
rr2.5%97.5%
。据我所知,它们表示95%置信区间的上下限。这是否正确?

是的,正确,这是您的边界,2.5%的左侧区域和97.5%的右侧区域是显著性水平

还请编辑以仅包含相关软件包。对于
读取dta
,似乎只需要一个。不需要先下载软件包。请参阅
帮助(confint)
。若要回答此问题,请选择“是”,默认值为95%(显示在“帮助”页面中)
> 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