# Errors and crashes

## Errors and crashes: Error messages during estimation/implausible results

### I get an error message when I run my model/ numerical problems

The linear multilevel model can be written in the general form
(1)
The matrix V is constructed from the random parameters - the variances and covariances of the random effects in E and an estimate of it used in the above expression. The estimates of the random parameters are also functions of the data and V (Goldstein, 2003).
The RIGLS/IGLS algorithm iteratively estimates the random and fixed parameters. In some circumstances it is possible to obtain inadmissible estimates for components of the model and MLwiN will issue one of the following warnings. You may need to take action, to ignore the warning or to proceed. Note that when carrying out a bootstrap any of these conditions will result in that particular bootstrap replicate being ignored and an extra failed replicate will be registered.

• V has gone negative definite
• The V matrix for a higher level unit or block has become negative definite. This can occur when, for example, the variance function for a particular combination of explanatory variable values becomes negative. Common cases are with repeated measures models where high order polynomials are fitted or in models where the level 1 variance is fitted as a function of a continuous explanatory variable such as age. MLwiN will automatically approximate V by the nearest positive definite matrix using a singular value decomposition.
• This problem may only occur during the course of iterations and convergence may eventually be achieved smoothly. If the problem persists and even if convergence is obtained you should carefully examine the specification of your model to see whether there is an obvious problem which can be fixed by adding or removing parameters.
• SSP matrix for fixed (random) part has gone negative definite
• The matrix has become negative definite. This can occur in similar situations to those above and MLwiN will approximate to the nearest positive definite matrix.
• Matrix in constraint procedure has gone negative definite
• When constraints are used, for example in cross classified models and generalised linear models, a further matrix which should be positive definite is created involving the constraint vectors and in some circumstances this can become negative definite. The matrix is approximated by the nearest positive definite matrix. Less is known about why this happens, and you should examine your model and any imposed constraints carefully.
• Random part has gone to zero - cannot continue
• Sometimes, in complex models, all the random parameters obtain zero values during iterations. In this situation the estimation cannot continue and you will need to restart and you should look carefully at your model. This sometimes occurs because the starting values used are inappropriate.
• Try running a simpler model than the one you wish to fit and then add further terms when convergence has been achieved. If you have already built up your model in this way try restarting with the most complex model specified.

### I got an error message 'cannot allocate rmatrix(fs)(like)'

This message is probably produced because you do not have enough memory available. To work around this you can either work with a subset of your data or close other applications to make more memory available.

### I tried to run a binomial model and got an error message

I (successfully) ran a multinomial model, then cleared the Equations window and set up a binomial model. When I pressed Start, I got an error message which said:

"error while obeying batch file C:\Program Files\MLwiN v2.10\discrete\pre at line number 11: name c1180 'H' C1181 'F~(H)' C1182 'H*' C1183 'P' c1184 'MASK' c1189 'Y-VAR'
Duplicate column name."

This error message occurs because when MLwiN estimates a binomial or multinomial model, it sets up some special columns in the worksheet. When it does this it gives them certain names. The names for the columns used when running a multinomial model are P, -P, H, F~(H), H*, Pi and Y-VAR, and these occupy c1178 to c1183 and c1189. When the model is cleared, these columns are not deleted. If another multinomial model is set up and run, c1178 to c1183 and c1189 get given these names again. This does not cause a problem because the same column is being given the same name. However, if instead a binomial model is set up and run, the names and locations of some of the special columns are different: H, F~(H), H*, P and Y-VAR are put in c1180 to c1183 and c1189. When MLwiN tries to give these names to these columns, it discovers that P is already the name of c1178. Since there can't be two columns with the same name, the error message is produced.

To solve the problem, after you clear the Equations window simply scroll down in the Names window to find c1178 to c1189, highlight these columns and select the Delete button at the top of the window. This removes the contents of the columns and renames them c1178, c1179, and so on. When you set up and run the binomial model MLwiN is then able to properly create the special columns it needs.

