MACRO mregdata 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; est will contain # 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.1 - k.r est MCONSTANT r m smpsize j st fin g.1 - g.w MMATRIX mat1 mat2 DEFAULT r = 50 # #NOECHO IF q ~= ( p+1 ) NOTE ERROR ! Must be one more column for coefficients than for predictors EXIT ENDIF # BRIEF 0 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 LET st = 1 + (j-1)*m LET fin = j*m 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 LET st = 1 + (j-1)*m LET fin = j*m 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.j. ENDDO STACK k.1 - k.r est ERASE k.1 - k.r 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