Skip to content
New issue

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

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

Already on GitHub? # to your account

Different behavior of confidence bands in ggcoxzph compared to plot.cox.zph #444

Open
ter-hel opened this issue Jan 26, 2020 · 9 comments
Open

Comments

@ter-hel
Copy link

ter-hel commented Jan 26, 2020

Hello,
I just encountered a problem with the ggcoxzph fuction while plotting the Schoenfeld residuals. The confidence bands seemed to be oddly wide. I compared the results to the plot from the function plot.cox.zph where they were much smaller.

Plot with ggcoxzph:
Rplot

Plot with plot.cox.zph:
Rplot01

I looked at the source code of both functions and noticed a difference:

# confidence bands in plot.cox.zph (v3.1-8 of survival package):
if (se) {
  bk <- backsolve(qmat$qr[1:df, 1:df], diag(df))
  xtx <- bk %*% t(bk)
  # seval <- d*((pmat%*% xtx) *pmat) %*% rep(1, df)
  seval <- ((pmat%*% xtx) *pmat) %*% rep(1, df)
}

# confidence bands in ggcoxzph (v0.4.6 of survminer package):
if (se) {
  bk <- backsolve(qmat$qr[1:df, 1:df], diag(df))
  xtx <- bk %*% t(bk)
  seval <- d * ((pmat %*% xtx) * pmat) %*% rep(1, df)
}

So it seems that the multiplication with d has been dropped in plot.cox.zph. The parameter d is defined earlier in both functions as:

yy <- x$y
d <- nrow(yy)

Should ggcoxzph be adjusted to match the results of plot.cox.zph? I prefer the smaller confidence bands of plot.cox.zph because it's earsier to see if the PH assumption is fulfilled from a visual point of view.

@kassambara
Copy link
Owner

thank you for reporting this; ggcoxzph needs to be adjusted

@etyas
Copy link

etyas commented Jun 1, 2020

Hello,
I am experiencing the same problem. Has the ggcoxzph function been adjusted yet?

@bcfgothenburg
Copy link

thank you for reporting this; ggcoxzph needs to be adjusted

This has not been corrected yet.

@raheems
Copy link

raheems commented Apr 13, 2021

This is an important issue and would appreciate a fix. Thanks.

@Hark-Jin
Copy link

Running into similar issue, hope this will be fixed soon

@marcoguerzoni
Copy link

Has anyone found an easy work around, meanwhile they fix it?

@Generalized
Copy link

@kassambara
Is there any chance to fix that? I mean either delete the "d" or expose it as a parameter with default value=1?

@padj
Copy link

padj commented May 19, 2022

Has anyone found an easy work around, meanwhile they fix it?

Use plot.cox.zph instead.
@kassambara Has acknowledged it and it should be a quick fix, so we'll just have to wait.

@arielhasidim
Copy link

@kassambara
Is there any chance to fix that? I mean either delete the "d" or expose it as a parameter with default value=1?

Temporary fix:
#534 (comment)

Also, pending PR:
#535

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants