[英]How to combine hazard ratios and confidence intervals from Cox regression analyses in R
我進行了Cox回歸分析,包括四個變量(性別,年齡和兩個二元解釋變量),這些變量均與結果密切相關。 我使用了R中“生存”包中的coxph函數:
library(survival)
cox <- coxph(Surv(time, status_risk==1) ~ sex + age + stone_number +stone_size, data=cox_cut)
summary(cox1_3_cut)
Call:
coxph(formula = Surv(time, status_risk == 1) ~ sex + age +
stone_number + stone_size, data = cox_cut)
n= 582, number of events= 48
(82 observations deleted due to missingness)
coef exp(coef) se(coef) z Pr(>|z|)
sexfemale 0.76993 2.15961 0.34577 2.227 0.025966 *
age -0.03222 0.96829 0.01201 -2.682 0.007311 **
stone_number>=2 0.60646 1.83393 0.29942 2.025 0.042821 *
stone_size>10 1.02593 2.78969 0.29391 3.491 0.000482 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
exp(coef) exp(-coef) lower .95 upper .95
sexfemale 2.1596 0.4630 1.0966 4.2530
age 0.9683 1.0327 0.9458 0.9914
stone_number>=2 1.8339 0.5453 1.0198 3.2980
stone_size>10 2.7897 0.3585 1.5681 4.9629
我想制作一個預測評分表,其中包含四個變量,每個變量具有4個年齡分層的組(30、40、50、60歲)。 為了獲得每個年齡組的HR,此表中的所有危險都必須除以一個預定義的危險。
對於R中的每個特定年齡組,如何使用95%CI來計算HR?
根據@shadow的評論,參數估計值的配置項基於整個數據集,如果您希望使用年齡條件配置項,則需要對數據進行子集化。 相反,如果您要生成以一組協變量(包括年齡)為條件的預期生存曲線,則應采用以下方法:
# Create a dummy dataset
df <- data.frame(sex = sample(c(T,F),100,T),
age = 50 + rnorm(100)*10,
foo = sample(c('a','b','c'),100,T),
bar = sample(c('x','y','z'),100,T),
status = sample(c(T,F),100,T),
start = 0,# required for the survfit with `individual = TRUE`
time = -log(runif(100)))
# fit the A coxph model in your full dataset data
cox <- coxph(Surv(start,time, status) ~ sex + age + foo + bar, data=df)
# create a data.frame with all the variables used in the formula
newData <- data.frame(sex = T,
age = 55,
foo = sample(c('a','b','c'),1),
bar = sample(c('x','y','z'),1),
status = T,# required but unused
start = 0,# required but unused
time = 1)# required but unused
# get a prediction from the fitted model, specifiying 'individual = TRUE'
pred <- survfit(cox, newdata=data.frame(newData),individual =TRUE)
# plot the survival curves
matplot(x = cbind(pred$"time"),
y = cbind(pred$surv,
pred$upper,
pred$lower),
type = 'l',
lty= c(1,2,2),
main = 'Predicted Survial with 95% CI')
您也可以檢查unclass(pred)
和summary(pred)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.