Random slope model in Runmlwin

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
ashish123
Posts: 9
Joined: Thu Mar 20, 2014 12:59 pm

Random slope model in Runmlwin

Post by ashish123 »

Hello,
I am working on impact of contextual factors on some health outcomes using
DHS data. For this purpose I am using Runmlwin program for running MLwIN within stata.I am employing the two level random intercept and random slope models. At the level one i am considering individual observation while at second level I am aggregating the individual level variable at area(psu) level
the syntax for the model is
runmlwin con_use cons pl_res literate sli_medi sli_high sur_daug age20_34 age35_44,
>level2(psu:cons nav_sli pro_cast) ///
>level1(lineno:)///
>discrete(distribution(binomial)link(logit)denominator(cons) pql2)///
I would like to ask that whether model specification at level 2 is appropriate i.e psu level variable (nav_sli and pro_caste) which are aggregate of individual level at psu (area) level in random part of the model.
Any positive response will be appreciated.
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Random slope model in Runmlwin

Post by GeorgeLeckie »

Hi Ashish,

You propose entering level-2 covariates into your two-level model with random-coefficients at level-2. This is somewhat unusual, normally we enter level-1 covariates with random-coefficients at level-2. What you are proposing is to essentially model the level-2. variance as a function of the level-2 covariate. That is, you are specifying a variance-function at level-2 (i.e., modelling heteroskedasticity at level-2).

Best wishes

George
ashish123
Posts: 9
Joined: Thu Mar 20, 2014 12:59 pm

Re: Random slope model in Runmlwin

Post by ashish123 »

Hello Lackie,
Thank for your response.Actually i would like to discuss that in two level binary response multilevel model, if i have some variables at second level(continuous type e.g wealth score) then how i can model the random slope and random intercept model with this varible in runmlwin program.Moreover, can i include one more aggregate level variable at level 2 (continuous ).I have run the previous posted syntax & it gives an error (i.e pro_caste is not allowed).Please guide me how to proceed in these kind of situation.Looking forward to reply
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Random slope model in Runmlwin

Post by GeorgeLeckie »

Hi Ashish,

As I said, entering level-2 predictors with random-coefficients defined at level-2 is non-standard. Most text books do not discuss this. When you do this you are specifying the level-2 random variability to be a heteroskedastic function of the level-2 predictor.

Consider the two-level logistic regression model with a random-intercept and where we enter a level-2 predictor with a random-coefficient at level-2

passexam_ij ~ Binomial(1,p_ij)

logit(p_ij) = b0 + b1*girl_ij + b2*avslrt_j + u0_j + u1_j*avslrt_j

We can fit this model using runmlwin as follows

Code: Select all

* Load the data
use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear

* Generate a binary response variable
generate passexam = (normexam>0)

* Fit two-level logistic regression with random-intercept and random-slope on
* a level-2 predictor
runmlwin passexam cons girl avslrt, ///
  level2(school: cons avslrt) ///
  level1(student:) ///
  discrete(distribution(binomial) link(logit) denom(cons)) ///
  nopause
The associated output is

Code: Select all

. * Load the data
. use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear

. 
. * Generate a binary response variable
. generate passexam = (normexam>0)

. 
. * Fit two-level logistic regression with random-intercept and random-slope on
. * a level-2 predictor
. runmlwin passexam cons girl avslrt, ///
>   level2(school: cons avslrt) ///
>   level1(student:) ///
>   discrete(distribution(binomial) link(logit) denom(cons)) ///
>   nopause
 
MLwiN 2.30 multilevel model                     Number of obs      =      4059
Binomial logit response model
Estimation algorithm: IGLS, MQL1

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
         school |       65          2       62.4        198
-----------------------------------------------------------

Run time (seconds)   =       1.80
Number of iterations =          7
------------------------------------------------------------------------------
    passexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |  -.1087616   .0793823    -1.37   0.171     -.264348    .0468248
        girl |   .2845695   .0825477     3.45   0.001     .1227791      .44636
      avslrt |   1.466569   .2479272     5.92   0.000      .980641    1.952498
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                   var(cons) |   .1031355   .0450527      .0148338    .1914373
            cov(cons,avslrt) |   .1442892   .1130338     -.0772531    .3658314
                 var(avslrt) |   1.283261   .6167635      .0744267    2.492095
------------------------------------------------------------------------------
This model does not have a random-slope interpretation. Rather it has a complex-variation at level-2 interpretation.

Essentially you are allowing the school effects to have a heteroskedastic variance given by the following expression

Var(u0_j + u1_j*w_j) = sigma2_u0 + 2*sigma_u02*w_j + sigma2_u2*w_j^2

So don't think of sigma2_u0 and sigma2_u2 as the intercept and slope variance. Rather think of them simply as coefficients of an expression for the heteroskedastic between school variance.

Best wishes

George
ashish123
Posts: 9
Joined: Thu Mar 20, 2014 12:59 pm

Re: Random slope model in Runmlwin

Post by ashish123 »

Hello Lackie,

Thank you for response with appropriate example. actually, I need a favor i would like to see the effect of community level variable(education and health) on some health outcome at individual as well as area level.I would like to know whether these runmlwin syntax will fulfill my purpose.

Random intercept model:

Code: Select all

. runmlwin con_use cons, ///
  level2(psu:cons) ///
  level(lineno:) ///
  discrete(distribution(binomial) link(logit) denominator(cons) pql2)
Random slope model:

Code: Select all

. runmlwin con_use cons pl_res literate sli_medi sli_high sur_daug age20_34 age35_44 nav_sli pro_cast, ///
  level 2(psu: cons any level one variable) ///
  level1(lineno:) ///
  discrete(distribution(binomial) link(logit) denominator(cons) pql2)  
(1) I have included community level variable(nav_sli, pro_cast) in fixed part of the model.will it serve my objective of looking the effect of community level variable on health outcome?

(2) At level 2 what kind of variable i should include ,Any suggestions.

Sorry for bothering you again.You previous replies has helped me immensely.If you have any other suggestion or improvement regarding analysis plan then please mention.
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Random slope model in Runmlwin

Post by GeorgeLeckie »

Hi Ashish,

A level-2 variable can only explain level-2 variation in the response.

So an area-level education variable (e.g., proportion of individuals with secondary education) can only explain area level differences in the response.

If you want to see how education explains both individual and area level variation then you should enter into the model an individual-level measure of education (e.g, a binary indicator of whether each individual completed secondary schooling) as well as an area-level variable (e.g., the proportion of individuals with secondary education.

Best wishes

George
ashish123
Posts: 9
Joined: Thu Mar 20, 2014 12:59 pm

Re: Random slope model in Runmlwin

Post by ashish123 »

Hi Lackie,
Thank you for your response.As you said only level -2 variable can explain the variance at level-2.I am including two aggregate variables(at level 2; nav_sli pro_cast) in the fixed part of the model.I would like to know whether that would be appropriate to analyse effect of level 2 co variate on response variable.
Kindly comment on the validity of codes for Random slope model attached here.

.runmlwin con_use cons urban literate sli_medi sli_high sur_daug age20_34 age35_44 nav_sli pro_cast, ///
level 2(psu: cons urban) ///
level1(lineno:) ///
discrete(distribution(binomial) link(logit) denominator(cons) pql2)
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Random slope model in Runmlwin

Post by GeorgeLeckie »

If you want to know what the effect of a level-2 variable is on the response variable, then yes, include that variable in the fixed part of the model.
Post Reply