Estimating multiple equations simultaneously

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
sujust18
Posts: 6
Joined: Wed Dec 05, 2012 4:54 pm

Estimating multiple equations simultaneously

Post by sujust18 »

Hello everyone,

is it possible to use runmlwin to estimate multiple equations simultaneously?

1. Seemingly unrelated equations

I'd like to estimate a model that consists of several regression equations, each having its own dependent variable and potentially different sets of exogenous explanatory variables. Each equation is a valid linear regression on its own and can be estimated separately (called seemingly unrelated regressions).
Such separate estimates are consistent, however generally not efficient when the error terms are correlated.

Example:
y1 = b0 + b1*x1 + b2*x2 + b3*x3
y2 = b4 + b5*x1 + b6*x2

Is it possible to estimate such structures with (run)mlwin?

The model can be further generalized into a simultaneous equations model, where the right-hand side regressors are allowed to be the endogenous variables as well.

2. Simultaneous equations model

Example:
y1 = b0 + b1*x1 + b2*x2 + b3*x3
x1 = b4 + b5*x2 + b6*x3

I know that it is possible to substitute the second into the first equation above and rearrange the model but am interested in the specific effects b5 and b6 as well.
Is there a way to implement these multiple equations in (run)mlwin and estimate the coefficients simultaneously?
If not, are you planning to implement this into future versions?

I hope I could make clear what I'd like to do and am looking forward to helpful comments.

Thanks a lot in advance,

Susann
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: Estimating multiple equations simultaneously

Post by GeorgeLeckie »

Dear Susann,

Yes you can fit all the models you describe using runmlwin.

Here is a simple example where we have two equations for two response variables (normexam and standlrt) and the same predictor (girl) in each. You can of course specify different covariates in each equation and you may wish to enter the response from one equation as a covariate in the other equation as you described.

I hope this helps

George

Code: Select all

. use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear

. runmlwin ///
>         (normexam cons girl, eq(1)) ///
>         (standlrt cons girl, eq(2)) ///
>         , ///
>         level2(school: (cons, eq(1)) (cons, eq(2))) ///
>         level1(student: (cons, eq(1)) (cons, eq(2))) ///
>         nopause
 
MLwiN 2.27 multilevel model                     Number of obs      =      4059
Multivariate response model
Estimation algorithm: IGLS

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

Run time (seconds)   =       3.02
Number of iterations =          3
Log likelihood       = -10263.911
Deviance             =  20527.822
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
normexam     |
      cons_1 |    -.16123   .0572912    -2.81   0.005    -.2735187   -.0489414
      girl_1 |    .261202   .0402489     6.49   0.000     .1823155    .3400884
-------------+----------------------------------------------------------------
standlrt     |
      cons_2 |  -.1142065   .0469738    -2.43   0.015    -.2062735   -.0221395
      girl_2 |    .155753   .0401182     3.88   0.000     .0771227    .2343833
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                 var(cons_1) |   .1613725   .0311917      .1002378    .2225072
          cov(cons_1,cons_2) |   .0917668   .0213467      .0499281    .1336055
                 var(cons_2) |   .0913071    .019033      .0540031    .1286112
-----------------------------+------------------------------------------------
Level 1: student             |
                 var(cons_1) |   .8394563   .0187846      .8026391    .8762735
          cov(cons_1,cons_2) |   .4990042   .0158479      .4679429    .5300654
                 var(cons_2) |   .8985293   .0201032      .8591278    .9379308
------------------------------------------------------------------------------
sujust18
Posts: 6
Joined: Wed Dec 05, 2012 4:54 pm

Re: Estimating multiple equations simultaneously

Post by sujust18 »

Hello George,

Thank you very much for your very fast and helpful reply again.

As always, I highly appreciate your reply and the great variety of features in (run)mlwin! :)

I managed to estimate several equations simultaneously and am now facing a new problem.
It would be awesome if you could please help me again.

Is it possible to specify the first equation as a logit model, the second (third and so on) as ordinary linear regressions?

I tried something like the following but unfortunately couldn't figure out the correct structure:

. runmlwin ///
> (normexam cons girl, eq(1)) ///
> (standlrt cons girl, eq(2)) ///
> , ///
> level2(school: (cons, eq(1)) (cons, eq(2))) ///
> level1(student: (cons, eq(1)) (cons, eq(2))) ///
> ,///
> discrete(distribution(binomial) link(logit) denominator(cons), eq(1))
> mcmc(cc) initsb(h1)
> nopause

Thank you so much in advance,

Susann
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: Estimating multiple equations simultaneously

Post by ChrisCharlton »

Your guess is fairly close, however when you specify discrete options for multivariate models with runmlwin you need to specify them for all the equations including those with normal responses. I believe that the correct form for your example model would be something like:

Code: Select all

. use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear

. generate binexam = (normexam>0)

. runmlwin ///
    (binexam cons, eq(1)) ///
    (standlrt cons, eq(2)) ///
    , ///
    level2(school: (cons, eq(1)) (cons, eq(2))) ///
    level1(student: (cons, eq(2))) ///
    discrete(distribution(binomial normal) link(logit) denominator(cons cons)) ///
    nopause

MLwiN 2.27 multilevel model                     Number of obs      =      4059
Multivariate 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)   =       4.27
Number of iterations =          5
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
binexam      |
      cons_1 |   .0358797    .086553     0.41   0.678     -.133761    .2055203
-------------+----------------------------------------------------------------
standlrt     |
      cons_2 |  -.0251763   .0411901    -0.61   0.541    -.1059075    .0555549
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                 var(cons_1) |   .4060033   .0848164      .2397662    .5722404
          cov(cons_1,cons_2) |   .1427446   .0348256      .0744877    .2110015
                 var(cons_2) |   .0916848   .0191831      .0540865     .129283
-----------------------------+------------------------------------------------
Level 1: student             |
                var(bcons_1) |   .9211251   .0200767      .8817755    .9604748
         cov(bcons_1,cons_2) |   .4562295   .0133584      .4300476    .4824115
                 var(cons_2) |          1          0             1           1
------------------------------------------------------------------------------
Note, if you wanted to use MCMC as in your example only the probit link function is implemented for mixed response models in MCMC.

For another example of this see http://www.bristol.ac.uk/cmm/media/runm ... siduals.do.
Post Reply