Note that the same problem does not occur if you try to run a multinomial model after having run a binomial model. This is because, although c1183 is already named P when MLwiN tries to name c1178 P, c1183 is being given a new name in the same command, and so c1178 is successfully named P without there being 2 columns with the same name.

### I tried to run a binomial model and got an error message (2)

Example question: I tried to set up and run a binomial model using a macro, but got the error message 'Variables random at bottom level should not be used in model'

It sounds as though you have included a command in your macro like this:

setv 1 'cons'

and this is causing the error message that you see. When fitting a binomial model, it is not necessary to specify an error term at level 1. This is because the level 1 error term is already included in the model, with a binomial distribution, when you specify a binomial response (It is attached to a specially created variable, which does not appear elsewhere in the model). When specifying models in the Equations window using the Graphical User Interface, you are not given the option to specify that any variable be random at level 1. Using commands or macros it is of course possible to issue a command that makes this specification, but this causes an error when MLwiN attempts to estimate the model. If you press the Start button after setting up a model like this using commands or a macro you will see the same error message. If you remove the command "setv 1 'cons' " from your macro the model should run as expected. For more information about binomial response models and level 1 residuals, see section C6.4 of the module on binary response models in our online training materials.

### When do I allow negative variances?

A common situation where you may wish to allow negative variances is when carrying out an iterated bootstrap for bias correction. In some cases allowing a variance, especially a level 1 variance, to go negative during the iterative procedure, can prevent estimation failure. For example, if the level 1 variance is very small compared to that at higher levels, the IGLS algorithm can stick at a zero estimate of the level 1 variance if a negative level 1 variance is encountered at an iteration and reset to zero - and at the subsequent iteration also be reset to zero so that convergence appears to have been achieved. Allowing it to go negative can avoid this problem and result in a final positive converged value. The most important case is when modelling complex level 1 variation with the variance a quadratic function of an explanatory variable. Here it is perfectly legitimate to have a negative variance so long as the total variance is not negative.

### I get an error message 'wrong parameter...' when using MCMC

Example question: I just tried to use MCMC methods in MLwiN but I always get error messages (wrong parameter...) even if I try to follow the tutorial in Chapter 10 of the MCMC manual.

This error may be caused by using a comma as the decimal separator. If you do not have the most recent version of MLwiN, you may find that upgrading to this version solves the problem. If you still experience the problem when using the most recent version, then try changing the decimal separator that your computer uses to a '.' (via Regional and Language Options in the Windows Control Panel).

### When I get the error message "MCMC error 0315: prior variance matrix is not positive definitive" while running a multinomial model using MCMC, what exactly do I need to do to the numbers in C1096?

Example question: I'm trying to run a two-level multinomial model using MCMC: the outcome variable has 4 categories (cat 1 n=6168, cat 2 n=1160, cat 3 n=1608, cat 4 n=1393). The dataset comprises 200 areas and 10,329 individuals. When switching the estimation control from mql/pql to MCMC I get the following error message: "MCMC error 0315: prior variance matrix is not positive definitive" followed by "Error in MCMC start-up - estimation halted". I checked HELP in MLwiN and it indicated I needed to manually change a setting at column 1096 but insufficient information is provided as to how to do this. I subsequently sent an email to the multilevel listserv and received the following helpful response from Bill Browne…

"the MQL method must have produced a variance matrix at a higher level that is non positive definite i.e. it estimates a correlation between random effects outside the range -1 to 1. In C1096 the numbers should correspond to the ones you see in the equations window and are starting from the highest level the lower diagonal elements of all the variance matrices. My advice is to run in MQL/PQL then before switching to MCMC go into c1096 and switch off diagonal elements to 0 - to check you are doing this correctly if you have the equations window up next to the data window then when you change the value in the data window the corresponding value in the equations window will change. Once you have changed all the off-diagonal elements to zero switch to MCMC and things should run".

