r - Residuals.cph error "you must specify x=TRUE in the fit"
问题描述
I am trying to analyze graphs showing deviance residuals for my covariates. I have created this cox model named res.cox1 as shown in the code below and then proceed to use the residuals.cph function. Turns out, I keep getting the error:
Error in residuals.cph(res.cox1, type = "deviance") : you must specify x=TRUE in the fit
I have tried to add x = TRUE, y = TRUE, surv = TRUE to my fit, but none of it is helping. I don't quite understand what's wrong with my code, as I did not have problems creating residual graphs when I used the coxph function. Reason why I insist on using the cph function is the because of rcs(). Using rcs() when I had my coxph function did not work out, hence why I am trying to make it work with cph.
I don't know what to do.
res.cox1 = cph(with(H, Surv(TimeAxis, new_totmort) ~ Ln_PWVx_AUS + rcs(MAP_PWV_AUS) + A_HRcarX_AUS + sex_AUS + age_scr_AUS + BMI_AUS + Ln_glukos_0_AUS + Current_smoking_AUS + BPlowering_AUS + Lipidlowering_AUS + Hypertension_AUS + Diabetes_confirmed_AUS + Had_CV_Treatment, x=TRUE))
resid(res.cox1, type = "deviance")
解决方案
尝试x=TRUE
向外移动一步,使其仅用一个括号括起来。
res.cox1 = cph(with(H, Surv(TimeAxis, new_totmort) ~ Ln_PWVx_AUS + rcs(MAP_PWV_AUS) + A_HRcarX_AUS + sex_AUS + age_scr_AUS + BMI_AUS + Ln_glukos_0_AUS + Current_smoking_AUS + BPlowering_AUS + Lipidlowering_AUS + Hypertension_AUS + Diabetes_confirmed_AUS + Had_CV_Treatment), x=TRUE)
resid(res.cox1, type = "deviance")
推荐阅读
- sql-server - 选择前如何使用结果值
- android - 防止 Elvis Operator 在重新格式化时闯入下一行
- php - php json_decode 不工作,json_last_error() thows 4
- php - 无法在 PHP 中跟踪 require_once 错误
- android - 将 PSD 文件转换为 Android XML
- azure - 本地数据库到 Azure SQL 数据库并持续同步
- javascript - Shift选项卡不保留元素焦点
- python - 如何将 3 个列表值与 If 条件进行比较
- c# - 为什么 xUnit 测试没有变成绿色?
- python - 使用 unittest 测试烧瓶应用程序时出错