Title | Stata7: Marginal effects by example | |
Author | Ronna Cong, StataCorp | |
Date | February 2001; updated May 2001 |
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.
Examples are presented for biprobit, heckman, heckprob, intreg, mlogit, ologit, oprobit, tobit, treatreg, xtintreg, xtlogit, xtprobit, and xttobit.
. 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)
. mfx compute, predict(ycond)The marginal effects for the probability of the dependent variable being observed, Pr(y observed), are
. mfx compute, predict(psel)
. 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)
. 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.
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.
. 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)
. 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.
. 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)
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)