Panel models

Repeated observations of the same people: random-effects logit

mecompare works after panel models such as xtlogit. The example uses the Health and Retirement Study, 2010 to 2020: about 104,000 interviews of 26,000 people aged 51 and older, interviewed every two years. The outcome is depressive symptoms (four or more of the eight CES-D items).

use "https://tdmize.github.io/data/data/hrs_si_2025", clear
keep if year >= 2010 & age >= 51
(169,991 observations deleted)
generate depressed = cesd >= 4 if !missing(cesd)
(5,843 missing values generated)
generate poorhealth = srhealthB == 0 if !missing(srhealthB)
(101 missing values generated)
drop if missing(depressed, poorhealth, marstatB, age, woman, race4cat, collegeB)
(6,274 observations deleted)
xtset hhidpn year
Panel variable: hhidpn (unbalanced)
 Time variable: year, 2010 to 2020, but with gaps
         Delta: 1 unit

. 
quietly xtlogit depressed i.marstatB c.age i.woman i.race4cat i.collegeB, re intpoints(60)
estimates store dep

After xtlogit, re, the marginal effects are changes in the probability of the outcome, averaged over the random effect (the default prediction of margins). Age is changed by ten years:

mecompare, models(dep) amount(10)
Predicting: Pr(depressed=1)

Marginal effects (N_dep=104078)

                                 |  ME #   Estimate         SE      P>|z|
---------------------------------+---------------------------------------
marstatB                         |                                       
    currently m - not curren     |                                       
                             dep |     1     -0.090      0.003      0.000
---------------------------------+---------------------------------------
age + 10 (centered)              |                                       
                             dep |     2     -0.012      0.001      0.000
---------------------------------+---------------------------------------
woman                            |                                       
                 woman - man     |                                       
                             dep |     3      0.039      0.003      0.000
---------------------------------+---------------------------------------
race4cat                         |                                       
         NH Black - NH White     |                                       
                             dep |     4      0.016      0.004      0.000
         Hispanic - NH White     |                                       
                             dep |     5      0.075      0.006      0.000
            Other - NH White     |                                       
                             dep |     6      0.054      0.009      0.000
---------------------------------+---------------------------------------
collegeB                         |                                       
    college degr - no degree     |                                       
                             dep |     7     -0.070      0.004      0.000

Being married is associated with a 9.0 percentage point reduction in the probability of depressive symptoms. Ten more years of age are associated with a 1.2 point reduction, and a college degree with a 7.0 point reduction.

Comparing two outcomes

The second model predicts fair or poor self-rated health. With two panel models, mecompare combines them with suest2, which clusters the standard errors on the panel identifier. Random-effects models need enough integration points to be combined; these two need intpoints(60), and mecompare says when a model needs more.

quietly xtlogit poorhealth i.marstatB c.age i.woman i.race4cat i.collegeB, re intpoints(60)
estimates store health
. 
mecompare, models(dep health) amount(10)
NOTE: mecompare clusters the standard errors on the highest-level group of the multilevel or panel m
> odel(s), so they will differ from the models' own. Fit every model without vce(robust); mecompare 
> supplies the clustering.


Predicting: Default prediction for each model

Marginal effects and cross-model differences (N_dep=104078) (N_health=104078)

                                 |  ME #   Estimate  Robust SE      P>|z|
---------------------------------+---------------------------------------
marstatB                         |                                       
    currently m - not curren     |                                       
                             dep |     1     -0.090      0.003      0.000
                          health |     2     -0.057      0.004      0.000
                      Difference |     3     -0.034      0.004      0.000
---------------------------------+---------------------------------------
age + 10 (centered)              |                                       
                             dep |     4     -0.012      0.002      0.000
                          health |     5      0.035      0.002      0.000
                      Difference |     6     -0.046      0.002      0.000
---------------------------------+---------------------------------------
woman                            |                                       
                 woman - man     |                                       
                             dep |     7      0.039      0.003      0.000
                          health |     8     -0.012      0.005      0.012
                      Difference |     9      0.051      0.004      0.000
---------------------------------+---------------------------------------
race4cat                         |                                       
         NH Black - NH White     |                                       
                             dep |    10      0.016      0.004      0.000
                          health |    11      0.101      0.006      0.000
                      Difference |    12     -0.085      0.006      0.000
         Hispanic - NH White     |                                       
                             dep |    13      0.075      0.006      0.000
                          health |    14      0.207      0.007      0.000
                      Difference |    15     -0.132      0.007      0.000
            Other - NH White     |                                       
                             dep |    16      0.054      0.009      0.000
                          health |    17      0.090      0.012      0.000
                      Difference |    18     -0.036      0.012      0.002
---------------------------------+---------------------------------------
collegeB                         |                                       
    college degr - no degree     |                                       
                             dep |    19     -0.070      0.004      0.000
                          health |    20     -0.167      0.005      0.000
                      Difference |    21      0.097      0.005      0.000

Being married is associated with a larger reduction in the probability of depressive symptoms (9.0 percentage points) than in the probability of fair or poor health (5.7 points); the difference of 3.4 points has p < .001. Age and gender go in opposite directions for the two outcomes: ten more years of age are associated with a 1.2 point reduction in depressive symptoms but a 3.5 point increase in fair or poor health, and women are 3.9 points more likely than men to report depressive symptoms but 1.2 points less likely to report fair or poor health.

A random-effects model mixes differences between people with changes within a person. The within-person effects example separates them.

Back to top