# When/why are average marginal effects (AME) equal to marginal effect at means (MEM)?

I wonder why my two versions of marginal effects (AME and MEM) yield identical results:

webuse nlswork, clear
xtset idcode year

xtreg ln_wage age c.age#c.age ttl_exp c.ttl_exp#c.ttl_exp tenure c.tenure#c.tenure, fe

margins, dydx(age)
margins, dydx(age) atmeans

------------------------------------------------------------------------------
|            Delta-method
|      dy/dx   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
age |  -.0063896   .0009607    -6.65   0.000    -.0082725   -.0045066
------------------------------------------------------------------------------


Merely the headline is different ("average" vs. "conditional" marginal effect). Thank you

In your first command (AME), you are asking margins to calculate the derivative of the expectation with respect to age for each person and then take the average. That derivative is function of (1) age and (2) the coefficients on age and age^2, namely _b[age] + 2*_b[c.age#c.age]*age. It is a linear function of age.
So it does not matter if you ask Stata to average _b[age] + 2*_b[c.age#c.age]*age in your sample, or if you tell Stata to plug in the average age into that formula and then take the in-sample average (the MEM in the second margins).