1

I'm running a coxph model with a spline using the cph wrapper {rms} and rcs as follows:

y <- cph(Surv(time, event) ~ rcs(data$z, df=4) + Age_recruitment + factor(eth) + bmi + factor(dm) , na.action=na.omit, data=data)

I'm afraid I can't post even a sample of the data as it is sensitive health info. data$z is a continuous variable. I get an error as follows:

Error in nact$nmiss : $ operator is invalid for atomic vectors

I understand this to mean that nact is a vector and therefore cannot be used with the $ - but not sure why this is happening since it is 'internal' to the cph call - i.e. not something I've created. I've tried removing the spline element in case that was the issue, but the same error occurs. Can anyone shed any light on this for me?

My goal is to run a series of coxph models using a different RCS each time and output the results meaningfully.

Thanks.

C. W.
  • 25
  • 6
  • Incidentally, after looking at the underlying code for cph, the nact is something to do with na.action, so I removed my na.action=na.omit specification and reran the model, receiving the following error: Error in X[, mmcolnames, drop = FALSE] : subscript out of bounds – C. W. Jan 27 '17 at 14:36
  • It seems that the **rms** fitting functions automatically use `na.exclude` or or equivalent, and supplying it twice results in this error. The normal reason to use `na.exclude` is to fill in `NA`s in e.g. `predict` or `resid`. But this happens by default, which is not true for **base** R `lm`. – CoderGuy123 Apr 13 '17 at 07:27

0 Answers0