Page 1 of 1

Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 10:33 am
by Jamoo
Hi,

I have a model which runs fine in MLwiN but then does not import back into Stata. The specific error (displayed in Stata) is as follows:

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

I've checked MLwiN and the model seems to fit fine (all the estimates turn green for example), and when I step through the macro, no error messages are displayed.

I am not sure where to start with sorting this out, so any guidance would be appreciated.

Thanks

Jamie

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 2:34 pm
by GeorgeLeckie
Hi Jamie,

Can you post the following on the forum so that we can see what might be the problem?

(1) Paste the runmlwin syntax;

(2) Paste a screen shot of the MLwiN Equations window for the converged model.

Best wishes

George

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 3:02 pm
by Jamoo
Hi George,

Sorry - I should have posted it before.

1) The runmlwin code is:

Code: Select all

runmlwin deltabmi cons gmcbmi1c sqgmcbmi1c gmcage1 gmcboy gmcbmi1cXgmcboy black asian other ///
		gmcsocial gmcprivate gmcunemployed gmcsinglepar gmcidaci07 gmcvillages gmctowns gmcbuilt ///
		gmcnprogperpm gmcnperprog gmcpcsessions proggmcsdbmi1c proggmcsdbmi1c if bmichangesample==1, ///
		level2(numprogid: cons, residuals(u)) level1(pid: cons) nopause   
2) The screenshot of the MLwiN output is attached.

Best wishes,

Jamie

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 3:27 pm
by GeorgeLeckie
Hi Jamie,

The model looks standard enough and I can see no obvious problems in the MLwiN Equations Window screen shot.

Looking at your syntax, I suspect that the problem lies with either

if bmichangesample==1

or the

, residuals(u)

part of your command.


To see whether this is the case, which if any of the following three models work for you?


* Model 1

Code: Select all

runmlwin deltabmi cons gmcbmi1c sqgmcbmi1c gmcage1 gmcboy gmcbmi1cXgmcboy black asian other ///
gmcsocial gmcprivate gmcunemployed gmcsinglepar gmcidaci07 gmcvillages gmctowns gmcbuilt ///
gmcnprogperpm gmcnperprog gmcpcsessions proggmcsdbmi1c proggmcsdbmi1c if bmichangesample==1, ///
level2(numprogid: cons) level1(pid: cons) nopause 
* Model 2

Code: Select all

keep if bmichangesample==1
runmlwin deltabmi cons gmcbmi1c sqgmcbmi1c gmcage1 gmcboy gmcbmi1cXgmcboy black asian other ///
gmcsocial gmcprivate gmcunemployed gmcsinglepar gmcidaci07 gmcvillages gmctowns gmcbuilt ///
gmcnprogperpm gmcnperprog gmcpcsessions proggmcsdbmi1c proggmcsdbmi1c, ///
level2(numprogid: cons, residuals(u)) level1(pid: cons) nopause 
* Model 3

Code: Select all

keep if bmichangesample==1
runmlwin deltabmi cons gmcbmi1c sqgmcbmi1c gmcage1 gmcboy gmcbmi1cXgmcboy black asian other ///
gmcsocial gmcprivate gmcunemployed gmcsinglepar gmcidaci07 gmcvillages gmctowns gmcbuilt ///
gmcnprogperpm gmcnperprog gmcpcsessions proggmcsdbmi1c proggmcsdbmi1c, ///
level2(numprogid: cons) level1(pid: cons) nopause

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 3:47 pm
by Jamoo
Hi George,

Thanks for taking a look at this. All three scenarios gave the same error as before.

Best wishes and thanks for your time, next time I'm in Bristol (that's right isn't it?) I'll buy you a pint.

Jamie

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 4:44 pm
by GeorgeLeckie
Hi Jamie,

If even Model 3 gave the same error message then try running the following commands to see whether the issue is to do with the IDs:

Code: Select all

* Model 4
keep if bmichangesample==1
egen templev2id = group(numprogid)
sort templev2id
gen templev1id = _n

runmlwin deltabmi cons gmcbmi1c sqgmcbmi1c gmcage1 gmcboy gmcbmi1cXgmcboy black asian other ///
gmcsocial gmcprivate gmcunemployed gmcsinglepar gmcidaci07 gmcvillages gmctowns gmcbuilt ///
gmcnprogperpm gmcnperprog gmcpcsessions proggmcsdbmi1c proggmcsdbmi1c, ///
level2(templev2id : cons) level1(templev1id : cons) nopause
If even this model gives the same error then please email me the data and dofile and we will have a look behind the scenes to see what might be the problem.

Pint in Bristol sounds good!

George

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 5:08 pm
by Jamoo
Hi,

On running your code, I discovered what the error was. I managed to repeat the same variable twice "proggmcsdbmi1c". Serves me right for having incomprehensible variable names.

runmlwin deltabmi cons gmcbmi1c sqgmcbmi1c gmcage1 gmcboy gmcbmi1cXgmcboy black asian other ///
gmcsocial gmcprivate gmcunemployed gmcsinglepar gmcidaci07 gmcvillages gmctowns gmcbuilt ///
gmcnprogperpm gmcnperprog gmcpcsessions proggmcsdbmi1c proggmcsdbmi1c, ///
level2(templev2id : cons) level1(templev1id : cons) nopause

Thanks again for all your help though, pint offer still stands of course.

Jamie

Re: Error importing model results from MLwiN

Posted: Thu Feb 02, 2012 7:44 pm
by GeorgeLeckie
Oh dear, I should have spotted that as well!

Anyway very glad the problem is cleared up

We will look into improving the error checking to avoid duplicate variable names

Best wishes

George