Test the proportional hazards assumption for a Cox regression model fit
(coxph).
cox.zph(fit, transform="km", terms=TRUE, singledf=FALSE, global=TRUE)the result of fitting a Cox regression model, using the
coxph or coxme functions.
a character string specifying how the survival times should be transformed
before the test is performed.
Possible values are "km", "rank", "identity" or a
function of one argument.
if TRUE, do a test for each term in the model rather than for each separate covariate. For a factor variable with k levels, for instance, this would lead to a k-1 degree of freedom test. The plot for such variables will be a single curve evaluating the linear predictor over time.
use a single degree of freedom test for terms that
have multiple coefficients, i.e., the test that corresponds most
closely to the plot. If terms=FALSE this argument has no
effect.
should a global chi-square test be done, in addition to the per-variable or per-term tests tests.
an object of class "cox.zph", with components:
a matrix with one row for each variable, and optionally a last row for the global test. Columns of the matrix contain a score test of for addition of the time-dependent term, the degrees of freedom, and the two-sided p-value.
the transformed time axis.
the untransformed time values
the matrix of scaled Schoenfeld residuals. There will be one column per
term or per variable (depending on the terms option above),
and one row per event. The row labels are a rounded form of the
original times.
the calling sequence for the routine.
The computations require the original x matrix of the Cox model fit.
Thus it saves time if the x=TRUE option is used in coxph.
This function would usually be followed by both a plot and a print of
the result.
The plot gives an estimate of the time-dependent coefficient
\(\beta(t)\).
If the proportional hazards assumption is true, the true
\(\beta(t)\) function would be a horizontal line.
The printout shows the score test for a time dependent effect of 0.
Random effects terms such a frailty or random effects in a
coxme model are not checked for proportional hazards.
P. Grambsch and T. Therneau (1994), Proportional hazards tests and diagnostics based on weighted residuals. Biometrika, 81, 515-26.
# NOT RUN {
fit <- coxph(Surv(futime, fustat) ~ age + ecog.ps,
data=ovarian)
temp <- cox.zph(fit)
print(temp) # display the results
plot(temp) # plot curves
# }
Run the code above in your browser using DataLab