I've made lots of progress with my models, but got stuck again because I cannot find how to code crosslevel interactions (level 2 * level 1).
Here is my model as I ran it incorrectly assuming the use of asterisks (*)
This is my model
############# Adding Network and Crosslevel predictors #####################
m5 = logit(AltAnySupport) ~ 1 + TieFam+ Married + Woman +
EgoTMig + AltFem + AltEth + AltNat + AltResidence + NetPropFemCen + NetPropFamCen +
NetPropIsEthCen + NetPropNatCen + NetPropResidCen + EgoTMig * AltEth + Woman * AltEth +
EgoTMig * TieSameSex + (1  EgoIdentifier)
(VarCompModel < runMLwiN(Formula = m5, D = "Binomial", data = MyData,
estoptions = list(EstM = 1)))
After running this model I got this error
>Error in `[.data.frame`(indata, , outvars) : undefined columns selected
So far I've found info here but is for MLWiN in which crosslevel interactions are specified as 'ccXtvXprethks' with 'X" indicating multiplication.
https://orca.cf.ac.uk/113202/1/MLwiN%20 ... Models.pdf
Many Thanks
How can I make cross level interactions?

 Posts: 1082
 Joined: Mon Oct 19, 2009 10:34 am
Re: How can I make cross level interactions?
R2MLwiN formulae are based on the standard used in other R estimation commands (https://stat.ethz.ch/Rmanual/Rdevel/l ... rmula.html).
Asterisk (*) should work, however a*b denotes a + b + a:b rather than just the interaction. You would therefore either use a colon (:) to specify the interaction term or remove the associated main effects from elsewhere in the formula if you want to use an asterisk. I also note that you have the variable TieSameSex in an interaction without a main effect, is this intentional?
Asterisk (*) should work, however a*b denotes a + b + a:b rather than just the interaction. You would therefore either use a colon (:) to specify the interaction term or remove the associated main effects from elsewhere in the formula if you want to use an asterisk. I also note that you have the variable TieSameSex in an interaction without a main effect, is this intentional?
Re: How can I make cross level interactions?
The "TieSameSex" was a mistake. I edited a bit the formula before submitting to simplify reading but messed it up.
I ran the following model and...
############# Random Intercept # Adding Network and Crosslevel predictors #####################
m5 = logit(AltAnySupport) ~ 1 + TieIsFamily + TieSameSex + TieSameAge + EgoMarital + EgoSex +
EgoTMig + AltSex + AltIsRoma + AltNatRomanian + AltResidence + NetPropFemCen + NetPropFamCen +
NetPropIsRomaCen + NetPropNatRomanianCen + NetPropResidCen + EgoTMig:AltIsRoma + EgoSex:AltIsRoma +
EgoTMig:TieSameSex + (1  EgoIdentifier)
(VarCompModel < runMLwiN(Formula = m5, D = "Binomial", data = RomaAllData,
estoptions = list(EstM = 1)))
Gave me this error below which I found that is a bug
>Error in `[.data.frame`(indata, , outvars) : undefined columns selected
http://www.bristol.ac.uk/cmm/software/r ... nbugs.html
I reordered the order of the interactions and it worked!!
Many Thanks
I ran the following model and...
############# Random Intercept # Adding Network and Crosslevel predictors #####################
m5 = logit(AltAnySupport) ~ 1 + TieIsFamily + TieSameSex + TieSameAge + EgoMarital + EgoSex +
EgoTMig + AltSex + AltIsRoma + AltNatRomanian + AltResidence + NetPropFemCen + NetPropFamCen +
NetPropIsRomaCen + NetPropNatRomanianCen + NetPropResidCen + EgoTMig:AltIsRoma + EgoSex:AltIsRoma +
EgoTMig:TieSameSex + (1  EgoIdentifier)
(VarCompModel < runMLwiN(Formula = m5, D = "Binomial", data = RomaAllData,
estoptions = list(EstM = 1)))
Gave me this error below which I found that is a bug
>Error in `[.data.frame`(indata, , outvars) : undefined columns selected
http://www.bristol.ac.uk/cmm/software/r ... nbugs.html
I reordered the order of the interactions and it worked!!
Many Thanks

 Posts: 1082
 Joined: Mon Oct 19, 2009 10:34 am
Re: How can I make cross level interactions?
I am glad to hear that you now have something that works. Thanks for reminding me about this bug, it is actually already fixed in the development version which we are currently working on submitting to CRAN. If you wanted to install this you can do so with the following command:
However as we expect this to be on CRAN relatively soon you could potentially wait for this and pick it up from there instead.
Code: Select all
library(devtools)
install_github("rforge/r2mlwin", subdir="R2MLwiN")