Dear Statalist,
I am using Stata15 and have an issue about how to plot adjusted predictions for interaction effects with continuous and discrete variables.
The application of the margins and marginsplot command is straightforward to me when interacting the main effect with a dummy variable, however, the same command only produces errors for continuous and discrete variables.
I am analyzing the effect of the variable A und the probability of B equaling 1 in a logit model. A can take on values between 0 and 1. I interact the variable A with three other variables X,Y and Z.
X is a dummy variable, Y is a discrete variable taking on values from 0 to 10, and Z is a continuous variable.
In order the show the graphical effect of the interacting variables on the main effect A on Pr(B)=1, I want to plot adjusted predictions A*X, A*Y and A*Z.
For the interaction of A*X (dummy variable) I used the following code:
Here, the marginsplot command produces a graph for adjusted predictions of Pr(B) depending on the levels of A moderated by X=0 and another graph for X=1.
I want a similar plot for the interaction with my discrete variable Y, comparing graphs for different values of Y, for example Y=0,5 and 10.
Further, I want a plot for the interaction with the continuous variable Z for specific values of Z, for example 20, 40 and 70.
How can I do this in Stata?
Thank you very much for your help!
Antonia
I am using Stata15 and have an issue about how to plot adjusted predictions for interaction effects with continuous and discrete variables.
The application of the margins and marginsplot command is straightforward to me when interacting the main effect with a dummy variable, however, the same command only produces errors for continuous and discrete variables.
I am analyzing the effect of the variable A und the probability of B equaling 1 in a logit model. A can take on values between 0 and 1. I interact the variable A with three other variables X,Y and Z.
X is a dummy variable, Y is a discrete variable taking on values from 0 to 10, and Z is a continuous variable.
In order the show the graphical effect of the interacting variables on the main effect A on Pr(B)=1, I want to plot adjusted predictions A*X, A*Y and A*Z.
For the interaction of A*X (dummy variable) I used the following code:
Code:
logit B c.A##i.X margins i.X, at(B==(0(0.1)1)) atmeans marginsplot
I want a similar plot for the interaction with my discrete variable Y, comparing graphs for different values of Y, for example Y=0,5 and 10.
Further, I want a plot for the interaction with the continuous variable Z for specific values of Z, for example 20, 40 and 70.
How can I do this in Stata?
Thank you very much for your help!
Antonia

Comment