# Is it meaningful to calculate predicted marginal effects of a count data model with an interaction effect?

In a little regression model of mine, I estimate the following formula a a negative binomial regression type (it would hold for a Poisson regression as well):

$$y = \beta * var1 + \gamma * var1 * binary + \delta * X + \epsilon$$ where $X$ is a matrix of control variables that are all on a discrete scale. $var1$ however is not discrete while $binary$ of course is a binary variable. The second term, $\gamma * var1 * binary$ is dedicated to check how $var$ acts different if $binary=1$.

Now I compute marginal effects, say with the mfx package for R. Since count data models are GLM, the marginal effects are evaluated at some value of all the other variables (typically the mean). But I wonder whether it is meaningful to evaluate $\partial y/\partial var1$ while holding $var1 * binary$ at the mean. Or did I misunderstand the concept of average marginal effects for GLMs?

In a Poisson model,

$$E[y \vert x]=\exp(\alpha + \beta x + \gamma x \cdot b).$$

The derivative would be $$\frac{\partial E[y \vert x]}{\partial x}=\frac{\partial \exp(\alpha + \beta x + \gamma x \cdot b )}{\partial x}=\exp(\alpha + \beta x + \gamma x \cdot b)\cdot(\beta+\gamma b).$$

This is a function of $$x$$ and $$b$$, and folks create many types of marginal effects. One option is to use the means, but that might be weird for binary variables since you might evaluate the derivative for someone who is .75 female. It might be strange for continuous variables if $$x$$ has a weird distribution. Another option is to set all the dummies to their modes or to zero, the base.

Another option is to use own values of the covariates for each observation and then average the derivatives. Personally, I like this one the most.

mfx allows you to easily do the first with atmean=TRUE and the last with atmean=FALSE. However, I am not sure if it will handle interactions on the fly, so it may omit the $$\gamma b$$ term.

• I might ask the maintainer to know what negbinmfx does when it evaluates an interaction effect. Apr 2 '15 at 17:41
• @MERose Thanks for spotting that. If you pick a public dataset (or post your data) and show your R code, it would be pretty easy to figure out by comparing it with Stata. Might be better to turn it into another question. Apr 2 '15 at 17:47
• The R package mfx does not handle the case of interactions correctly (as most other implementations of marginal effects). A simple (but meaningless) example would be to add a factor to the cars data cars\$fac <- factor(rep(1:2, each = 25)), fit a Poisson model m <- glm(dist ~ speed * fac, data = cars, family = poisson), compare the naive marginal effects exp(sum(coef(m) * colMeans(model.matrix(m)))) * coef(m) with poissonmfx(m, data = cars). This reports three (rather than two) marginal effects and uses the naive computations for the "two" speed-related variables. Apr 2 '15 at 22:06
• Two further comments: (1) A useful reference for this kind of problem in GLMs is Ai & Norton (2003, Economics Letters, 80, 123-129) who explain the issues in detail for logit and probit models. (2) If you are willing to look at effects rather than marginal effects, then have a look at the R package effects. This correctly resolves interactions, e.g., plot(allEffects(m)). Apr 2 '15 at 22:10