harrelfe / rms

Regression Modeling Strategies
https://hbiostat.org/R/rms
Other
170 stars 48 forks source link

"Error in solve.default system is computationally singular" after restricted cubic splines with df > 3 (Cox Regression) #117

Open jedHK opened 2 years ago

jedHK commented 2 years ago

I am using rcs() to account for nonlinearity in my Cox regression. Aside from dealing with nonlinearity, I also hope that specifying the correct functional form might help with deal some proportional hazard violations.

If I use rcs(var, df=3) on all the covariates for which I'd like to use restricted cubic splines, I have no difficulties then using cox.zph after cph in rms to check for PH violation. However, when I try to increase degrees of freedom to 4 or 5 on too many variables, I encounter the error: "Error in solve.default system is computationally singular".

I have a dataset of 100k, 1772 events and a total df of 109 (with df=3 on all continuous variables. Hence, I have enough degrees of freedom spare (1772/12 ≈ 141) to spend on splines with more degrees of freedom to (hopefully) alleviate some remaining PH issues. However, I seem to be fatally limited by this error. Any advice on working around this?

Thanks.