1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
70
71 title 'The Population Variation Method for Selecting Sample Size';
72
73 /*********************** popvar.sas ****************************
74 * This code writes on the log file. *
75 /***************************************************************/
76
77 /*****************************************************************
78 Given a population effect size A, what sample size is required
79 to detect the effect with a given probability?
80
81 Suppose we are planning a 2x3x4 analysis of covariance,
82 with two covariates, and factors named A, B and C. We
83 are setting it up as a regression model, with one dummy
84 variable for A, 2 dummy variables for B, and 3 for C.
85 Interactions are represented by product terms, and there
86 are 2 products for the AxB interaction, 3 for AxC, 6 for
87 BxC, and 1*2*3 = 6 for AxBxC. The regression coefficients
88 for these plus two for the covariates and one for the
89 intercept give us p = 26. The null hypothesis is that of no
90 BxC interaction, so s = 6. The "other effects in the
91 model" for which we are "controlling" are represented
92 by 2 covariates and 17 dummy variables and products of
93 dummy variables.
94
95 What sample size is required for a power of 0.80 if the BxC
96 interaction explains 10% of the remaining variation IN THE
97 POPULATION? The sample variation method yielded n = 144 for
98 this problem.
99 *****************************************************************/
100
101 /*********************************************/
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 needed
in order to have probability 0.8 of rejecting H0
for 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 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 734.62k
OS Memory 28072.00k
Timestamp 04/01/2020 08:00:02 AM
Step Count 70 Switch Count 2
Page Faults 0
Page Reclaims 169
Page Swaps 0
Voluntary Context Switches 10
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
126
127 /******************************************************************/
128 /* Given sample size, what effect size (population A) is required */
129 /* to have a specified power? */
130 /******************************************************************/
131
132 /* This example uses the same design as above. Suppose we did have the
133 n = 144 for a = 0.10 located by the sample variation method. What
134 POPULATION effect size would be necessary for this sample size to
135 yield a power of 0.80? */
136
137 /*********************************************/
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 level
alpha = 0.05 controlling for the other variables,
and a sample size of 144 , the variables need to explain
A = 0.109 of the remaining POPULATION variation to have a
probability 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 seconds
user cpu time 0.00 seconds
system cpu time 0.00 seconds
memory 701.40k
OS Memory 28072.00k
Timestamp 04/01/2020 08:00:02 AM
Step Count 71 Switch Count 2
Page Faults 0
Page Reclaims 95
Page Swaps 0
Voluntary Context Switches 9
Involuntary Context Switches 0
Block Input Operations 0
Block Output Operations 264
164
165
166
167 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
178