-1

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")
Hakim
  • 1
  • 2

1 Answers1

0

Try moving the x=TRUE one step outwards, so that it is only enclosed by a single parenthesis.

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")
Janzon
  • 1