Hello guys,

I'm trying to run a bootstrapping simulation just like here: https://www.statalist.org/forums/for...trap-residuals

Code:
program bs_resid
version 13.1
syntax, RESidual(varname numeric) MATrix(name)
* get the varlist for -regress-
local xvars : colna `matrix'
local CONS _cons
local xvars : list xvars - CONS
* compute the linear prediction
tempvar xb idx y
matrix score double `xb' = `matrix'
* idx randomly selects the observations with replacement
gen long `idx' = ceil(_N*runiform())
* the new dependent variable using resample residuals
gen double `y' = `xb' + `residual'[`idx']
regress `y' `xvars', vce(robust)
end      
 

set seed 12345
sysuse auto  
regress mpg turn trunk displ, vce(robust)
matrix b = e(b)
predict double resid, residuals
histogram resid  

simulate _b _se, reps(1000) : bs_resid, res(resid) mat(b)
sum
I was wondering if anyone knows how to modify the code so that stata only returns `y' values (i don't need to run this regression):

Code:
 regress `y' `xvars', vce(robust)
Thanks