… I followed Bill's advice and MCMC ran fine (which suggests I followed the advice correctly). However, I then added additional variables to my model and again went through the process of generating starting values using mql/pql and then switching to MCMC and the same two error messages returned, however, this time resetting the off-diagonal values to zero in c1096 did not fix the problem. And unfortunately my technical/programming knowledge of MCMC is very limited.

Bill's advice sounds spot on and I am surprised that it didn't solve the problem the second time round. Note, if you add any additional random effects then the rows of c1096 that you set to zero the second time will differ from the first time. Make sure that the second time you run the model the variance-covariance matrices look as Bill described before starting the MCMC chain. Also check whether any of the on-diagonal terms (i.e. the variances as opposed to covariances) are zero. If so, try changing them to 0.001.

Note that not positive definite does NOT mean the matrix contains some elements which are negative. It is perfectly possible for a matrix which contains only positive elements to not be positive definite. Therefore when following the advice above it is important to change ALL the off-diagonal elements to 0, not just any negative off-diagonal elements.

### I get an error message asking me to 'generate unique ID codes'. How do I do this?

Example question: I am attempting to fit a 3-level proportional odds model with time (measured in months) as the first level, person (RID) as the second level, and institution (FID) as the third level. In setting up an ordinal model I get the error message

"Unexpanded level 2 id column (Month)must not contain consecutive repeated codes, in multivariate or multinomial models. Use GENErate command to generate unique ID codes".

I do not understand what is needed of the data and it isn't clear from the data manipulation menu how to use the GENE command. Please advise me on this.

When you fit a multinomial model (whether ordinal or unordered), MLwiN needs your level 1 ID codes to obey the condition that the same value does not appear on adjacent rows of the dataset. So if your level 1 is Month, you can't for example have values of 1,2,3 for Individual 1 and 3,4,5 for Individual 2 because then the level 1 ID column will read '1,2,3,3,4,5,…' and that repeated 3 is a problem. (This does not apply to Normal response models, where repeated values like this are not a problem). To get around this, the simplest thing is to create a new variable to be your level 1 ID which has values 1,2,3,4,...,n where n is the length of your dataset: in other words a variable which is just a seqence from 1 to the length of the dataset, and which takes no account of any information about individuals or time points. This is what the error message is asking you to do when it tells you to use the GENErate command (more on this in a moment). You might think using a sequence like this as your level 1 ID is a problem because you are discarding all your information about when people were measured. However this information can still go into this model if you put Month in as an explanatory variable (you will probably want to do this anyway). The explanatory variable is the proper place for this information; all that is needed for the level 1 ID is that it should change from row to row, to signify that each row is a different occasion, it doesn't matter for the level 1 ID how far apart the occasions are or which people are measured on the same occasion.

The reason that repeated values are a problem is that MLwiN needs to create an expanded dataset when you fit a multinomial model, as described in the User's Guide. (With a Normal response model, MLwiN does not expand the dataset). The process that it uses to expand the dataset requires that the level 1 IDs satisfy this condition. In the expanded dataset, a new level 1 is created and the level you specified as level 1 is now level 2, so the level 2 referred to in the error message is the level you specified as level 1.

The sequence to use for level 1 in place of Months can be created either using a command or via the GUI. To create using the GUI, select 'Generate vector' from the 'Data Manipulation' menu. In the window that appears, select 'Sequence' under 'Type of vector'. Select any free column next to 'Output column' and type 1 next to 'Start number', the length of your dataset (this would be for example the length of your Month variable) next to 'End number' and 1 next to 'Step value' and select 'Generate'. To create using a command, in the Command interface window type 'Gene 1 n 1 c100', replacing n by the length of your dataset and c100 by any free column; for example if your Months variable is of length 4587 and column 48 is free you could type 'Gene 1 4587 1 c48'.

### Implausible results or convergence problems

You may sometimes obtain estimates for a model which seem to be incorrect. Possibilities are:

