\HeaderA{mt.teststat}{Computing test statistics for each row of a data frame}{mt.teststat}
\aliasA{mt.teststat.num.denum}{mt.teststat}{mt.teststat.num.denum}
\keyword{univar}{mt.teststat}
\begin{Description}\relax
These functions provide a convenient way to compute test statistics,
e.g., two-sample Welch t-statistics, Wilcoxon statistics,
F-statistics, paired t-statistics,
block F-statistics, for each row of a data frame.
\end{Description}
\begin{Usage}
\begin{verbatim}
mt.teststat(X,classlabel,test="t",na=.mt.naNUM,nonpara="n")
mt.teststat.num.denum(X,classlabel,test="t",na=.mt.naNUM,nonpara="n")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{X}] A data frame or matrix, with \eqn{m}{} rows corresponding to variables
(hypotheses) and\eqn{n}{} columns to observations. In the case of gene 
expression data, rows
correspond to genes and columns to mRNA samples. The data can
be read using \code{\LinkA{read.table}{read.table}}.

\item[\code{classlabel}] A vector of integers corresponding to observation (column)
class labels. For \eqn{k}{} classes, the labels must be integers
between 0 and \eqn{k-1}{}. For the \code{blockf} test option,
observations may be divided into
\eqn{n/k}{} blocks of \eqn{k}{} observations each. The observations are
ordered by block, and within each block, they are labeled using the
integers 0 to \eqn{k-1}{}.

\item[\code{test}] A character string specifying the statistic to be
used to test the null hypothesis of no association between the
variables and the class labels.\\
If \code{test="t"}, the tests are based on two-sample Welch t-statistics
(unequal variances).  \\
If \code{test="t.equalvar"}, the tests are based on two-sample
t-statistics with equal variance for the two samples. The
square of the t-statistic is equal to an F-statistic for \eqn{k=2}{}. \\
If \code{test="wilcoxon"}, the tests are based on standardized rank sum Wilcoxon statistics.\\
If \code{test="f"}, the tests are based on F-statistics.\\
If \code{test="pairt"}, the tests are based on paired t-statistics. The
square of the paired t-statistic is equal to a block F-statistic for \eqn{k=2}{}. \\
If \code{test="blockf"}, the tests are based on F-statistics which
adjust for block differences
(cf. two-way analysis of variance).

\item[\code{na}] Code for missing values (the default is \code{.mt.naNUM=--93074815.62}).
Entries with missing values will be ignored in the computation,
i.e., test statistics will be based on a smaller sample size. This
feature has not yet fully implemented.

\item[\code{nonpara}] If \code{nonpara}="y", nonparametric test statistics are computed based on ranked data. \\
If  \code{nonpara}="n", the original data are used.
\end{ldescription}
\end{Arguments}
\begin{Value}
For \code{\LinkA{mt.teststat}{mt.teststat}}, a vector of test statistics for each row (gene). \\ \\
For \code{\LinkA{mt.teststat.num.denum}{mt.teststat.num.denum}}, a data frame with \\
\begin{ldescription}
\item[\code{teststat.num}] the numerator of the test statistics for each row, depending on the
specific \code{test} option.
\item[\code{teststat.denum}] the denominator of the test statistics for each row, depending on the
specific \code{test} option.
\end{ldescription}
\end{Value}
\begin{Author}\relax
Yongchao Ge, \email{yongchao.ge@mssm.edu}, \\
Sandrine Dudoit, \url{http://www.stat.berkeley.edu/~sandrine}.
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{mt.maxT}{mt.maxT}}, \code{\LinkA{mt.minP}{mt.minP}}, \code{\LinkA{golub}{golub}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
# Gene expression data from Golub et al. (1999)
data(golub)

teststat<-mt.teststat(golub,golub.cl)
qqnorm(teststat)
qqline(teststat)

tmp<-mt.teststat.num.denum(golub,golub.cl,test="t")
num<-tmp$teststat.num
denum<-tmp$teststat.denum
plot(sqrt(denum),num)

tmp<-mt.teststat.num.denum(golub,golub.cl,test="f")

\end{ExampleCode}
\end{Examples}


