如何计算十分位数的优势比和 95% 置信区间

How to calculate Odds ratio and 95% confidence interval for decile

我做过逻辑回归,部分结果如下

 Coefficients:
                                Estimate Std. Error z value Pr(>|z|)                         
  (Intercept)                    -1.9056     0.4967  -3.837 0.000125 ***
  GWAS$value                     0.4474     0.1157   3.868 0.000110 ***

这是我用来做逻辑回归的数据。

  ID  Phenotype   value
1 128         0 1.510320
2 193         1 1.956477
3 067         0 2.038308
4 034         1 2.058739
5 159         0 2.066371
6 013         0 2.095866

我想知道如何计算值的十分位数的优势比和 95% 置信区间?我的目的是绘制一个图,y 轴是 OR(95%CI),x 轴是我数据中值的十分位数 谁能告诉我如何在 R 中计算这个值? 这是图中的例子。 enter image description here

我没有你的数据,所以我无法为你获得合适的模型。诀窍是使预测变量有序,并使用它来回归您的响应变量。之后,您只需绘制每个组的 CI ,并在需要时加入线条。下面我使用了一个示例数据集,如果你使用相同的步骤,你应该得到下面的图:

library(tidyverse)
ldata <- read.csv("https://stats.idre.ucla.edu/stat/data/binary.csv")
# we break gre column into quintiles
ldata <- ldata %>% mutate(GRE = cut_number(gre,5))

#regression like you did, calculate lor for all quintiles
fit <- glm(admit ~ 0+GRE,data=ldata,family="binomial")

# results like you have
results = coefficients(summary(fit))
# rename second column, SE for plotting
colnames(results)[2] = "SE"
#use ggplot
data.frame(results) %>% 
mutate(X=1:n()) %>%
ggplot(aes(x=X,y=Estimate)) + geom_point()+
geom_line() + 
# 95% interval is 1.96*SE
geom_errorbar(aes(ymin=-1.96*SE+Estimate,ymax=1.96*SE+Estimate),width=0.2)+
scale_x_continuous(label=rownames(results))+
xlab("GRE quintiles") +ylab("Log Odds Ratio")