Dear Statalisters,
Here's something I just learned (the hard way) about the mixed command in Stata.
I'm fitting thousands of mixed models to determine a frequentist model averaging (FMA) estimator for a set of fixed effects. Since my focus is not on the random effects, I'm using the nostderr option to speed up the process.
I was surprised to find that this makes a difference when I later use estat ic to calculate information criteria, such as Akaike's information criterion (AIC), which I need to determine FMA weights.
Here's an example from the documentation:
Since AIC is calculated as -2 * log-likelihood + 2 * degrees of freedom, everything works as intended because, by default, Stata computes the number of degrees of freedom as kf + kr, where kf and kr are the number of estimated fixed-effects (here: 7) and random-effects parameters (here: 3).
So I didn't expect that the results would change if I used
. However, this is not the case:
As you can see, the number of degrees of freedom is now 7 instead of 10. One could argue that this makes sense because the standard errors for the random effects are not calculated. However, I didn't expect this to affect the computation of information criteria, so I thought it might be worth mentioning.
HTH,
Ali
Here's something I just learned (the hard way) about the mixed command in Stata.
I'm fitting thousands of mixed models to determine a frequentist model averaging (FMA) estimator for a set of fixed effects. Since my focus is not on the random effects, I'm using the nostderr option to speed up the process.
I was surprised to find that this makes a difference when I later use estat ic to calculate information criteria, such as Akaike's information criterion (AIC), which I need to determine FMA weights.
Here's an example from the documentation:
Code:
use https://www.stata-press.com/data/r18/productivity, clear . mixed gsp private emp hwy water other unemp || region: || state: Performing EM optimization ... Performing gradient-based optimization: Iteration 0: Log likelihood = 1430.5017 Iteration 1: Log likelihood = 1430.5017 Computing standard errors ... Mixed-effects ML regression Number of obs = 816 Grouping information ------------------------------------------------------------- | No. of Observations per group Group variable | groups Minimum Average Maximum ----------------+-------------------------------------------- region | 9 51 90.7 136 state | 48 17 17.0 17 ------------------------------------------------------------- Wald chi2(6) = 18829.06 Log likelihood = 1430.5017 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ gsp | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- private | .2671484 .0212591 12.57 0.000 .2254814 .3088154 emp | .754072 .0261868 28.80 0.000 .7027468 .8053973 hwy | .0709767 .023041 3.08 0.002 .0258172 .1161363 water | .0761187 .0139248 5.47 0.000 .0488266 .1034109 other | -.0999955 .0169366 -5.90 0.000 -.1331906 -.0668004 unemp | -.0058983 .0009031 -6.53 0.000 -.0076684 -.0041282 _cons | 2.128823 .1543854 13.79 0.000 1.826233 2.431413 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects parameters | Estimate Std. err. [95% conf. interval] -----------------------------+------------------------------------------------ region: Identity | var(_cons) | .0014506 .0012995 .0002506 .0083957 -----------------------------+------------------------------------------------ state: Identity | var(_cons) | .0062757 .0014871 .0039442 .0099855 -----------------------------+------------------------------------------------ var(Residual) | .0013461 .0000689 .0012176 .0014882 ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 1154.73 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . estat ic Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 816 . 1430.502 10 -2841.003 -2793.959 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] IC note.
So I didn't expect that the results would change if I used
Code:
nostderr
Code:
. mixed gsp private emp hwy water other unemp || region: || state:, nostderr /// <-- here's the change Performing EM optimization ... Performing gradient-based optimization: Iteration 0: Log likelihood = 1430.5017 Iteration 1: Log likelihood = 1430.5017 Mixed-effects ML regression Number of obs = 816 Grouping information ------------------------------------------------------------- | No. of Observations per group Group variable | groups Minimum Average Maximum ----------------+-------------------------------------------- region | 9 51 90.7 136 state | 48 17 17.0 17 ------------------------------------------------------------- Wald chi2(6) = 18829.06 Log likelihood = 1430.5017 Prob > chi2 = 0.0000 ------------------------------------------------------------------------------ gsp | Coefficient Std. err. z P>|z| [95% conf. interval] -------------+---------------------------------------------------------------- private | .2671484 .0212591 12.57 0.000 .2254814 .3088154 emp | .754072 .0261868 28.80 0.000 .7027468 .8053973 hwy | .0709767 .023041 3.08 0.002 .0258172 .1161363 water | .0761187 .0139248 5.47 0.000 .0488266 .1034109 other | -.0999955 .0169366 -5.90 0.000 -.1331906 -.0668004 unemp | -.0058983 .0009031 -6.53 0.000 -.0076684 -.0041282 _cons | 2.128823 .1543854 13.79 0.000 1.826233 2.431413 ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ Random-effects parameters | Estimate Std. err. [95% conf. interval] -----------------------------+------------------------------------------------ region: Identity | var(_cons) | .0014506 . . . -----------------------------+------------------------------------------------ state: Identity | var(_cons) | .0062757 . . . -----------------------------+------------------------------------------------ var(Residual) | .0013461 . . . ------------------------------------------------------------------------------ LR test vs. linear model: chi2(2) = 1154.73 Prob > chi2 = 0.0000 Note: LR test is conservative and provided only for reference. . estat ic Akaike's information criterion and Bayesian information criterion ----------------------------------------------------------------------------- Model | N ll(null) ll(model) df AIC BIC -------------+--------------------------------------------------------------- . | 816 . 1430.502 7 -2847.003 -2814.072 ----------------------------------------------------------------------------- Note: BIC uses N = number of observations. See [R] IC note.
HTH,
Ali
Comment