Bookmark and Share

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: thetas from xtreg, re


From   Gabi Huiber <[email protected]>
To   [email protected]
Subject   st: thetas from xtreg, re
Date   Thu, 10 Mar 2011 12:32:47 -0500

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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index