Welcome to the forum for R2MLwiN users. Feel free to post your question about R2MLwiN 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!

runMLwiN is inconsistent accepting interactions in my formulas and I don't see a pattern. For example, interactions that work when in separate models create an error when included in the same formula. Here's an example. (Unfortunately, I haven't been able to recreate the problem with MLwiN's example data sets so far.)

#set up formula for three models
form.raceInteract1 <- formula(z_pcm3partr ~ 1 + d0locIndeg + d0extIndeg + zN0mapDDpopBXisol + zN0mapDDextpopBXisol + d1BlackNonHisp_scs + d1BlackNonHisp_scs:d0locIndeg + (1|scid) + (1|commID) + (1|aid) )

The first two models run as they should but the third returns. Error in `[.data.frame`(indata, , outvars) : undefined columns selected

All three models include the same variables. The only difference is that both interaction terms are included in the third. The variables with the d prefix are dummy variables. All the fixed parameters are at level 1.

I've also tried turning the dummies to factors but with the same result.

Can anyone offer advice as to what may be going on?

appears to refer to the first formula (form.raceInteract1) instead of the third (form.raceInteract3). If you are using different data between the fits then this might explain the error. If not then can you try the fixed part of the model with other R fit functions (e.g. lm() or lmer()) to see whether you see similar behaviour there?

The form.raceInteract1 for the third model was just a typo copying to the post. The fitted model was correct.
It's the same data set for all models and the formula works fine with lmer.

Could you please provide further information about the variables in the data, e.g. number of factor levels with their labels and number of unique values for each variable?

You will see that the term order of the interaction d1BlackNonHisp_scs:d0locIndeg has been flipped around to d0locIndeg:d1BlackNonHisp_scs. The extra data variables are generated from this, however R2MLwN will be looking for them as they are in the original formula. Could you try adjusting your third formula to match the variables as above to see if that fixes it?

I tried to bypass the problem entirely by using a character string instead of a formula object, which the manual says can be done. I can't find examples of this approach, so I'm confused why I'm getting the following error. I think I'm following the syntax rules on page 22 of the manual correctly.

I don't think that specifying the formula as a string is likely to make a difference as it will be converted back to a formula object internally anyway. Could you try adding the option drop.data=FALSE to your estoptions list in case one of the variables is being inadvertently removed and see if that makes a difference?

I believe that we have now managed to track down the cause of this bug. Could you please let us know whether the attached test version of the package fixes the problem for you?

Hmmm... Well with this version, the model that was producing the error before (form.raceInteract3 in the original post) now runs.
Unfortunately, the two models that worked before (form.raceInteract1 and form.raceInteract2) no longer work. They now produce