discrete time multilevel event history 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
scarpent
Posts: 12
Joined: Thu Apr 19, 2012 6:43 am

discrete time multilevel event history model

Post by scarpent »

Dear George,

I am trying to run a multilevel event history model in discrete time with the very useful command runmlwin.
However, I am not able to do mcmc estimation (and to obtain deviance statistics), as stata gives me the comment “unrecognized command: putmata”

I am using the following command in stata SE 11 after running the model with igls estimation:
runmlwin dead cons seqvar seqvar_quadratic seqvar_cubic geslacht_zm z_lft z_lft_squared, level2 (cniscit: cons) level1 (insz) ///
discrete(distribution(binomial) link(cloglog) denominator(cons)) nopause mcmc(on) initsprevious

the full mcmc estimation procedure seems to be done in Mlwin, but however there appears to be a problem.

Can you suggest me what I can do?

Best wishes,

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

Re: discrete time multilevel event history model

Post by GeorgeLeckie »

Hi Sarah,

That sounds odd. First rule out the obvious by making sure that you are using the latest version of runmlwin

Code: Select all

. ssc install runmlwin, replace
Then check and let us know whether the following two-level complementary log-log model works for you?

Code: Select all

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

generate lc1 = (lc==1)

generate lc2 = (lc==2)

generate lc3plus = (lc>=3)

runmlwin use cons lc1 lc2 lc3plus age, ///
	level2(district: cons) ///
	level1(woman) ///
	discrete(distribution(binomial) link(logit) denominator(cons)) ///
	nopause

runmlwin use cons lc1 lc2 lc3plus age, ///
	level2(district: cons) ///
	level1(woman) ///
	discrete(distribution(binomial) link(cloglog) denominator(cons)) ///
	mcmc(burnin(100) chain(100)) initsprevious ///
	nopause
You should get the following output

Code: Select all

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

. 
. generate lc1 = (lc==1)

. 
. generate lc2 = (lc==2)

. 
. generate lc3plus = (lc>=3)

. 
. runmlwin use cons lc1 lc2 lc3plus age, ///
>         level2(district: cons) ///
>         level1(woman) ///
>         discrete(distribution(binomial) link(cloglog) denominator(cons)) ///
>         nopause
 
MLwiN 2.25 multilevel model                     Number of obs      =      2867
Binomial cloglog response model
Estimation algorithm: IGLS, MQL1

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
       district |       60          3       47.8        173
-----------------------------------------------------------

Run time (seconds)   =       1.87
Number of iterations =          5
------------------------------------------------------------------------------
         use |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
        cons |  -1.452805   .1021738   -14.22   0.000    -1.653062   -1.252548
         lc1 |   .7986261   .1035022     7.72   0.000     .5957654    1.001487
         lc2 |   1.013427   .1100134     9.21   0.000     .7978048    1.229049
     lc3plus |   .9755441   .1151138     8.47   0.000     .7499252    1.201163
         age |  -.0140022   .0048857    -2.87   0.004    -.0235779   -.0044264
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |   Estimate   Std. Err.     [95% Conf. Interval]
-----------------------------+------------------------------------------------
Level 2: district            |
                   var(cons) |   .1656706   .0430655      .0812637    .2500775
------------------------------------------------------------------------------

. 
. runmlwin use cons lc1 lc2 lc3plus age, ///
>         level2(district: cons) ///
>         level1(woman) ///
>         discrete(distribution(binomial) link(cloglog) denominator(cons)) ///
>         mcmc(burnin(100) chain(100)) initsprevious ///
>         nopause
 
MLwiN 2.25 multilevel model                     Number of obs      =      2867
Binomial cloglog response model
Estimation algorithm: MCMC

-----------------------------------------------------------
                |   No. of       Observations per Group
 Level Variable |   Groups    Minimum    Average    Maximum
----------------+------------------------------------------
       district |       60          3       47.8        173
-----------------------------------------------------------

Burnin                     =        100
Chain                      =        100
Thinning                   =          1
Run time (seconds)         =       8.88
Deviance (dbar)            =    3547.90
Deviance (thetabar)        =    3504.78
Effective no. of pars (pd) =      43.11
Bayesian DIC               =    3591.01
------------------------------------------------------------------------------
         use |      Mean    Std. Dev.     ESS     P       [95% Cred. Interval]
-------------+----------------------------------------------------------------
        cons |  -1.512619   .0568166        6   0.000    -1.619796    -1.42745
         lc1 |   .8606958   .0803905       18   0.000     .6911665    1.012832
         lc2 |   1.035085   .1022211        9   0.000      .766243    1.236741
     lc3plus |   .9891277   .0751214        5   0.000     .8546815    1.127385
         age |  -.0111892   .0035376       25   0.000    -.0185326   -.0049203
------------------------------------------------------------------------------

------------------------------------------------------------------------------
   Random-effects Parameters |     Mean   Std. Dev.   ESS     [95% Cred. Int]
-----------------------------+------------------------------------------------
Level 2: district            |
                   var(cons) |  .1782444  .0450026     13   .1115918  .2932636
------------------------------------------------------------------------------

. 
end of do-file
Best wishes

George
scarpent
Posts: 12
Joined: Thu Apr 19, 2012 6:43 am

Re: discrete time multilevel event history model

Post by scarpent »

Dear George,

Thank you for your reaction.
I use the latest version from runmlwin.
I can run the igls estimation for the two-level cloglog model with the bristol cmm-data, and I obtain the same output (however, with the cloglog link function, and not with the logit).
By contrast, when I try to run the mcmc estimation of the model, I get the same error message “unrecognized command: putmata”

Best wishes,

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

Re: discrete time multilevel event history model

Post by ChrisCharlton »

It sounds as if you may not have Stata fully up to date. According to http://www.stata.com/help.cgi?whatsnew11 the putmata command was added to Stata 11 in the 11feb2010 update.

Ideally you would update Stata with the following command:

Code: Select all

update all
If for some reason you are unable to do this then you might be able to trick runmlwin into thinking that it's running in an older version of Stata by using the version prefix, i.e. something like:

Code: Select all

version 10: runmlwin normexam cons standlrt, level2(school: cons) level1(student: cons) nopause
scarpent
Posts: 12
Joined: Thu Apr 19, 2012 6:43 am

Re: discrete time multilevel event history model

Post by scarpent »

Hi,

Thank you for the suggestions.
After updating stata I still receive an error message:
setup_problem(): 3499 strtoreal() not found
put(): - function returned error
<istmt>: - function returned error
But with the prefix version 10: it works.

Thanks a lot!

Best wishes,

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

Re: discrete time multilevel event history model

Post by ChrisCharlton »

Assuming that you restarted Stata after the update I'm not sure what would be causing this. strtoreal (http://www.stata.com/help.cgi?mf_strtoreal) is function that should be part of Stata.

You should be able to check whether there is anything else to update with the command

Code: Select all

update query
If you still can't get it to work without the version prefix then I can only suggest that you see whether Stata support can help you further.
Post Reply