Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Marginal & Impact Effects in a Tobit


From   May Boggess <mboggess@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Marginal & Impact Effects in a Tobit
Date   03 Aug 2004 12:34:42 -0500

On Tuesday, Gonzalo wrote:

> I'm running a tobit with several dummies.
> I calculated the marginal effect in the average probabilities and in the
> average characteristics and the results are quite different from the ones
> I obtain after the command 'dtobit' in Stata.

Before I get started on -dtobit-, we must make certain we know what
the formulas for the prediction functions following -tobit-.
Here is some code that computes the predictions "by hand".
Unfortunately, this is not simple, so I have used some local
macroes, hoping that the expressions will be a little easier to
understand that way:

clear
sysuse auto 
tobit mpg weight , ll(20)
local xb=" _b[weight]*wei+_b[_cons] "
local nn="norm((20-(_b[weight]*wei+_b[_cons]))/_b[_se])" 
local nd="normden((20-(_b[weight]*wei+_b[_cons]))/_b[_se])" 
local p 1 - `nn' 
local e  `xb'+ _b[_se]*`nd'/(1 - `nn') 
local ys (`p')*(`e') + 20*`nn' 

 predict xb,xb
 gen myxb=`xb'
 sum xb myxb

 predict p, p(20, .)
 di "`p'"
 gen myp=`p'
 sum p myp

 predict e, e(20, .)
 di "`e'"
 gen mye=`e'
 sum e mye

 predict ys, ys(20, .)
 di "`ys'"
 gen myys=`ys'
 sum ys myys

Now, to compute discrete marginal effect we just take the difference
between the value of the prediction at 1 and the value at 0.
This is what -mfx- does, what and what the user-written command 
-dtobit- does. Unfortuntely, -dtobit- has a typo ( a 1 instead of an l)
on line 239 of the ado code. Here is an example:

 clear
 sysuse auto 
 tobit mpg for, ll(20)
 dtobit, brief

 local xb0=" _b[for]*0+_b[_cons] "
 local xb1=" _b[for]*1+_b[_cons] "
 local nn0="norm((20-(`xb0'))/_b[_se])"
 local nn1="norm((20-(`xb1'))/_b[_se])"  
 local nd0="normden((20-(`xb0'))/_b[_se])" 
 local nd1="normden((20-(`xb1'))/_b[_se])" 
 local p0 1 - `nn0' 
 local p1 1 - `nn1' 
 local e0  `xb0'+ _b[_se]*`nd0'/(`p0') 
 local e1  `xb1'+ _b[_se]*`nd1'/(`p1') 
 local ys0 (`p0')*(`e0') + 20*`nn0' 
 local ys1 (`p1')*(`e1') + 20*`nn1'

 mfx, predict(xb)  
 display "mfx = " (`xb1')-(`xb0')
 
 mfx, predict(ystar(20, .))
 display "mfx = " (`ys1')-(`ys0')

 mfx, predict(e(20, .))
 display "mfx = " (`e1')-(`e0')

 mfx, predict(p(20, .))
 display "mfx = " (`p1')-(`p0')

You will notice the difference in ystar and e. To make the change to
your copy of dtobit.ado, type

 which dtobit

on the command line in Stata. That will tell you where the file is
stored. Copy that, and use your favorite text editor to open the file.
If your text editor shows you lines numbers, you won't have too much
trouble finding line 239. It looks like this:

		scalar `E_c1' = `x1' + `se'*normd((`ll'-`x1')/`se')  /*
		*/ / (1-normprob((`l1'-`x1')/`se'))

You want to change the l1 to an ll, so it will
look like this:

		scalar `E_c1' = `x1' + `se'*normd((`ll'-`x1')/`se')  /*
		*/ / (1-normprob((`ll'-`x1')/`se'))

Once you have made that change, you can rerun the above example,
and you should find that now -dtobit- agrees with -mfx-.
An update for -dtobit- will appear in the next Stata Journal.

-- May
mmb@stata.com


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index