如何对 R 中的 flexsurvreg 对象执行逐步模型选择?

问题描述

使用包 flexsurvreg,我们可以对事件发生时间数据进行分析。例如,我可以使用 ovarian 数据集中的所有变量创建以下完整模型。

library(flexsurv)
library(eha)

full_model = flexsurvreg(Surv(futime,fustat) ~ 1 + age + 
                           as.factor(resid.ds) + 
                           as.factor(rx) + 
                           as.factor(ecog.ps),data = ovarian,dist="weibull")

这将创建一个 flexsurvreg 类对象。

> class(full_model)
[1] "flexsurvreg"

flexsurvreg 函数输出提供有关 AIC 的信息

> full_model
Call:
flexsurvreg(formula = Surv(futime,fustat) ~ 1 + age + as.factor(resid.ds) + as.factor(rx) + as.factor(ecog.ps),dist = "weibull")

Estimates: 
                      data mean  est        L95%       U95%       se         exp(est) 
shape                        NA   1.92e+00   1.20e+00   3.09e+00   4.66e-01         NA
scale                        NA   3.87e+04   3.79e+03   3.96e+05   4.60e+04         NA
age                    5.62e+01  -6.50e-02  -1.03e-01  -2.69e-02   1.95e-02   9.37e-01
as.factor(resid.ds)2   5.77e-01  -5.21e-01  -1.29e+00   2.47e-01   3.92e-01   5.94e-01
as.factor(rx)2         5.00e-01   5.21e-01  -1.15e-01   1.16e+00   3.24e-01   1.68e+00
as.factor(ecog.ps)2    4.62e-01  -6.68e-02  -7.00e-01   5.67e-01   3.23e-01   9.35e-01
                      L95%       U95%     
shape                        NA         NA
scale                        NA         NA
age                    9.02e-01   9.74e-01
as.factor(resid.ds)2   2.76e-01   1.28e+00
as.factor(rx)2         8.91e-01   3.18e+00
as.factor(ecog.ps)2    4.96e-01   1.76e+00

N = 26,Events: 12,Censored: 14
Total time at risk: 15588
Log-likelihood = -87.84709,df = 6
AIC = 187.6942

我想根据 AIC 对变量执行自动选择。我尝试使用 stepAIC 函数执行逐步回归,但出现错误

> library(MASS)
> stepAIC(full_model)
Error in terms.default(object) : no terms component nor attribute

似乎 stepAIC 不适用于此类对象。

是否可以根据 AIC 标准对 flexsurvreg 类对象执行自动逐步模型选择?

注意: 此示例仅用于说明我的问题。这不是我使用的实际数据,我只是创建了这个例子来重现我的问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)