6
$\begingroup$

I cannot find somewhere where it is clearly stated the difference between using coxme and coxph functions in R. My interest is mostly in the case of simple random effects.

I don't have a real data to work on but let's imagine a vey simple situation: I have a dataset that includes data from a cohort recruited in a specific period in the past. The participants were enrolled in different areas of country, each corresponding to a recruiment centre (centre). I am interested in the association between a treatment (treatment) and a time-to-event outcome (time as time to the event and status as indicator for event occurrence). There are also other variables involved which might act as confounders (covariates), so I decide to include them in the model as well.

If I had to run a Cox Proportional Hazards model, the syntax would be this:

  • coxme(Surv(time, status) ~ treatment + covariates + (1|centre))
  • coxph(Surv(time, status) ~ treatment + covariates + frailty(centre))

From what I was able to understand reading on the web, the main difference everything is left as default, is that in coxme the random effect has distribution $N(0,1)$, while in coxph the frailty term is distributed as a $Gamma(\alpha,\beta)$, but I don't know the value for $\alpha$ and $\beta$. Is that the only difference?

I found some info on this old thread from 2007, but considering that the packages might have been updated, I wonder if someone has clearer and more definitive insights on this.

$\endgroup$

1 Answer 1

8
+50
$\begingroup$

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.

$\endgroup$
5
  • 3
    $\begingroup$ There's less difference than that: the Gamma frailty is on the hazard scale and the Normal is on the log hazard scale, so the difference is really between Gamma and log-Normal multiplicative effects, which are extremely similar in distribution and can be greater than or less than 1 (or equivalently between Normal and log-Gamma additive effects, which again are similar and can be positive or negative) $\endgroup$ Commented Oct 10 at 21:39
  • 2
    $\begingroup$ Thanks @ThomasLumley either I had forgotten about that, or I never even knew. Either way, thank you. I have made several edits. $\endgroup$ Commented Oct 11 at 9:32
  • $\begingroup$ Can't we select a different distribution for each random ter in coxme? I know that in mlogit for random effects in multinomial logit models, each random term can take one of normal, log-normal, triangle, and uniform distributions. I hope coxme is flexible in this way, too. $\endgroup$
    – DrJerryTAO
    Commented Oct 15 at 0:47
  • $\begingroup$ @DrJerryTAO unfortunately I have bad news for you. coxme does not allow any other specification for the random intercept distribution. It does offer the flexibility of specifying covariance structures for the random effects through the varlist argument, which allows you to define how the random effects are correlated (eg., diagonal matrices for uncorrelated effects, more complex covariance matrices for structured dependence). But obviously this is not the same as specifying an alternative distribution of the random effects. $\endgroup$ Commented Oct 16 at 9:05
  • $\begingroup$ Also, from the documentation it says on page 3: "coxme: Fit a mixed effects Cox model...Description: Fit a Cox model containing mixed (random and fixed) effects. Assume a Gaussian distribution for the random effects. " $\endgroup$ Commented Oct 16 at 9:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.