?DEMO * Program to get OLS standard errors by Bootstrapping. * Run the original regression, save residuals and coefficients. OLS CONSUME INCOME PRICE / RESID=E PREDICT=YHAT GEN1 N=$N GEN1 K=$K GEN1 NREP=1000 * Create space to hold vectors of bootstrapped coefficients. DIM BETA K NREP * Turn off DO-loop printing or you will get lots of output. SET NODOECHO SET NOOUTPUT SET RANFIX DO #=1,NREP * Draw a random sample of errors with replacement. GENR NEWE=SAMP(E)*SQRT(N/(N-K)) * Generate new dependent variable by using NEWE. GENR Y=YHAT+NEWE OLS Y INCOME PRICE / COEF=BETA:# ENDO * Transpose the BETA matrix for use in STAT and PLOT commands. * This is needed to get the numbers in column order. MATRIX BETA=BETA' SET OUTPUT * Set the sample size to number of replications. SAMPLE 1 NREP * Get the statistics on the replications. STAT BETA * * Look at the frequency distribution for the INCOME coefficient. GENR B1=BETA:1 * Plot a histogram GRAPH B1 / HISTO GROUPS=30 * Now get a nonparametric density estimate NONPAR B1 / DENSITY GRAPH STOP