# marginal effects of a GLM

A marginal effect is the effect one independent variable on the dependent variable has when it is changed by one unit and the other independent variables constant. In the simple OLS regression correspond to the marginal effects the values of the regression coefficients (beta-values).

How do I calculate these for other GLMs, particular I am interested in Gamma (log link) and Lognormal GLMs.

I read that I can multiply the estimated GLM coefficients by the probability density function of the linked distribution (which is the derivative of the cumulative density function).

So in a simplified R example this would be:

df <- data.frame(y= abs(rnorm(20)), v1= rnorm(100), v2=rnorm(100))
# marginal effect
me <- coef(m) * mean(d__<WHAT DIST HERE>__(predict(m, type="link"))


Another question, in simple OLS the betas are the marginal effects, is this true for a Tobit model as well?

The analogous marginal effect is the same linear model parameter from your general linear model for independent data. The interpretation differs slightly, in that gaussian GLMs (or OLS) estimate mean differences, whereas logistic regression (a type of binomial GLM) estimates a log odds ratio. The Gamma distribution uses an inverse link which gives rise to a harmonic mean difference. This might be a good way of comparing variability in the number of tasks a machine can perform per hour, and puts more or less influence on the same metrics that an arithmetic mean difference would. Poisson regression uses a log-link, and this estimates a geometric mean difference. For instance, in modeling count outcomes based outcomes over consistent time denominators, the geometric mean difference would be a relative rate.

In general any model for independent data will estimate a marginal effect. The difference arises when you consider models for dependent data. When you have repeated measures within an individual and use a conditional likelihood (e.g. random effects) to control for the (possibly) of hundreds of unmeasured variables, the fixed effects are conditional effects, or that is an expected "difference" (on some scale) within an individual having all fixed effects equal.

• thanks, but the marginal effect is something different. The marginal effect of an independent variable is the derivative (that is, the slope) of a given function of the covariates and coefficients of the preceding estimation. The derivative is evaluated at a point that is usually, and by default, the means of the covariates. – spore234 Oct 7 '16 at 20:57
• @spore234 I disagree with your definition. It has no tie to the generalized linear model and is limited in that regard. Work on the average derivative and its relation to non-parametric OLS is interesting, but it has nothing to do with marginal vs. conditional effects. – AdamO Nov 30 '16 at 18:18

First, the Gamma link function only allows for positive values. In your example, your dependent variable, y, would have negative values so the regression wouldn't even work if you wanted to. I think your question addresses regression on non-negative values (since you brought up Tobit models).

Second, have you tried looking at different threads? There are a few out there with some answers:

Using R for GLM with Gamma distribution

How to interpret parameters in GLM with family=Gamma

• thanks for pointing out the error, I corrected that. The code is just a toy example. The second link you provided mentions marginal effects as $\hat y \cdot \beta$, so would that be `me <- coef(m) * mean(predict(m, type="link"))' in my example? – spore234 Oct 7 '16 at 17:58