Page 1 of 1

interaction plots

Posted: Tue Feb 27, 2018 5:15 pm
by ginamartin
Hello,
I am attempting to plot a cross-level continuous variable x continuous variable interaction from a logistic regression using runmlwin MCMC. I have found the examples very useful at: http://www.bristol.ac.uk/cmm/software/r ... /examples/ particularly http://www.bristol.ac.uk/cmm/media/runmlwin/7.6.do however, I cannot find an example for an interaction with two continuous variables. In the past I have used the margins command but I know this isn't available for runmlwin. Any suggestions would be appreciated.

Thanks,
Gina

Re: interaction plots

Posted: Wed Feb 28, 2018 12:12 pm
by GeorgeLeckie
Dear Gina,

Yes you are right, -margins- is not allowed after runmlwin. You will have to generate your plot from first principles. Essentially mucking around with the regression coefficients and some fictitious co-variate data.

So something like this where x1 and x2 are your continuous predictors and where you want to do a plot of the predicted y against x1 separately for three separate values of x2 (-1, 0 and 1)...

generate ylo = _b[cons] + _b[x1]*x1 + _b[x2]*-1 + _b[x1x2]*x1*-1
generate yav = _b[cons] + _b[x1]*x1 + _b[x2]*0 + _b[x1x2]*x1*0
generate yhi = _b[cons] + _b[x1]*x1 + _b[x2]*1 + _b[x1x2]*x1*1

line ylo yav yhi x1

Best wishes

George