我有這樣的模型在生存分析:預測功能survreg r中
full_model_lognormal <- survreg(Surv(DF$TimeDeath, DF$event) ~ age + sex + mutation +BM1 + BM2, data = DF,
dist = "lognormal")
我需要計算一個男病人誰51歲,沒有基因突變的預期故障時間,以及BM1他值爲3.7mg/dL,BM2爲251mg/dL。
我需要使用預測功能,任何幫助嗎?
我有這樣的模型在生存分析:預測功能survreg r中
full_model_lognormal <- survreg(Surv(DF$TimeDeath, DF$event) ~ age + sex + mutation +BM1 + BM2, data = DF,
dist = "lognormal")
我需要計算一個男病人誰51歲,沒有基因突變的預期故障時間,以及BM1他值爲3.7mg/dL,BM2爲251mg/dL。
我需要使用預測功能,任何幫助嗎?
這個問題確實是一個重複:Finding the mean of the log-normal distribution in survival analysis in R
,但不能將其標記爲這樣的,因爲答案(我)沒有upvotes或複選標記:
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分位數」,因爲它是無窮大。我想,你可以計算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))
謝謝你的回答,我在理論上知道如何使用預測模型,但不知道如何恰好符合我的問題 – user140734
謝謝你的反饋,它不是真的重複,因爲我不是要求資助中位數生存時間,但這些具體參數的生存時間。 – user140734
你沒有提供一個允許有用的插圖的數據對象,但是如果你有,我會告訴你如何使用'newdata = ...'參數來做你所要求的。 –