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 at the end of May, and its replacement, statalist.org is already up and running.


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

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


From   Suryadipta Roy <sroy2138@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Interpretation of interaction term in log linear (non linear) model
Date   Sun, 9 Jun 2013 00:19:23 -0400

Thank you very much for the elaborate examples! I have actually used
Poisson regression for my paper (being deeply influenced by William
Gould's Stata blog writeup and Austin Nichol's Stata Meeting
presentation), but would still include results from the log linear
regressions to have some background for doing the Poisson/NB
regressions. My current post is related to my post last month:
http://www.stata.com/statalist/archive/2013-05/msg01005.html , where
my query was on the interpretation of the interaction term in a
Poisson regression. Basically, my current question is, if the
coefficients and the interaction terms in a log-linear regression will
have similar interpretation as in a Poisson regression. Given that the
log-linear model is also a non linear model, based on my reading of
Maarten Buis's Stata tip # 87 "Interpretation of interactions in
non-linear model", I believe that the answer is yes. We can, of
course, derive the marginal effects of explanatory variables in most
models using -margins- but interpretation of the interaction term as
multiplicative effects is different from the marginal effect. Any
thought/suggestion is greatly appreciated.

Sincerely,
Suryadipta.


On Sat, Jun 8, 2013 at 5:35 PM, Dimitriy V. Masterov <dvmaster@gmail.com> wrote:
> 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/
*
*   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/


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