I want to find if the functional forms of covariates in my Cox model are linear. I understand the way to do this is to plot the Martingale residuals against the covariate of interest.

I have found two ways of doing this in R -

Option 1: http://www.math.wustl.edu/~jmding/math434/R_model_diag.R

fit2 = coxph(Surv(time,delta)~wtime+factor(dtype)+factor(gtype)+score, data=hodg, 
plot(hodg$wtime, resid(fit2), xlab="Waiting Time to Transplant (months)",
     ylab="Martingale Residuals", main='Figure 11.4 on page 361')
lines(lowess(hodg$wtime, resid(fit2)),col='red')

Option 2: Modeling Survival Data: Extending the Cox Model

fit <- coxph(Surv(pgtime,pgstat) ~ 1, data = prostate)
plot(prostate$g2, resid(fit))
smooth <- mlowess(prostate$g2, resid(fit), iter=0)

In Option 1, the Cox model is created using all the covariates. In Option 2, the formula object in the coxph function just has ~ 1, instead of a list of covariates.

What does this ~ 1 mean, and which method should I be using?

  • $\begingroup$ The ~1 just means to fit a model using only the global intercept. Please don't sign your questions. Your identicon w/ a link to your userpage is automatically added to all your posts. It is better to ask questions here in ways that are indifferent to software, as many users who can / might answer are not R users & may not be able to read your code. If you can translate these, please do so. If you can't, you'll have to wait for someone who is expert in both to answer your Q. Note that pure R coding questions are off-topic here, but you are OK this time b/c of the substantive portion. $\endgroup$ – gung - Reinstate Monica Oct 21 '14 at 15:52
  • $\begingroup$ @gung Sorry, my stats background is poor and I don't know what 'global intercept' means. Does it mean to find the survival curve that best fits the data without trying to separate out the effects of the covariates? $\endgroup$ – user5064 Oct 21 '14 at 16:16
  • $\begingroup$ No, I just mean it is the average of y for all your data. $\endgroup$ – gung - Reinstate Monica Oct 21 '14 at 16:20

Option 2, as noted by @gung, is a null model. So, unlike Option 1, it will not provide any adjustment for relations among the predictor variables. As Therneau cautions in the 1996 Technical Report Extending the Cox Model, "This method works well when the data are uncorrelated, but fails when correlations are present. The same failure occurs for ordinary scatter plots in uncensored data..." (page 19). That Report includes S-Plus code for several other ways to judge functional forms of relations of covariates to outcome, which should almost directly be useable as R code.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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