Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

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

From |
Sergiy Radyakin <[email protected]> |

To |
"[email protected]" <[email protected]> |

Subject |
Re: st: How to store marginal effect value after using margin command? |

Date |
Sat, 8 Jun 2013 18:07:32 -0400 |

type either 'return list' or 'ereturn list' (depending on the command) to see which results are saved after these commands. From what you describe you are interested in matrices r(b) and e(b) sysuse auto, clear generate lp=log(price) regress lp weight length headroom mpg mfx matrix list e(b) Best, Sergiy On Sat, Jun 8, 2013 at 4:50 PM, Vũ Võ <[email protected]> wrote: > Hi everyone, > > I am writing a code in do file to calculate the marginal effect of x > on y (log-linear model) > > The function form as following: > > Ln(Y) = a0 + a1*X + a2*X^2 + e ----> Y = exp(a0 + a1*X + a2*X^2) > > So, dY/dX = (a1 + 2*a2*X)*exp(a0 + a1*X + a2*X^2) eq(1) > > If I run the regression by command line as: > > reg lnY x c.x#c.x > > after that using margins command: > > margins, dydx(x). > > I will obtain the marginal effect of x on Ln(Y): (a1 + 2*a2*X). > > How can I calculate the dY/dX as in eq(1) by using the do file, not > calculating manually? > > > 2. Second question is: > > If I use command margins, predict(p) and obtain the results as following: > > Marginal effects after hetprob > y = Pr(y) (predict, p) > = .54284206 > ------------------------------------------------------------------------------ > variable | dy/dx Std. Err. z p>|z| [ 95% C.I. ] X > ---------+-------------------------------------------------------------------- > x | .3704576 .03237 11.44 0.000 .307015 .4339 .020114 > xhet | -.0736092 .02423 -3.04 0.002 -.121095 -.026124 .502716 > off1 | (offset1) 1.00516 > off2 | (offset2) 1.09709 > ------------------------------------------------------------------------------ > > The question is how to store the marginal effects value, say in this > case is 0.3704576, > > in the scalar in stata? > > > Thank you so much. > > Vo Duc Hoang Vu > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/faqs/resources/statalist-faq/ > * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:

**References**:

- Prev by Date:
**Re: st: Going through each observation of a variable** - Next by Date:
**Re: st: need help to perform SEM for observed continuous and categorical data** - Previous by thread:
**st: How to store marginal effect value after using margin command?** - Next by thread:
**Re: st: How to store marginal effect value after using margin command?** - Index(es):