Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multi-level model (mixed command) with two level 2 variables - Problem with group number in output

    I am using Stata 14.1 on Windows 10.

    I am doing a simple multi-level model on tolerance (tolind) with age (age, agesq), period, and cohort. Period (year) has 17 categories and cohort (cohort5) has 16 categories. Using:

    Code:
    mixed tolind age agesq || cohort5: || year:
    The output shows cohort5 has 16 groups but it shows year having 232 groups. I checked the year variable, it has only 17 groups.

    If I change the code to:

    Code:
    mixed tolind age agesq || year: || cohort5:
    the output shows year with 17 groups and cohort5 with 232 groups.

    The correct code – in terms of order for my level 2 variables is:
    Code:
    mixed tolind age agesq || cohort5: || year:
    Why is year showing 232 groups instead of 17 and how can I correct it?
    Thanks,
    Marie
    Last edited by Marie Eisenstein; 01 Oct 2016, 08:43.

  • #2
    You have coded this model with year nested in cohort5 (or the other way around, the second time). With nesting, if the year 2002 occurs with cohort5 = 1 and also with cohort5 = 5, it is counted as two different years. That is why you are getting those results.

    I suspect it is more likely that you actually have crossed, not nested effects and would need to model them accordingly:

    Code:
    mixed tolind age agesq || _all: R.cohort5 || _all: R.year
    The [ME] manual section on the -mixed- command has some nicely worked example, including an especially simple and clear illustration of this approach to modeling crossed random effects.

    As an aside, if your intent is to model age quadratically, then do not use separate age and agesq variables. Use
    Code:
    mixed tolind c.age##c.age || _all: R.cohort5 || _all: R.year
    This will enable you to make use of the -margins- and -marginsplot- commands after estimation.

    All of that said, and acknowledging that I have only the barest glimpse of what your context is, cohort and year are unusual variables to use as random effects. I'm not saying it's wrong to do that, but it is much more common to model them as fixed effects. Just something to think about.

    Comment


    • #3
      Thank you! This helps me understand perfectly! I'm sure you know this, you are right - I do have crossed effects. I am new to both Stata and multi-level modeling and needed to make sure I understood what was occurring before I build a more complex model (period and cohort as both fixed and random effects). Thanks also for the advice on the age variable.

      Comment

      Working...
      X