
Title | Marginal effects by example | |
Author | Ronna Cong, StataCorp | |
Date | May 2001 |
mfx will not work after clogit or nlogit since the property of the prediction after clogit/nlogit states that probabilities are estimated for each group as a whole, not for individual observations.
The marginal effect is defined as
d F(X) ---------- d XThe predict() option in mfx allows users to specify the form of F(X), and the at() option allows users to specify the points (X) where the marginal effects are to be evaluated.
Examples are presented under two sections: Section 1: Specifying the form of F(X); and Section 2: Specifying the Xs.
Exactly what mfx can calculate is determined by the previous estimation command and by the predict() option. Users should check the predict options for the estimation command before running mfx.
Examples are presented for biprobit, heckman, heckprob, intreg, mlogit, ologit, oprobit, tobit, treatreg, xtintreg, xtlogit, xtprobit, and xttobit.
The marginal effects for positive outcomes, Pr(depvar1=1, depvar2=1), are
. mfx compute, predict(p11)The marginal effects for Pr(depvar1=1, depvar2=0) are
. mfx compute, predict(p10)The marginal effects for Pr(depvar1=0, depvar2=1) are
. mfx compute, predict(p01)The marginal effects for Pr(depvar1=0, depvar2=0) are
. mfx compute, predict(p00)The marginal effects for the marginal probability of outcome 1, Pr(depvar1=1), are
. mfx compute, predict(pmarg1)The marginal effects for the marginal probability of outcome 2, Pr(depvar2=1), are
. mfx compute, predict(pmarg2)The marginal effects for the conditional probability of outcome 1 given outcome 2, Pr(depvar1=1 | depvar2=1), are
. mfx compute, predict(pcond1)The marginal effects for the conditional probability of outcome 2 given outcome 1, Pr(depvar2=1 | depvar1=1), are
. mfx compute, predict(pcond2)
The marginal effects for the expected value of the dependent variable conditional on being observed, E(y | y observed), are
. mfx compute, predict(ycond)The marginal effects for the probability of the dependent variable being observed, Pr(y observed), are
. mfx compute, predict(psel)
The marginal effects for the probability of a positive outcome, Pr(depvar=1), are
. mfx compute, predict(pmargin)The marginal effects for the probability of a positive outcome given the dependent variable being observed, Pr(depvar=1 | depvar_s=1), are
. mfx compute, predict(pcond)The marginal effects for the probability of the dependent variable being observed, Pr(depvar_s=1), are
. mfx compute, predict(psel)The marginal effects for Pr(depvar=1, depvar_s=1) are
. mfx compute, predict(p11)The marginal effects for Pr(depvar=1, depvar_s=0) are
. mfx compute, predict(p10)The marginal effects for Pr(depvar=0, depvar_s=1) are
. mfx compute, predict(p01)The marginal effects for Pr(depvar=0, depvar_s=0) are
. mfx compute, predict(p00)
The marginal effects for the probability of being uncensored are
. mfx compute, predict(p(a,b))where a is the lower limit for left censoring and b is the upper limit for right censoring.
The marginal effects for the expected value of the dependent variable conditional on being uncensored, E(y | a<y<b), are
. mfx compute, predict(e(a,b))where a is the lower limit for left censoring and b is the upper limit for right censoring.
The marginal effects for the unconditional expected value of the dependent variable, E(y*), where y* = max(a, min(y,b)), are
. mfx compute, predict(ys(a, b))where a is the lower limit for left censoring and b is the upper limit for right censoring.
Due to the multiple-outcome feature of these three commands, mfx must be run separately for each outcome.
Run the estimation command first:
. use auto, clear . mlogit rep78 mpgor
. ologit rep78 mpgor
. oprobit rep78 mpgThe marginal effects for the probability of outcome 1, Pr(y=1), are
. mfx compute, predict(outcome(1))The marginal effects for the probability of outcome 2, Pr(y=2), are
. mfx compute, predict(outcome(2))and so forth.
The marginal effects for the expected value of y conditional on being treated, E(y | treatment = 1), are
. mfx compute, predict(yctrt)The marginal effects for the expected value of y conditional on being untreated, E(y | treatment =0), are
. mfx compute, predict(ycntrt)The marginal effects for the probability of being treated, Pr(treatment=1), are
. mfx compute, predict(ptrt)
The marginal effects for the probability of being uncensored are
. mfx compute, predict(pr0(a, b))where a is the lower limit for left censoring and b is the upper limit for right censoring.
The marginal effects for the expected value of y conditional on being uncensored are
. mfx compute, predict(e0(a, b))where a is the lower limit for left censoring and b is the upper limit for right censoring.
The marginal effects for the unconditional expected value of y are
. mfx compute, predict(ys(a, b))where a is the lower limit for left censoring and b is the upper limit for right censoring.
The marginal effects for predicted probability after the random-effects model are
. mfx compute, predict(pu0)The marginal effects for the predicted probability, taking into account offset() after the population-averaged model, are
. mfx compute, predict(mu)The marginal effects for predicted probability, ignoring offset() after the population-averaged model, are
. mfx compute, predict(rate)
By default, mfx calculates the marginal effects at the means of the independent variables.
To calculate the marginal effects at the medians, type
. mfx compute, at(median)To calculate the marginal effects at zeros, type
. mfx compute, at(zero)To calculate the marginal effects at mpg=20 and zeros for other independent variables, type
. mfx compute, at(zero mpg=20)