Announcement

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

  • Troubleshooting a random-intercept model

    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? Thank you so much

    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.

  • #2
    To follow-up: Since I'm using STATA 15, it looks like using "mixed" instead of "xtmixed" corrected it. I don't see an option to delete my post yet. So am posting this as opposed to deleting the post

    Comment


    • #3
      Thank you for posting your solution to your problem. There is no option for deleting posts, for good reason.

      The Statalist Forum is not a help desk. It is a community of Stata users who are sharing what they know and don't know and learning together. So when we find a solution to our own problem, the norm is to continue the thread and show the solution. That way, when someone encounters a similar problem and searches Statalist for a solution, they will find your problem statement and solution.

      Comment


      • #4
        Maisha, please also note that the -xi- prefix has long been unnecessary (I think since Stata 12). You can just write factor variable notation directly without any prefix. I'm not sure if that would have made any difference, but it's a good to get out of the habit.
        Be aware that it can be very hard to answer a question without sample data. You can use the dataex command for this. Type help dataex at the command line.

        When presenting code or results, please use the code delimiters format them. Use the # button on the formatting toolbar, between the " (double quote) and <> buttons.

        Comment

        Working...
        X