簡體   English   中英

預測R中Survreg中的功能

[英]Predict function in survreg in r

我在生存分析中有這個模型:

full_model_lognormal <- survreg(Surv(DF$TimeDeath, DF$event) ~ age + sex + mutation +BM1 + BM2, data = DF,
                             dist = "lognormal")

我需要計算一名51歲,無基因突變的男性患者的預期失敗時間,對於BM1,他的值為3.7 mg / dL,對於BM2,他的值為251 mg / dL。

我需要使用預測函數來做,有幫助嗎?

這個問題確實是重復的: 在R中的生存分析中找到對數正態分布的均值

但不能將其標記為這樣,因為答案(我的答案)沒有投票或復選標記:

lfit <- survreg(Surv(time, status) ~ ph.ecog, data=lung)
pct <- 1:98/100   # The 100th percentile of predicted survival is at +infinity
ptime <- predict(lfit, newdata=data.frame(ph.ecog=2), type='quantile',
                 p=pct, se=TRUE)
matplot(cbind(ptime$fit, ptime$fit + 2*ptime$se.fit,
                          ptime$fit - 2*ptime$se.fit)/30.5, 1-pct,
         xlab="Months", ylab="Survival", type='l', lty=c(1,2,2), col=1)
 # The plot should be examined since you asked for a median survival time
 abline(h= 0.5)
 # You can  drop a vertical from the intersection to get that graphically 
.... or ...
 str(ptime)
List of 2
 $ fit   : num [1:98] 9.77 16.35 22.13 27.46 32.49 ...
 $ se.fit: num [1:98] 2.39 3.53 4.42 5.16 5.82 ...

您可以使用以下方法從該生存時間序列中提取第50個百分位數(即中位生存期):

ptime$fit[which((1-pct)==0.5)]
# [1] 221.6023   

如果您想獲取平均時間,則您不希望使用“第100個分位數”,因為它是Infinity。 我想,您可以計算0.1-0.99分位數的平均值,然后除以0.99。

為了預測響應,您可以執行以下操作:

require(survival)
fit <- survreg(Surv(time,status) ~ age + I(age^2), data=stanford2, 
               dist='lognormal') 
pred <- predict(fit, newdata=list(age=1:65), type='quantile', 
                p=c(.1, .5, .9))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM