\Header{isBalanced}{Check a Design for Balance}
\methalias{isBalanced.groupedData}{isBalanced}
\keyword{data}{isBalanced}
\begin{Description}\relax
Check the design of the experiment or study for balance.
\end{Description}
\begin{Usage}
\begin{verbatim}
isBalanced(object, countOnly, level)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{object}] A \code{groupedData} object containing a data frame and a
formula that describes the roles of variables in the data frame.  The
object will have one or more nested grouping factors and a primary
covariate.
\item[\code{countOnly}] A logical value indicating if the check for balance
should only consider the number of observations at each level of the
grouping factor(s).  Defaults to \code{FALSE}.
\item[\code{level}] an optional integer vector specifying the desired
prediction levels. Levels increase from outermost to innermost
grouping, with level 0 representing the population (fixed effects)
predictions. Defaults to the innermost level.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
A design is
balanced with respect to the grouping factor(s) if there are the same
number of observations at each distinct value of the grouping factor or
each combination of distinct levels of the nested grouping factors.  If
\code{countOnly} is \code{FALSE} the design is also checked for balance
with respect to the primary covariate, which is often the time of the
observation.  A design is balanced with respect to the grouping factor
and the covariate if the number of observations at each distinct level
(or combination of levels for nested factors) is constant and the times
at which the observations are taken (in general, the values of the
primary covariates) also are constant.
\end{Details}
\begin{Value}
\code{TRUE} or \code{FALSE} according to whether the data are balanced
or not
\end{Value}
\begin{Author}\relax
Jose Pinheiro \email{Jose.Pinheiro@pharma.novartis.com} and Douglas Bates \email{bates@stat.wisc.edu}
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{table}}, \code{\Link{groupedData}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
data(Orthodont)
isBalanced(Orthodont)                    # should return TRUE
isBalanced(Orthodont, countOnly = TRUE)  # should return TRUE
data(Pixel)
isBalanced(Pixel)                        # should return FALSE
isBalanced(Pixel, level = 1)             # should return FALSE
\end{ExampleCode}
\end{Examples}

