1

I have built a multivariable cox model with coxph(). However, I am unable to run ggcoxfunctional() on some of the variables because of missing data.

ggcoxfunctional(Surv(time, status=="failed") ~ wbc3, data = selr3cox)
Error in xy.coords(x, y) : 'x' and 'y' lengths differ.

If I run ggdiagnostics() on the cox.model with type="martingale" ,

ggcoxdiagnostics(res.cox, type = "martingale",
                 linear.predictions = FALSE, ggtheme = theme_bw())

I get a reasonably horizontal line. Does that mean linearity assumption for all the variables included in the model holds or must I still run ggcoxfunctional() on each variable (with imputed data) in the model?

Next, if after transforming a variable to make it linear is unsuccessful, am I right to think that variable should not be included in the model? How would one do multivariate analysis to check on the significance of that variable then?

The link below contains part of my data. Apologies if this question should appear on SO rather than Crossvalidated. Hope someone can help.

https://github.com/dcicantab5/recover-study.git

kjetil b halvorsen
  • 63,378
  • 26
  • 142
  • 467
saifulsafuan
  • 123
  • 7
  • `Surv(time, status=="failed")` is not syntax consistent with the [documentation of the survival package](https://stat.ethz.ch/R-manual/R-devel/library/survival/html/Surv.html) which I assume you are using. I do not think it does what you expect. – Roland Sep 07 '17 at 13:30

1 Answers1

1

"'x' and 'y' lengths differ" is often a more serious programmatic problem.

I imagine that your selection/filtering 'status=="failed"' makes the y vector of shorter length. Your 'wbc3' variable does not get filtered in the same way.

Sextus Empiricus
  • 43,080
  • 1
  • 72
  • 161
  • 1
    Although this is absolutely right, OP gives an explanation for this problem/error: *missing data*. I'd recon a dataset with only complete cases would not give this error. On another (side)note, your answer does not answer OPs question (which in the context of Crossvalidated, I read to be "how to deal with non-linearity in the case of cox survival models"). Could you elaborate? – IWS Sep 07 '17 at 13:10