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 |
"Dimitriy V. Masterov" <dvmaster@gmail.com> |

To |
Statalist <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: Interpretation of interaction term in log linear (non linear) model |

Date |
Sat, 8 Jun 2013 14:35:23 -0700 |

I would do this in a glm/robust poisson setting to avoid the logging. See http://blog.stata.com/2011/08/22/use-poisson-rather-than-regress-tell-a-friend/ (especially Austin Nichols' talk cited there), and the references at http://davegiles.blogspot.com/2011/03/dummies-for-dummies.html, for some good reasons. Economists do love their logs, but there are better methods that are starting to catch on with us. Since I don't have your data, let's take a toy model with the cars. This is recommended practice on this list that makes it more likely that you get a good response to your questions. Suppose we ran this regression: sysuse auto poisson price c.mpg##i.foreign, vce(robust) The expected value of price conditional on continuous mpg, binary foreign, and their interaction is E[price|mpg,foreign]=exp{a + b*mpg + c*foreign + d*mpg*foreign} The derivative of expected price with respect to mpg is exp{...}(b+d*foreign) using the chain rule. To turn that into a semielasticity, we need to multiply by 1/(expected price), which is conveniently exp{...}. We can evaluate both exp{}s at the actual values of the covariates or representative values like the mean, median, or mode, but in either case they cancel, leaving you with (b+d*foreign). I can also evaluate this semielasticity for domestic cars, which leaves me with (b+d*0)=b. The difference between the two semielasticities is d, which you can get from the regression table. This gives you the extra percentage increase in price for an additional mpg for foreign cars. In this case, it's ~17%. Here are some examples of how to do this in Stata. For some reason I could not replicate dydx1 and dydx0 using margins, but the rest seems to works. This intuition carries through in the logged y OLS case as well. I used Chris Baum's levpredict below since E[y|x] != exp{x'b}, but that's not really necessary. **************************** sysuse auto, clear /* Easy Way: Just look at the table */ /* note how glm and poisson are similar */ glm price c.mpg##i.foreign, link(log) family(poisson) poisson price c.mpg##i.foreign, vce(robust) /* A Bit Harder Using Margins */ margins // this is yhat below margins, eydx(mpg) at(foreign==1) // This is eps1 below margins, eydx(mpg) at(foreign==0) // This is eps0 below margins r.foreign, eydx(mpg) // This is diff_eps /* Pedagocial, Manual Way */ /*coeflegend allows you to see coeff. names */ poisson price c.mpg##i.foreign, vce(robust) coeflegend gen double yhat = exp(_b[_cons] + _b[mpg]*mpg + _b[1.foreign]*foreign + _b[1.foreign#c.mpg]*mpg*foreign) gen double dydx1 = yhat * (_b[mpg] + _b[1.foreign#c.mpg]*1) gen double eps1 = dydx1 * (1/yhat) gen double dydx0 = yhat * (_b[mpg]) gen double eps0 = dydx0 * (1/yhat) gen double diff_eps = eps1 - eps0 sum yhat eps* diff_eps /* Logged Price */ drop yhat dydx* eps* diff_eps gen lnp=ln(price) reg lnp c.mpg##i.foreign, vce(robust) margins r.foreign, dydx(mpg) levpredict yhat, duan gen double dydx1 = yhat * (_b[mpg] + _b[1.foreign#c.mpg]*1) gen double eps1 = dydx1 * (1/yhat) gen double dydx0 = yhat * (_b[mpg]) gen double eps0 = dydx0 * (1/yhat) gen double diff_eps = eps1 - eps0 sum diff_eps **************************** * * 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**:**Re: st: Interpretation of interaction term in log linear (non linear) model***From:*Suryadipta Roy <sroy2138@gmail.com>

**References**:**st: Interpretation of interaction term in log linear (non linear) model***From:*Suryadipta Roy <sroy2138@gmail.com>

- Prev by Date:
**st: How to store marginal effect value after using margin command?** - Next by Date:
**Re: st: Going through each observation of a variable** - Previous by thread:
**st: Interpretation of interaction term in log linear (non linear) model** - Next by thread:
**Re: st: Interpretation of interaction term in log linear (non linear) model** - Index(es):