3
$\begingroup$

I'm trying to run a discrete-time multilevel hazard analysis comparable to the model proposed by Barber et al. I am attempting to model the hazard of migrating internationally using predictors at the individual, household, community, and regional levels. (Most of the variables of interest are at the individual, community, and regional levels--I just need to account for clustering by household)

Is there a package that will allow me to do this in R? I've used lme4 for regular multilevel modeling, but can it also be used for multilevel survival models? How would I go about coding such a model? (And if this can't be done in R, can it be done in Stata, or do I have to bite the bullet and buy and learn HLM or MLwiN?)

Please let me know if you need any additional information. Thanks!

ETA: Barber et al. refers to: Barber, Jennifer S., Susan A. Murphy, William Axinn, and Jerry Maples. 2000. "Discrete-Time Multilevel Hazard Analysis." Sociological Methodology, 30: 201-235.

$\endgroup$
5
  • $\begingroup$ Welcome to CV @Karen. Have you looked at the coxme package? I think that's close to what you need. $\endgroup$
    – Russ Lenth
    Commented Aug 26, 2014 at 1:47
  • $\begingroup$ I also would like to welcome you to CrossValidated, @Karen. Please be aware that we all come from very different disciplines. A reference like "model proposed by Barber et al." is too vague and many people may think that they cannot help you bcs they have no idea what paper you are talking about. $\endgroup$ Commented Aug 26, 2014 at 7:03
  • $\begingroup$ @RussLenth I've heard of it, but I haven't looked too closely at it, since I thought Cox models were for continuous-time? I'm very new to survival analysis though, so I could be completely mistaken. I'll take a look at it! $\endgroup$
    – Karen
    Commented Aug 27, 2014 at 1:51
  • 1
    $\begingroup$ @BerndWeiss, my apologies--there was supposed to have been a link! I've edited my question to include the full citation and a link now. $\endgroup$
    – Karen
    Commented Aug 27, 2014 at 1:56
  • $\begingroup$ @Karen, you may well be right about the continuous-time thing. I only know some of the terminology for these models, and have no experience with them. $\endgroup$
    – Russ Lenth
    Commented Aug 27, 2014 at 2:39

1 Answer 1

7
$\begingroup$

Yes, you can use R and lme4 for fitting discrete-time multilevel hazard models. According to Hox (2010, p. 163) "[t]he discrete or grouped survival model extends readily to multilevel models [...]". The analysis, though, have to be based on person-period data.

You also might want to check out the following references:

  • Hox, J. (2010). Multilevel Analysis: Techniques and Applications (2 edition.). New York: Routledge.
  • Snijders, T. A. B., & Bosker, R. J. (2012). Multilevel analysis. An introduction to basic and advanced multilevel modeling. London; Thousand Oaks, California: Sage. [esp. chapter 17]
  • Steele, F. (2011). Multilevel Discrete-Time Event History Models with Applications to the Analysis of Recurrent Employment Transitions. Australian & New Zealand Journal of Statistics, 53(1), 1–20.

Example from Hox (2010: 168):

Here is an example that is about modelling divorce risks (data can be found here). Please find below the table from Hox' book:

enter image description here

And here is the corresponding R code and the results based on lme4. The results are not identical but I do not have the time to play with the model and the options for the estimators. It should be clear, though, that the results are close enough (except the variance of the random effects, that difference is pretty large)...

library(foreign)
library(lme4)
dat <- read.spss("D:/tmp/DataExchange/DataExchange/8 Survival/SibDivPP.sav", 
                 to.data.frame = TRUE)

summary(glmer(divorce ~ t + t2 + t3 + (1 | famid), family = binomial, nAGQ = 1, 
              data = dat))

Here are the results from R:

> summary(glmer(divorce ~ t + t2 + t3 + (1|famid), 
+               family = binomial, nAGQ=1, data = dat))
Generalized linear mixed model fit by maximum likelihood (Laplace
  Approximation) [glmerMod]
 Family: binomial  ( logit )

[... output omitted ...]

Random effects:
 Groups Name        Variance Std.Dev.
 famid  (Intercept) 1.709    1.307   
Number of obs: 43141, groups:  famid, 953

Fixed effects:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept) -5.47827    0.14413  -38.01  < 2e-16 ***
t           -0.50515    0.14804   -3.41 0.000644 ***
t2          -0.43206    0.11677   -3.70 0.000215 ***
t3           0.14260    0.05972    2.39 0.016951 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
$\endgroup$
3
  • $\begingroup$ thank you for your answer! Hox's book looks particularly useful. I'm going to get a copy, but do you know if it comes with sample code? I've read so many articles which explain these types of models in equation form but don't include how to translate that into practical code. $\endgroup$
    – Karen
    Commented Aug 27, 2014 at 2:01
  • $\begingroup$ @Karen I have updated my answer and added an example from Hox. If my answer is helpful, please consider upvoting it. $\endgroup$ Commented Aug 27, 2014 at 5:47
  • $\begingroup$ If anyone is wondering 8 years later why their answers are different, it's because t, t1. and t2 are continuous variables. They should be indicator variables. t2 is the square of t and t3 is the cube of t $\endgroup$
    – Eli
    Commented Sep 8, 2022 at 20:33

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.