Runmlwin syntax for interaction effects

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
FatimaGhani
Posts: 6
Joined: Wed Oct 15, 2014 7:07 am

Runmlwin syntax for interaction effects

Post by FatimaGhani »

Hi there,
I’d like to run a binomial logistic regression with an interaction effect between percrimecat and sex, but I’m not sure about the syntax.
I created dummy variables for a binomial logistic regression model:
* My reference category is low perception of crime (percrimecat==1)
gen percrimeMedium = (percrimecat==2)
gen percrimeHigh = (percrimecat==3)

I’ve tried the STATA term [i.percrimecat#sex] and [percrimecat#sex], as well as [percrimeMedium#sex percrimeHigh#sex] in the bolded section below, but MLwin keeps crushing. What is the right syntax for including interations in the model?

quietly runmlwin aawlktotguide cons percrimeMedium percrimeHigh sex [and here I would like to include the interaction between percrimecat and sex], level2(cd2006:cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons) pql2) nopause
runmlwin aawlktotguide cons percrimeMedium percrimeHigh sex [and here I would like to include the interaction between percrimecat and sex], level2(cd2006:cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons)) mcmc(on) initsprevious nopause nogroup

Many thanks for your help.
Fatima
FatimaGhani
Posts: 6
Joined: Wed Oct 15, 2014 7:07 am

Re: Runmlwin syntax for interaction effects

Post by FatimaGhani »

On further exploration of the problem, I generated an interaction term between percrimecat and age, and I added this interaction to the model, which produced an output, but

generate percrimecatXsex = percrimecat*age
quietly runmlwin aawlktotguide cons percrimeMedium percrimeHigh sex percrimecatXsex, level2(cd2006:cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons) pql2) nopause
runmlwin aawlktotguide cons percrimeMedium percrimeHigh sex percrimecatXsex, level2(cd2006:cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons)) mcmc(on) initsprevious nopause nogroup

Is this correct?

Thanks,
Fatima
ChrisCharlton
Posts: 1384
Joined: Mon Oct 19, 2009 10:34 am

Re: Runmlwin syntax for interaction effects

Post by ChrisCharlton »

I would have expected the interactions to involve each of the dummy variables to be multiplied by the second variable, otherwise the variable is being treated as continuous within the interaction. In your example you also seem to be multiplying percrimecat by age, and then naming it as if you had multiplied by sex, was this intentional? Assuming that age is to be treated as a continuous variable I would have normally expected something like:

Code: Select all

generate percrimeMediumXage = percrimeMedium*age
generate percrimeHighXage = percrimeHigh*age

quietly runmlwin aawlktotguide cons percrimeMedium percrimeHigh age percrimeMediumXage percrimeHighXage, level2(cd2006:cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons) pql2) nopause

runmlwin aawlktotguide cons percrimeMedium percrimeHigh age percrimeMediumXage percrimeHighXage, level2(cd2006:cons) level1(id:) discrete(distribution(binomial) link(logit) denominator(cons)) mcmc(on) initsprevious nopause nogroup
Post Reply