\HeaderA{pi0.est}{Estimation of the prior probability}{pi0.est}
\keyword{htest}{pi0.est}
\keyword{smooth}{pi0.est}
\begin{Description}\relax
Estimates the prior probability that a gene is not differentially
expressed by the natural cubic splines based method of Storey and
Tibshirani (2003).
\end{Description}
\begin{Usage}
\begin{verbatim}
  pi0.est(p, lambda = seq(0, 0.95, 0.05), ncs.value = "max", 
      ncs.weights = NULL)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{p}] a numeric vector containing the p-values of the genes
\item[\code{lambda}] a numeric vector or value specifying the \eqn{\lambda}{lambda}
values used in the estimation of the prior probability
\item[\code{ncs.value}] a character string. Only used if \code{lambda} is a
vector. Either \code{"max"} or \code{"paper"}. For details, see 
\code{Details}
\item[\code{ncs.weights}] a numerical vector of the same length as \code{lambda}
containing the weights used in the natural cubic spline fit. By default
no weights are used
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
For each value of \code{lambda}, \eqn{\pi_0(\lambda)}{pi0(lambda)} is
computed by the number of p-values \code{p} larger than
\eqn{\lambda}{lambda} divided by \eqn{(1-\lambda)/m}{(1-lambda)\m},
where \eqn{m}{} is the length of \code{p}.

If \code{lambda} is a value, \eqn{\pi_0(\lambda)}{pi0(lambda)} is the
estimate for the prior probabiltity \eqn{\pi_0}{pi0} that a gene is
not differentially expressed.

If \code{lambda} is a vector, a natural cubic spline \eqn{h}{} with 3 degrees of
freedom is fitted through the data points 
\eqn{(\lambda,\pi_0(\lambda))}{(lambda,pi0(lambda))},
where each point is weighed by \code{ncs.weights}. \eqn{\pi_0}{pi0} is estimated
by \eqn{h(v)}{h(v)}, where \eqn{v=\max\{\lambda\}}{v=max\{lambda\}} if 
\code{ncs.value="max"}, and \eqn{v=1}{v=1} if \code{ncs.value="paper"}.
\end{Details}
\begin{Value}
\begin{ldescription}
\item[\code{p0}] the estimate of the prior probability that a gene is not
differentially expressed
\item[\code{spline.out}] the output of \code{smooth.spline} used in this function
\end{ldescription}
\end{Value}
\begin{Author}\relax
Holger Schwender, \email{holger.schw@gmx.de}
\end{Author}
\begin{References}\relax
Storey, J.D., and Tibshirani, R. (2003). Statistical Significance for 
Genome-wide Studies. \emph{PNAS}, 100, 9440-9445.
\end{References}
\begin{SeeAlso}\relax
\code{\LinkA{SAM-class}{SAM.Rdash.class}},\code{\LinkA{sam}{sam}},\code{\LinkA{qvalue.cal}{qvalue.cal}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}## Not run: 
  # Load the package multtest and the data of Golub et al. (1999)
  # contained in multtest.
  library(multtest)
  data(golub)

  # Perform a SAM analysis.
  sam.out<-sam(golub,golub.cl,B=100,rand=123)

  # Estimate the prior probability that a gene is not significant
  pi0.est(sam.out@p.value)
## End(Not run)\end{ExampleCode}
\end{Examples}


