[R] one-way anova power calculations

apjaworski at mmm.com apjaworski at mmm.com
Tue Feb 19 17:27:43 CET 2008


Will,

Your SAS input indicates that within standard deviation is 9, not the
variance.  If you use within.var=81 in your R statement you will get the
answer matching SAS.

Cheers,

Andy

__________________________________
Andy Jaworski
518-1-01
Process Laboratory
3M Corporate Research Laboratory
-----
E-mail: apjaworski at mmm.com
Tel:  (651) 733-6092
Fax:  (651) 736-3122


                                                                           
             "Will Holcomb"                                                
             <wholcomb at gmail.c                                             
             om>                                                        To 
             Sent by:                  r-help <r-help at r-project.org>       
             r-help-bounces at r-                                          cc 
             project.org                                                   
                                                                   Subject 
                                       [R] one-way anova power             
             02/19/2008 10:19          calculations                        
             AM                                                            
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




I have been attempting some basic power calculations using R and I am not
getting the results I expect. I had a homework assignment in SAS, but I
want
to learn R as well, so I was attempting to reproduce my result. (No one
else
in the class is doing R, so there's no need to obsfucate the answer, the
SAS
code is what I get my grade for.) The code I am using is:

# You assume that the within-population standard deviations all equal 9.
You
set the Type 1 error rate at
# alpha = .05. You presume that the population means will have the
following
values: 17.5, 19, 25, 20.5.
# You intend to run 80 subjects in all, with equal n's across all 4 groups.
Compute your power to reject
# the null hypothesis under these conditions.

means = c(17.5, 19, 25, 20.5)
power.anova.test(groups = length(means), n = 80 / length(means),
                 between.var = var(means), within.var = 9,
                 sig.level = 0.05)

The result I'm getting is:

     Balanced one-way analysis of variance power calculation

         groups = 4
              n = 20
    between.var = 10.5
     within.var = 9
      sig.level = 0.05
          power = 1

 NOTE: n is number in each group

I've already done the calculation in SAS with the following code:

data Dep;
Input cue $ mean weight;
datalines;
A 17.5  1
B 19    1
C 25    1
D 20.5  1
;

proc glmpower;
class cue;
model mean = cue;
weight weight;
power
    stddev = 9
    alpha = 0.05
    ntotal= 80
    power = .;
run;

This produces a power of 0.616 which is the answer I was supposed to get.
Any idea what I need to change?

Will

             [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list