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
Code:
regress `y' `xvars', vce(robust)
0 Response to Simulation
Post a Comment