MACRO aregdata y x.1 - x.p; coefs b.1 - b.q; reps r; ci g.1 - g.w est. # y is the dependent variable, the x's are the predictors # the coefficients go into the b's: b.1 is estimates of beta zero ... # reps is an optional subcommand -- the default is 50 replications # ci is an optional subcommand -- if not given, no predictions are made for the bootstrap ci # to use ci put values for x.1 thru x.p in g.1 - g.w; column est will # have all predicted values for y # # this macro resamples cases ( Mooney & Duval p17 ) # copyright 2005 Robert L. Raymond University of St Thomas. Free use for # teaching and noncommercial research-retain this notice in this and derivative works MCOLUMN y x.1 - x.p b.1 - b.q sy sx.1 - sx.p ry rx.1 - rx.p c.1 - c.r k e2 est MCONSTANT r m smpsize j st fin g.1 - g.w jminus prev MMATRIX mat1 mat2 DEFAULT r = 50 # IF q ~= (p+1) NOTE ERROR! Must be one more column for coefficients than for predictors. NOTE EXIT ENDIF # BRIEF 0 NOECHO Let m = COUNT (y) LET smpsize = r*m SAMPLE smpsize y x.1 - x.p sy sx.1 - sx.p ; REPLACE. # IF ci = 0 DO j = 1:r SUBT 1 j jminus MULT jminus m prev ADD 1 prev st MULT j m fin COPY sy sx.1 - sx.p ry rx.1 - rx.p ; USE st:fin. REGRESS ry p rx.1 - rx.p; COEFFICIENTS c.j. ENDDO ELSE IF w ~= p BRIEF 2 NOTE ERROR ! number of values for prediction must equal number of predictors EXIT ENDIF DO j = 1:r SUBT 1 j jminus MULT jminus m prev ADD 1 prev st MULT j m fin COPY sy sx.1 - sx.p ry rx.1 - rx.p ; USE st:fin. REGRESS ry p rx.1 - rx.p; COEFFICIENTS c.j; PREDICT g.1 - g.w; PFITS k. STACK e2 k e2 ENDDO COPY e2 est ENDIF ERASE sy sx.1 - sx.p ry rx.1 - rx.p COPY c.1 - c.r mat1 ERASE c.1 - c.r TRANSPOSE mat1 mat2 ERASE mat1 COPY mat2 b.1 - b.q BRIEF 2 ECHO ENDMACRO