runmlwin with imputed data

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/
fonnyyyy
Posts: 13
Joined: Mon Jun 16, 2014 8:54 am

Re: runmlwin with imputed data

Post by fonnyyyy »

This is what I further tried to do:

- update the runmlwin-procedure: does not make any difference.
- surpressing the errors on convergence by using the errorok-option and storing the results with the mi saving. This seemed to work but at a giving moment it errored again saying
no imputations to compute between-imputation variance no results will be saved r(2000);
I can provide you with my latest code:

Code: Select all

xi: mi estimate, esampvaryok cmdok post: runmlwin move_a /*
	*/ cons /*
	*/ age_child age_child2 gndr_child i.edu3_child i.mstat_child i.employ_child distance_child_z siblings /*
	*/ i.recent_child transfer_child receive_child /*
	*/ help_child_hh i.help_child_int2 /*
	*/ i.mstat i.edu3 extrahh hinc parent_move iadlmean urban owner/*
	*/ formal_care /*
	*/ i.country if selection > 1 & age_child >= -22.00958, /*
	*/ forcesort level2(couplelevel2: cons, diagonal) level1(n) discrete(dist(multinomial) link(mlogit) denom(cons) basecategory(0)) maxiterations(150) initsv(V) initsb(c) mcmc(on) nopause
Other possibilities:
1) Turn off the maxiterations?
2) Is it a problem for MCMC-estimation to use esampvaryok? I use this because one of my selection-variables (see "if") is imputed and therefore varies between the imputed datasets.

Given the size, providing the dataset is difficult unless I could wetransfer it, or...?
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: runmlwin with imputed data

Post by ChrisCharlton »

Going back to my previous example and updating it to use MCMC worked for me:

Code: Select all

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

. // Make 10% of urban missing
. gen ind = runiform()
. replace urban = . if ind < 0.1
(279 real changes made, 279 to missing)

. // Store IGLS version of the model for initial values
. preserve
. drop if urban == .
(279 observations deleted)
. quietly runmlwin use4 cons urban, ///
>              level1(woman: ) ///
>              discrete(distribution(multinomial) link(mlogit) denominator(cons) basecategory(4)) ///
>              nopause
. estimates store igls
. restore

. // Impute new values for urban
. mi set mlong
. mi register imputed urban
(279 m=0 obs. now marked as incomplete)
. mi impute logit urban age educ hindu, add(10)

Univariate imputation                       Imputations =       10
Logistic regression                               added =       10
Imputed: m=1 through m=10                       updated =        0

------------------------------------------------------------------
                   |               Observations per m             
                   |----------------------------------------------
          Variable |   Complete   Incomplete   Imputed |     Total
-------------------+-----------------------------------+----------
             urban |       2588          279       279 |      2867
------------------------------------------------------------------
(complete + incomplete = total; imputed is the minimum across m
 of the number of filled-in observations.)

. // Now fit the model to the imputed data with MCMC
. mi estimate, cmdok: runmlwin use4 cons urban, ///
>              level1(woman: ) ///
>              discrete(distribution(multinomial) link(mlogit) denominator(cons) basecategory(4)) ///
>              initsmodel(igls) ///
>              mcmc(on) ///
>              nopause

Multiple-imputation estimates                   Imputations       =         10
Unordered multinomial logit response model      Number of obs     =      2,867
                                                Average RVI       =          .
                                                Largest FMI       =          .
DF adjustment:   Large sample                   DF:     min       =     575.76
                                                        avg       =          .
                                                        max       =          .

------------------------------------------------------------------------------
             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
FP1          |
      cons_1 |  -1.805271   .0735022   -24.56   0.000    -1.949362   -1.661179
     urban_1 |   .2412033    .153445     1.57   0.117    -.0601769    .5425836
-------------+----------------------------------------------------------------
FP2          |
      cons_2 |  -1.535267   .0659495   -23.28   0.000     -1.66453   -1.406004
     urban_2 |   1.184752   .1048985    11.29   0.000     .9791343    1.390369
-------------+----------------------------------------------------------------
FP3          |
      cons_3 |  -1.883377   .0760028   -24.78   0.000    -2.032348   -1.734405
     urban_3 |   .2751548   .1526243     1.80   0.072     -.024182    .5744916
-------------+----------------------------------------------------------------
OD           |
     bcons_1 |          1          .        .       .            .           .
------------------------------------------------------------------------------
1) Changing maxiterations shouldn't make any difference as this relates to running the model with (R)IGLS and should there be ignored for your model.
2) I would not expect esampvaryok to cause a problem as MLwiN will only see the shorter dataset at the point of running the model, you could however test this by removing the condition from your model specification.

I would suggest that you diagnose this by starting with the simplest model (for example with just a cons predictor) and once you have determined that this works add in the other features one at a time (i.e. more predictors, the i. syntax and then the condition).
fonnyyyy
Posts: 13
Joined: Mon Jun 16, 2014 8:54 am

Re: runmlwin with imputed data

Post by fonnyyyy »

Ok, thank you once again.

I will first start to try with the IGLS listwise deletion startvalues (cfr. your example). That's something new. :-)
If this doesn't work, I'll try the accumulate-approach following your suggestion.
fonnyyyy
Posts: 13
Joined: Mon Jun 16, 2014 8:54 am

Re: runmlwin with imputed data

Post by fonnyyyy »

After trying everything (empty model, different dependent variables, varying level numbers, new imputed datasets, etc. etc.) I decided to replicate your example using the online bang dataset and the same convergence error occurred. I will now update the MLwiN 2.30 (Stata version is 12.1).
ChrisCharlton
Posts: 1351
Joined: Mon Oct 19, 2009 10:34 am

Re: runmlwin with imputed data

Post by ChrisCharlton »

I just tested my example with Stata 12.1 and didn't get any errors. I would be surprised if it was related to the MLwiN version, but updating is worth a try. Could you also run the Stata command:

Code: Select all

. which runmlwin
and report the output, in case it is picking up an old version of the command from elsewhere for some reason?
Post Reply