1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;7071 title 'The Population Variation Method for Selecting Sample Size';7273 /*********************** popvar.sas ****************************74 * This code writes on the log file. *75 /***************************************************************/7677 /*****************************************************************78 Given a population effect size A, what sample size is required79 to detect the effect with a given probability?8081 Suppose we are planning a 2x3x4 analysis of covariance,82 with two covariates, and factors named A, B and C. We83 are setting it up as a regression model, with one dummy84 variable for A, 2 dummy variables for B, and 3 for C.85 Interactions are represented by product terms, and there86 are 2 products for the AxB interaction, 3 for AxC, 6 for87 BxC, and 1*2*3 = 6 for AxBxC. The regression coefficients88 for these plus two for the covariates and one for the89 intercept give us p = 26. The null hypothesis is that of no90 BxC interaction, so s = 6. The "other effects in the91 model" for which we are "controlling" are represented92 by 2 covariates and 17 dummy variables and products of93 dummy variables.9495 What sample size is required for a power of 0.80 if the BxC96 interaction explains 10% of the remaining variation IN THE97 POPULATION? The sample variation method yielded n = 144 for98 this problem.99 *****************************************************************/100101 /*********************************************/102 data fpower1; /* Replace alpha, s, p, and wantpow below */103 alpha = 0.05; /* Significance level */104 s = 6; /* Numerator df = # IVs being tested */105 p = 26; /* There are p beta parameters */106 A = 0.10; /* POPULATION effect size */107 wantpow = .80; /* Find n to yield this power. */108 /*********************************************/109 power = 0; n = p; oneminus = 1-alpha; /* Initializing ... */110 do until (power >= wantpow);111 n = n+1 ;112 ncp = (n-p)*A/(1-A);113 df2 = n-p;114 power = 1-probf(finv(oneminus,s,df2),s,df2,ncp);115 end;116 put ' *********************************************************';117 put ' ';118 put ' For a multiple regression model with ' p 'betas, ';119 put ' testing ' s 'explanatory variables using alpha = ' alpha ',';120 put ' a sample size of ' n 'is needed';121 put ' in order to have probability ' wantpow 'of rejecting H0';122 put ' for a POPULATION effect of size A = ' A ;123 put ' ';124 put ' *********************************************************';125 run;*********************************************************For a multiple regression model with 26 betas,testing 6 explanatory variables using alpha = 0.05 ,a sample size of 155 is neededin order to have probability 0.8 of rejecting H0for a POPULATION effect of size A = 0.1*********************************************************NOTE: The data set WORK.FPOWER1 has 1 observations and 10 variables.NOTE: DATA statement used (Total process time):real time 0.00 secondsuser cpu time 0.00 secondssystem cpu time 0.00 secondsmemory 734.62kOS Memory 28072.00kTimestamp 04/01/2020 08:00:02 AMStep Count 70 Switch Count 2Page Faults 0Page Reclaims 169Page Swaps 0Voluntary Context Switches 10Involuntary Context Switches 0Block Input Operations 0Block Output Operations 264126127 /******************************************************************/128 /* Given sample size, what effect size (population A) is required */129 /* to have a specified power? */130 /******************************************************************/131132 /* This example uses the same design as above. Suppose we did have the133 n = 144 for a = 0.10 located by the sample variation method. What134 POPULATION effect size would be necessary for this sample size to135 yield a power of 0.80? */136137 /*********************************************/138 data fpower2; /* Replace alpha, s, n, p, and wantpow below */139 alpha = 0.05; /* Significance level */140 s = 6; /* Numerator df = # IVs being tested */141 n = 144; /* Sample size */142 p = 26; /* There are p beta parameters */143 wantpow = .80; /* Find effect size A to yield this power. */144 /*********************************************/145 df2 = n-p; oneminus = 1 - alpha;146 critval = finv(oneminus,s,df2);147 /* Initializing ... */ A = 0;148 do until (power ge wantpow);149 A = A + .001 ;150 ncp = (n-p)*A/(1-A);151 power = 1-probf(critval,s,df2,ncp);152 end;153 put ' ******************************************************';154 put ' ';155 put ' For a multiple regression model with ' p 'betas, ';156 put ' testing ' s ' explanatory at significance level ';157 put ' alpha = ' alpha ' controlling for the other variables,';158 put ' and a sample size of ' n', the variables need to explain';159 put ' A = ' A ' of the remaining POPULATION variation to have a';160 put ' probability of ' wantpow 'of being significant';161 put ' ';162 put ' *******************************************************';163 run;******************************************************For a multiple regression model with 26 betas,testing 6 explanatory at significance levelalpha = 0.05 controlling for the other variables,and a sample size of 144 , the variables need to explainA = 0.109 of the remaining POPULATION variation to have aprobability of 0.8 of being significant*******************************************************NOTE: The data set WORK.FPOWER2 has 1 observations and 11 variables.NOTE: DATA statement used (Total process time):real time 0.00 secondsuser cpu time 0.00 secondssystem cpu time 0.00 secondsmemory 701.40kOS Memory 28072.00kTimestamp 04/01/2020 08:00:02 AMStep Count 71 Switch Count 2Page Faults 0Page Reclaims 95Page Swaps 0Voluntary Context Switches 9Involuntary Context Switches 0Block Input Operations 0Block Output Operations 264164165166167 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;178