### Issue with Interactions in Formula

Posted:

**Mon Sep 11, 2017 2:54 pm**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.)

The first two models run as they should but the third returns.

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?

Thank you in advance!

*#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) )

form.raceInteract2 <- formula(z_pcm3partr ~ 1 + d0locIndeg + d0extIndeg + zN0mapDDpopBXisol + zN0mapDDextpopBXisol + d1BlackNonHisp_scs + d1BlackNonHisp_scs:d0extIndeg + (1|scid) + (1|commID) + (1|aid) )

form.raceInteract3 <- formula(z_pcm3partr ~ 1 + d0locIndeg + d0extIndeg + zN0mapDDpopBXisol + zN0mapDDextpopBXisol + d1BlackNonHisp_scs + d1BlackNonHisp_scs:d0locIndeg + d1BlackNonHisp_scs:d0extIndeg + (1|scid) + (1|commID) + (1|aid) )

#fit models

fit1 <- runMLwiN(form.raceInteract1, data=DF, D="Normal")

fit2 <- runMLwiN(form.raceInteract2, data=DF, D="Normal")

fit3 <- runMLwiN(form.raceInteract1, data=DF, D="Normal")form.raceInteract1 <- formula(z_pcm3partr ~ 1 + d0locIndeg + d0extIndeg + zN0mapDDpopBXisol + zN0mapDDextpopBXisol + d1BlackNonHisp_scs + d1BlackNonHisp_scs:d0locIndeg + (1|scid) + (1|commID) + (1|aid) )

form.raceInteract2 <- formula(z_pcm3partr ~ 1 + d0locIndeg + d0extIndeg + zN0mapDDpopBXisol + zN0mapDDextpopBXisol + d1BlackNonHisp_scs + d1BlackNonHisp_scs:d0extIndeg + (1|scid) + (1|commID) + (1|aid) )

form.raceInteract3 <- formula(z_pcm3partr ~ 1 + d0locIndeg + d0extIndeg + zN0mapDDpopBXisol + zN0mapDDextpopBXisol + d1BlackNonHisp_scs + d1BlackNonHisp_scs:d0locIndeg + d1BlackNonHisp_scs:d0extIndeg + (1|scid) + (1|commID) + (1|aid) )

#fit models

fit1 <- runMLwiN(form.raceInteract1, data=DF, D="Normal")

fit2 <- runMLwiN(form.raceInteract2, data=DF, D="Normal")

fit3 <- runMLwiN(form.raceInteract1, data=DF, D="Normal")

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?

Thank you in advance!