Bookmark and Share

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]

st: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot


From   "Joseph Coveney" <[email protected]>
To   <[email protected]>
Subject   st: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
Date   Wed, 20 Mar 2013 11:49:13 +0900

Wensheng Sun wrote:

Hi, I have a question regarding multilevel model when I use log-transformation
on the dependent variable.

. webuse childweight
. gen ln_weight=ln(weight)
. xtmixed ln_weight  c.age##i.girl  || id: age, cov(uns) res(ind) mle variance
. margins girl, at(age=(0 (0.5)2.5))
. marginsplot

Is there a way if I change the above code a bit, I can let margins prediction
and marginsplot show me back log estimation and back log values on the
marginsplot?

--------------------------------------------------------------------------------

I'm not sure how to get back-transformation right with -margins-, but you could
look at the user-written command -predlog- (-findit predlog-) and the
accompanying _Stata Technical Bulletin_ article for inspiration about the
back-transforming the fixed effects (random effects set to zero).

Also, you could fit the model without log-transformation in the first place by
using a generalized linear mixed model with a log link.  Something like:

generate byte k = 1
eq cons: k
eq age: age
gllamm weight age _I*, i(id) nrf(2) eqs(cons age) ///
    family(gaussian) link(log) adapt

The upside is that the response variable is in its untransformed metric and so
there's no need for back-transformation.  The downside is that you'll have to do
manually (using -lincom-) what -margins- and -marginsplot- does for you.

Joseph Coveney

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index