MVML model: no display _b[cons_2]

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
guobl
Posts: 22
Joined: Wed Nov 18, 2009 12:25 pm

MVML model: no display _b[cons_2]

Post by guobl »

Hi George, here is a question for you.
I run the MVML model from runmliwn help file, it is working very well, but when I wanna use regression coefficient, ie. _b[], I hit a snag, here are the output for your kind reference

. dis _b[female_2]
[female_2] not found
r(111);

. dis _b[cons_2]
[cons_2] not found
r(111);

. dis _b[cons_1]
49.452133

. dis _b[female_1]
-2.5029507

see, I can get the coefficents for the 1st equation, could not get them for the 2nd equation. any help pls?
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: MVML model: no display _b[cons_2]

Post by GeorgeLeckie »

Hi guobl,

Yes the parameter referencing is little bit trickier in multivariate response models.

Here are the necessary commands...

Code: Select all

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

* Fit the two-level students-within-schools bivariate response model for students' written and coursework marks
runmlwin ///
	(written cons female, eq(1)) ///
	(csework cons female, eq(2)) ///
	, ///
	level2(school: (cons, eq(1)) (cons, eq(2))) ///
	level1(student: (cons, eq(1)) (cons, eq(2))) ///
	nopause

* List the vector of parameter estimates in order to check their internal Stata names
matrix list e(b)

* Display the intercept for the first equation
display _b[FP1:cons_1]

* Display the female coefficient for the first equation
display _b[FP1:female_1]

* Display the intercept for the second equation
display _b[FP2:cons_2]

* Display the female coefficient for the second equation
display _b[FP2:female_2]
Output...

Code: Select all

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

. 
. * Fit the two-level students-within-schools bivariate response model for students' written and cou
> rsework marks
. runmlwin ///
>         (written cons female, eq(1)) ///
>         (csework cons female, 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      =      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)   =       3.56
Number of iterations =          4
Log likelihood       = -13400.244
Deviance             =  26800.488
------------------------------------------------------------------------------
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
written      |
      cons_1 |   49.45213   .9338434    52.96   0.000     47.62183    51.28243
    female_1 |  -2.502951   .5607219    -4.46   0.000    -3.601945   -1.403956
-------------+----------------------------------------------------------------
csework      |
      cons_2 |   69.67165   1.171786    59.46   0.000       67.375    71.96831
    female_2 |   6.751392   .6706493    10.07   0.000     5.436944    8.065841
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: school              |
                 var(cons_1) |   46.81301   9.187332      28.80617    64.81985
          cov(cons_1,cons_2) |   24.87784   8.880355      7.472661    42.28301
                 var(cons_2) |   75.16624   14.56484      46.61968    103.7128
-----------------------------+------------------------------------------------
Level 1: student             |
                 var(cons_1) |   124.6343   4.349835      116.1088    133.1598
          cov(cons_1,cons_2) |   73.00323    4.17829      64.81393    81.19253
                 var(cons_2) |   180.0982   6.245802      167.8566    192.3397
------------------------------------------------------------------------------

. 
. * List the vector of parameter estimates in order to check their internal Stata names
. matrix list e(b)

e(b)[1,10]
             FP1:          FP1:          FP2:          FP2:          RP2:          RP2:
          cons_1      female_1        cons_2      female_2   var(cons_1)  cov(cons_~2)
y1     49.452133    -2.5029507     69.671654     6.7513924     46.813007     24.877836

             RP2:          RP1:          RP1:          RP1:
     var(cons_2)   var(cons_1)  cov(cons_~2)   var(cons_2)
y1     75.166245     124.63431     73.003227     180.09819

. 
. * Display the intercept for the first equation
. display _b[FP1:cons_1]
49.452133

. 
. * Display the female coefficient for the first equation
. display _b[FP1:female_1]
-2.5029507

. 
. * Display the intercept for the second equation
. display _b[FP2:cons_2]
69.671654

. 
. * Display the female coefficient for the second equation
. display _b[FP2:female_2]
6.7513924

guobl
Posts: 22
Joined: Wed Nov 18, 2009 12:25 pm

Re: MVML model: no display _b[cons_2]

Post by guobl »

Thanks George,
follow your suggestion, I can use the fixed coefficients from each equation for further analysis such as nlcom, however, there is still one more thing need your help. Here is the question, I can not pick up the covariance term from e(b) using same approach. For both level 1 and level 2, I can only pick up the variances term. See the output pls. Maybe I incorrectly name the covariance term?

display _b[RP2:var(cons_1)]
46.813007
display _b[RP2:var(cons_2)]
75.166245

display _b[RP2:cov(cons_2,cons_2)]
[RP2:cov(cons_2,cons_2)] not found
r(111);

display _b[RP1:var(cons_1)]
124.63431

display _b[RP1:var(cons_2)]
180.09819

display _b[RP1:cov(cons_1,cons_1)]
[RP1:cov(cons_1,cons_1)] not found
r(111);
GeorgeLeckie
Site Admin
Posts: 432
Joined: Fri Apr 01, 2011 2:14 pm

Re: MVML model: no display _b[cons_2]

Post by GeorgeLeckie »

Hi guobl,

You need...

Code: Select all

_b[RP1:cov(cons_1\cons_1)]
Rather than

Code: Select all

_b[RP1:cov(cons_1,cons_1)]
as Stata doesn't like commas in parameter names. So while we display the latter in the Results window, the actually underlying name which you need to refer to is the former.

You can see all the parameter names by typing

Code: Select all

. matrix list e(b)
after fitting a model

I hope that helps

George
guobl
Posts: 22
Joined: Wed Nov 18, 2009 12:25 pm

Re: MVML model: no display _b[cons_2]

Post by guobl »

Thanks George,
sorry have to stick my head with MVML model at the moment!! I also tested MCMC function for MVML model minutes ago. Unlike the the general ML MCMC modelling, after I run the MVML model using runmlwin example, I notice the model run as expected without savingchains, but can not save the chain values, here is the output again for your kind reference.

runmlwin (written cons female, eq(1)) (csework cons female, eq(2)), level2(school: (cons, eq(1)) (cons, eq(2))) level1(student: (cons, eq
(1)) (cons, eq(2))) nopause initsprevious mcmc(on savechains(Z:\stats\mvml_mcmc_output, replace))

variable FP1_cons_1 not found
r(111);

thanks for your attention and help George.
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: MVML model: no display _b[cons_2]

Post by ChrisCharlton »

I can't replicate the exact error that you are seeing, however I do get an error if I don't put a .dta extension on the specified chains file. Could you try adding this and seeing whether you get the same issue?
guobl
Posts: 22
Joined: Wed Nov 18, 2009 12:25 pm

Re: MVML model: no display _b[cons_2]

Post by guobl »

Many thanks Chris, I got the saved parameters chain file now, following your suggestion, yes, with dta extension!!
Post Reply