Hi All,

My question: Would you have an idea why my random-effects model is reporting a much lower # observations and # groups than I expect?

Some background:
  • This is an unbalanced longitudinal dataset for K-8 students, where each student can have either 2 or 3 years of data. The person-unit variable is record_id (unique to each student) and the time variable is year (values: 1, 2, 3). In the long dataset, n=4581
  • I ran a random-effects model assessing the longitudinal association between proportion of absences (variable name: absenty_p, it is a continuous variable) and the child's mean BMI (variable name: bmim). Although BMI is an age and gender-adjusted measure, I wanted to see if random intercepts by the grade-levels (variable name: grade, values: 0-8) are statistically significant or not. I also wanted to see if the random slopes by grade are stat sig or not. So, I ran the following model:
  • RANDOM INT-ONLY: xi: xtmixed: absenty_p bmim || grade:
  • RANDOM INT & RAND SLOPE: xi: tmixed: absenty_p bmim || grade: bmim
Given there are about 2500 observations with non-missing absences, BMI, and grade info, and that there are eight grades, I'm surprised that the above models' results report n=343 and #groups=1 (instead of the 8 grades). Am I missing something? Would you guys know why the n is not closer to 2500 and the #groups is not 8?

The STATA results are below:

Code:
. xi: xtmixed absenty_p2 bmim || grade: 

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log likelihood =  439.52204  
Iteration 1:   log likelihood =  439.54599  
Iteration 2:   log likelihood =  439.54626  
Iteration 3:   log likelihood =  439.54626  

Computing standard errors:

Mixed-effects ML regression                     Number of obs     =        343
Group variable: grade                           Number of groups  =          1

                                                Obs per group:
                                                              min =        343
                                                              avg =      343.0
                                                              max =        343

                                                Wald chi2(1)      =       0.04
Log likelihood =  439.54626                     Prob > chi2       =     0.8378

------------------------------------------------------------------------------
  absenty_p2 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        bmim |  -.0001856   .0009069    -0.20   0.838    -.0019632    .0015919
       _cons |    .069757   .0171076     4.08   0.000     .0362267    .1032873
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
grade: Identity              |
                   sd(_cons) |   1.16e-12   2.22e-11      6.27e-29    21485.93
-----------------------------+------------------------------------------------
                sd(Residual) |   .0671777   .0025649      .0623341    .0723976
------------------------------------------------------------------------------
LR test vs. linear model: chibar2(01) = 1.1e-13       Prob >= chibar2 = 1.0000

. xi: xtmixed absenty_p2 bmim || grade: bmim

Performing EM optimization: 

Performing gradient-based optimization: 

Iteration 0:   log likelihood =  439.48383  
Iteration 1:   log likelihood =  439.54043  
Iteration 2:   log likelihood =  439.54626  
Iteration 3:   log likelihood =  439.54626  

Computing standard errors:

Mixed-effects ML regression                     Number of obs     =        343
Group variable: grade                           Number of groups  =          1

                                                Obs per group:
                                                              min =        343
                                                              avg =      343.0
                                                              max =        343

                                                Wald chi2(1)      =       0.04
Log likelihood =  439.54626                     Prob > chi2       =     0.8378

------------------------------------------------------------------------------
  absenty_p2 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        bmim |  -.0001856   .0009069    -0.20   0.838    -.0019632    .0015919
       _cons |    .069757   .0171076     4.08   0.000     .0362267    .1032873
------------------------------------------------------------------------------

------------------------------------------------------------------------------
  Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
grade: Independent           |
                    sd(bmim) |   3.37e-12   5.55e-09             0           .
                   sd(_cons) |   6.20e-11   1.41e-07             0           .
-----------------------------+------------------------------------------------
                sd(Residual) |   .0671777   .0025649      .0623341    .0723976
------------------------------------------------------------------------------
LR test vs. linear model: chi2(2) = 1.1e-13               Prob > chi2 = 1.0000

Note: LR test is conservative and provided only for reference.