Stata can run this regression: reg Y X1 i.X1#c.X2 i.X2. However, while a coefficient is calculated for both X1 and i.X1#c.X2, margins is for some reason unable to obtain the marginal effects of X1 over X2.
I have had this problem several times, and right now I'm having this problem in a situation where I have other fixed effect accounted for, and so am using xtreg. However, the problem is generalizable to a situation where one is using reg only. I have replicated the problem in the auto dataset, below, and would be incredibly grateful for thoughts on what's going on.
Code:
sysuse auto, clear
xtset foreign
gen lprice=log(price)
gen HIGHmpg=mpg>25
** Reg 1: This works fine
xtreg lprice i.HIGHmpg i.turn
margins, dydx(i.HIGHmpg)
** Works fine w/ no interaction
** Reg 2: This does not work
xtreg lprice i.HIGHmpg i.HIGHmpg#c.turn i.turn
margins, dydx(i.HIGHmpg) at(c.turn=(32 36 40 44 48 52))
/* Command does not run. Error returned:
c.turn ambiguous abbreviation
r(111); */
** Reg 3: This "trick" also doesn't work
gen test=turn
xtreg lprice i.HIGHmpg i.HIGHmpg#c.test i.turn
margins, dydx(i.HIGHmpg) at(c.test=(32 36 40 44 48 52))
/* Command runs, but interactions deemed "not estimable" */
** Reg 2 w/ reg instead of xtreg
reg lprice i.HIGHmpg i.HIGHmpg#c.turn i.turn
margins, dydx(i.HIGHmpg) at(c.turn=(32 36 40 44 48 52))
** Same error given
** Reg 3 w/ reg instead of xtreg
reg lprice i.HIGHmpg i.HIGHmpg#c.test i.turn
margins, dydx(i.HIGHmpg) at(c.test=(32 36 40 44 48 52))
** Interactions still deemed "not estimable"
** Note: it is possible to allow an interaction between i.HIGHmpg and EVERY
** value of test, as below, but this is not what I want to do, as it wastes power.
** In my own examples, it is helpful to do this because I can see a linear or
** non-linear pattern in the marginal effects, but then I ultimately want to run
** the model allowing only a continuous change in the marginal effects.
xtreg lprice i.HIGHmpg i.HIGHmpg#i.turn i.turn
margins, dydx(i.HIGHmpg) over(i.turn)
0 Response to Margins: trouble with continuous interactions under simultaneous fixed effects
Post a Comment