| mpower | Retrospective power analysis for multivariate GLMs | mpower | 
![[download]](../icons/download.gif) get mpower.sas)
 get mpower.sas)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 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.
Power is then calculated from the equivalent F-statistic.
proc glm data=  outstat=STATS;                                
	class  classvars;                                          
	model  depvars = independents / SS3 nouni;  * use SSn option;
	contrast 'name' effect {coefficients};
	manova h=effects;                     
For 
every effect tested on the MODEL statement or in a CONTRAST
statement, observations in the OUTSTAT= dataset will be produced
containing the hypothesis SSCP matrix.
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 mpower macro calculates the power for each of these.
Then invoke the mpower macro, supplying the OUTSTAT= dataset as the data= parameter to mpower
%mpower; %mpower(data=STATS, ..., )You must supply a value for the YVAR= parameter to specify the dependent variables in the dataset. The arguments may be listed within parentheses in any order, separated by commas. For example:
%mpower(data=STATS, yvar=depvars) %mpower(data=STATS, yvar=depvars, alpha=.01, tests=WILKS ROY)
%include data(dogfood); title 'Retrospective Power Analysis: OneWay MANOVA Design'; proc glm order=data outstat=stats; class formula; model start amount = formula / ss3 nouni; contrast 'Ours vs. Theirs' formula 1 1 -1 -1; * contrast 'Old - New' formula 1 -1 0 0; * contrast 'Major vs. Alps' formula 0 0 1 -1; manova h=formula; run;Power analysis for the effect of FORMULA and the contrast 'Ours vs. Theirs' is carried out by the mpower macro:
%include macros(mpower); *-- or include in an autocall library; title2 'Multivariate power'; %mpower(data=stats, yvar=start amount);The results include:
               Retrospective Power Analysis: OneWay MANOVA Design           
                               Multivariate power
                                     EFFECT              ALPHA
                  Power analysis for FORMULA SS3          0.05
                    Value        F    df1   df2     Eta##2 Non-Cent.     Power
 Wilks' Lambda      0.319    2.827      6    22     0.4353      8.48    0.4352
 Pillai's Trace     0.702    2.162      6    24     0.3509    6.4869    0.3414
 Lawley Trace       2.071    3.452      6    20     0.5088    10.357    0.5135
 Roy's max. Root    2.040    8.158      3    12      0.671    24.475    0.9529
                             EFFECT                              ALPHA
          Power analysis for Ours vs. Theirs CONTRAST             0.05
                    Value        F    df1   df2     Eta##2 Non-Cent.     Power
 Wilks' Lambda      0.375    9.178      2    11     0.6253    9.1778    0.6509
 Pillai's Trace     0.625    9.178      2    11     0.6253    9.1778    0.6509
 Lawley Trace       1.669    9.178      2    11     0.6253    9.1778    0.6509
 Roy's max. Root    1.669    9.178      2    11     0.6253    9.1778    0.6509