Model Failure, exiting procedure

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
as3601
Posts: 14
Joined: Thu Apr 07, 2011 2:31 pm

Model Failure, exiting procedure

Post by as3601 »

Hi Guys,

I am running a simulation, and sometimes the model doesnt fit. I expect this to happen on the odd occasion. However it would be nice if MLwiN didn't exit with an error and stop the simulation running.
What would be nice if there was stored local macro saying if the model had converged and everything went ok i.e. 1 and returned 0 if it had not.

Obviously this functionality is really only appropriate for simulation type studies as you want people to be aware of when the model hasn't fitted.

i.e. a similar function to statas capture command.

The error code i get is :
******************************************************
error while obeying batchfile mypath
@ line 59 CALC c502 = sqrt(c502)
999 numeric error in calc command
first 20 entries affected listed
Affected entries replace with system missing
******************************************************
This error relates to the generation of the residual standard errors.

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

Re: Model Failure, exiting procedure

Post by ChrisCharlton »

You can check whether (R)IGLS models have converged by looking in e(converged), although if the macro doesn't finish running this might not be filled in. There is already an MLwiN macro command to ignore errors in macros (ERRO 0) which is sometimes used in simulations. We shall investigate whether this can be used by the macros generated by runmlwin (the danger is that important messages may be missed). In the mean time, could you let me know whether the simulation is still aborted if you put a capture command in front of the runmlwin?

as3601
Posts: 14
Joined: Thu Apr 07, 2011 2:31 pm

Re: Model Failure, exiting procedure

Post by as3601 »

Hi Chris,

If you capture runmlwin it still stops working.

I agree. missing important error messages is a problem, but in a simulation as long as you know which ones failed you can knock them out at the end.


Many thanks for the quick response.

Cheers
Adrian

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

Re: Model Failure, exiting procedure

Post by GeorgeLeckie »

Hi Adrian,

The cause of your error message is that some of the posterior variances of your residuals are negative. MLwiN attempts to take the square root of these posterior variances in order to calculate the posterior standard errors. You can't square root negative numbers hence the MLwiN error message that you received.

We will add a variances suboption to the residuals option to allow the return of the posterior variances instead of the posterior standard errors. Sometimes one wants the posterior variances directly rather than the posterior standard errors so this is a useful option to have in its own right. Adding this option should also solve your problem as when specified MLwiN will no longer attempt to calculate the square root of the negative numbers.

Why you get negative posterior variances is a separate problem and not one I want to get into here! Broadly, these negative posterior variances probably reflects the fact that the estimation model that you are specifying is rather different from the data generating model or that the parameters or data structure of the data generating model are in some way peculiar or extreme.

We will announce on this thread once we have implemented the variances sub option to the residuals option.

Best wishes

George

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

Re: Model Failure, exiting procedure

Post by GeorgeLeckie »

Hi Adrian,

We have now implemented the variances sub option to the residuals option. This new option allows users to request the posterior variances for their residuals rather than the default of the posterior standard deviations.

Using this option will also get around the error which you ran into previously, though I encourage you to work out what the root cause of the original error was. (Check that the way you are simulating data makes sense)

To get the latest version of runmlwin, simply type the following in a net-aware version of Stata:

. adoupdate runmlwin, update

Best wishes

George

Post Reply