[英]newdata when plotting survival curve of a cox regression in r
我試圖通過在使用變量交互時繪制 cox 回歸來繪制調整后的生存曲線。
閱讀 survfit.coxph 頁面https://stat.ethz.ch/R-manual/R-devel/library/survival/html/survfit.coxph.html
我看到參數“newdata”
newdata
a data frame with the same variable names as those that appear in the coxph formula. It is also valid to use a vector, if the data frame would consist of a single row.
The curve(s) produced will be representative of a cohort whose covariates correspond to the values in newdata. Default is the mean of the covariates used in the coxph fit.
我想在我的 cox 輸出中繪制交互的線條。 即如果我的 cox 輸出看起來像:
coef exp(coef) se(coef) z p
Drug2 -0.1345 0.876 0.1812 -0.732 4.5e-01
Drug3 -0.3678 0.719 0.0816 -3.966 7.2e-05
Drug4 0.0468 1.063 0.0432 0.932 3.4e-01
Sex 0.2574 1.294 0.0786 3.133 1.2e-03
Sex:Drug2 -0.1283 0.880 0.1809 -0.709 4.8e-01
Sex:Drug3 -0.3226 0.724 0.0817 -3.950 7.8e-05
Sex:Drug4 0.0524 1.054 0.0574 0.913 3.6e-01
我想在與Sex
交互后為我的 Drug 變量繪制新的生存曲線。
這讓我newdata
了這個newdata
參數。
與調用 newdata 相比,不包括 newdata 和僅使用協變量的平均值有什么區別? 在這一點上,我什至不知道如何正確構建 newdata。
如果任何人都可以給我我如何去建立任何指針newdata
根據我的Cox模型,什么是它的意義相比,只是利用平均值。 在根據 cox 數據繪制這個新的生存圖時,我應該期待我的原始生存曲線中有相同數量的線。
您仍然將調整后的平均生存作為隱式“基線生存曲線”,但基於新數據的曲線的風險比將從 1.0 偏移 exp(coef) 的一個因子。 您輸入代表您想要估計的特征的值,並且expand.grid
函數將創建協變量的所有 2way 組合。 不清楚您是如何對 Sex 建模的,但從輸出看來,它是一個數字而不是一個因子,我假設存在一個單位差異。 嘗試:
plot( survfit( my.fit, newdata=expand.grid(Sex=c(1,2), drug=factor(1:4) ) ) )
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.