1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;7071 /********************************* matpow1.sas ******************************/72 title 'Power analysis for fixed-effects factorial ANOVA: Matrix approach';73 proc iml;NOTE: IML Ready74 /********* Edit this input: Rows of matrices are separated by commas ********/75 alpha = 0.05;76 wantpow = .80;77 f = {1,1,1,1,1,1};77 ! /* Relative sample sizes */78 C = { 1 -1 -1 1 0 0, /* Contrast matrix */79 0 0 1 -1 -1 1};80 eff = {0,-.5};80 ! /* In standard deviation units */81 /*****************************************************************************/82 p = nrow(f) ;82 ! q = nrow(eff);82 ! f = f/sum(f);8384 /*** Echoing input ***/85 print " Significance level: " alpha;86 print " Desired power: " wantpow;87 print " Relative sample sizes:" f;88 print " Contrast matrix ";88 ! print C;89 print " Effect matrix (in SD units): " eff;90 /*** Checking input ***/91 print " Checking input ... ";92 inerr = 0;92 ! /* Input error = no. This may be changed below */93 if nrow(C) ^= q then do;94 print "Error: Length of eff must equal number of rows in C";95 inerr=1;96 end;97 if ncol(C) ^= p then do;98 print "Error: Length of f must equal number of cols in C";99 inerr=1;100 end;101 if eff`*eff = 0 then do;102 print "Error: eff can't be zero; this would cause an infinite loop!";103 inerr=1;104 end;105 aa = min(f##2);106 if aa = 0 then do;107 print "Error: No sample size may be zero.";108 inerr=1;109 end;110111 /*** Proceed if no input errors ***/112 if inerr = 1 then abort;113 else do;114 print "Input appears to be okay. ";115 core = inv(C*inv(diag(f))*C`);116 effsize = eff`*core*eff;116 ! print " Effect size = " effsize;117 power = 0;117 ! n = p;117 ! oneminus = 1-alpha;117 ! /* Initializing ...*/118 do until (power >= wantpow);119 n = n+1 ;120 ncp = n * effsize;121 df2 = n-p;122 power = 1-probf(finv(oneminus,q,df2),q,df2,ncp);123 end;123 ! /* End Loop */124 print " Required sample size is " n;125 end;125 ! /* End computation (Conditional on no input errors) */126 quit;NOTE: Exiting IML.NOTE: PROCEDURE IML used (Total process time):real time 0.05 secondsuser cpu time 0.06 secondssystem cpu time 0.00 secondsmemory 2230.46kOS Memory 29604.00kTimestamp 03/18/2020 03:10:30 AMStep Count 48 Switch Count 0Page Faults 0Page Reclaims 393Page Swaps 0Voluntary Context Switches 0Involuntary Context Switches 0Block Input Operations 0Block Output Operations 8127128 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;139