Last chance! 50% off unlimited learning
Sale ends in
Performs power simulation for one-factorial single hypothesis tests.
powerOneWayTests(
mu,
n = 10,
errfn = c("Normal", "Lognormal", "Exponential", "Chisquare", "TDist", "Cauchy",
"Weibull"),
parms = list(mean = 0, sd = 1),
test = c("kruskalTest", "leTest", "vanWaerdenTest", "normalScoresTest",
"spearmanTest", "cuzickTest", "jonckheereTest", "johnsonTest", "oneway.test",
"adKSampleTest", "bwsKSampleTest", "bwsTrendTest", "mackWolfeTest", "chackoTest",
"flignerWolfeTest"),
alternative = c("two.sided", "greater", "less"),
var.equal = TRUE,
dist = NULL,
alpha = 0.05,
FWER = TRUE,
replicates = 1000,
p = NULL
)
numeric vector of group means.
number of replicates per group. If n
is a scalar, then
a balanced design is assumed. Otherwise, n
must be a vector of same
length as mu
.
the error function. Defaults to "Normal"
.
a list that denotes the arguments for the error function.
Defaults to list(mean=0, sd=1)
.
the test for which the power analysis is
to be performed. Defaults to "kwManyOneConoverTest"
.
the alternative hypothesis. Defaults to "two.sided"
,
ignored if the selected error function does not use this argument.
a logical variable indicating whether to treat the variances
in the samples as equal. "TRUE"
, then a simple F test for
the equality of means in a one-way analysis of variance is
performed. If "FALSE"
, an approximate method of Welch (1951)
is used, which generalizes the commonly known 2-sample Welch
test to the case of arbitrarily many samples. Defaults to "TRUE"
; only relevant,
if test = "oneway.test"
, otherwise ignored.
the test distribution. Only relevant for
kruskalTest
. Defaults's to NULL
.
the nominal level of Type I Error.
logical, indicates whether the family-wise error should be computed.
Defaults to TRUE
.
the number of Monte Carlo replicates or runs. Defaults to 1000
.
the a-priori known peak as an ordinal number of the treatment
group including the zero dose level, i.e. NULL
. Only relevant, if "mackWolfeTest"
is selected.
An object with class powerOneWayPMCMR
.
The linear model of a one-way ANOVA can be written as:
For each Monte Carlo run, the function simulates
# NOT RUN {
set.seed(12)
mu <- c(0, 0, 1, 2)
n <- c(5, 4, 5, 5)
parms <- list(mean=0, sd=1)
powerOneWayTests(mu, n, parms, test = "cuzickTest",
alternative = "two.sided", replicates = 1E4)
## Compare power estimation for
## one-way ANOVA with balanced design
## as given by functions
## power.anova.test, pwr.anova.test
## and powerOneWayTest
groupmeans <- c(120, 130, 140, 150)
SEsq <- 500 # within-variance
n <- 10
k <- length(groupmeans)
df <- n * k - k
SSQ.E <- SEsq * df
SSQ.A <- n * var(groupmeans) * (k - 1)
sd.errfn <- sqrt(SSQ.E / (n * k - 1))
R2 <- c("R-squared" = SSQ.A / (SSQ.A + SSQ.E))
cohensf <- sqrt(R2 / (1 - R2))
names(cohensf) <- "Cohens f"
## R stats power function
power.anova.test(groups = k,
between.var = var(groupmeans),
within.var = SEsq,
n = n)
## pwr power function
pwr.anova.test(k = k, n = n, f = cohensf, sig.level=0.05)
## this Monte-Carlo based estimation
set.seed(200)
powerOneWayTests(mu = groupmeans,
n = n,
parms = list(mean=0, sd=sd.errfn),
test = "oneway.test",
var.equal = TRUE,
replicates = 5E3)
## Compare with effect sizes
R2
cohensf
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab