Announcement

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

  • xtset with unbalanced nested panel data

    Hello
    I am trying to perform a fixed effect analysis on student achievement gain scores. My data is nested panel data that is two-level data as I have gain scores of students within classrooms. I have 1-2 gain scores for students, and there are 20-30 students per classroom. My data is such that:

    class_room student_id . gain_score gain_year
    1 1 2 1
    1 2 3 1
    1 3 2 1
    2 1 2 2
    2 4 1 1
    2 5 2 1
    2 2 2 2

    My data is unbalanced as I only have records for the students in the classrooms and they may proceed in these schools or drop-out. Additionally because the students are nested within the classrooms they would naturally be repeated measures within the classrooms. I used the code: xtset class_room gain_year and received the error: repeated time values within panel. I am not sure how best to proceed.Any suggestions would be greatly appreciated.

  • #2
    Kim:
    welcome to this forum.
    If your data are nested and your regressand is continuous, why not considering -mixed-?
    That said, whenever Stata throws the error you received after -xtset-. provided that you're not interested in using time series related commands such as lags and leads, you can simply -xtset- your data with -panelid- only:
    Code:
    xtset panelid
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you so much Carlo. I am using -mixed for most of the analysis, but I wanted to separate the fixed effect at school/class level (so using xtset panelid then xtreg gain_score covariates, fe). I just wanted to confirm that i didn't need to add in a time variable after xtset, since given the nature of the data it is panel data, but is also nested. many thanks!

      Comment


      • #4
        Kim:
        the main issue seems to be that you have repeated time values within the same panel. The usual work-around is to -xtset- your dataset with -panelid- only. Unfortunately, this fix comes at the cost of making the use of time series related commands, sigh as lags and leads, unfeasible.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X