mjthoms2
mjthoms2

Reputation: 21

How do you store marginal effects using margins command in Stata?

I'm estimating a regular probit model in Stata and using the margins command to calculate the marginal effects.

I'm trying to illustrate the change in effects when treating the dummy variables as continuous in my estimate as opposed to treating them as a discrete change from 0 to 1.

probit dead dmage dmeduc i.dmar i.foreignb i.mblack i.mhispan i.motherr agesq i.tobacco i.alcohol
margins, dydx(alcohol tobacco) // treating the discrete variables 
margins, dydx(alcohol tobacco) continuous

According to the documentation the margins command stores the estimates using the e(). However when I try and save the estimates after using the margins command, regardless of whether I use

return list 
ereturn list

it just returns the saved post estimation results from my probit model and not from the margins command.

How do I store the marginal effects values and then put them in a table to show the comparison?

Upvotes: 2

Views: 14578

Answers (1)

Maarten Buis
Maarten Buis

Reputation: 2694

The documentation of margins says that the results are returned in e() if you specify the post option. So here is an example that does what you want:

sysuse auto, clear
gen byte good = rep78 > 3 if !missing(rep78)

probit good i.foreign price
margin , dydx(foreign) post
est store indicator

probit good foreign price
margins , dydx(foreign) post
est store continuous

est table indicator continuous, se

Upvotes: 8

Related Questions