rpower Retrospective power analysis for univariate GLMs rpower

SAS Macro Programs: rpower

$Version: 1.1 (2 Nov 2000)
Michael Friendly
York University



The rpower macro ( [download] get rpower.sas)

Retrospective power analysis for univariate GLMs

The rpower macro performs retrospective power analysis for a PROC GLM analysis. This treats the sample means as if they were population means, determines an effect size, and calculates the power for specified effects.

The program reads the OUTSTAT= data set constructed in a PROC GLM step. For each effect tested, the program calculates the nominal power of the test, if the sample means were population values. For specified alpha and power values, the required sample size to achieve that power is also determined.

Caution

To interpret the results of retrospective power analysis properly, you need to understand that the power and sample size values computed are direct functions of the sample p-values for effects in the analysis. Small p-values (large effects) imply large power and vice versa.

For proper power analysis and sample size planning, you should consider the size of differences among groups which are meaningful to detect in terms of the research questions.

Method

Effect sizes, and non-centrality parameters for the F distribution are calcualted as described by O'Brien (1988, p.1098), SAS SUGI Conference.

Usage

First run a PROC GLM analysis of your data using the OUTSTAT= option to create a dataset containing summary statistics:
proc glm data=  outstat=STATS;                                
	class  classvars;                                          
	model  depvars = independents / SS3;  * use SSn option;
	contrast 'name' effect {coefficients};                     
For each dependent variable, and for every effect tested on the MODEL statement or in a CONTRAST statement, observations in the OUTSTAT= dataset will be produced. If you do not specify an SSn option on the MODEL statement, GLM will produce both Type I (SS1) and Type III (SS3) sum of squares. The rpower macro calculates the power for each of these.

Then invoke the rpower macro, supplying the OUTSTAT= dataset as the data= parameter to rpower

   %rpower;
   %rpower(data=STATS, ..., )
There are no required parameters.

Parameters

Default values are shown after the name of each parameter.
DATA=_LAST_
OUTSTAT= data set from GLM. If not specified, the most recently created dataset is used.
ALPHA=.05
Desired alpha level(s) of tests A separate computation is performed for each value specified. You may specify a single value, a list of values separated by commas, a range of the form x TO y BY z, or a combination of these.
POWER=.90
The desired power value(s). A separate computation is performed for each value specified. You may specify a single value, a list of values separated by commas, a range of the form x TO y BY z, or a combination of these. However, you must surround the POWER= value with %STR() if any commas appear in it. For example,
power=.70 to .9 by .1
power=%str(.7, .8, .85)
power=%str(.5, .70 to .9 by .1)
SIGMA=1
alternate estimate of root MSE. If not specified, the macro uses the MSE from the OUTSTAT= dataset.
OUT=_power_
Name of the output dataset containing power statistics

Example

The following example reads means for a 3-way design and uses the stat2dat macro to create an equivalent raw data set having the same means and within group standard deviations.
data learning;
	do grade = 5,12;
	do words = 'low ', 'high';
	do feedback = 'Control', 'Pos', 'Neg';
		input mean @@;
		output;
		end; end; end;
lines;
8.8 8.0 7.6
8.0 4.4 3.8
9.0 8.4 8.0
7.8 7.4 7.2
;

%stat2dat(data=learning, class=grade words feedback,
	out=raw, mean=mean, n=5, MSE=1.75, depvar=recall);
The GLM step tests all effects up to the 3-way interaction, plus a contrast of the FEEDBACK variable. The OUTSTAT= dataset is read by the rpower macro:
proc glm data=raw outstat=stats;
	class feedback words grade;
	model recall = feedback|words|grade / ss3;
	contrast 'Cont:+,-' feedback  -2 1 1;
	freq freq;

%include macros(rpower);        *-- or include in an autocall library;
%rpower(data=stats);
The output from the rpower macro:
                                             F Nominal Adj.     Non-
SOURCE               _NAME_ _TYPE_   DF  Value  power  power Centrality

FEEDBACK             RECALL SS3       2   9.61  0.975  0.950    19.22
WORDS                RECALL SS3       1  29.87  1.000  0.999    29.87
FEEDBACK*WORDS       RECALL SS3       2   1.61  0.324  0.134     3.22
GRADE                RECALL SS3       1  12.34  0.931  0.897    12.34
FEEDBACK*GRADE       RECALL SS3       2   3.11  0.573  0.390     6.23
WORDS*GRADE          RECALL SS3       1   6.44  0.701  0.606     6.44
FEEDBACK*WORDS*GRADE RECALL SS3       2   2.47  0.472  0.280     4.93
Cont:+,-             RECALL CONTRAST  1  18.30  0.987  0.979    18.30

                             Adj_Non-   Req'd  Total  Req'd
SOURCE               _NAME_ Centrality    N      N    power  ALPHA

FEEDBACK             RECALL    16.42      2.2    7.5   0.9    0.05
WORDS                RECALL    27.62      1.9    3.6   0.9    0.05
FEEDBACK*WORDS       RECALL     1.08     12.7  447.4   0.9    0.05
GRADE                RECALL    10.83      2.4    7.0   0.9    0.05
FEEDBACK*GRADE       RECALL     3.97      4.4   44.3   0.9    0.05
WORDS*GRADE          RECALL     5.17      3.4   15.8   0.9    0.05
FEEDBACK*WORDS*GRADE RECALL     2.73      5.8   82.8   0.9    0.05
Cont:+,-             RECALL    16.54      2.2    5.0   0.9    0.05

See also

fpower Power computations for ANOVA designs
meanplot Plotting means for factorial designs
mpower Retrospective power analysis for multivariate GLMs
stat2dat Convert summary dataset to raw data equivalent