Hello everyone,
I'm trying to understand something about the margins command. I'm using a dataset where my co-author created an interaction by hand and asked me to plot it in Stata. So I did, just like in the following code. I plotted the components of the interaction in margins. But then I tried to replicate the interactive terms by using the "var1##c.var2" pattern. Of course, the model coefficients are the same, but somehow, the margins results are completely different. Am I missing something?
I'm trying to understand something about the margins command. I'm using a dataset where my co-author created an interaction by hand and asked me to plot it in Stata. So I did, just like in the following code. I plotted the components of the interaction in margins. But then I tried to replicate the interactive terms by using the "var1##c.var2" pattern. Of course, the model coefficients are the same, but somehow, the margins results are completely different. Am I missing something?
Code:
webuse lbw, clear gen smokeXage = smoke*age logit low smoke age smokeXage margins, at(age=(14(5)45) smoke=(0 1)) marginsplot, name(byhand, replace) logit low i.smoke##c.age margins, at(age=(14(5)45) smoke=(0 1)) marginsplot, name(stata, replace) graph combine byhand stata
Comment