Saving bootstrapped samples

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Saving bootstrapped samples

Margaret MacDougall
Hello

  I am interested in adapting the syntax file oms_bootstrapping.sps provided in the SPSS tutorials folder (at least for SPSS 14.0) in order to ensure that I have a datafile containing each of the assumed 100 bootstrap samples  generated for the two independent variables.  For convenience, I provide the original code below. Could someone kindly assist by editing this code to ensure that I obtain the samples I require.

  Thank you very much

  Margaret
  ============================================================
  ***oms_bootstrapping.sps***.

  PRESERVE.
  SET TVARS NAMES.

  ***first OMS command just suppresses Viewer output***.
  OMS /DESTINATION VIEWER=NO /TAG='suppressall'.

  DATASET DECLARE bootstrap_example.

  ***select regression coefficients tables and write to data file***.
  ***Note that DIMNAMES values vary based on output language***.
  ***/COLUMNS SEQUENCE=[R2 C1] will achieve the same result in all languages***.

  OMS /SELECT TABLES
      /IF COMMANDS=['Regression'] SUBTYPES=['Coefficients']
      /DESTINATION FORMAT=SAV OUTFILE='bootstrap_example'
     /COLUMNS DIMNAMES=['Variables'  'Statistics']
     /TAG='reg_coeff'.

  ***define a macro to draw samples with replacement and run Regression commands***.
  DEFINE regression_bootstrap (samples=!TOKENS(1)
                                             /depvar=!TOKENS(1)
                                             /indvars=!CMDEND)

  COMPUTE dummyvar=1.
  AGGREGATE
    /OUTFILE = * MODE = ADDVARIABLES
    /BREAK=dummyvar
    /filesize=N.
  !DO !other=1 !TO !samples
  SET SEED RANDOM.
  WEIGHT OFF.
  FILTER OFF.
  DO IF $casenum=1.
  - COMPUTE #samplesize=filesize.
  - COMPUTE #filesize=filesize.
  - COMPUTE newsample=salbegin.
  END IF.
  DO IF (#samplesize>0 and #filesize>0).
  - COMPUTE sampleWeight=rv.binom(#samplesize, 1/#filesize).
  - COMPUTE #samplesize=#samplesize-sampleWeight.
  - COMPUTE #filesize=#filesize-1.
  ELSE.
  - COMPUTE sampleWeight=0.
  END IF.
  WEIGHT BY sampleWeight.
  FILTER BY sampleWeight.
  REGRESSION
    /STATISTICS COEFF
    /DEPENDENT !depvar
    /METHOD=ENTER !indvars.
  !DOEND
  !ENDDEFINE.

  ***insert any valid path\data file name***.
  GET FILE='c:\Program Files\SPSS\Employee data.sav'.

  ***Call the macro, and specify number of samples, dependent variable, and independent variables***.
  regression_bootstrap
     samples=100
     depvar=salary
     indvars=salbegin  jobtime .

  OMSEND.

  DATASET ACTIVATE bootstrap_example.

  ***Variable names here indvar variable names with***.
  *** "_B" and "_Beta" appended to end of variable names***.
  FREQUENCIES
    VARIABLES=salbegin_B salbegin_Beta jobtime_B jobtime_Beta
    /FORMAT NOTABLE
    /PERCENTILES= 2.5 97.5
    /HISTOGRAM NORMAL.

  RESTORE.

  ========================================================




---------------------------------
 Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail.