I want to do a survival analysis using a discrete time multilevel model in Stata, because the data I have is subject to heaping at certain ages (which explains the discrete time) and because the data I have is hierarchal (children are nested in households, the variable hh_number).

Specifically, I want to look at whether the variable polygamy has an effect on survival. I created the following variables:

  • death_indicator_1: that takes 1 if the child died 0 and 11 months,
  • death_indicator_2: that takes 1 if the child died between 12 and 23 months, and
  • death_indicator_3 that takes 1 if the child died between 24 and 60 months.

I also created the variables

  • survival_time_1 for survival time between 0 and 11 months,
  • survival_time_2 for survival time between 12 and 23 months, and
  • survival_time_3 for children between 24 and 60 months.

The variable polygamy takes 1 if the child was born into a polygamous household. In the papers I read that use a similar model, the survival analysis in discrete time is always in reference to one time-interval.

I tried this command to declare interval-timed survival model:

stset survival_time_1 survival_time_2 survival_time_3, failure(death_indicator_1 == 1 | death_indicator_2 == 1 | death_indicator_3 == 1)

But Stata says: too many variables specified

And this command to run the multilevel fixed effect logistic regression:

clogit death_indicator_1 death_indicator_2 death_indicator_3 i.polygam, base(0), group(hh_number)

But I get: invalid 'group'

How can I do this correctly?

  • 1
    $\begingroup$ "do not work" is not helpful as a problem report. The code is illegal? Or otherwise unsatisfactory? Quite how? $\endgroup$
    – Nick Cox
    Commented Aug 13, 2023 at 9:52
  • $\begingroup$ Thank you. For the first command, Stata says : too many variables specified````. And for the second command, I get invalid 'group' ``` $\endgroup$
    – jean_strass
    Commented Aug 13, 2023 at 10:04
  • $\begingroup$ help stset explains that you need one time variable; no more are allowed. The second command has too many commas. Sorry, I don't specialise in survival analysis and never used clogit. But it's puzzling to be asked are these the right commands when Stata is indicating syntax errors in each case. $\endgroup$
    – Nick Cox
    Commented Aug 13, 2023 at 10:15

1 Answer 1


The first step to do this correctly is to prepare and organize your data. An amazing reference on how to undertake survival analysis using Stata is Cleves et al.'s 2010 book (refs below). It is very clear and helpful, plus it includes worked examples and commands. I agree with Nick in the comments about the syntax error. Since the goal is to investigate the same relationship over time, there is no need to define three sets of variables. You could just re-estimate the same model for each sub-period or consider a different one, such as a piecewise model.

On the logistic regression point, the use of logit (or similar) models for discrete-time survival analysis requires a specifically structured dataset. Stephen Jenkins explains it well at p.95 of his unpublished manuscript (2005, still available); the procedure is also described in the Stata help. Honestly, I am not sure how well this kind of discrete-time survival models deals with fixed effects and multilevel interactions. However, the literature you refer to may provide further details in this regard.


  • Cleves, M., Gould, W. W., Gutierrez, R. G., & Marchenko, Y. U. (2010). An introduction to survival analysis using Stata, Third Edition. College Station. TX: Stata Press, StataCorp.
  • Jenkins, S. P. (2005). Survival analysis. Unpublished manuscript, Institute for Social and Economic Research, University of Essex, Colchester, UK.

Your Answer

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