Page 1 of 1

Runmlwin syntax for interaction effects

Posted: Thu Oct 16, 2014 7:07 am
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

Re: Runmlwin syntax for interaction effects

Posted: Thu Oct 16, 2014 7:15 am
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

Re: Runmlwin syntax for interaction effects

Posted: Thu Oct 16, 2014 9:11 am
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