Hi Stata Users

It seems simple but I have a question on how to manually calculate the marginal effects at mean for logit model. So basically I need to replicate the results of the output I obtained when I used margins, dydx (*) atmeans using a manual method (in other words, I need to replicate the red colored numbers using a manual method). I tried several things but couldn't replicate it. My continuous variables are gre and gpa and the categorical variable is rank. The dataset is attached

use binary
qui logit admit gre gpa i.rank
margins , dydx(*) atmeans

The output is given below

. qui logit admit gre gpa i.rank

. margins , dydx(*) atmeans

Conditional marginal effects Number of obs = 400
Model VCE : OIM

Expression : Pr(admit), predict()
dy/dx w.r.t. : gre gpa 2.rank 3.rank 4.rank
at : gre = 587.7 (mean)
gpa = 3.3899 (mean)
1.rank = .1525 (mean)
2.rank = .3775 (mean)
3.rank = .3025 (mean)
4.rank = .1675 (mean)

------------------------------------------------------------------------------
| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
gre | .0004743 .0002282 2.08 0.038 .0000271 .0009215
gpa | .1684057 .0691417 2.44 0.015 .0328904 .3039211
|
rank |
2 | -.164317 .0770559 -2.13 0.033 -.3153438 -.0132903
3 | -.2979896 .0761584 -3.91 0.000 -.4472572 -.1487219
4 | -.3319332 .0821748 -4.04 0.000 -.4929928 -.1708735
------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.