Logistic回归模型假设响应是伯努利试验(或更普遍的是二项式,但为简单起见,我们将其保持为0-1)。生存模型假设响应通常是事件发生的时间(同样,我们会跳过对此的概括)。另一种表达方式是,单位将通过一系列值,直到事件发生。并不是说硬币实际上在每个点上都是离散翻转的。(当然可能会发生这种情况,但随后您需要一个用于重复测量的模型-也许是GLMM。)
您的逻辑回归模型将每个死亡视为该年龄段发生的硬币翻转并出现尾巴。同样,它会将每个被检查的基准视为在指定年龄发生并向上旋转的单个硬币翻转。这里的问题是,这与实际数据不一致。
这是数据的一些图以及模型的输出。(请注意,我将对数回归模型中的预测值翻转为预测值,以便该线与条件密度图相匹配。)
library(survival)
data(lung)
s = with(lung, Surv(time=time, event=status-1))
summary(sm <- coxph(s~age, data=lung))
# Call:
# coxph(formula = s ~ age, data = lung)
#
# n= 228, number of events= 165
#
# coef exp(coef) se(coef) z Pr(>|z|)
# age 0.018720 1.018897 0.009199 2.035 0.0419 *
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# exp(coef) exp(-coef) lower .95 upper .95
# age 1.019 0.9815 1.001 1.037
#
# Concordance= 0.55 (se = 0.026 )
# Rsquare= 0.018 (max possible= 0.999 )
# Likelihood ratio test= 4.24 on 1 df, p=0.03946
# Wald test = 4.14 on 1 df, p=0.04185
# Score (logrank) test = 4.15 on 1 df, p=0.04154
lung$died = factor(ifelse(lung$status==2, "died", "alive"), levels=c("died","alive"))
summary(lrm <- glm(status-1~age, data=lung, family="binomial"))
# Call:
# glm(formula = status - 1 ~ age, family = "binomial", data = lung)
#
# Deviance Residuals:
# Min 1Q Median 3Q Max
# -1.8543 -1.3109 0.7169 0.8272 1.1097
#
# Coefficients:
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -1.30949 1.01743 -1.287 0.1981
# age 0.03677 0.01645 2.235 0.0254 *
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# (Dispersion parameter for binomial family taken to be 1)
#
# Null deviance: 268.78 on 227 degrees of freedom
# Residual deviance: 263.71 on 226 degrees of freedom
# AIC: 267.71
#
# Number of Fisher Scoring iterations: 4
windows()
plot(survfit(s~1))
windows()
par(mfrow=c(2,1))
with(lung, spineplot(age, as.factor(status)))
with(lung, cdplot(age, as.factor(status)))
lines(40:80, 1-predict(lrm, newdata=data.frame(age=40:80), type="response"),
col="red")
考虑数据适合生存分析或逻辑回归的情况可能会有所帮助。设想一项研究,以确定根据新的治疗方案或护理标准,出院后30天内将患者重新送入医院的可能性。但是,所有患者都被随访到再次入院,并且没有检查(这是不现实的),因此可以通过生存分析(即此处的Cox比例风险模型)来分析再次入院的确切时间。为了模拟这种情况,我将使用速率分别为.5和1的指数分布,并使用值1作为代表30天的临界值:
set.seed(0775) # this makes the example exactly reproducible
t1 = rexp(50, rate=.5)
t2 = rexp(50, rate=1)
d = data.frame(time=c(t1,t2),
group=rep(c("g1","g2"), each=50),
event=ifelse(c(t1,t2)<1, "yes", "no"))
windows()
plot(with(d, survfit(Surv(time)~group)), col=1:2, mark.time=TRUE)
legend("topright", legend=c("Group 1", "Group 2"), lty=1, col=1:2)
abline(v=1, col="gray")
with(d, table(event, group))
# group
# event g1 g2
# no 29 22
# yes 21 28
summary(glm(event~group, d, family=binomial))$coefficients
# Estimate Std. Error z value Pr(>|z|)
# (Intercept) -0.3227734 0.2865341 -1.126475 0.2599647
# groupg2 0.5639354 0.4040676 1.395646 0.1628210
summary(coxph(Surv(time)~group, d))$coefficients
# coef exp(coef) se(coef) z Pr(>|z|)
# groupg2 0.5841386 1.793445 0.2093571 2.790154 0.005268299
在这种情况下,我们看到,从逻辑回归模型的p值(0.163
)是不是从生存分析的p值较高(0.005
)。为了进一步探索这个想法,我们可以扩展仿真以估计逻辑回归分析与生存分析的能力,以及Cox模型的p值低于逻辑回归的p值的可能性。我还将使用1.4作为阈值,这样我就不会因使用次优截止值而不利于逻辑回归:
xs = seq(.1,5,.1)
xs[which.max(pexp(xs,1)-pexp(xs,.5))] # 1.4
set.seed(7458)
plr = vector(length=10000)
psv = vector(length=10000)
for(i in 1:10000){
t1 = rexp(50, rate=.5)
t2 = rexp(50, rate=1)
d = data.frame(time=c(t1,t2), group=rep(c("g1", "g2"), each=50),
event=ifelse(c(t1,t2)<1.4, "yes", "no"))
plr[i] = summary(glm(event~group, d, family=binomial))$coefficients[2,4]
psv[i] = summary(coxph(Surv(time)~group, d))$coefficients[1,5]
}
## estimated power:
mean(plr<.05) # [1] 0.753
mean(psv<.05) # [1] 0.9253
## probability that p-value from survival analysis < logistic regression:
mean(psv<plr) # [1] 0.8977
所以逻辑回归的功率是比存活分析(约93%)下(约75%),而90%来自存活分析的p值均大于从逻辑回归对应的p值低。考虑到滞后时间,而不是仅仅小于或大于某个阈值,确实会产生您所直觉的更多统计能力。