Press "Enter" to skip to content

Based on this post by Michael Norman Mitchell, I want to remember the difference between the Marginal Effect at Mean and the Average Marginal Effect.

I conduct an ordered logistic regression (proportional odds model) to predict the effect of sex on likelihood of voting:

`ologit vote c.age i.female c.chfreq c.edu_years, allbase coeflegend`

Marginal Effect at Mean
To obtain the probability of vote = “certainly not” at the mean of the other covariates, I execute this margins-command:

```margins i.female, predict(outcome(1)) atmeans // .0511123; .0596168
margins, dydx(i.female) predict(outcome(1)) atmeans // direct calculation of the MEM```

Alternatively by hand:

```lincom  _b[vote:age] * 37.62104 + _b[vote:1.female] * 1 + _b[vote:chfreq] * 7.235061 + _b[vote:edu_years] * 12.02012
di 1 / (1 + exp(3.333369-_b[cut1:_cons])) // .051112

lincom _b[vote:age] * 37.62104 + _b[vote:1.female] * 0 + _b[vote:chfreq] * 7.235061 + _b[vote:edu_years] * 12.02012
di 1 / (1 + exp(3.496284-_b[cut1:_cons])) // .0596168```

The marginal effect of being female on likelihood of voting at the mean of age, chfreq and edu_years then is -.0085045.

Average Marginal Effect
Instead of setting all covariates to their respective means, the average marginal effects leaves (besides female) all covariates like they were observed. The probability of voting = “certainly not” is then calculated assuming first every observation in the data-set is female and second every observation in the data-set is male. The average marginal effect is the difference in those predicted probabilities. The margins command offers the most convenient way to do this:

```margins i.female, predict(outcome(1)) // .0583623; .0677809
margins, dydx(i.female) predict(outcome(1)) // direct calculation of the AME
```

If one wishes to do this by hand, follow these steps:
Leaving all other covariates like they were observed, I change the data in the sense, that everybody is female now and predict the probability of vote = “certainly not. Then I do the opposite, namely assuming every individual is male. The AME is the difference in those predicted probabilities:

```clonevar female_backup = female // As I have to recode female, I create a copy of it

replace female = 1
predict y1, pr outcome(1)

replace female = 0
predict y0, pr outcome(1)

replace female = female_backup // I change female back to it's original values

sum y1 y0
di .0583623 - .0677809 // -.0094186
```

The average marginal effects of being female on the likelihood on voting then is -.0094348.
In this example MEM (-.0085045) and AME (-.0094186) are very close together. This might not be the case if atmeans is not representative for the sample. (Example???)