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: thetas from xtreg, re
From
Gabi Huiber <[email protected]>
To
[email protected]
Subject
Re: st: thetas from xtreg, re
Date
Thu, 10 Mar 2011 15:59:00 -0500
Dear Statalist,
I figured it out, and here it is in case anybody ever makes the same
mistake: the distribution of thetas that "xtreg, re theta" shows on
screen has to do with how many individuals in the panel exhibit each
of the theta values, not with the theta values themselves. In this
case there were 15 non-missing thetas:
theta_re | Freq. Percent Cum.
------------+-----------------------------------
.2519613 | 533 11.35 11.35
.3767292 | 498 10.60 21.95
.4545638 | 484 10.30 32.25
.5090276 | 411 8.75 41.00
.5498765 | 421 8.96 49.97
.5819767 | 398 8.47 58.44
.6080627 | 345 7.35 65.79
.6298048 | 323 6.88 72.66
.6482885 | 302 6.43 79.09
.6642541 | 270 5.75 84.84
.6782259 | 202 4.30 89.14
.690587 | 158 3.36 92.51
.7016249 | 147 3.13 95.64
.71156 | 119 2.53 98.17
.7205645 | 86 1.83 100.00
------------+-----------------------------------
Total | 4,697 100.00
.609 may be the median value, but that's not of interest. e(thta_50)
is the halfpoint of the 4,697 individuals: .549. All is well.
Thank you,
Gabi
On Thu, Mar 10, 2011 at 12:32 PM, Gabi Huiber <[email protected]> wrote:
> Dear Statalist,
>
> I am trying to collect the theta estimates from xtreg, re. I am using Stata 10.
>
> I did not see any way I could attach xtreg, re's own calculated values
> as an additional variable, so I thought I'd reconstitute them by hand
> using the formula on page 410 of the [XT] book (release 10).
>
> Somehow, my calculations and Stata's don't match. The formula works
> fine in balanced panels, where T_i is a constant, but not so much in
> unbalanced panels. The difference is pretty big, as shown in the
> results below. I'm not sure what I'm doing wrong. I would appreciate
> your help.
>
> ______ results from screen here _______
>
> Median theta from xtreg, re 0.5499
> My calculated median theta 0.6906
>
> _______ my code starts here _______
>
> // theta by hand compared to theta you get from xtreg, re
> capture prog drop compareTheta
> program compareTheta
>
> version 10
>
> // example on p. 402 of [XT] release 10
> use http://www.stata-press.com/data/r10/nlswork, clear
> foreach k in age ttl_exp tenure {
> gen `k'2=`k'^2
> }
> gen byte black=race==2
> local xlist grade age* ttl_exp* tenure* black not_smsa south
>
> xtreg ln_w `xlist', re theta
> count
> count if e(sample)
>
> scalar er =e(sigma_e)
> scalar ur_re =e(sigma_u)
> scalar theta_med=e(thta_50)
>
> // formula on p. 410 of [XT] r. 10
> keep if e(sample)
> egen years=count(year), by(idcode)
> gen theta_re=1-sqrt((er^2)/(years*ur_re^2+er^2))
>
> preserve
> keep theta_re
> duplicates drop
> sum theta_re, detail
> local theta_re=r(p50)
> restore
> scalar theta_re=`theta_re'
>
> local cols _col(25) %8.4fc
> di ""
> di "Median theta from xtreg, re " `cols' theta_med
> di "My calculated median theta " `cols' theta_re
>
> end
>
> compareTheta
> _____________________________________________ code ends here
>
> Thank you,
>
> Gabi
> *
> * 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/