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]
Re: st: RE: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
From
William Buchanan <[email protected]>
To
[email protected]
Subject
Re: st: RE: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
Date
Mon, 15 Apr 2013 13:52:49 -0700
Read the GLLAMM manual.
On Apr 15, 2013, at 1:46 PM, "Sun, Wensheng" <[email protected]> wrote:
> Hi, Please help. How to do post multilevel regression estimation after gllamm? I tried "margins" command, it seems not work. Please fix it for me. Thanks.
>
> Wensheng
>
> clear
> set more off
> set linesize 80
> webuse childweight
> xi i.girl*age
> g byte k =1
> eq cons: k
> eq age: age
> gllamm weight age _Igirl_1 _IgirXage_1, i(id) nrf(2) eqs(cons age) family(gaussian) link(log) adapt nolog
> and the output was:
> number of level 1 units = 198
> number of level 2 units = 68
> Condition Number = 9.3286293
> gllamm model
> log likelihood = -369.79782
> ------------------------------------------------------------------------------
> weight | Coef. Std. Err. z P>|z| [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> age | .3312893 .0187497 17.67 0.000 .2945405 .368038
> _Igirl_1 | -.087405 .0484338 -1.80 0.071 -.1823335 .0075235
> _IgirXage_1 | .0047005 .0276294 0.17 0.865 -.0494522 .0588531
> _cons | 1.82589 .0329648 55.39 0.000 1.76128 1.8905
> ------------------------------------------------------------------------------
> Variance at level 1
> -----------------------------------------------------------------------------
> 2.0966599 (.24691662)
> Variances and covariances of random effects
> -----------------------------------------------------------------------------
> ***level 2 (id)
> var(1): .00263901 (.00311924)
> cov(1,2): .00065959 (.00057154) cor(1,2): 1
> var(2): .00016486 (.00043059)
> -----------------------------------------------------------------------------
>
> . margins girl, at(age=(0 (0.5)2.5))
> Warning: cannot perform check for estimable functions.
> 'girl' not found in list of covariates
> r(322);
> . margins _Igirl_1, at(age=(0 (0.5)2.5))
> Warning: cannot perform check for estimable functions.
> '_Igirl_1' not found in list of covariates
> r(322);
> . margins i.girl, at(age=(0 (0.5)2.5))
> Warning: cannot perform check for estimable functions.
> 'girl' not found in list of covariates
> r(322);
>
>
> ________________________________________
> From: [email protected] [[email protected]] On Behalf Of Sun, Wensheng [[email protected]]
> Sent: Monday, April 15, 2013 3:19 PM
> To: [email protected]
> Subject: RE: st: RE: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
>
> Hi, Joseph and William,
>
> I just re-installed gllamm on my Stata 12. The codes work now. Thank you for your help.
>
> Wensheng
>
> ________________________________________
> From: [email protected] [[email protected]] On Behalf Of Sun, Wensheng [[email protected]]
> Sent: Monday, April 15, 2013 3:07 PM
> To: [email protected]
> Subject: RE: st: RE: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
>
> I used Stata 11 from my other computer to run the same code. I got the same results as you had listed below. But if I use Stata 12, I always got the same error message "1m2 invalid name". Is the code specifically not work in Stata 12, or just my copy of Stata 12 has some problem? Thanks.
>
> Wensheng
>
> ________________________________________
> From: [email protected] [[email protected]] On Behalf Of William Buchanan [[email protected]]
> Sent: Monday, April 15, 2013 10:46 AM
> To: [email protected]
> Subject: Re: st: RE: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
>
> Hi Wensheng,
>
> I'm not sure how you were able to generate that specific error message with those commands. I just ran:
>
> clear
> set more off
> set linesize 80
> webuse childweight
> xi i.girl*age
> g byte k =1
> eq cons: k
> eq age: age
> gllamm weight age _Igirl_1 _IgirXage_1, i(id) nrf(2) eqs(cons age) family(gaussian) link(log) adapt nolog
>
> and the output was:
>
> number of level 1 units = 198
> number of level 2 units = 68
>
> Condition Number = 9.3286293
>
> gllamm model
>
> log likelihood = -369.79782
>
> ------------------------------------------------------------------------------
> weight | Coef. Std. Err. z P>|z| [95% Conf. Interval]
> -------------+----------------------------------------------------------------
> age | .3312893 .0187497 17.67 0.000 .2945405 .368038
> _Igirl_1 | -.087405 .0484338 -1.80 0.071 -.1823335 .0075235
> _IgirXage_1 | .0047005 .0276294 0.17 0.865 -.0494522 .0588531
> _cons | 1.82589 .0329648 55.39 0.000 1.76128 1.8905
> ------------------------------------------------------------------------------
>
> Variance at level 1
> -----------------------------------------------------------------------------
> 2.0966599 (.24691662)
>
> Variances and covariances of random effects
> -----------------------------------------------------------------------------
>
> ***level 2 (id)
>
> var(1): .00263901 (.00311924)
> cov(1,2): .00065959 (.00057154) cor(1,2): 1
>
> var(2): .00016486 (.00043059)
> -----------------------------------------------------------------------------
>
>
> That being said, several list members have already suggested going through the GLLAMM manual in greater depth and detail to understand how to specify the model(s) that you are interested in. It isn't clear that you've followed the advice that others have already provided to you. Additionally, "Stata" provided you with an error message, not "STATA."
>
> HTH,
> Billy
>
>
> On Apr 15, 2013, at 8:26 AM, "Sun, Wensheng" <[email protected]> wrote:
>
>> Thank you Joseph for the detailed codes. I tried, but STATA gives me the error message 1m2 invalid name.
>>
>> . clear
>> . set more off
>> . set linesize 80
>> . webuse childweight
>> (Weight data on Asian children)
>> . xi i.girl*age
>> i.girl _Igirl_0-1 (naturally coded; _Igirl_0 omitted)
>> i.girl*age _IgirXage_# (coded as above)
>> . generate byte k = 1
>> . eq cons: k
>> . eq age: age
>> . gllamm weight age _Igirl_1 _IgirXage_1, i(id) nrf(2) eqs(cons age) family(gaus
>>> sian) link(log) adapt nolog
>> 1m2 invalid name
>>
>> Please let me know if I have miss something. Thank you very much!
>>
>> Wensheng
>>
>> ________________________________________
>> From: [email protected] [[email protected]] On Behalf Of Joseph Coveney [[email protected]]
>> Sent: Sunday, April 14, 2013 10:11 PM
>> To: [email protected]
>> Subject: st: Re: xtmixed with log-transfered dependent variable: back to non-log on margins and marginsplot
>>
>> Wensheng Sun wrote:
>>
>> 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!
>>
>> [snip]
>>
>> --------------------------------------------------------------------------------
>>
>> The user-written command -gllamm- pre-dates the introduction of factor variables
>> in Stata, and so it doesn't recognize the factor-variable syntax that you typed.
>> Prior to factor variables, Stata used the command -xi- to manually create
>> regression terms for categorical variables and their interactions. The command
>> -xi- is still around for use with those commands that do not allow
>> factor-variable notation. I show its use with -gllamm- below for the model that
>> you tried to fit.
>>
>> Your syntax for -gllamm- seems to be some kind of hodgepodge of that for
>> -xtmixed- and -gllamm-. As others have mentioned, you're probably better off
>> referring to the user's manual for -gllamm-, which can be downloaded from the
>> website shown in the command's help file.
>>
>> Joseph Coveney
>>
>>
>> . clear *
>>
>> . set more off
>>
>> . set linesize 80
>>
>> . webuse childweight
>> (Weight data on Asian children)
>>
>> . xi i.girl*age
>> i.girl _Igirl_0-1 (naturally coded; _Igirl_0 omitted)
>> i.girl*age _IgirXage_# (coded as above)
>>
>> . generate byte k = 1
>>
>> . eq cons: k
>>
>> . eq age: age
>>
>> . gllamm weight age _Igirl_1 _IgirXage_1, i(id) nrf(2) eqs(cons age) family(gaus
>>> sian) link(log) adapt nolog
>>
>> number of level 1 units = 198
>> number of level 2 units = 68
>>
>> Condition Number = 9.3286288
>>
>> gllamm model
>>
>> log likelihood = -369.79782
>>
>> ------------------------------------------------------------------------------
>> weight | Coef. Std. Err. z P>|z| [95% Conf. Interval]
>> -------------+----------------------------------------------------------------
>> age | .3312893 .0187497 17.67 0.000 .2945405 .368038
>> _Igirl_1 | -.0874049 .0484338 -1.80 0.071 -.1823335 .0075236
>> _IgirXage_1 | .0047005 .0276294 0.17 0.865 -.0494521 .0588531
>> _cons | 1.82589 .0329648 55.39 0.000 1.76128 1.8905
>> ------------------------------------------------------------------------------
>>
>> Variance at level 1
>> ------------------------------------------------------------------------------
>>
>> 2.0966596 (.2469165)
>>
>> Variances and covariances of random effects
>> ------------------------------------------------------------------------------
>>
>>
>> ***level 2 (id)
>>
>> var(1): .00263901 (.00311924)
>> cov(2,1): .00065959 (.00057154) cor(2,1): 1
>>
>> var(2): .00016486 (.00043059)
>> ------------------------------------------------------------------------------
>>
>> *
>> * 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/
>
>
> *
> * 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/
> *
> * 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/
*
* 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/