Fpower1: F-Distribution Power Calculation

Description Usage Arguments Value Author(s) Examples

View source: R/Fpower1.R

Description

Calculates the power for one-way ANOVA

Usage

1
Fpower1(alpha,nlev,nreps,Delta,sigma)

Arguments

alpha

input - significance level of the F-test.

nlev

input - the number of levels of the factor

nreps

input - the number of replicates in each level of the factor.

Delta

input - the size of a practical difference in two cell means.

sigma

input - the standard deviation of the experimental error.

Value

probability of exceeding fcrit(alpha, nu1,nu2) with the non-central F-distribution with nu1 and nu2 degrees of freedom and noncentrality parameter nc

Author(s)

John Lawson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Fpower1(alpha=.05,nlev=3,nreps=4,Delta=3,sigma=sqrt(2.1))


rmin <-2 #smallest number of replicates considered
rmax <-6 # largest number of replicates considered
alpha <- rep(0.05, rmax - rmin +1) 
sigma <-rep(sqrt(2.1), rmax - rmin +1)
nreps <-c(rmin:rmax)
nlev <- rep(3,rmax - rmin +1)
nreps <- rmin:rmax
Delta <- rep(3,rmax - rmin +1)
power <- Fpower1(alpha,nlev,nreps,Delta,sigma)
data.frame(r=nreps,Power=power)


## The function is currently defined as
Fpower1<-function(alpha=NULL, nlev=NULL,nreps=NULL, Delta=NULL, sigma=NULL)
{
##### Power Calculation for one way ANOVA ###########
# Argument list
# alpha the significance level of the test
# nlev the number of levels of the factor 
# nreps the number of replicates in each level of the factor
# Delta the size of a practical difference in two cell means
# sigma the standard deviation of the experimental error
#####################################################
if (is.null(alpha)|is.null(nlev)|is.null(nreps)|is.null(Delta)|is.null(sigma))
  stop("you must supply alpha, nlev, nreps, Delta and sigma")
css<-(Delta^2)/2
nc<- (nreps*css)/(sigma^2)
df1<-nlev-1
df2<-(nreps-1)*nlev
power <- 1-pf(Fcrit(alpha,df1,df2),df1,df2,nc)
return(power)
}

Example output

Registered S3 method overwritten by 'DoE.base':
  method           from       
  factorize.factor conf.design
     alpha nlev nreps Delta    sigma     power
[1,]  0.05    3     4     3 1.449138 0.5903406
  r Power.alpha Power.nlev Power.nreps Power.Delta Power.sigma Power.power
1 2        0.05          3           2           3    1.449138   0.1947995
2 3        0.05          3           3           3    1.449138   0.4041857
3 4        0.05          3           4           3    1.449138   0.5903406
4 5        0.05          3           5           3    1.449138   0.7328895
5 6        0.05          3           6           3    1.449138   0.8329923

daewr documentation built on March 13, 2021, 3:01 a.m.