Dear all,
I am trying to get bootstrapped standard errors for a two-stage estimation procedure. I use the first-stage to estimate a group-level measure to be used as independent variable in the second stage. My dataset is at individual-level in the first-stage and then reduced to group-level in the second stage. I'd like to write a program that can be called on in the bootstrap command and do the following:
This is the program have I written so far, but it returns the error “no observations”, which should be due to how I treat the first stage. Any help would be very much appreciated.
I am trying to get bootstrapped standard errors for a two-stage estimation procedure. I use the first-stage to estimate a group-level measure to be used as independent variable in the second stage. My dataset is at individual-level in the first-stage and then reduced to group-level in the second stage. I'd like to write a program that can be called on in the bootstrap command and do the following:
Code:
statsby, by(group) saving(test, replace): reg y1 i.x merge m:1 group using “test.dta”, nogen g mod=_b[1.x] duplicates drop group, force reg y2 mod
Code:
program “twostage”, eclass *First stage: tempfile test statsby, by (group) saving(`test', replace): reg y1 i.x merge m:1 group using `test', nogen tempvar mod g `mod’=_b[1.x] *Second stage duplicates drop group, force reg y2 `mod' tempvar used g byte `used’ = e(sample) tempname b mat `b' = e(b) mat colnames `b' = mod _cons ereturn post `b’, esample(`used’) end bootstrap _b, reps(1000) seed(16121992) cluster(group): twostage
Comment