Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: Estout after xtmixed with ar(1) residuals

 From Tom Trikalinos To statalist@hsphsun2.harvard.edu Subject Re: st: Estout after xtmixed with ar(1) residuals Date Sun, 21 Mar 2010 10:06:08 -0400

```Dimitri,

It appears that Stata has parameterized their optimization a bit
differently than you (and I) expected.

r_lns2ose is NOT the log(SE) of the residuals in level 1 of the
grouping variable.
It appears that Stata parameterizes the SE of the residuals in level 1
of the grouping variable using the values at level 0 of the grouping
variable as a reference.

log(SE_level1_of_grouping) = lnsig_e + r_lns2ose   (i.e., r_lns2ose is
the log of the factor that multiplied by the SE of the residuals at
level 0 of the grouping variable, gives you the desired SE).

not sure how you do it in estout. If there is no easier way, you can
always calculate the needed value, add it to the estimation results
and then run estout.

take care
t

I run this silly example:

**************Code begins ********************

webuse nlswork
// make a grouping variable with 2 levels
gen race2 = (race>=2)

res(ar 1, t(year) by(race2))

// store the the numbers in the betas
mat betas = e(b)

// these are the random effects parameters -- exp transformation, as you stated
di exp(el(betas,1,colnumb(betas,"lns1_1_1:_cons")))
di exp(el(betas,1,colnumb(betas,"lns1_1_2:_cons")))

// this is the standard deviation of the residual group 1 -- exp
transformation of
// lnsig_e + r_lns2ose
di exp(el(betas,1,colnumb(betas,"lnsig_e:_cons"))+el(betas,1,colnumb(betas,"r_lns2ose:_cons")))

// you already know how to get the correlations.

****************code ends**********************

On Sun, Mar 21, 2010 at 8:20 AM, Dimitris Pavlopoulos
<Dimitris.Pavlopoulos@soc.kuleuven.be> wrote:
> Dear Thoma,
>
> thank you for your reply. I am doing what you suggest but it doesn't work.
>
> Specifically, in estout, I am using the transformation "transform(ln*: exp(@) exp(@) r_ln*: exp(@) exp(@) at*: tanh(@) (1-tanh(@)^2) r_atr*: tanh(@) (1-tanh(@)^2))", so I am calculating  exp(r_lns2ose). Apparently it's not the correct transormation.
>
> best regards,
> Dimitris
>
>
>
> ________________________________________
> From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] On Behalf Of Tom Trikalinos [ttrikalin@gmail.com]
> Sent: Thursday, March 18, 2010 5:23 PM
> To: statalist@hsphsun2.harvard.edu
> Subject: Re: st: Estout after xtmixed with ar(1) residuals
>
> Just guessing here -- you should be able to work out quickly if I'm
> right or wrong.
>
> Typically in an ML routine you would optimize for t=log( of an SD or a variance)
> this guarantees that the exp(t) (the SD or the variance) is non negative.
>
> So I'm guessing that to get your variance or SE it should be exp(r_lns2ose)
>
> Similarly for correlations. If they are allowed to range between -1
> and 1, one probably optimizes for z=tanh^-1 of the correlation, as the
> tanh(z) is bounded between -1 and 1.
> However, in an autoregressive model the correlation should be between
> 0 and 1, no? So I would program the optimization so that the
> back-transformation is 0.5*tanh(z)+0.5  -- bounded between 0 and 1.  I
> dunno what Stata does.
>
> Please, send an e-mail to the list when you've figured out.
>
>
>
> Thomas A Trikalinos MD, PhD
>
> Co-Director Tufts Evidence-based Practice Center
> Associate Director, Center for Clinical Evidence Synthesis
>
> Institute for Clinical Research and Health Policy Studies
> Tufts Medical Center | 800 Washington St | Boston, 02111 MA
>
> Phone: +1 617 636 0734
> Fax:   +1 617 636 8628
> email: ttrikalinos@tuftsmedicalcenter.org
>
>
>
>
> On Thu, Mar 18, 2010 at 8:17 AM, Dimitris Pavlopoulos
> <Dimitris.Pavlopoulos@soc.kuleuven.be> wrote:
>> Dear all,
>>
>> I am trying to use estout after xtmixed (STATA 11 /SE). I am using a model with random slopes and an ar(1) stucture for the residuals. Stata 11 allows the estimation of separate correlation and residual standard deviation according to the values of a categorical variable. I have used this feature for a binary variable.
>>
>> My problem is that I cannot find which function is estout using to transform the standard deviation of the residuals that corresponds to value 1 of the grouping variable. So, for the residuals estout present:
>>
>> lnsig_e: variance for residuals corresponding to value 0 of grouping variable
>> r_atr1: autoregressive correlation corresponding to value 0 of grouping variable
>> r_lns2ose: variance for residuals corresponding to value 1  of grouping variable
>> r_atr2: autoregressive correlation corresponding to value 1 of grouping variable
>>
>> for lnsig_e, I need to exponantiate to get the standard deviation
>> For r_atr1 and r_atr2, I am using the tanh()  function.
>>
>> Does anybody know what function do I have to use to get the standard deviation from r_lns2ose?
>>
>>
>> best regards,
>> Dimitris
>> *
>> *   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/
>

*
*   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/
```