>> Home >> Products >> Stata 14 >> Multilevel survival models
Stata Release 14: Available now

Multilevel survival models

Multilevel survival models


  • Random intercepts and random coefficients
  • Two-, three-, and higher-level models
  • Crossed random effects
  • Right-censoring
  • Single- and multiple-record data
  • Exponential, loglogistic, Weibull, lognormal,
    and gamma survival distributions
  • Support for complex survey data
  • Graphs of marginal survivor,
    cumulative hazard, and hazard functions

What's this about?

In multilevel data, we have subjects that can be divided into groups. These may be patients treated at the same hospital, cars manufactured at the same plant, students attending the same school, and so on. If, in these examples, we believe that unobserved characteristics of the hospital, plant, or school may affect the outcome, we can use one of Stata's specialized commands for multilevel mixed-effects models to include group-level random effects in our model. These commands fit models for continuous, binary, ordinal, and count outcomes. For more information, see the Multilevel Mixed-Effects Reference Manual.

Stata also has a suite of features for analyzing survival-time data with outcomes such as length of hospital stays, time to remission for a particular type of cancer, or length of time living in a city. These commands allow us to summarize, graph, and model this type of data. See the Survival Analysis Reference Manual for details.

mestreg allows us to combine multilevel modeling with the parametric analysis of survival-time outcomes.

Let's see it work

Suppose we are interested in modeling the effects of laparoscopic surgery and age on length of hospital stay for adult patients with appendicitis. We believe that doctors affect the length of a patient's stay, so we include a random effect for doctor.

Before we fit the model, we use stset to specify that we have survival-time data. Here, los represents the patient's length of stay in hours. We observe the length of stay for all patients; there is no censoring. Therefore, we simply identify our survival-time variable by typing

. stset los

We fit a Weibull model for length of stay:

. mestreg lap_surg age || doctor:, distribution(weibull)

         failure _d:  1 (meaning all fail)
   analysis time _t:  los

(output omitted)

Mixed-effects Weibull regression                  Number of obs     =       457
Group variable:          doctor                   Number of groups  =       185

                                                  Obs per group:
                                                                min =         1
                                                                avg =       2.5
                                                                max =         8

Integration method: mvaghermite                   Integration pts.  =         7

                                                  Wald chi2(2)      =     81.66
Log likelihood =  242.81044                       Prob > chi2       =    0.0000

_t Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
lap_surg 7.606502 1.819963 8.48 0.000 4.759081 12.15757
age .9565034 .0149671 -2.84 0.004 .9276137 .9862929
_cons 2.48e-21 5.79e-21 -20.32 0.000 2.55e-23 2.41e-19
/ln_p 2.37308 .0490434 48.39 0.000 2.276956 2.469203
doctor var(_cons) 1.479597 .3157442 .9738638 2.247961
LR test vs. Weibull model: chibar2(01) = 80.96 Prob >= chibar2 = 0.0000

Remember that "failure" is the happy event of departing the hospital. With a hazard ratio greater than 1, laparoscopic surgery is associated with shorter hospital stays. Increased age is associated with longer hospital stays. We also see a large variation across doctors that might have contaminated our results had we not taken them into account.

We can plot the marginal survivor function for surgery method:


After about two days (48 hours), the marginal probability of remaining in the hospital begins to decrease quickly for laparoscopic surgery patients. Those having more invasive surgery can expect to remain in the hospital longer.

We could fit a similar model using streg with shared frailties, but streg assumes the frailties follow a gamma distribution. mestreg makes the often more plausible assumption that random effects are normally distributed, meaning frailties are lognormal. mestreg also lets us extend the types of models that we can fit beyond two-level models with random intercepts.

Suppose we also believe that unobserved hospital characteristics such as discharge procedures may also impact the length of hospital stay. We will assume that doctors practice in only one hospital, so patients are nested within doctors and doctors nested within hospitals. We fit a three-level model with hospital-level and doctor-level random effects.

.  mestreg lap_surg age || hospital: || doctor:, distribution(weibull)

         failure _d:  1 (meaning all fail)
   analysis time _t:  los

(output omitted)

Mixed-effects Weibull regression                Number of obs     =        457

No. of Observations per Group
Group Variable Groups Minimum Average Maximum
hospital 12 1 38.1 73
doctor 185 1 2.5 8
Integration method: mvaghermite Integration pts. = 7 Wald chi2(2) = 99.68 Log likelihood = 278.87609 Prob > chi2 = 0.0000
_t Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
lap_surg 7.025563 1.410613 9.71 0.000 4.739957 10.41329
age .9716888 .0127353 -2.19 0.028 .9470459 .9969729
_cons 3.34e-21 7.60e-21 -20.70 0.000 3.84e-23 2.89e-19
/ln_p 2.369253 .0477084 49.66 0.000 2.275746 2.462759
var(_cons) .8650249 .436397 .3218143 2.325155
var(_cons) .7086671 .175355 .436333 1.150977
LR test vs. Weibull model: chi2(2) = 153.09 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference.

We draw the same conclusions with regard to age and having laparoscopic surgery as we drew with the previous model. We now find that there is large variation across both doctors and hospitals.

Tell me more

Read more about multilevel mixed-effects parametric survival analysis in the Stata Multilevel Mixed-Effects Reference Manual.

Read the overview from the Stata News.

Upgrade now Order Stata





The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ YouTube
© Copyright 1996–2016 StataCorp LP   •   Terms of use   •   Privacy   •   Contact us