The Schoenfeld residual-based test for proportional-hazards violations in the Cox duration model is predicated on a key assumption pertaining to homoskedasticity in the residuals. This assumption is likely to be violated in the presence of stratified hazards, which is noted in estat phtest’s help file. We provide a wrapper command, stratph, that implements a straightforward modification to the residual-based diagnostic that corrects for the potential assumption violation. We use the stratified hazards example from the stcox help file to demonstrate the stratph command’s workings.
1 Introduction
Proportional hazards (PH) is a key assumption underlying the Cox semiparametric duration model. The assumption originates from the way in which these models’ functional form is defined and states that each covariate’s effect is proportional over time—if changing a covariate’s value increases the risk of an event by 10% at t = 1, then that same change should increase the risk of an event by 10% at t = 10, t = 50, and so on. Even one covariate violating the PH assumption can yield misleading inferences regarding any of the model’s covariates (Box-Steffensmeier and Zorn 2001, 974–975). Testing the assumption is therefore crucial and is typically done with residual-based diagnostics involving Schoenfeld residuals (estat phtest).
However, we know from the biostatistics literature that the Schoenfeld diagnostic test is predicated on a key assumption: variance homogeneity across risk sets (Therneau and Grambsch 2000, 141). Therneau and Grambsch (2000, 133–134) make this assumption for simplifying purposes (because the variance remains fairly constant across time) and also to help stabilize the Schoenfeld variance estimate across all time points because the estimate can become erratic in later periods as fewer and fewer subjects remain at risk. We also know from the biostatistics literature that, if the homogeneous variance assumption is not met, we may draw erroneous conclusions about whether a covariate’s effect is proportional from standard Schoenfeld residual-based tests.
In this article, we discuss a command, stratph, that adjusts the Schoenfeld-based PH test in Stata in the presence of stratification to yield appropriate results because the variance homogeneity assumption is likely to be violated when multiple strata are present.
1
This command acts as a wrapper to the mstatecox package’s mstphtest command, which is written to account for the presence of strata and other potential complexities involving covariate effects. We begin by discussing the PH test adjustment and then discuss stratph’s general syntax. We conclude by providing a stratified hazard example from the stcox help file, in which the conclusions we draw about PH violations differ once we stratify the PH test.
2 Adjusting the PH test
The basic intuition to correct the PH test for a model with strata is straightforward. If researchers have a Cox model with strata (call this the overall model) but suspect that the Schoenfeld variance differs across these strata, the solution is to run the PH test on each stratum (Therneau and Grambsch 2000, 142). Doing so involves rerunning the Cox model separately on each stratum, constraining the stratum-specific Cox models’ coefficient estimates to be the same as the overall Cox model’s coefficient estimates, and then running the PH test using each stratum-specific model.
2
We refer to this as “stratifying the PH test”. Constraining the stratum-specific estimates is the crucial part of the correction; otherwise, Stata will refit a new model using only that stratum’s observations, which amounts to estimating stratum-specific covariate effects, almost certainly yielding different coefficient estimates from the overall model.
3 Syntax
stratph [,
estat_phtest_opts
]
stratph requires that a Cox model be in memory. The Cox model must also have a variable included in strata(); if it does not, stratph will print an informational message and then run estat phtest as if the latter had been called directly. stratph also requires that strata()’s values are discrete in nature. If they are not, you will receive an error message and be asked to recode the variable.
Any of the permissible options for estatphtest are permissible options for stratph. The sole exceptions are the plot-based options. These options produce an error message in mstphtest, which is the command stratph ultimately calls. Finally, the detail option is hardcoded into mstphtest; it does not need to be specified again but harms nothing if it is.
stratph requires the mstatecox package (Metzger and Jones 2018), which pertains to multistate Cox models. Basic Cox models with stratified hazards are a special case of multistate Cox models, allowing us to exploit mstatecox’s functionality. Stratified hazards are ubiquitous for multistate models, as are more complex covariate patterns that may vary by strata, both of which have implications for PH testing. For these reasons, mstatecox includes the mstphtest command, which tests the PH assumption by using the Schoenfeld-based test for every unique value of the Cox model’s strata() variable. It also automatically constrains the coefficients to be the same as the original Cox model if needed. When stratph is finished executing, it purges all of mstatecox’s intermediate calculations and variables. Like mstphtest, stratph returns the individual coefficient table and global test matrix for each stratum in r-class memory.
4 Example
We use the stratified hazard example from stcox’s help file, involving stan3.dta, a dataset of patients admitted to the Stanford Heart Transplantation Program (Crowley and Hu 1977).
3
This example is particularly attractive, aside from it using one of Stata’s stock datasets, because the conclusions we draw about PH-violating covariates are different once we properly stratify the PH test.
4
We begin by executing the code from the stcox help file, which posits that the underlying rate at which heart transplant candidates die differs depending on when they were accepted into the transplant program: 1967–1969, 1970–1972, or 1973–1974. If such differences exist, it suggests we should stratify the baseline hazard by these groups:
If we run estat phtest at this juncture using the default time-scale transform, t, we obtain
None of the three coefficients’ p-values are statistically significant at conventional levels. Neither is the global test. Based on this output alone, we would conclude that no evidence of a PH violation exists.
However, as we have discussed, estat phtest does not properly adjust for the presence of strata. Once we stratify the PH test, a very different picture emerges:
stratph’s output begins by disambiguating what Transition
# means: it is the strata() variable’s value. The command then proceeds to calculate the PH test for each unique value of strata() and output the result.
5
From the stratum-specific tests, we see no evidence of PH violations in the pgroup = 1 stratum. We also see no evidence of violations in pgroup = 2. The story changes when we examine pgroup = 3. In this stratum, age is weakly significant (p = 0.08), which offers suggestive evidence of a PH violation. Although the global test fails to achieve statistical significance in this case, we should not necessarily dismiss the individual covariate tests indicating violations of the PH assumption (Box-Steffensmeier, Reiter, and Zorn 2003, 45). As a result, there is evidence it may be appropriate to correct for a PH violation for age in the third stratum. Doing so would likely involve stratumspecific covariates of some sort, which the multistate model literature discusses at length (Metzger and Jones 2016; Putter, Fiocco, and Geskus 2007).
5 Programs and supplemental materials
To install a snapshot of the corresponding software files as they existed at the time of publication of this article, type
Supplemental Material
Supplemental Material, sj-zip-1-stj-10.1177_1536867X211063408 - Properly calculating estat phtest in the presence of stratified hazards
Supplemental Material, sj-zip-1-stj-10.1177_1536867X211063408 for Properly calculating estat phtest in the presence of stratified hazards by Shawna K. Metzger and Benjamin T. Jones in The Stata Journal