\Header{power.anova.test}{Power calculations for balanced one-way analysis of variance tests}
\keyword{htest}{power.anova.test}
\begin{Description}\relax
Compute power of test or determine parameters to obtain target power.
\end{Description}
\begin{Usage}
\begin{verbatim}
power.anova.test(groups = NULL, n = NULL, between.var = NULL,
                 within.var = NULL, sig.level = 0.05, power = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{groups}] Number of groups
\item[\code{n}] Number of observations (per group)
\item[\code{between.var}] Between group variance
\item[\code{within.var}] Within group variance
\item[\code{sig.level}] Significance level (Type I error probability)
\item[\code{power}] Power of test (1 minus Type II error probability)
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Exactly one of the parameters \code{groups}, \code{n}, \code{between.var},
\code{power}, \code{within.var}, and \code{sig.level} must be passed as NULL,
and that parameter is determined from the others. Notice that
\code{sig.level} has non-NULL default so NULL must be explicitly
passed if you want it computed.
\end{Details}
\begin{Value}
Object of class \code{"power.htest"}, a list of the arguments
(including the computed one) augmented with \code{method} and
\code{note} elements.
\end{Value}
\begin{Note}\relax
\code{uniroot} is used to solve power equation for unknowns, so
you may see errors from it, notably about inability to bracket the
root when invalid arguments are given.
\end{Note}
\begin{Author}\relax
Claus Ekstrøm
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{anova}}, \code{\Link{lm}}, \code{\Link{uniroot}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
power.anova.test(groups=4, n=5, between.var=1, within.var=3)
# Power = 0.3535594

power.anova.test(groups=4, between.var=1, within.var=3,
                 power=.80)
# n = 11.92613

## Assume we have prior knowledge of the group means:
groupmeans <- c(120, 130, 140, 150)
power.anova.test(groups = length(groupmeans),
                 between.var=var(groupmeans),
                 within.var=500, power=.90) # n = 15.18834

\end{ExampleCode}
\end{Examples}

