I'm using Stata.
I ran a probit of the form $$ \text{outcome}_i = \beta \ f(\text{income}_i) + \gamma\text{ Controls}_i $$
Where $f(\text{income}_i)$ is a fractional polynomial.
I'm interested on the marginal probability $\frac{\delta \ P \ (\text{outcome}_i | \text{mean (Controls}_i))}{\delta \ \text{income}_i}$ for all values of $i$. When I run margins, dydx(varname)
I only get the average marginal effect, not for the whole distribution. Moreover, I have to calcualte bootstrap standard errors, so I need some way to get the marginal probability that doesn't rely on specifying the functional form beforehand (i.e. _b[var1] + 2*_b[var2]*var2
for a 2nd order polynomial), as $f(\cdot)$ will change for each of the 500 bootstrap estimations.
A bit of context in case this is an instance of an xy problem.
I'm implementing an estimator of the form:
$$ \beta(\mathbf{x}) = \triangledown \Psi(\mathbf{x}) + \frac{\Psi(\mathbf{x})}{\mathrm{G_M}(\mathbf{x})}\triangledown \mathrm{G_M}(\mathbf{x}) $$
Where $\mathbf{x}$ is a vector of size $N$ (number of observations), $\Psi(\mathbf{x})$ is the prediction of the conditional mean, $\mathrm{G_M}(\mathbf{x})$ is the prediction of the probability that the outcome is greater than zero, and $\triangledown \Psi(\mathbf{x})$, $\triangledown \mathrm{G_M}(\mathbf{x})$ refer to their respective marginal effects.
The paper I'm following specifies:
But it doesn't include more information on this topic.
I hope I have been clear enough. Thanks in advance.
margins
has a badly documentedgen(me_income)
option. Does that do the trick for storing the marginal effects (rather than just their average)? $\endgroup$margins
all over and couldn't find that! Thanks! $\endgroup$help undocumented
to see the other goodies. Can I ask how you specify the derivative with respect to the fp-ized variable? $\endgroup$margins, xb(income_1 income_2) gen(me)
it generatesme1
andme2
. These are the marginal effects wrt the variable transformed according to fp (i.e. raised to some power) so by the chain rule the marginal effect with respect to the non transformed variable should be me1*dydx where dydx is the derivative of the transformed variable wrt to the original. I wrote some code to do that, if you're interested I can post it. $\endgroup$