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: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
From
"Sun, Wensheng" <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: RE: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
Date
Sat, 13 Apr 2013 13:51:54 -0500
Hi, Joseph,
Thank you for the suggetion of log link and gllamm. I am new to gllamm. The following is the error message when I was trying gllamm. Please let me know how should I fix that. Thank you very much!
Wensheng
. webuse childweight
(Weight data on Asian children)
. generate byte k = 1
. eq cons: k
. eq age: age
. gllamm weight age c.age##i.girl || id: age, cov(uns) res(ind) mle variance , i(id) nrf(2) eqs(cons age) || id: age, cov(uns) res(ind) mle variance family(gaussian) link(log)
> adapt
factor variables and time-series operators not allowed
r(101);
. gllamm weight age c.age##i.girl || id: age, cov(uns) res(ind) mle variance , i(id) nrf(2) eqs(cons age) family(gaussian) link(log) adapt
factor variables and time-series operators not allowed
r(101);
________________________________________
From: [email protected] [[email protected]] On Behalf Of Joseph Coveney [[email protected]]
Sent: Tuesday, March 19, 2013 9:49 PM
To: [email protected]
Subject: st: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
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/
*
* 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/