runmlwin has encountered an error importing the 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
RitaPatel
Posts: 1
Joined: Fri Mar 16, 2012 12:21 pm

runmlwin has encountered an error importing the model...

Post by RitaPatel »

Hi
My do file stops dispite being done 'noisily'. This has happened 3 times out of 560 combinations of 3 age variables.

This is the main part of the do file:
gen fp1=age_yr
gen fp2=age_yr^2
gen fp3=age_yr^3
gen fpmh=age_yr^-0.5
gen fph=age_yr^0.5
gen fp0=log(age_yr)
gen fpm1=age_yr^-1
gen fpm2=age_yr^-2
gen fpm20=fpm2*fp0
gen fpm10=fpm1*fp0
gen fpmh0=fpmh*fp0
gen fp00=fp0*fp0
gen fph0=fph*fp0
gen fp10=fp1*fp0
gen fp20=fp2*fp0
gen fp30=fp3*fp0

tab treatment, gen(case)
global MLwiN_path C:\Program Files\MLwiN v2.24\mlwin.exe
*********************************************************************
*2. Models with age in occ level- treatment interacts with the 3 vars
**********************************************************************
*Males
tempname memhold
postfile `memhold' str15 var1 str15 var2 str15 var3 loglike deviance converge iter cons coef1 coef2 coef3 using 3boys_fp_loglike_years.dta, replace

/* run fp models */
forvalues i = 354/560{

mata st_local("var1", varcombs[1,`i'])
mata st_local("var2", varcombs[2,`i'])
mata st_local("var3", varcombs[3,`i'])
di `i' "~" "var1: `var1'", _col(15) "var2: `var2'", _col(30) "var3: `var3'"

sort clinic id time
capture noisily runmlwin bmi cons `var1' `var2' `var3' if sex==2, ///
level1 (time: cons ageweeks, diagonal reset(none)) ///
level2 (id: cons `var1' `var2' `var3', reset(none)) ///
level3 (clinic: cons ) ///
nopause maxiterations(100) batch
post `memhold' ("`var1'") ("`var2'") ("`var3'") (e(ll)) (e(deviance)) (e(converged)) (e(iterations)) (_b[cons]) (_b[`var1']) (_b[`var2']) (_b[`var3'])
}

This is the Stata message:

runmlwin has encountered an error importing the model results from MLwiN. Check that the model has run properly in MLwiN.

[fph0] not found
post: above message corresponds to expression 11, variable coef3
r(111);

These are the models which fail:
Model 115
fp2 =age_yr^2
fp3=age_yr^3
fph0= age_yr^0.5* log(age_yr)

Model 353
fph=age_yr^0.5
fpm1=age_yr^-1
fpm10= age_yr^-1* log(age_yr)

Model 504
fpm2=age_yr^-2
fp20= age_yr^2* log(age_yr)
fp30= age_yr^3* log(age_yr)

If I run these particular models in MLWin this is what I see:
MLwin.docx
(100.51 KiB) Downloaded 474 times
I'd be grateful for any help.

Many thanks
Rita
ChrisCharlton
Posts: 1354
Joined: Mon Oct 19, 2009 10:34 am

Re: runmlwin has encountered an error importing the model...

Post by ChrisCharlton »

You should be able carry on with the loop by either putting a capture in front of the post command so that it carries on with the loop when it fails, or by only calling post when runmlwin succeeds by putting it in an if !c(rc) statement.
Post Reply