简体   繁体   English

使用R中的生存包在考克斯比例风险模型中实现非线性关系

[英]implementing a non-linear relationship within a cox proportional hazards model using the survival package in R

I am modeling tree mortality based on tree census data. 我正在根据树木普查数据对树木死亡率进行建模。 People go out at various intervals, and record whether trees lived or died. 人们以不同的时间间隔外出,并记录树木是否生死。 I am using the coxph function to run a cox proportional hazard model to analyze the probability of tree mortality as a function of several predictor variables. 我正在使用coxph函数来运行cox比例风险模型,以将树木死亡率作为几个预测变量的函数进行分析。 The code looks like: 代码如下:

 model <- coxph(S ~ x1 + x2 + x3, data = data)

However, one of my predictors, tree size, is actually expected to have a non-linear relationship with mortality probability. 但是,实际上我的预测因子之一是树的大小与死亡率的关系是非线性的。 Specifically, trees die a lot when they are small, the probability of death goes down as they reach a 'juvenile' stage and are an intermediate size, and then the mortality probability creeps back up as trees get older and larger in size. 具体来说,树木很小时会死亡很多,死亡的概率随着它们进入“少年”阶段而下降,并且处于中等大小,然后死亡概率随着树木的变大和变大而回升。 This creates a 'inverse J shaped' pattern between mortality probability and tree size. 这在死亡率概率和树木大小之间创建了“反J形”模式。 It looks like this: 看起来像这样: 树的大小与死亡率的关系

How can I incorporate this non-linear relationship into the coxph framework? 如何将这种非线性关系合并到coxph框架中? If this is not possible, how else can I analyze the mortality probability in the R environment, using a JAGS model or something else? 如果这不可能,那么我如何使用JAGS模型或其他方法分析R环境中的死亡率概率?

Try: 尝试:

library(mgcv)
fit <- gam(S ~ s(x1, bs = 'cr', k = 10) + s(x2, bs= 'cr', k = 10) +
           s(x3, bs = 'cr', k = 10), family = cox.ph(), data = data)

You can fit an additive Cox proportional hazards model , where all terms are non-linear splines. 您可以拟合加性Cox比例风险模型 ,其中所有项均为非线性样条曲线。 See ?cox.ph for extensive examples. 有关更多示例,请参见?cox.ph

If you have not used mgcv before, you may need to look at ?gam and ?s as well. 如果您以前没有使用过mgcv ,则可能还需要查看?gam?s After model fitting, summary.gam() , gam.check() and predict.gam() are your friends. 拟合模型后, summary.gam()gam.check()gam.check() predict.gam()是您的朋友。

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

相关问题 在使用R进行的生存分析中,考克斯比例危害模型中surv函数的目的是什么? - In Survival Analysis with R, what is the purpose of the `surv`function in the Cox Proportional Hazards Model? 使用R中的Cox比例风险模型计算生存预测 - Calculate the Survival prediction using Cox Proportional Hazard model in R 我可以为R中的Cox比例风险模型执行所有子集变量选择吗? - Can I perform all subsets variable selection for a Cox Proportional Hazards Model in R? 如何使用 mgcv package 从非线性 model 在 R 中创建 ggplot? - How do I create a ggplot in R from a non-linear model using the mgcv package? R中时变Covariate Cox比例风险模型的数据格式 - Data Formatting for Time Varying Covariate Cox Proportional Hazards Modeling in R 使用基础 R package 将非线性方程拟合到数据 - Fitting non-linear equation to data using base R package 如何满足 R 中幼苗存活数据的 Cox 比例风险模型假设 - How to meet Cox proportional hazard model assumptions for seedling survival data in R 使用fitModel函数进行R非线性模型拟合 - R non-linear model fitting using fitModel function 使用sbrier(R)估计Cox生存模型的预测准确性 - Estimating prediction accuracy of a Cox survival model using sbrier (R) 如何在R中的nls包(非线性模型)中计算R平方? - How to calculate R-squared in nls package (non-linear model) in R?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM