2
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Surv(time, status=="failed") is not syntax consistent with the documentation of the survival package which I assume you are using. I do not think it does what you expect. $\endgroup$
    – Roland
    Sep 7, 2017 at 13:30

1 Answer 1

1
$\begingroup$

"'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.

$\endgroup$
1
  • 1
    $\begingroup$ 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? $\endgroup$
    – IWS
    Sep 7, 2017 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.