楼主: 梨棠皮皮
23241 18

[其他] [求助]STATA中用mfx命令求边际效应 [推广有奖]

11
蓝色 发表于 2007-12-24 10:34:00

你能不能具体给我们来两个例子,让大家学习一下。

最好能有公式推倒,否则你这样说我还是不明白。

你可以举一般线性模型、probit、tobit三个做个比较,我们也就知道了。

谢谢。

12
spoonshen 发表于 2007-12-24 11:19:00
from Stata website (FAQ):
http://www.stata.com/support/faqs/stat/mfx_ologit.html . 在tobit里面,应该直接用dtobit命令就行了。


Stata 7: How do you compute marginal effects after ologit/oprobit/mlogit using mfx?

Title   Stata7: Marginal effects by example
Author Ronna Cong, StataCorp
Date February 2001; updated May 2001

The Stata 7 command mfx numerically calculates the marginal effects or the elasticities and their standard errors after estimation. mfx works after ologit, oprobit, and mlogit. However, due to the multiple-outcome feature of these three commands, one has to run mfx separately for each outcome.

The marginal effect is defined as

 d F(X)
----------
d X
The 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.


Section 1: Specifying the form of F(X)

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.

biprobit

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)

heckman

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)

heckprob

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)

intreg and tobit

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.

mlogit, ologit, and oprobit

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 mpg
or
 . ologit rep78 mpg
or
 . oprobit rep78 mpg
The 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.

treatreg

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)

xtintreg and xttobit

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.

xtlogit and xtprobit

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)

Section 2: Specifying the Xs

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)

13
蓝色 发表于 2007-12-24 11:28:00
但是这些对常数项是没有作用的

14
蓝色 发表于 2007-12-24 11:32:00

根据你上面列的:

The marginal effect is defined as

 d F(X)
----------
 d X 
比如:y=a+bX
那么常数项a的边际影响是什么?
怎么计算

15
spoonshen 发表于 2007-12-25 03:20:00
我的理解是比较常数为零和非零的两种情况。

16
蓝色 发表于 2007-12-25 12:41:00
以下是引用spoonshen在2007-12-25 3:20:00的发言:
我的理解是比较常数为零和非零的两种情况。

呵呵,那这个和一个虚拟变量就没有区别啊。

真不知道他们到底是怎么做的。

17
danVdan 发表于 2010-10-5 10:18:37
spoonshen 发表于 2007-12-25 03:20
我的理解是比较常数为零和非零的两种情况。
这应该是正解。

18
改革同步 发表于 2010-10-6 13:23:28
很奇怪那个文献是怎么算出来的!

19
moonforsun 发表于 2011-4-12 10:05:19
本人不才,想问一下,为什么要求边际效应,是用来做什么的啊?
我想分析不同变量的作用影响大小,请问一下,怎么算呢?用STATA可以算出变量的标准化系数来不?

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群
GMT+8, 2025-12-27 05:46