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

Re: st: biprobit: test for difference in marginal effects


From   May Boggess <mboggess@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: biprobit: test for difference in marginal effects
Date   04 Nov 2004 13:38:05 -0600

On Thursday,  Wenhui Wei wrote:
> I'm runing a biprobit model (two treatment modes) and get two sets
> marginal effects by the MFX command.
> 
> 
> My quesiton is: for a certain variable, for example, gender (with male
> as the base), how to test whether its estimated marginal effects are
> significant different in the 2 equations. i.e. the marginal effect of
> female in treatment mode 1 is significantly different from that in
> treatment mode 2?
> 
> test command only test for the difference in the estimated
> coefficients, not marginal effects.
> 

We can do this by saving the marginal effects and their covariance
matrix as estimation results and then use -test-. Let's begin with an
example we can work with:

 clear
 sysuse auto
 set seed 12345
 gen y1=uniform()>0.5
 gen y2=uniform()>0.5
 biprobit y1 y2 mpg for

I am interested in the marginal effect for for=1 and for=0.
I am going to use a matrix to pass the numbers into the -at()-
option of -mfx-:

 matrix A1=(20, 1)
 mfx, var(mpg) at(A1) tr(2)
 mat m1=e(Xmfx_dydx)
 mat D1=(.32062124, .00432451, .00432453, .11510433, -.0019256,
-.0019256, -.00114118)

When you use the -tracelvl()- option on -mfx- you get to the see
the second derivatives that a calculated so -mfx- can use the
delta method to get the standard error of the marginal effect.
-mfx- doesn't save those guys in a matrix for us, so we'll have to copy
and paste them in by hand. Same thing for the marginal effect at for=0:

 matrix A0=(20, 0)
 mfx, var(mpg) at(A0) tr(2)
 mat m0=e(Xmfx_dydx)
 mat D0= (.28952027, 0, .00463938, .19246524, 0, -.00111842, .00006737)

 mat D=D1\D0
 mat list D

Now, to get the covariance matrix for these two marginal effects,
I need the covariance matrix for the coefficients of the model:

 mat V=e(V)

Then multiply:

 mat COV=D*V*D'
 mat rownames COV = m1 m0
 mat colnames COV = m1 m0
 mat list COV

To be able to test if the two marginal effects are the same,
I want to use a Wald test. This is done in Stata using the command
-test-.

I can take advantage of that by posting the marginal effects
and the covariance matrix as estimation results. Before I do so,
I have to make sure the rows and columns are labeled appropriately,
which means, mathing the names on the covariance matrix COV:

 mat b=[m1[1,1],m0[1,1]]
 mat colnames b = m1 m0
 mat list b
 eret post b COV
 eret display
 mat list e(b)
 mat list e(V)

You can see the marginal effects and the covariance matrix are now
stored in the e() results. So now we can use test:

 test _b[m1]=_b[m0]


--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