Statalist


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

Re: st: RE: Accessing random coefficients in xtmixed


From   Sven-Oliver Spieß <[email protected]>
To   [email protected]
Subject   Re: st: RE: Accessing random coefficients in xtmixed
Date   Sat, 12 Dec 2009 00:32:06 +0100

Hi Andrew,

It is true that Stata does not list the standard deviations in the
matrices. However it saves the logarithms of them in the e(b) matrix.
Thus you can easily get the desired estimates by exponentiating the
values in the matrices:
	xtmixed depvar indepvar || groupvar: , cov(unstr) mle
	di exp([lns1_1_1]_b[_cons])
	di exp([lnsig_e]_b[_cons])


Beware that the order of the standard deviation of the random intercept
changes when you add random slopes.
Thus in a model with a random slope you'd have to access the SD of the
RI by typing:
	xtmixed depvar indepvar || groupvar: indepvar, cov(unstr) mle
	di exp([lns1_1_2]_b[_cons])	// --> RI now lns1_1_*2*

This behavior makes sense considering the convention that Stata always
lists constants in models last but at first this threw me slightly off.


Cheers,
Sven-Oliver


On Fri, 2009-12-11 at 23:28 +0100, Martin Weiss wrote:
> <>
> 
> You have to undo Stata`s transformations, that much is true:
> 
> 
> *******
> webuse pig, clear
> 
> xtmixed weight week || id: week
> 
> nlcom(sd_week: exp(_b[lns1_1_1:_cons])) /* 
>  */  (sd_cons: exp(_b[lns1_1_2:_cons])) /* 
>  */  (sd_res: exp(_b[lnsig_e:_cons]))
> *******
> 
> 
> HTH
> Martin
> 
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Andrew Spiegelman
> Sent: Freitag, 11. Dezember 2009 23:21
> To: [email protected]
> Subject: st: Accessing random coefficients in xtmixed
> 
> I am running the following model:
> xtmixed depvar indepvar || groupvar: indepvar, cov(unstr) mle
> 
> and I want to access the random effects parameters that Stata
> calculates.  For example, I'd like to be able to refer to sd(indepvar)
> in later work.  Normally this is done with _b[indepvar].  In more
> complex cases, one refers to the equation name first, as described
> here (http://www.stata.com/support/faqs/stat/streg.html).  Normally,
> one can find the equation names by typing "matrix list e(V)" or
> "matrix list e(b)."
> 
> However, Stata does not seem to list the standard deviation for
> indepvars in these matrix lists.  That is, the random part of the
> coefficient on indepvar, which is listed prominently in the Stata
> output under Groupvar:  Unstructured (it appears as sd(indepvar)), is
> not shown anywhere in e(b) or e(V).
> 
> Is there any way to access/reference the estimated random-effects
> parameters in xtmixed?
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index