Mark sample 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
RAWILDEMAN29
Posts: 6
Joined: Tue Apr 22, 2014 2:54 pm

Mark sample in runmlwin

Post by RAWILDEMAN29 »

Dear colleagues,

I would like to know how to activate the marksample function of Stata in runmlwin.

I know in Stata, it is marksample1 if xvar==value, and then after that if correlation, it is corr x y if sample1==1.

Thank you,
Russell
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Mark sample in runmlwin

Post by ChrisCharlton »

The same syntax that you referred to should apply, i.e.:

Load data:

Code: Select all

use http://www.bristol.ac.uk/cmm/media/runmlwin/tutorial, clear
Run model on full dataset:

Code: Select all

. runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause
 
MLwiN 2.31 multilevel model                     Number of obs      =      4059
Normal 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)   =       1.08
Number of iterations =          4
Log likelihood       = -4678.6211
Deviance             =  9357.2422
------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |   .0023908   .0400224     0.06   0.952    -.0760516    .0808332
    standlrt |   .5633712   .0124654    45.19   0.000     .5389394    .5878029
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                   var(cons) |   .0921275   .0181475      .0565591     .127696
-----------------------------+------------------------------------------------
Level 1: student             |
                   var(cons) |    .565731   .0126585      .5409209    .5905412
------------------------------------------------------------------------------
Mark subsample to use:

Code: Select all

. mark sample1 if girl==1
Run model on subsample:

Code: Select all

. runmlwin normexam cons standlrt if sample1==1, level2(school: cons) level1(student: cons) nopause
 
MLwiN 2.31 multilevel model                     Number of obs      =      2436
Normal response model
Estimation algorithm: IGLS

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
         school |       55          1       44.3        120
-----------------------------------------------------------

Run time (seconds)   =       1.21
Number of iterations =          3
Log likelihood       = -2761.4929
Deviance             =  5522.9858
------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |    .059983   .0461238     1.30   0.193    -.0304179     .150384
    standlrt |   .5563728   .0164685    33.78   0.000     .5240951    .5886504
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                   var(cons) |   .0965134   .0217593       .053866    .1391608
-----------------------------+------------------------------------------------
Level 1: student             |
                   var(cons) |   .5403317   .0156572      .5096441    .5710193
------------------------------------------------------------------------------
You can also skip the -mark- command and use an expression directly:

Code: Select all

. runmlwin normexam cons standlrt if girl==1, level2(school: cons) level1(student: cons) nopause
 
MLwiN 2.31 multilevel model                     Number of obs      =      2436
Normal response model
Estimation algorithm: IGLS

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
         school |       55          1       44.3        120
-----------------------------------------------------------

Run time (seconds)   =       1.23
Number of iterations =          3
Log likelihood       = -2761.4929
Deviance             =  5522.9858
------------------------------------------------------------------------------
    normexam |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |    .059983   .0461238     1.30   0.193    -.0304179     .150384
    standlrt |   .5563728   .0164685    33.78   0.000     .5240951    .5886504
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                   var(cons) |   .0965134   .0217593       .053866    .1391608
-----------------------------+------------------------------------------------
Level 1: student             |
                   var(cons) |   .5403317   .0156572      .5096441    .5710193
------------------------------------------------------------------------------

RAWILDEMAN29
Posts: 6
Joined: Tue Apr 22, 2014 2:54 pm

Re: Mark sample in runmlwin

Post by RAWILDEMAN29 »

Thank you Chris.

Much appreciated,
Russell
Post Reply