View source: R/powerOneWayTests.R
powerOneWayTests | R Documentation |
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
)
mu |
numeric vector of group means. |
n |
number of replicates per group. If |
errfn |
the error function. Defaults to |
parms |
a list that denotes the arguments for the error function.
Defaults to |
test |
the test for which the power analysis is
to be performed. Defaults to |
alternative |
the alternative hypothesis. Defaults to |
var.equal |
a logical variable indicating whether to treat the variances
in the samples as equal. |
dist |
the test distribution. Only relevant for
|
alpha |
the nominal level of Type I Error. |
FWER |
logical, indicates whether the family-wise error should be computed.
Defaults to |
replicates |
the number of Monte Carlo replicates or runs. Defaults to |
p |
the a-priori known peak as an ordinal number of the treatment
group including the zero dose level, i.e. |
The linear model of a one-way ANOVA can be written as:
X_{ij} = \mu_i + \epsilon_{ij}
For each Monte Carlo run, the function simulates \epsilon_{ij}
based on the given error function and
the corresponding parameters. Then the specified test is performed.
Finally, Type I and Type II error rates are calculated.
An object with class powerOneWayPMCMR
.
powerMCTests
,
pwr.anova.test
,
power.anova.test
## 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
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.