help for margeff8                              (This version: 10 February 2006)

Marginal effects for categorical dependent variable models

margeff8 [compute] [if exp] [in range] [, at(atlist) count nodiscrete dummies(varlist_1 [\ varlist_2 ..]) eform model(stata_cmd) nooffset outcome(numlist) percent replace ]

margeff8 replay

where stata_cmd is one of

[group 1:] probit logit logistic cloglog heckprob xtprobit > [group 2:] oprobit ologit gologit mlogit biprobit [group 3:] poisson nbreg zip zinb

and atlist is { mean | median | zero [ varname = # [, varname = #] [...]] } { [mean] |[median] | [zero] varname = # [, varname = #] [...] }

and varlist_1 [\ varlist_2 ... ] are lists of dummy variables, where all dummies of a list indicate different categories of the same underlying categorical variable.


margeff8 compute analytically estimates marginal effects, and standard errors for marginal effects using the delta method. The default behavior of margeff8 is the following:

1. margeff8 calculates average marginal effects, that is, changes in the quantities of interest evaluated for each observations, and the reported marginal effects are sample averages of these changes. Note that margeff8 can also compute marginal effects evaluated at sample means or at other values if the user specifies the at(atlist) option. Calculations are restricted to the estimation sample.

2. For continuous variables, marginal effects are partial changes in the quantities of interest. For dummy variables, marginal effects are discrete changes in the quantities of interest as the dummy variable changes from 0 to 1. Dummies are automatically detected. Before using margeff8, please 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. Users can change this behavior by specifying the count or nodiscrete options.

3. Quantities of interest are defined as follows:

[group 1:] the probability of positive outcome [group 2:] the probabilities of all possible outcomes defined by the dependent variable(s) [group 3:] the expected number of counts or the incidence rate

4. margeff8 supports only the above listed models. The model(stata_cmd) option, however, adds some flexibility. This is useful if users wish to obtain marginal effects after the survey version of stata_cmd, or after their own program.

5. margeff8 behaves as a post-estimation command (see help postest). However, option replace forces margeff8 to behave as an estimation command (see help est). This enables the use of post-estimation commands like lincom or test after margeff8.

Typed without arguments, margeff8 replays the results of the previous margeff8 computations, provided the last use of margeff8 was combined with the replace option.

margeff8 replay replays the results of the previous margeff8 computation.


at(atlist) forces margeff8 to estimate marginal effects at points specified in atlist, instead of estimating average marginal effects.

at( mean | median | zero [ varname = # [, varname = # [...]] ) specifies that the marginal effects be evaluated at means, at medians of the independent variables, or at zeros. It also allows users to specify particular values for one or more independent variables, assuming that the rest are means, medians, or zeros.

at( [mean] |[median] | [zero] varname = # [, varname = #] [...] ) specifies that the marginal effects be evaluated at particular values for one or more independent variables, assuming that the rest are means.

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, margeff8 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 increase by unity.

nodiscrete forces margeff8 to treat dummy variables as if they were continuous. Recall that if nodiscrete is not specified, the marginal effect of a dummy variable is calculated as the discrete change in the expected value of the dependent variable as the dummy variable changes from 0 to 1.

dummies(varlist_1 [\ varlist_2 ... ]) modifies the calculation of marginal effects for dummy variables. Let xvar be a categorical variables with K+1 (K>1) categories. In this case, not xvar, but K dummies - say, D1, ..., DK - are included in the regression model. The estimated marginal effects for these K dummies may be misleading (see the example below). The correct result is obtained if one specifies the dummies(D*) option.

eform forces margeff8 to define the quantity of interest as exp(xb), where xb is the linear prediction.

model(stata_cmd) forces margeff8 to estimate marginal effects as if the preceeding estimation command were stata_cmd. stata_cmd must be one of the supported commands that are listed above. The model(stata_cmd) is likely to be helpful if you wish to obtain marginal effects after the survey version of a supported estimation command, or you wish to estimate a supported model using glm. The estimates, however, will be meaningful only if the estimation command issued by the user and stata_cmd have the same link functions. It is the user's responsibility to ensure that this condition holds.

nooffset causes margeff8 to ignore the offset variable during the calculations.

outcome(numlist) causes margeff8 to display only the probability outcomes corresponding to the numbers specified numlist (see numlist for syntax guide). This option is useful after estimation commands listed as [group 2] models. The correspondence rule is the following: 1. After biprobit, numbers 1 2 3 and 4 refer to outcomes p00 p01 p10 p11. 2. After ologit, oprobit, gologit and mlogit, number # refers to the #th category of the dependent variable. Thus, number 1 always indicates the lowest category. And if the dependent variable has, say, 5 categories, then number 5 indicates the highest category.

percent causes margeff8 to display the results in a percentage form.

replace causes margeff8 to overwrite the estimation results left behind. This option is useful if 1. you wish to include marginal effects in publication-quality tables using either the official estimates table command or the user-written commands outreg or estout; or 2. your model contains a variable (such as age-squared) which is a mathematical transformation of another independent variable, and you wish to obtain the total effect of that variable (age) using the lincom or the nlcom command.


margeff8 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 margeff8 up-to-date, visit the website http://www.uni-corvinus.hu/bartus or type net from http://www.uni-corvinus.hu/bartus/stata net install margeff8


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] . margeff8

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:

. margeff8, dummies(_I*)

Easy calculation of the total effect of age

Suppose you wish to model employment status as a function of the usual human capital variables: gender, years of education, experience, and the square of experience. Assume further that the sample average of experience is 20. The total effect of experience on employment probabilities can be estimated as follows:

. logit employed gender edu exp exp2 . margeff8, at(mean) replace . lincom exp+40*exp2


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.

Also see

Online: help for est, postest; mfx


Tamas Bartus Department of Sociology and Social Policy, Corvinus University Budapest, Budapest, Hungary URL: http://www.uni-corvinus.hu/bartus Email: tamas.bartus@uni-corvinus.hu