Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How to visualize standard errors as the number of bootstrap replications isincreased


From   [email protected]
To   [email protected]
Subject   st: How to visualize standard errors as the number of bootstrap replications isincreased
Date   Wed, 23 May 2007 16:01:01 +0800

Dear all,

I would like to visualize the standard errors associated with a
bootstrapped regression as the number of replications is increased. The
purpose of this is to assess how many replications to perform. I wrote the
following code designed for qreg regressions. I named it grbs for "graph
bootstrap".

-----------------------------
 capture program drop grbs
 program define grbs
 version 9
 postfile results n sa using data, replace
 forvalues n=2(5)10{
 noisily display "`n'" "`sa'"
 set seed 123456789
 quietly bootstrap "qreg $y $x" _b, reps(`n')
 local n=e(N_reps)
 local sa=e(sum_adev)
 post results (`n') (`sa')
 }
 postclose results
 end

 use data, clear
 graph twoway scatter sa n, xtitle("replications") ytitle("bootstrap
standard error")
-----------------------------


I am no programmer -- the code was put together by using related bits of
codes found here and there. There is clearly an error somewhere (or
several) as the saved dataset "data.dta" appears with missing values.

Any hints would be greatly appreciated.

Patrick.
[email protected]

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



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