\HeaderA{squeezeVar}{Smooth Sample Variances}{squeezeVar}
\keyword{htest}{squeezeVar}
\begin{Description}\relax
Smooth a set of sample variances by computing empirical Bayes posterior means.
\end{Description}
\begin{Usage}
\begin{verbatim}
squeezeVar(var, df)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{var}] numeric vector of independent sample variances
\item[\code{df}] numeric vector of degrees of freedom for the sample variances
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The sample variances \code{var} are assumed to follow scaled chi-squared distributions.
An inverse chi-squared prior is assumed for the true variances.
The scale and degrees of freedom for the prior distribution are estimated from the data.

The effect of this function is to smooth or shrink the variances towards a common value.
The smoothed variances have a smaller expected mean square error to the true variances than do the sample variances themselves.

This function is called by \code{eBayes}, but beware a possible confusion with the output from that function.
The values \code{var.prior} and \var{var.post} output by \code{squeezeVar} correspond to the quantities \code{s2.prior} and \code{s2.post} output by \code{eBayes}, whereas \code{var.prior} output by \code{eBayes} relates to a different parameter.
\end{Details}
\begin{Value}
A list with components
\begin{ldescription}
\item[\code{var.post}] numeric vector of posterior variances
\item[\code{var.prior}] location of prior distribution
\item[\code{df.prior}] degrees of freedom of prior distribution
\end{ldescription}
\end{Value}
\begin{Author}\relax
Gordon Smyth
\end{Author}
\begin{References}\relax
Smyth, G. K. (2004). Linear models and empirical Bayes methods for
assessing differential expression in microarray experiments.
\emph{Statistical Applications in Genetics and Molecular Biology}, \bold{3},
No. 1, Article 3. \url{http://www.bepress.com/sagmb/vol3/iss1/art3}
\end{References}
\begin{Examples}
\begin{ExampleCode}
s2 <- rchisq(20,df=5)/5
squeezeVar(s2, df=5)
\end{ExampleCode}
\end{Examples}

