survminer
survminer copied to clipboard
Different behavior of confidence bands in ggcoxzph compared to plot.cox.zph
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:
Plot with plot.cox.zph:
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.
thank you for reporting this; ggcoxzph
needs to be adjusted
Hello, I am experiencing the same problem. Has the ggcoxzph function been adjusted yet?
thank you for reporting this;
ggcoxzph
needs to be adjusted
This has not been corrected yet.
This is an important issue and would appreciate a fix. Thanks.
Running into similar issue, hope this will be fixed soon
Has anyone found an easy work around, meanwhile they fix it?
@kassambara Is there any chance to fix that? I mean either delete the "d" or expose it as a parameter with default value=1?
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.
@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: https://github.com/kassambara/survminer/issues/534#issuecomment-860125015
Also, pending PR: https://github.com/kassambara/survminer/pull/535