As you have noted, the primary difference between coxme
and coxph
is in the way they handle random effects (or frailty
terms) for clustered or grouped/multilevel data. Both functions fit Cox proportional hazards models but differ in their assumptions and methodology for modeling random effects.
Main points of departure
1. Random Effects Distribution
coxme
: The random effects are assumed to follow a normal (Gaussian) distribution with mean 0 and an unknown variance estimated from the data. Specifically, random effects (eg., for recruitment centers) are modeled as
$N(0, \sigma^2)$, where $\sigma^2$ is the variance of the random effects. This allows recruitment center effects to either increase or decrease the hazard rate, meaning they can shift the hazard in either direction.
coxph
: The frailty term, which acts as a random effect, is modeled using a Gamma distribution rather than a normal distribution. Specifically, the frailty term follows a Gamma distribution with mean 1 and variance $\frac{1}{\alpha}$ where $\alpha$ is the Gamma distribution parameter. The Gamma distribution is constrained to positive values, meaning the frailty term can only multiply the baseline hazard, either increasing or decreasing it multiplicatively but never allowing the hazard to drop below zero.
However, it is worth noting that the Gamma frailty is on the hazard scale, while the normal random effect is on the log-hazard scale. This means the difference is between Gamma and log-Normal multiplicative effects, which are similar in distribution and behavior. Both can cause hazards to be greater or less than 1. On the additive scale, this is equivalent to a difference between Normal and log-Gamma additive effects, which can also be positive or negative.
2. Interpretation of Random Effects
coxme
: The random effects can either increase or decrease the baseline hazard, making this setup appropriate when you expect cluster-specific effects to be symmetrically distributed around zero. For example, some recruitment centers might reduce the hazard while others increase it.
coxph
: The Gamma-distributed frailty term is positive by definition, meaning it acts multiplicatively on the hazard function. This is suitable when you expect certain clusters to have proportionally higher risks (eg., some centers may have uniformly higher event rates), without anticipating any cluster-specific effects that would decrease the hazard multiplicatively.
3. Flexibility of Random Effects Models
coxme
: Provides more flexibility in modeling random effects. You can specify random intercepts, random slopes, and more complex hierarchical random structures. For instance, you could model recruitment centers with both random intercepts and random slopes (eg., allowing the effect of treatment to vary by center). Additionally, you can incorporate multiple levels of random effects, such as participants nested within centers.
coxph
: While it supports random effects through the frailty function, coxph
is more limited in flexibility. The frailty term essentially acts as a random intercept for the clusters but cannot easily extend to more complex random structures like random slopes. The model also assumes a Gamma-distributed frailty, which limits its application in contexts where a normal random effect or more complex structures may be required.
4. Estimation
coxme
: Uses penalized likelihood estimation, which estimates both the fixed effects (eg., treatment, covariates) and the variance of the random effects simultaneously. This helps avoid overfitting by penalizing large random effect variances, leading to more stable estimates for complex models.
coxph
: Uses partial likelihood estimation for the fixed effects, with the frailty variance estimated separately. While this approach is computationally simpler, it is less flexible and may not be as robust when fitting models with multiple levels of random effects or more complex random structures.
5. Use Cases and Practical Considerations
coxme
: If your model requires multiple random effects or more complex structures (eg., random intercepts and slopes), coxme
is the better choice. It’s designed to handle mixed-effects Cox models, making it ideal for situations where the random effects are expected to follow a normal distribution. For example, it works well when modeling recruitment centers with both random intercepts and slopes for treatment effects, or when participants are nested within centers.
coxph
: If you only need a simple frailty term (random intercept) to account for clustering, and you believe the frailty term follows a Gamma distribution, coxph
is a more straightforward option. It’s especially useful in settings where frailty is expected to act multiplicatively on the hazard, such as genetic or epidemiological studies where individual or group-level heterogeneity can be modeled using Gamma-distributed frailties.
7. Diagnostics and Software Support
coxme
: Provides more diagnostics related to mixed-effects models, such as checking the distribution of random effects and residuals. This is important for assessing the fit and assumptions of the model. However, as it is a more specialized package (coxme
package), it may require more tuning or expertise to fully leverage its capabilities.
coxph
: As part of the widely used survival package, coxph
has broader software support and is simpler to use when only a frailty term is needed. However, it is less flexible for more complex models that involve multiple or hierarchical random effects. It provides standard diagnostics such as checking proportional hazards assumptions, but is less focused on random effects diagnostics.
Conclusion
The main difference between coxme
and coxph
lies in the distribution of the random effects: coxme
assumes normally distributed random effects, while coxph
uses Gamma-distributed frailties. This affects the interpretation of the random effects, with coxme
allowing random effects to shift the hazard in either direction, whereas coxph
's frailty term acts multiplicatively on the hazard and is constrained to positive values.
However, the Gamma frailty operates on the hazard scale, and the normal random effect operates on the log-hazard scale, so the practical difference is between Gamma and log-Normal multiplicative effects, which are quite similar in distribution and behavior.
Use coxme
when your data require normally distributed random effects or when you need more flexibility to model complex random structures (eg., random intercepts and slopes or nested data).
Use coxph
when you need a simpler multiplicative frailty model with Gamma-distributed random effects, particularly for survival analysis contexts where you expect frailty to act multiplicatively on the hazard.