Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: ratio of marginal effects when using two -margins- commands


From   Mirko <mirko.moro@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: ratio of marginal effects when using two -margins- commands
Date   Tue, 13 Apr 2010 13:01:34 +0100

Dear all,

I am wondering whether is possible to obtain standard errors and
confidence intervals of ratio of marginal effects when they are
obtained by running two (or more) times the command -margins-.
-margins- makes life a lot easier especially after estimating models
with interaction terms or nonlinear models:

* simple case
use http://www.stata-press.com/data/r11/margex
logistic outcome sex##group age
margins sex, post
nlcom (risk_ratio: _b[1.sex] / _b[0.sex])


However, there may be some cases in which one needs to compute two
separate -margins- commands to obtain the marginal effects of
interest. For example, after a model of Y on X, Z and the interaction
term XZ:

Y = a + bX + bZ + bXZ + e,

I'd like to obtain the statistical significance of the ratio of

(marginal effects of variable X conditional on variable Z)/ (marginal
effects of variable Z conditional on X) =

ME1/ME2

****begin example*****************************************
* -margins*

sysuse auto, clear
set more off
qui regress mpg foreign i.rep78##c.weight headroom
* ME1
margins, dydx(rep78) atmeans
* ME2
margins, dydx(weight) over(rep78)

**********end example***************************************

Is there an easy way to get standard errors and confidence intervals
of ratios of two -margins- ME1/ME2?

Or do I need to use -nlcom- like below?


****begin example********************************
* ratio of marginal effects with -nlcom-
sysuse auto, clear
set more off
qui tab rep78, gen(rep)
forval i=2/5{
	qui gen rep`i'Xweight = rep`i'*weight
}
regress mpg foreign rep2-rep5 rep2Xweight-rep5Xweight weight headroom
qui sum weight if e(sample)
local meanw = r(mean)
* ratio of ME1/ME2
nlcom (_b[rep2] + _b[rep2Xweight]*`meanw')/(_b[weight] + _b[rep2Xweight])
nlcom (_b[rep3] + _b[rep3Xweight]*`meanw')/(_b[weight] + _b[rep3Xweight])
nlcom (_b[rep4] + _b[rep4Xweight]*`meanw')/(_b[weight] + _b[rep4Xweight])
nlcom (_b[rep5] + _b[rep5Xweight]*`meanw')/(_b[weight] + _b[rep5Xweight])

****end example****************************************************************

I would appreciate any help on this.
Thanks
Best regards,
Mirko
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index