Subscripts in multivariate model

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Post Reply
ahigginson
Posts: 2
Joined: Fri Jan 06, 2012 1:45 am

Subscripts in multivariate model

Post by ahigginson »

I'm trying to run a multilevel multivariate model with two responses, nested in individuals, nested in suburbs. When I run a model for either of the two responses separately, the subscripts for the suburb level variables appear with one less subscript letter than the individual level variables as expected, but when I run the multivariate version the subscripts for the suburb level variables have the same subscript as for the individual level variables. This occurs whether I use runmlwin or enter the equation directly into MLwiN. Examples of a simplified code are below. Could you please confirm which way the suburb level variable is being treated?

Thanks,
Angela.


runmlwin (number_friends cons female women_work_outside_suburb_mc, equation(1)) , /// this code gives ij for level 1 subscript and j for level 2 subscript
level2(suburb: (cons, eq(1))) ///
level1(id: (cons, eq(1)))

runmlwin (friends cons female women_work_outside_suburb_mc , equation(1)) /// this code gives ijk for both level 1 and level 2 subscript
(igc cons female women_work_outside_suburb_mc , equation(2)) , ///
level2(suburb: (cons, eq(1)) (cons, eq(2))) ///
level1(id: (cons, eq(1)) (cons, eq(2)))
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Subscripts in multivariate model

Post by GeorgeLeckie »

Hi Angela,

Good question

Consider the following commands which fit a two-level bivariate response model to students' written exam score and students' coursework scores where students are nested within schools:

Code: Select all

use http://www.bristol.ac.uk/cmm/media/runmlwin/gcsemv1, clear
bysort school: egen propfemale = mean(female)

runmlwin ///
    (written cons female propfemale, eq(1)) ///
    (csework cons female propfemale, eq(2)), ///
    level2(school: ///
        (cons, eq(1)) ///
        (cons, eq(2))) ///
    level1(student: ///
        (cons, eq(1)) ///
        (cons, eq(2)) ///
)
The runmlwin output associated with these commands is as follows

Code: Select all

MLwiN 2.24 multilevel model                     Number of obs      =      1905
Multivariate response model
Estimation algorithm: IGLS

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
         school |       73          2       26.1        104
-----------------------------------------------------------

Run time (seconds)   =     304.24
Number of iterations =          4
Log likelihood       = -13397.034
Deviance             =  26794.068
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
written      |
      cons_1 |   57.30624   3.262535    17.56   0.000     50.91179     63.7007
    female_1 |  -2.361196   .5635149    -4.19   0.000    -3.465665   -1.256727
propfemale_1 |  -13.68515   5.454531    -2.51   0.012    -24.37584   -2.994468
-------------+----------------------------------------------------------------
csework      |
      cons_2 |   71.94487   4.224108    17.03   0.000     63.66577    80.22397
    female_2 |    6.79795   .6733461    10.10   0.000     5.478216    8.117684
propfemale_2 |  -3.957516    7.04136    -0.56   0.574    -17.75833    9.843295
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                 var(cons_1) |   43.18563    8.56542      26.39772    59.97355
          cov(cons_1,cons_2) |   23.77094   8.551468      7.010365     40.5315
                 var(cons_2) |   74.78298   14.49797      46.36747    103.1985
-----------------------------+------------------------------------------------
Level 1: student             |
                 var(cons_1) |   124.5577   4.346989      116.0377    133.0776
          cov(cons_1,cons_2) |   73.00115   4.177027      64.81433    81.18797
                 var(cons_2) |   180.0967   6.245744      167.8553    192.3382
------------------------------------------------------------------------------
And so we enter as covariates student gender (a level-1 variable) and the proportion of students in each school (a level-2 variable)

If you now look at the MLwiN equations window (simply fit the model without the nopause option) all covariates, irrespective of the level at which they are measured, have ijk subscripts. Your question is: Why is this?

The reason why all covariates have ijk subscripts is to do with the way that the multivariate response models are setup in MLwiN.
While the data are in wide format in Stata (there is one row per student and two response variables). In MLwiN the data are automatically reshaped to long format (two rows per student, one for written and one for coursework, and one combined response variable). MLwiN then creates two binary response indicator variables (dummy variables) one for each of the two responses. Multivariate response models in MLwiN then interact each covariate with the relevant binary response indicator variable (i.e. dummy variables).

For example we want to include gender twice in the model, once to predict written scores and once to predict coursework scores. The way we do this is to enter gender once interacted with the indicator variable for written scores and once interacted with the indicator variable for coursework scores. The indicator variables vary at level 1 and so any covariate (irrespective of its level) which is interacted with the indicator variable will also be at level 1. Hence the ijk subscripts on all variables.

Suggest you read Chapter 14, Section 14.2, of the MLwiN manual for full details.

http://www.bristol.ac.uk/cmm/software/m ... f#page=230

I hope this helps

George
ahigginson
Posts: 2
Joined: Fri Jan 06, 2012 1:45 am

Re: Subscripts in multivariate model

Post by ahigginson »

Thanks for the quick reply George... that puts my mind at ease! I had read that section of the manual and understood it in terms of the interactions of response and individual characteristics, but obviously didn't extrapolate the effect to the level 2 variable subscripts :D
Post Reply