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
interaction plots
-
- Site Admin
- Posts: 432
- Joined: Fri Apr 01, 2011 2:14 pm
Re: interaction plots
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
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