1. A value is clearly inconsistent with the model setup. This will often arise when you are running models which rely upon macros for implementation, such as MQL/PQL discrete response models. Check the settings carefully and in particular make sure that you have not overwritten any reserved columns or boxes.
2. The estimates are unexpected. In this case you may, of course, have a genuinely new result, but you should also make sure that you check every aspect of your model setup carefully. Try taking out parameters and reinserting them and look carefully at residuals and associated Normal plots etc.
3. Make sure that you have sorted the data within the worksheet to correspond to the multilevel structure you are modelling.
4. It is often a good idea to centre continuous (but not discrete) variables around their grand mean - this can avoid numerical problems.
5. Try building up your model in a different way. For example, start with a variance components model and add random coefficients rather than trying to fit many random coefficients from scratch.

### MLwiN is giving the standard errors of parameter estimates as 0, but I know from comparison with other software packages that the standard errors should not be 0

Example question: I have been using MLwiN to fit an ordered categorical model. In the first instance I have been doing this for a single level model and have been replicating the analysis in SPSS. When I fit a model including only the ordered response variable SPSS and MLwiN give the same answers more or less. When I add a categorical fixed effect explanatory variable, all but two of the standard errors of the parameter estimates are set to zero in MLWin. They are not in SPSS. Is there any explanation for this? I have suppressed the warning of negative variance in the iterative procedure to obtain convergence, is this the key? Is there any way round it? I am keen to pursue the use of MLWin because it is more powerful and I am particularly interested in the standard errors of the predictions. Thanks.

You can check whether these standard errors have really been set to zero or if they have been estimated but are very small. Check this by changing the display format for numbers from 3 decimal places to 3 significant figures. Go to: options Numbers (Display precision and missing value code) and change the selection from 'decimal format' to 'signif digit format'; in the box '# significant digits' select 3. If standard errors are still zero then you have some kind of estimation problem. One reason may well be: MLwiN is more sensitive than SPSS and Stata and can fail to estimate models that SPSS and Stata provide numbers for. This can be a good thing as MLwiN will fail when a model is poorly specified whilst SPSS/Stata will throw out results and you may not realise you have a problem. So make sure that your model makes sense and that all the variables in the model are sensible and have sensible distributions. You could try to see if the problem applies with other explanatory variables and an alternative ordered response. Other possibilities are: You have done something wrong in setting up the model in MLwiN. Check very carefully that the summary statistics for your variables look the same as in SPSS. Make sure that you have read the relevant chapter in the User Guide (chapters 9 and 11).Then try repeating your MLwiN/SPSS comparison for the simpler case of a binary response (i.e. collapse your ordered outcome down to two categories). As for 'suppressing the warning of negative variance in the iteratice procedure', there is no variance (apart from the implicit probit or logit variance) in single level ordered models so you should not be doing this.

## Errors and crashes: Crashes/ problems opening MLwiN or worksheets

### Why has MLwiN crashed?

If you encounter a crash in MLwiN please report it via the bug report page: https://www.cmm.bris.ac.uk/clients/bugreport/

### The European convention of using a comma as a decimal point causes MLwiN 2.10 to crash when using the Intervals and Tests window

Changing the windows decimal separator to a point (.) resolves this problem. You can do this via the regional settings screen available from the Windows control panel.

### MLwiN fails to open after changing the default worksheet settings

If you run into this problem do the following:

1. Open the windows command line (Start Run)
2. Type the following in the windows command line:mlwin /reset. MLwiN will launch with its default worksheet settings
3. In MLwiN, open the worksheet window (Options worksheet)
4. Adjust the worksheet setting to your desired values and then select the use as defaults button. MLwiN will now be able to open on subsequent attempts to launch the software.

### When I run MLwiN I get the error message "Pre or Post file does not exist (post)"

Example question: I have just successfully installed MLwiN. However upon initiation of MLwiN, I now receive the message "Pre or Post file does not exist (post)". Is this OK, or should it be repaired?

Open the OptionsDirectories menu. If User defined settings is chosen check that the specified files and directories exist

If this problem has been encountered when running a macro that specifies a path for these files, check that the path is correctly specified in the macro.

### I have a worksheet saved on a network drive that I can't open using MLwiN

