\HeaderA{aovFbyrow}{calculate aov F-statistic for each row of a matrix}{aovFbyrow}
\keyword{htest}{aovFbyrow}
\begin{Description}\relax
Returns on aov F-statistic for each row of \code{x}
\end{Description}
\begin{Usage}
\begin{verbatim}
aovFbyrow(x = Golub, cl = golub.info$cancer)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] features by observations matrix
\item[\code{cl}] fact that classifies the values in each row
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
This uses the functions \code{qr()} and \code{qr.qty()} for the main
part of the calculation, for handling the calculations efficently
\end{Details}
\begin{Value}
one F-statistic for each row of \code{x}
\end{Value}
\begin{Note}\relax
\end{Note}
\begin{Author}\relax
John Maindonald
\end{Author}
\begin{References}\relax
\end{References}
\begin{SeeAlso}\relax
See also \code{\LinkA{orderFeatures}{orderFeatures}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
mat <- matrix(rnorm(1000), ncol=20)
cl <- factor(rep(1:3, c(7,9,4)))
Fstats <- aovFbyrow(x = mat, cl = cl)

## The function is currently defined as
aovFbyrow <- 
function(x=matrix(rnorm(1000), ncol=20), 
         cl=factor(rep(1:3, c(7,9,4)))){
    y <- t(x)
    qr.obj <- qr(model.matrix(~cl))
    qty.obj <- qr.qty(qr.obj,y)
    tab <- table(factor(cl))
    dfb <- length(tab)-1
    dfw <- sum(tab)-dfb-1
    ms.between <- apply(qty.obj[2:(dfb+1), , drop=FALSE]^2, 2, sum)/dfb
    ms.within <- apply(qty.obj[-(1:(dfb+1)), , drop=FALSE]^2, 2, sum)/dfw
    Fstat <- ms.between/ms.within
  }
\end{ExampleCode}
\end{Examples}

