I have mocked up a basic example here using the auto data. I want to run a regression for a subset of data, and then I want to predict the fitted value for the full data, and then run a second regression on those fitted values. (This is only a mock, so I am not interested in other ways to do this simple task. In practice I have another 20 lines of code that I would like to run for each bootstrap).
How do i get a bootstrap estimate of the second regression, knowing that i need to run a bootstrap for the first 3 lines of code as well.
Code:
sysuse auto, clear bootstrap, reps(5): areg price trunk weight displ if headroom<3, a(foreign) predict Xprice_tmp, d egen Xprice = mean(Xprice_tmp), by(foreign) reg headroom Xprice
Mike
0 Response to Bootstrapping across multiple lines of code
Post a Comment