Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: plot Time in the OX axis in ggcoxdiagnostics() #124

Closed
pbiecek opened this issue Jan 25, 2017 · 4 comments
Closed

Suggestion: plot Time in the OX axis in ggcoxdiagnostics() #124

pbiecek opened this issue Jan 25, 2017 · 4 comments

Comments

@pbiecek
Copy link
Contributor

@pbiecek pbiecek commented Jan 25, 2017

Right now the ggcoxdiagnostics() may have either Fitted values of Observation ID on the OX axis.
To choose one can set the linear.predictions.
But for some residuals (like schoenfeld) it is convenient to plot Time on the OX axis.

Suggestion: replace the linear.predictions parameter with ox.scale = c("linear.predictions", "time", "observation.id").
This will allow more choices for OX scale.

@MarcinKosinski what do you think about this?

@kassambara
Copy link
Owner

@kassambara kassambara commented Jan 28, 2017

I think that a solution is provided by the function survminer::ggcoxzph() as a graphical diagnostic of the proportional hazards assumption (related blog post: http://www.sthda.com/english/wiki/cox-model-assumptions.)

@pbiecek what do you think about that?

If this solution is optimal, then we can close the issue...

Example:

library("survival")

# Fit cox model
res.cox <- coxph(Surv(time, status) ~ age + sex + wt.loss, data =  lung)
# Test for the proportional-hazards assumption
test.ph <- cox.zph(res.cox)
rho chisq     p
age     -0.0483 0.378 0.538
sex      0.1265 2.349 0.125
wt.loss  0.0126 0.024 0.877
GLOBAL       NA 2.846 0.416
# Graphical diagnostic using the function ggcoxzph()
# Produces, for each covariate, graphs of the scaled Schoenfeld residuals against the time
library(survminer)
ggcoxzph(test.ph)

rplot02

More examples are provided in the documentation: http://www.sthda.com/english/rpkgs/survminer/reference/ggcoxzph.html

@pbiecek
Copy link
Contributor Author

@pbiecek pbiecek commented Jan 28, 2017

The ggcoxzph() function is great, especially for people used to survival::cox.zph() (like me).
I have maybe one minor problem with this function. In the title of ggcoxzph() it is said that it's a wrapper over plot.cox.zph(). But it's not a wrapper, rather a transplant of few lines of an R code.
Further changes in plot.cox.zph() (if any) will not be automatically reflected in ggcoxzph() thus it will be harder to maintain.

Returning to ggcoxdiagnostics().
The ggcoxzph() is working only for scaled Schoenfeld residuals, while the ggcoxdiagnostics() may be much more flexible.
But right now the ggcoxdiagnostics() allows only to plot the Schoenfeld residuals versus linear predictions or versus indexes of failure times.
IMHO it shall be easy to add the Time on OX axis, so why not do this.
The ggcoxdiagnostics() will be easier to maintain than ggcoxzph() -- it calls the resid() function directly, not doing any linear algebra by itself.
But if you think it is not necessary or confusing for existing users of survminer I'm ok with closing this issue.

@kassambara
Copy link
Owner

@kassambara kassambara commented Jan 28, 2017

Yeah, I agree with you and I think that, we should definitively go for adding the option, you suggested, in the ggcoxdiagnostics() function.

Thanks:-)!

pbiecek added a commit to pbiecek/survminer that referenced this issue Feb 1, 2017
pbiecek added a commit to pbiecek/survminer that referenced this issue Feb 1, 2017
kassambara added a commit that referenced this issue Feb 1, 2017
Fix for #124
@kassambara
Copy link
Owner

@kassambara kassambara commented Feb 1, 2017

Thank you for the pull request:-)!

kassambara added a commit that referenced this issue Feb 1, 2017
@pbiecek pbiecek closed this Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.