# Multilevel model: Include levels as dummies?

In a Stata example for multilevel modeling, Chuck Huber estimates a US state's Gross State Product (gsp) over time (cyear is a centered year variable). In the end, he runs the following Stata code:

xtmixed gsp cyear, || region: || state: cyear, cov(indep)


So he includes state and region as levels, and cyear as a predictor.

My question is: Why does he not include state-dummies as predictors as well? He would then run something like

tabulate state, generate(state_dummy)
xtmixed gsp cyear state_dummy*, || region: || state: cyear, cov(indep)


And what would happen if he did? Would this change the model?

Here are the links to his example:

http://blog.stata.com/2013/02/04/multilevel-linear-models-in-stata-part-1-components-of-variance/

http://blog.stata.com/2013/02/18/multilevel-linear-models-in-stata-part-2-longitudinal-data/

• There is a statistical question here, but my suggestion is that it would make much more sense for you to post this on Statalist. People who don't use Stata will inevitably have to work at guessing what the code does and won't easily be able to show you results. – Nick Cox Dec 5 '16 at 11:57
• @NickCox i think the code in the question is sufficiently close to that of other languages plus the clear explanation of the question for us not to worry. I do not use Stata and I was OK with it. – mdewey Dec 5 '16 at 13:49

You do not include state dummies (as fixed-effects) because you included them as random-effects (by stating "|| betnr:"). You can include in this model an overall (fixed) intercept but not all single state dummies.

By including state dummies you take out all the variation between states which you need to calculate the state random effects.

Try it out

use http://www.stata-press.com/data/r12/productivity.dta
egen cyear = std(year)
xtmixed gsp cyear, || region: || state: cyear, cov(indep)
tabulate state, generate(state_dummy)
xtmixed gsp cyear state_dummy*, || region: || state: cyear, cov(indep)


And look at variation of the random effect "state: Independent" -> "sd(_cons)"

xtmixed gsp cyear state_dummy*, || region: || state: cyear, cov(indep)
note: state_dummy48 omitted because of collinearity
Performing EM optimization:

Iteration 0:   log likelihood =  1285.4493
Iteration 1:   log likelihood =  1286.9064
Iteration 2:   log likelihood =  1286.9508
Iteration 3:   log likelihood =  1286.9508

Computing standard errors:

Mixed-effects ML regression                     Number of obs      =       816

-----------------------------------------------------------
|   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(48)      = 402947.61
Log likelihood =  1286.9508                     Prob > chi2        =    0.0000

-------------------------------------------------------------------------------
gsp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
--------------+----------------------------------------------------------------
cyear |   .1347569   .0080845    16.67   0.000     .1189117    .1506022
state_dummy1 |   1.302481   .0155805    83.60   0.000     1.271944    1.333018
[...]
state_dummy47 |   1.711969   .0155805   109.88   0.000     1.681432    1.742506
state_dummy48 |          0  (omitted)
_cons |   9.235048   .0110171   838.25   0.000     9.213455    9.256641
-------------------------------------------------------------------------------

------------------------------------------------------------------------------
Random-effects Parameters  |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
region: Identity             |
sd(_cons) |   1.80e-11   2.67e-10      4.64e-24    70.07652
-----------------------------+------------------------------------------------
state: Independent           |
sd(cyear) |   .0549153   .0102601      .0380767    .0792005
sd(_cons) |   2.47e-12          .             .           .
-----------------------------+------------------------------------------------
sd(Residual) |   .0454246   .0016555      .0422931    .0487881
------------------------------------------------------------------------------
LR test vs. linear regression:       chi2(3) =   578.39   Prob > chi2 = 0.0000


`

Another way of looking at this is to consider state as a grouping variable. What we are trying to do is to fit a model so that all the units within one level of that variable (i.e. one state) share the same intercept but it may be different from that for other levels. There are two ways of doing this, either to specify parameters of the distribution of the intercepts (random model) or to fit each one with its own parameter (fixed model). Put like perhaps we can see that we can either do one or the other but not both simultaneously.