O'Reilly logo

Adaptive Tests of Significance Using Permutations of Residuals with R and SAS by Thomas W. O'Gorman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

APPENDIX F

SAS MACRO FOR ADAPTIVE TEST WITH PAIRED DATA

Note: The macro adaptwts in Appendix B on file adaptall.sas must also be included.

/*

Notes:

  • 1) The variables that are used in the macro call are described as follows:

    images

  • 2) No missing values are allowed in the differences.
  • 3) If variables are formatted, then the formats will need to be placed before the macro.
  • 4) The number of observations must not exceed 10,000.
  • 5) The number of dependent variables must not exceed 20.
*/

options nocenter linesize=80 nonotes;

%macro adaptpaired(dataset=, diff=, nvars=1,
          seed1=1492, seed2=314, seed3=2718, nsignchs=20000);
data dresid1 dresid2;
  set &dataset;
  res1 = &diff/2; output dresid1;
  res1 =-&diff/2; output dresid2;
data dresid;
  retain n 0;
  set dresidl dresid2;
  n = n + 1;
  call symput(‘nobs’,n);
  output dresid;
run;
%adaptwts(datares=dresid, resvars=resl-res&nvars,
           nobs= &nobs, nvars = &nvars);
data ddiffwts;
  merge &dataset(in=ind) dweights;
  if ind eq 1;
data ddbaru(keep=sumwt2 dbaru);
  retain sumwt2 0;
  retain sumwtd 0;
  set ddiffwts end=last;
  sumwt2 = sumwt2 + weight*weight;
  sumwtd = sumwtd + weight*weight*&diff;
  if last then do;
    db a ru=s umwtd/sumwt 2;
    output;
    end;
data dsse(keep=sseu count);
  retain dbarur sumwt2r sseu 0;
  set ddbaru(in=indbar) ddiffwts(in=indiff) end=last;
  if indbar then dbarur = dbaru;
  if indiff then
     sseu=sseu+weight*weight*((&diff-dbarur)**2)/2.0;
  if last then do;
count=0; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required