It is possible to open, work with and save worksheets on a network drive. However, you will need to have the drive mapped to a drive letter (and to type the filepath in this form, if you are opening/ saving the worksheet via commands). This is because MLwiN does not recognise the more recent notation for accessing a network drive directly. If using the GUI to open and save files, then provided the drive you want to access has been mapped to a drive letter, the procedure is just the same as when opening files saved on your local computer: simply browse to find the network drive (which will probably have its name in the longer more recent notation but with the letter after it in brackets), double click on it just as with a folder, and continue browsing to find your worksheet, then click on the worksheet and select Open. If using commands to open and save files, then for example if you have a network drive mapped to the letter Q and want to open 'file1.ws' in the Data folder in this drive, you would type:
"RETR 'Q:\Data\file1.ws' "
"RETR '\\computername\sharedfolder\Data\file1.ws' ".

If you have a worksheet saved to a network drive which is not mapped to a drive letter then the simplest thing to do is to copy the worksheet to your local computer disk (or a memory stick) and open it from there.

This applies to both MLwiN worksheets and to SPSS, Stata, and Minitab worksheets (if using MLwiN version 2.10).

### When I try to open the worksheets for the LEMMA course I get an error message

Example question: I'm taking the LEMMA Course and until yesterday everything was working perfectly, but today I just couldn't open the MLwiN Datafiles. Every time I try I get this message: "Run-time error '5': Invalid procedure call or argument". I've already install the latest version (2.10 beta 6), but it didn't work. I tried several times uninstalling and reinstalling the software, but it didn't work… Any ideas of what can I do? Many thanks in advance.

Has anything on your system changed between when you were able to open the worksheets and now? Examples might be other software being installed or removed. It might be worth manually clearing the MLwiN installation directory after removing it, before attempting to reinstall it. This is the directory where you chose to install it (usually C:\Program Files\MLwiN v2.10). If you have an account with administrative privileges on that machine it might also be worth checking to see if you have the same problems when running as that user.

Enquirer's reply: I don't have administrator rights in my computer, it is a pain each time I need to install a software. Finally I could open the files. As I realized I can open the old example files, what I did was to save the files in my computer and then change the extension from '.wsz' to '.ws' I know it is not the best, but it worked.

### When I double click on one of the worksheets for the LEMMA course, it opens with notepad not MLwiN

Example question: When I select the icon for 5.1.wsz in Module 5.1 I seem to get a notepad file that has a lot of blank characters, not a data file.

First note that the datasets for the LEMMA course will not open with MLwiN version 2.02: you will need version 2.10 or the teaching version ( which you can download for free here). Make sure that you have one of these versions of MLwiN. If you do have the appropriate version but are experiencing this problem, then first try reinstalling your copy of MLwiN. If this fails, you can try downloading again and then reinstalling. If that doesn't work or if you cannot do this, there are two options: a work around or a fix.

Option 1: Work around
When you select the link to the datafile, choose Save to computer instead of Open. Then start MLwiN and open the data file from MLwiN's File menu.

Option 2: Fix
The fix is to reassociate the data file's .wsz extension with MLwiN (so that Windows opens them in MLwiN if you double click them, or if you choose Open instead of Save to computer when downloading), which is pretty easy and takes just a minute.
Again, when you select the link to the datafile in your browser choose Save to computer rather than Open, and save for example to My Documents. Then open up My Documents or whichever folder you have saved the file into in Windows Explorer - so you can see the data file's icon. If the cause of the problem with opening the files is the situation this fix is designed for, then it should not have the MLwiN logo on it. (If the data file does have the MLwiN logo then there is probably a different cause of the problem and this fix will probably not work).
The next part of these instructions is written correctly for Windows XP, but probably something similar will work for Windows Vista. Right click on the data file (i.e. select with the right mouse button, not the left one that people usually use), and choose the menu option Open With, then in the submenu select Choose Program. You should get a new window with a list of programs and a tick box labelled "Always use the selected program to open this kind of file" WHICH YOU SHOULD TICK, then select MLwiN, then select OK. If MLwiN is not in the list of programs, select the Browse button and locate and open the "mlwin.exe" file. It would normally be in the folder C:\Program Files\MLwiN v2\ or C:\Program Files\MLwiN v2.10. (Note that the icon for the program should be pale blue and white, not yellow and dark blue: the program with the yellow and dark blue icon is version 2.02 which will not open the LEMMA datafiles).
After doing this, the data file on your computer should now have the MLwiN logo, and when you double click it should open up in MLwiN, and when you open files directly from your browser, they should open in MLwiN too.

Enquirer's reply:I didn't reinstall, but I tried the work around (didn't work), and the fix (which did).

## Errors and crashes: Other errors/ problems

### When trying to plot a graph, I get the error message 'Failed to open Graphics Server'

Example question: I have worked through Module 5 up to p. 8 (P5.1.2) but when I try to produce the caterpillar plot (selecting 'apply' in the Plots tab), I get the error message: 'Failed to open Graphics Server', selecting OK or closing produces the error message: 'The server is already running', Clicking or closing this message repeats the earlier message, and so on …

• The following may fix this
2) Close all open copies of MLwiN
4) Select the "Processes" tab
5) Locate and select "gsw32.exe" from the list and select "End Process"
6) Open MLwiN
8) Try producing the graph again

### Why has my data become corrupted?

It is possible that data in the worksheet columns can become corrupted unintentionally for a number of reasons:

• When fitting discrete response models the data are transformed during the course of an iteration and later transformed back to their original values. If a problem occurs which interrupts an iteration the data may remain in their transformed state. If your data have been corrupted you must retrieve a correct worksheet. Corruption of data in this way will often become apparent when highly implausible results are seen
• An abnormal termination while running a generalised linear model or a macro may result in data corruption.
• You may have read data (at input or subsequently) into a protected or reserved column and since these columns are used by MLwiN to store various parameters anything in these columns will be overwritten.

You should always make sure that you have a recent backed up worksheet copy which you can retrieve if you get into this situation

### I can't get the LOGOn command to work

The command LOGO <filename> does not work in the current version of MLwiN. However the commands LOGO <filename> 1 to switch on logging and LOGO 0 to switch logging off should do exactly the same thing the LOGO <filename> command used to do. Note that the <filename> needs to be the full path of the file, unless you have set the working directory to the directory that the file is in using Options dIrectories and then setting the directory using the current directory box.

To make things clearer, here is an example of using the LOGO command that should work:

ECHO 1
LOGO 'C:\Documents and Settings\All Users\Documents\logfile.txt' 1
SAY 'Hello World'
LOGO 0

(Note that 'ECHO 1' turns on echoing, which means that commands coded in macros will be displayed).

If this does not work an alternative way to preserve a record of what has been done in a session is to copy the commands from the Command interface window (see When I set up a model in the Equations window, is there any way to record the commands that will do the same thing?). Also note that you can save sequences of commands in a macro to execute again later (see How can I easily save and run commands?)

### I noticed a difference in values I get between versions of MLwiN

Example question: I fitted a model using version 2.02 and then upgraded to version 2.10
Beta and fitted the model again. All the estimates of the coefficients and
variance parameters were the same, but the -2*log(likelihood) value given
was different.

We have found in some rare cases that MLwiN 2.10 Beta (subversions 1-9) produced incorrect likelihoods for models estimated with (R)IGLS. The problem does not apply to models estimated in MCMC (since there is no likelihood calculated for these models; the problem does not apply to the DIC). The problem was not present in previous release versions (2.02 and earlier). The problem was fixed in MLwiN Beta 2.10.

Our research has found the problem to only occur in single level models with a large number of cases (>10,000). Furthermore, the problem does not occur if a second level is declared but no variance component is fitted at level 2.. If users have fitted a single level model in MLwiN 2.10 Beta (subversions 1-9), with only a single level hierarchy defined, the -2*log(likelihood) should be regarded as suspect and the model should be re-run in MLwiN 2.1 or subsequent version.