# Re: st: slopes as outcomes?

 From rgutierrez@stata.com (Roberto G. Gutierrez, StataCorp) To statalist@hsphsun2.harvard.edu Subject Re: st: slopes as outcomes? Date Thu, 16 Nov 2006 10:44:31 -0600

```SamL <saml@demog.berkeley.edu> asks:

> I've attempted to figure out how to specify a slopes-as-outcomes multilevel
> model using _xtmixed- and at this point I am swirling in confusion.  I have
> checked statalist and the manual, and cannot find an example that I am
> confident matches my aim.  So, if my data has persons (i) nested within
> univerities (j), and Model 1, a 2-equation model I seek to estimate, is:

> Y_ij = b0 + b1_j*X1_ij + b2*X2_ij + e_ij
> b0 = g00
> b1_j = g10 + g11*Z1_j + u1_j
> b2 = g20

> what would be the appropriate syntax?

This is equivalent to

Y_ij = g00 + g10*X1_ij + g11*X1_ij*Z1_j + u1_j*X1_ij + g20*X2_ij + e_ij

= (g00 + g10*X1_ij + g11*X1_ij*Z1_j + g20*X2_ij) + u1_j*X1_ij + e_ij

fix in -xtmixed- using

. gen x1z1 = x1*z1
. xtmixed y x1 x1z1 x2 || university: x1, noconstant

Note the -noconstant- option.  This is because you have a random slope on
-x1-, but no random intercept.

> And, if Model 2 has a slightly different specification:

> Y_ij = b0_j + b1*X1_ij + b2*X2_ij + e_ij
> b0 = g00 + g01*Z1_j + u0_j
> b1 = g10
> b2 = g20

This implies

Y_ij = g00 + g01*Z1_j + u0_j + g10*X1_ij + g20*X2_ij + e_ij

= g00 + g01*Z1_j + g10*X1_ij + g20*X2_ij + u0_j + e_ij

fitted as

. xtmixed y z1 x1 x2 || university:

i.e., as a random-intercept (at the university level) model.

They key is to manipulate your multilevel specification so that it reads as
fixed effects part + random effects part.

--Bobby
rgutierrez@stata.com
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```