Pregunta

I have a probit model and I'm trying to compute and plot the marginal effects of a continuous variable for all the observations in the sample.

I'm using Stata and I have five independent variables. The variable for which I would like to compute marginal effects for all individuals takes 9 possible integer values (0 to 8), and I treat it as continuous (not as a factor variable). The most common command for marginal effects seems to be margins:

margins, dydx(x) at(x=(0(1)8))
marginsplot 

This command doesn't do what I would like to do. It seems to compute marginal effects for all individuals with x=0, x=1 and so forth and then average them for each value of x. The output I get reports a marginal effect and a standard error for each value of x.

I would like to obtain the marginal effect of x for each individual in the sample. Two individuals for whom x=0 should have different marginal effects if the other variables in the model take different values for these observations. How can compute and plot these effects?

¿Fue útil?

Solución

You can estimate the model, predict, change x with replace, and predict again. Then you can calculate the differences between the two predictions to get the marginal effects. You can change x by 1 or by a small amount epsilon (which will approximate what margins calculates much better). The first version will obviously be larger.

Here's an example using the cars data:

set more off
sysuse auto, clear
keep foreign mpg rep78 make

clonevar orig_rep78 = rep78

probit foreign mpg rep78
margins, dydx(rep78)

predict phat, pr

replace rep78 = rep78 + 1
predict phat_plus_one, pr
gen double finite_diff = phat_plus_one - phat

replace rep78 = orig_rep78 + 0.01
predict phat_plus_eps, pr

gen double eps_diff = (phat_plus_eps - phat)/.01

drop rep78
rename orig_rep78 rep78

tw (scatter finite_diff mpg) (scatter eps_diff mpg)

sum *_diff

You can see that the eps version matches the margins output more closely. You might want to see how sensitive your estimates are to different values of epsilon.

I don't know what sort of graph you had in mind, so I just plotted the MEs against the other regressor. You can see that the ME is increasing in mpg, which makes sense since the index function coefficients are all positive. The low values for mpg above 30 make sense since the predicted probability is already near 1, so additional repairs can't raise it all that much.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top