[英]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% 置信區間? 我的目的是輸出 plot,y 軸是 OR(95%CI),x 軸是我數據中值的十分位數誰能告訴我如何在 R 中計算這個值? 這是該圖的示例。 在此處輸入圖像描述
我沒有您的數據,所以我無法為您獲取正確的 model。 訣竅是使預測變量序數,並使用它來回歸您的響應變量。 之后,您只需 plot 每個組的 CI,並在需要時加入行。 下面我使用了一個示例數據集,如果你使用相同的步驟,你應該得到下面的 plot:
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")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.