简体   繁体   English

绘制 r 中 cox 回归的生存曲线时的新数据

[英]newdata when plotting survival curve of a cox regression in r

I am trying to plot an adjusted survival curve by plotting a cox regression when using variable interactions.我试图通过在使用变量交互时绘制 cox 回归来绘制调整后的生存曲线。

reading the survfit.coxph page https://stat.ethz.ch/R-manual/R-devel/library/survival/html/survfit.coxph.html I see the parameter "newdata"阅读 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.

Where I want to plot lines in my cox output that are interactions.我想在我的 cox 输出中绘制交互的线条。 Ie if my cox output looks like:即如果我的 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

I want to plot the new survival curves for my Drug variable after interaction with Sex .我想在与Sex交互后为我的 Drug 变量绘制新的生存曲线。

Which leads me to this newdata parameter.这让我newdata了这个newdata参数。

What is the difference in not including newdata and just using the mean of the covariates, compared to calling newdata.与调用 newdata 相比,不包括 newdata 和仅使用协变量的平均值有什么区别? At this point I don't even know how to build newdata correctly.在这一点上,我什至不知道如何正确构建 newdata。

If anyone can give me any pointers on how I would build newdata based on my cox model, and what is it's significance compared to just using the mean.如果任何人都可以给我我如何去建立任何指针newdata根据我的Cox模型,什么是它的意义相比,只是利用平均值。 I should be expecting the same amount of lines in my original survival curve when plotting this new survival plot based of the cox data.在根据 cox 数据绘制这个新的生存图时,我应该期待我的原始生存曲线中有相同数量的线。

You will still have the adjusted mean survival as the implicit "baseline survival curve" but the curves based on newdata will have their hazard ratios offset from 1.0 by a factor of exp(coef).您仍然将调整后的平均生存作为隐式“基线生存曲线”,但基于新数据的曲线的风险比将从 1.0 偏移 exp(coef) 的一个因子。 You put in values that represent features for which you want estimates, and the expand.grid function will create all the 2way combinations of covariates.您输入代表您想要估计的特征的值,并且expand.grid函数将创建协变量的所有 2way 组合。 It's not clear how you have Sex modeled but it appears from the output that it is as a numeric rather than a factor and I will assume that there is a one unit difference.不清楚您是如何对 Sex 建模的,但从输出看来,它是一个数字而不是一个因子,我假设存在一个单位差异。 Try:尝试:

plot( survfit( my.fit, newdata=expand.grid(Sex=c(1,2), drug=factor(1:4) ) ) )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM