I have a large dataset that contains information on 160,000 enterprises from 43 countries over 15 years. The dataset is unique at the enterprise level.
I want to do the following 1000 times and store the regression coefficients and standard error:
use combined_data.dta,clear
tempname buffer
capture postutil clear
postfile `bootstrap' observation intercept se_constant X1 se_X1 X2 se_X2 X3 se_X3 using buffer.dta, replace
quietly {
forvalues i = 1(1)1000 {
bsample round(0.8*_N), strata(country year X)
collapse (mean) Y, by (country year X)
regress Y i.X
post `bootstrap' (`i') (`=_b[_cons]') (`=_se[_cons]') (`=_b[X1]') (`=_se[X1]') (`=_b[X2]') (`=_se[X2]') (`=_b[X3]') (`=_se[X3]')
}
}
postclose `buffer'
use buffer.dta, clear
However, it gives me the same coefficients and standard error 1000 times. What am I doing wrong?
Any help would be much appreciated.
I want to do the following 1000 times and store the regression coefficients and standard error:
- Randomly draw a certain fraction (say 60 percent) of the data
- Collapse the dataset at the country-year level
- Run a regression of Y on X (variable X is a categorical variable that goes from 1 to 4)
use combined_data.dta,clear
tempname buffer
capture postutil clear
postfile `bootstrap' observation intercept se_constant X1 se_X1 X2 se_X2 X3 se_X3 using buffer.dta, replace
quietly {
forvalues i = 1(1)1000 {
bsample round(0.8*_N), strata(country year X)
collapse (mean) Y, by (country year X)
regress Y i.X
post `bootstrap' (`i') (`=_b[_cons]') (`=_se[_cons]') (`=_b[X1]') (`=_se[X1]') (`=_b[X2]') (`=_se[X2]') (`=_b[X3]') (`=_se[X3]')
}
}
postclose `buffer'
use buffer.dta, clear
However, it gives me the same coefficients and standard error 1000 times. What am I doing wrong?
Any help would be much appreciated.

Comment