# Re: st: -estimates table- display question

 From Maarten buis <[email protected]> To [email protected] Subject Re: st: -estimates table- display question Date Sat, 20 Jan 2007 18:18:42 +0000 (GMT)

In example 2 it is actually informative to sort on the size of the
estimated parameter for x. This will show that the estimates of x and
_cons are negativly correlated. See improved example two below:

Hope this helps,
Maarten

*----------- begin example 2 ---------------
set more off
clear
local m = 50
local n = 100
matrix sd = 1
scalar r = 1
scalar a = 1
scalar b = 1

forvalues i = 1/`m' {
drawnorm u`i', n(`n') sds(sd)
}

gen x = uniform()*r
sort x

local ncols = `m' + 1
matrix result = J(8, `ncols',.)

gen ytrue = a + b*x
quietly regress ytrue x

tempname memhold
tempfile results
postfile `memhold' bx lbx ubx b_cons lb_cons ub_cons r2 rmse /*
*/ using `results'
forval i = 1/`m' {
gen y`i' = ytrue + u`i'
quietly regress y`i' x
quietly predict y`i'hat
local lbx = _b[x] - invttail(e(df_r),0.025)*_se[x]
local ubx = _b[x] + invttail(e(df_r),0.025)*_se[x]
local lb_cons = _b[_cons] - invttail(e(df_r),0.025)*_se[_cons]
local ub_cons = _b[_cons] + invttail(e(df_r),0.025)*_se[_cons]
post `memhold' (_b[x]) (`lbx') (`ubx') /*
*/ (_b[_cons]) (`lb_cons') (`ub_cons') /*
*/ (e(r2)) (e(rmse))
}
postclose `memhold'

preserve
use `results', clear

local b = scalar(b)
local a = scalar(a)
sort bx
gen sample = _n
twoway rcap lbx ubx sample, horizontal || /*
*/ scatter sample bx, xline(`b') name(x) /*
*/ legend(label(1 "95% confidence" "interval") /*
*/  label(2 "b"))
twoway rcap lbx ubx sample, horizontal || /*
*/ scatter sample bx, xline(`a') name(cons) /*
*/ legend(label(1 "95% confidence" "interval") /*
*/  label(2 "_cons"))
hist r2, name(r2)
hist rmse, name(rmse)
restore
*------------ end example 2 ----------------

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------

___________________________________________________________
New Yahoo! Mail is the ultimate force in competitive emailing. Find out more at the Yahoo! Mail Championships. Plus: play games and win prizes.
http://uk.rd.yahoo.com/evt=44106/*http://mail.yahoo.net/uk
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/