I would like to be able to manually reproduce the results that Stata provides from the margins command from a nonlinear regression (e.g. logit).
For example, let's say that I have 1000000 observations of a binary dependent variable Y1 and a continuous variable X1, and I am running a logit regression of Y1 on X1. How might I manually calculate the marginal effects for each observation, and then manually calculate the average marginal effect for the entire logit regression, such that I get the exact same result as what Stata produces when I type 'margins, dydx(x1)' ?
My attempts to calculate the marginal effect of each observation by using the pdf of logit seem to fail, as when I then take the average of those marginal results, I get a number that is not equal to what I get when I type 'margins, dydx(x1)'
0 Response to How exactly does Stata calculate derivatives via the margins command for nonlinear functions?
Post a Comment