Announcement

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

  • How to Lag Variables in a Three-Level Mixed Effects Model

    Dear Stata Listserv,

    I’m seeking help with how to lag variables in a three-level mixed effects model using the mixed command. Level 1 is individuals, level 2 is the country-year, and level 3 is the country.

    Before my current project, I was working with country-year (pooled time-series) data, using the mixed command. With these data, it was a simple matter to xtset the data <xtset country year> and then use the L. operator to lag any time-varying variables. More recently, however, I merged in individual-level data from the World Values Survey into this existing country-year dataset. So the basic unit of analysis is now the individual person (nested within survey years, nested within countries). With the individual-level data merged in, Stata (version 15) is no longer allowing me to xtset the data, so I can’t use the L. operator. However, I still want to lag my country-level time-varying variables by one year or more. How can I do that?

    Thanks a lot,

    Louisa
    Last edited by Louisa Roberts; 16 May 2019, 12:05.

  • #2
    You'll increase our ability to help you by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dataex.

    You can combine the country numerical indicator with the individual numerical indicator to create a country-individual panel indicator. If country is a 2 digit number and individual a 4 digit number
    g panel=country*100000+individual

    would work.

    Comment

    Working...
    X