0
$\begingroup$

Say I have a binary logistic regression model:

model1 : logit = b0 + b1 *age + b2 *gender_f + b3 *race_f

with age being continuous and race_f and gender_f being two-level factors. The margins() function in R (or equivalently the margins command in Stata) can be used to estimate AME's for the three IV's. There also exists a so called APE, which for "age" can be obtained, following Mood (Logistic regression: why we cannot do what we think we can do, and what we can do about it, 2009), by averaging the marginal effects of age, dydx_age = b1 * p * (1-p), across the distribution of other variables at different given values of age; here p denotes the predicted probability of a person.

I'm stuck with how to calculate this APE measure. Roughly, I can think of two ways.

  1. Select all people with age=20 in my dataset, and calculate the average dydx_age value for this subset.

  2. With "margins", the "at" option can be used, as in R's: margins(model1, at=list(age=20)). Stata has a similar option. This at= option actually constructs a new dataset, equal to the original data, except for age=20 now for ALL respondents in the new dataset. Then, for each person in this new dataset p is calculated (based on age=20, and gender and race as observed) and then the average of all dydx_age values is obtained. This average is another way I can think of, to calculate the APE. I would never have considered this way of calculating APE, had I not read about at= in T. Leeker's manual of margins and in R. Williams's paper on Stata's margins.

Not many texts could I find in which AME and APE are clearly contrasted, only the one mentioned by Carina Mood. Wooldridge discusses APE but reading this text is not simple, at least for me. On some internet pages the terms AME and APE seem to be used as synonyms, improperly given Mood's explanation.

As to the at= option, more in general, I would like to find an explanation of when to use this instead of working with subgroups. Reading the many examples about using margins in Stata or R, it seems so "obvious" to use at=, that the subgroups options seems " wrong" anyway. Is this indeed wrong, or "stupid"? The fictitious data, as generated by at=, seems "wrong" to, in the sense of not leading to a random sample of 20 year old people from the population.

Thanks for any help or reference!!

Ben.

After receiving a response from Tom, about an explanation of what an average partial effect is by Kjetil B. Halvorsen, see:

What are average partial effects?

I added the following:

I happened to read this explanation just before posting my question. As you will have noticed, the two terms are used as synonyms there. In https://cran.r-project.org/web/packages/margins/vignettes/Introduction.html the two terms are also used but with a different meaning: AME refers (in case of logit link) to the linear predictor scale, whereas APE is reserved for the response scale. This is quite different from the way AME is mostly used (e.g. in R. Williams's Stata paper) namely to express change on the response scale.

But apart from this, the explanation you pointed to is much in line with Wooldridge's text, as far as I can see. Also, it seems to suggest (but correct me please if I'm wrong) that calculating the average partial effect APE boils down to taking the average of the derivative (dydx_age in R's margins terms) over the SUBGROUP in the original sample with age=20, or age=21, 22 etc. Or to put it differently: APE is AME calculated over a subgroup. In Stata this would mean using option "over=" And this is definitely NOT the same as using at=.

In Richard Williams's text, "at" is used as the more or less "obvious" way to go, if you want to compare the effect of e.g. race across different ages. But now I believe that this is less obvious than I first thought. In case of an experiment and a completely balanced dataset, I guess the two methods of calculating APE for age=20 would lead to the same estimate (though probably different std. errors). But given that the data in Richard Williams's examples are observational (I think) wouldn't it be at least equally plausible to use method 1 described above?

B.t.w., using margins in R would not produce a std. error for the average dydx_age at age=20 obtained for the subgroup method; only for the at=list(age=20) method, there would be a std. error. I'm not sure if Stata produces a std. error for a subgroup when using over=.

Further, the cplot(.., what="effect") function in R produces at= like results. As far as I can see now, it would be nice if cplot could also generate subgroup results (which of course can easily be generated, knowing that the dydx_age etc. columns are available in a data frame, made by margins).

$\endgroup$
4
  • $\begingroup$ Have you checked if any other questions on CrossValidated tackle this topic? stats.stackexchange.com/questions/12313/… $\endgroup$
    – Tom
    May 7 at 11:54
  • $\begingroup$ Does this answer your question? What are average partial effects? $\endgroup$
    – Tom
    May 7 at 11:55
  • 1
    $\begingroup$ With regard to your reaction to my comment, which is now posted here as an answer: stats.stackexchange.com/questions/12313/…. I have the feeling that you are mixing up a couple of things (but it is hard for me to exactly figure out what). If many people do not make a clear distinction between AME and APE (and even Wooldridge does not), you have to clearer explain what you want and what you are aiming for. I think it is also more fruitful to think about what you want to achieve instead what name you want to give to what you are doing. $\endgroup$
    – Tom
    May 7 at 16:11
  • $\begingroup$ Sorry Tom, I didn't notice I was typing at the wrong place. You are right that what I want to achieve should be most relevant. The problem is that I only recently started looking at marginal effects as a useful tool in case of logistic regression. And then I ran into this problem of not knowing which of the two average effects to use in which situation. Hence my questions. Thanks for taking the time to answer!! $\endgroup$
    – Ben Pelzer
    May 7 at 17:39
0
$\begingroup$

This is probably unsettled terminology, especially once you start crossing disciplinary boundaries, but according to Baby Wooldridge (7e), APE and AME are synonyms:

enter image description here

There are at least three calculations that you can do that correspond to different thought experiments about what happens to $\Pr(Y=1 \vert X, age)$ when age:

  1. goes from observed $age$ to $age+1$ (most common)
  2. goes from $20$ to $21$ (i.e., pretend everyone is 20 in your data, less common)
  3. when $age$ goes from $age$ to $age+1$ for all the folks who are 20 in your data (fairly uncommon, equivalent to (2), but for a subset of the data)

The only difference between (1) and (3) is the sample over which the average is computed. The latter is occasionally interesting, but usually, you would do something like the effect of age for women rather than the effect of age for 20-years-olds.

(2) used to be common, but typically you would also set the other covariates to some interesting value (like means, medians, modes, or something like an 18-year-old male HS graduate). You can think of this as the effect of age for an "interesting" or "representative" person.

It's hard to recommend which one to use since we don't know what you have in mind. However, (1) is probably a reasonable default.

I am using effect here, but these are associations or correlations.

$\endgroup$
2
  • $\begingroup$ Thanks Dimitriy for your comment, things are getting a bit more clear for me. Best regards, Ben. $\endgroup$
    – Ben Pelzer
    May 11 at 14:28
  • $\begingroup$ @BenPelzer Did these clear things up? $\endgroup$
    – dimitriy
    Jul 6 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.