Average marginal effects for categorical and limited dependent variable models
margin [, count dummies(Varlist_1 [ \ Varlist_2 \ ... \ Varlist_N]) eform hascons mean model(stata_cmd) percent replace table ]
where stata_cmd is one of
[class 1:] probit logit logistic cloglog xtprobit xtlogit [class 2:] oprobit ologit gologit mlogit biprobit [class 3:] poisson nbreg zip zinb [class 4:] tobit cnreg intreg heckman heckprob
and Varlist_K includes dummy variables where all of the dummies indicate different categories of the same underlying categorical variable.
margin calculates marginal effects, and standard errors for marginal effects using the delta method. By default, margin calculates the average of partial and discrete changes over the observations. margin can also compute marginal effects at the sample means of the variables if the mean option is specified. In either cases, calculations are restricted to the estimation sample.
By default, the marginal effects calculated are as follows:
[class 1:] changes in the probability of positive outcome [class 2:] changes in the probabilities of all possible outcomes defined by the dependent variable(s) [class 3:] changes in the expected number of counts or in the incidence rate (for zip and zinb, changes in E(y|y>0) and Pr(y>0) also displayed) [class 4:] changes in the expected value of the dependent variable conditional on the dependent variable being observed (not censored)
However, if the eform option is specified, margin calculates the changes in the value of exp(xb), where xb is the linear prediction.
margin can be also be used after commands that are not on the list above. For example, users may wish to obtain marginal effects after the survey version of stata_cmd, or after their own program. This is made possible by the model() option.
margin can be used both as an estimation command and as a post-estimation command; see help est and postest. By default, margin behaves as a post-estimation command, i.e. it does not affect the estimation results. However, option replace forces margin to behave as an estimation command. This enables the use of post-estimation commands like lincom or test after margin.
Typed without arguments, margin redisplays the marginal effects.
count modifies the calculation of marginal effects for count variables, i.e. variables that take more than two values and all of the values are integers. By default, margin treates count variables as continuous variables, thus marginal effects correspont to small changes in the independent variables. If the count option is specified, the marginal effects are changes in probabilities when the count variables increases by unity.
dummies(Varlist_1 [ \ Varlist_2 \ ... \ Varlist_N]) modifies the calculation of marginal effects for dummy variables. Let xvar be a categorical variables with K (K>2) categories. In this case, not xvar, but (K-1) dummies are included in the regression model. The estimated marginal effects for these K-1 dummies may be misleading (see the example below). The correct result is obtained if one specifies the dummy option by including the K-1 variables in varlist_1.
eform forces margin to define marginal effects as changes in the value of exp(xb), where xb is the linear prediction.
hascons forces margin to display the expected value that corresponds to the constant term. Note that this is not marginal effect (that is, change in expected value). For instance, after a logit model the hascons option adds a new line to the output showing the predicted probability of the event conditional on all explanatory variables are zero.
mean forces margin to compute the marginal effects at the sample means of explanatory variables.
model(stata_cmd) allows one to run margin after any command. stata_cmd must be one of the commands listed above. margin will produce correct results only if the estimation commannd issued before margin and stata_cmd have exactly the same link functions, i.e. the function which links the linear combination of variables and parameters to the outcome under study. It is the user's responsibility to ensure that this condition holds.
percent causes margin to display the results in a percentage form.
replace causes margin to overwrite the estimation results left behind.
table causes margin to display a table containing the descriptive statistics of individual marginal effects.
margin is a work-in-progress; comments, suggestions, bug reports are welcome! Please direct correspondence to the adress described at the end of the help file. To keep margin up-to-date, visit the website http://www.bkae.hu/bartus/stata or type net from http://www.bkae.hu/bartus/stata net install margin
Before using margin, make sure that you coded your dummy variables as 0/1 variables. Otherwise your dummies will be considered as being continuous variables, and you run the risk of obtaining misleading results.
Illustrating the importance of the dummies( varlist_1 \ ... ) option Type the following commands:
. [save mydata, replace] . tabi 60 30 10 \ 20 60 20 \ 10 10 80 , replace . xi: mlogit col i.row [fw=pop] . margin
You will see that the marginal effects do not correspond to changes in probabilities in the 3X3 table. Only the changes in the probabilities of the third outcome approximate the true changes, namely 0.1 and 0.7. The correct results are obtained after specifying the dummies(..) option:
. margin , dummies(_I*)
Some parts of the code relies on margfx (version 30 Jul 1999 for Stata 5) written by Jonah B. Gelbach, Dept of Economics, Univ of MD at College Park.
Online: help for est, postest; mfx
Tamas Bartus Department of Sociology and Social Policy, Corvinus University Budapest (former University of Economics), Budapest, Hungary URL: http://www.uni-corvinus.hu/bartus Email: email@example.com