如何解决如何对 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"
> 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 举报,一经查实,本站将立刻删除。