Dear Stata Users:
I'd like to retain individual parameter (B) and standard error (se) estimates from a bootstrap procedure. That is, sample with replacement N times, run a regression on each of the N resamples, and save one of the B's (and the associated se) in a dataset. In each iteration, I save the desired B and se in a 2 x 1 matrix. then I try to concatenate the matrices. The code is very cumbersome, and am hoping this problem can be simplified somehow.
Here's the code:
Complicating the problem is that I've got the cheap "flavor" of Stata at work, which only allows for matrices with 800 rows.
Is there no easier way to do this? I looked into the "bootstrap" command, and it looks like it gives me summary statistics, but it doesn't look possible to save the estimates from each iteration.
Thanks!
David
I'd like to retain individual parameter (B) and standard error (se) estimates from a bootstrap procedure. That is, sample with replacement N times, run a regression on each of the N resamples, and save one of the B's (and the associated se) in a dataset. In each iteration, I save the desired B and se in a 2 x 1 matrix. then I try to concatenate the matrices. The code is very cumbersome, and am hoping this problem can be simplified somehow.
Here's the code:
Code:
use data.dta sum scalar n = r(N) scalar N = 10000 forvalues i=1/N {preserve bsample n /*sample w/ replacement*/ display "" display "" display `i' /*display iteration number*/ reg y x1 x2 /*run regression*/ mat A = r(table) mat A`i' = (A[1,2], A[2,2]) /*save B and se for X2*/ restore }*Concatenate A matrices mat B1 = A1 forvalues i=2/10000 {local k = `i'-1 mat B`i' = (B`k' \ A`i') }
Is there no easier way to do this? I looked into the "bootstrap" command, and it looks like it gives me summary statistics, but it doesn't look possible to save the estimates from each iteration.
Thanks!

David
Comment