\HeaderA{var.test}{F Test to Compare Two Variances}{var.test}
\methaliasA{var.test.default}{var.test}{var.test.default}
\methaliasA{var.test.formula}{var.test}{var.test.formula}
\keyword{htest}{var.test}
\begin{Description}\relax
Performs an F test to compare the variances of two samples from normal
populations.
\end{Description}
\begin{Usage}
\begin{verbatim}
var.test(x, ...)

## Default S3 method:
var.test(x, y, ratio = 1,
         alternative = c("two.sided", "less", "greater"),
         conf.level = 0.95, ...)

## S3 method for class 'formula':
var.test(formula, data, subset, na.action, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, y}] numeric vectors of data values, or fitted linear model
objects (inheriting from class \code{"lm"}).
\item[\code{ratio}] the hypothesized ratio of the population variances of
\code{x} and \code{y}.
\item[\code{alternative}] a character string specifying the alternative
hypothesis, must be one of \code{"two.sided"} (default),
\code{"greater"} or \code{"less"}.  You can specify just the initial
letter.
\item[\code{conf.level}] confidence level for the returned confidence
interval.
\item[\code{formula}] a formula of the form \code{lhs \textasciitilde{} rhs} where \code{lhs}
is a numeric variable giving the data values and \code{rhs} a factor
with two levels giving the corresponding groups.
\item[\code{data}] an optional data frame containing the variables in the
model formula.
\item[\code{subset}] an optional vector specifying a subset of observations
to be used.
\item[\code{na.action}] a function which indicates what should happen when
the data contain \code{NA}s.  Defaults to
\code{getOption("na.action")}.
\item[\code{...}] further arguments to be passed to or from methods.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The null hypothesis is that the ratio of the variances of the
populations from which \code{x} and \code{y} were drawn, or in the
data to which the linear models \code{x} and \code{y} were fitted, is
equal to \code{ratio}.
\end{Details}
\begin{Value}
A list with class \code{"htest"} containing the following components:
\begin{ldescription}
\item[\code{statistic}] the value of the F test statistic.
\item[\code{parameter}] the degrees of the freedom of the F distribtion of
the test statistic.
\item[\code{p.value}] the p-value of the test.
\item[\code{conf.int}] a confidence interval for the ratio of the population
variances.
\item[\code{estimate}] the ratio of the sample variances of \code{x} and
\code{y}.
\item[\code{null.value}] the ratio of population variances under the null.
\item[\code{alternative}] a character string describing the alternative
hypothesis.
\item[\code{method}] the character string
\code{"F test to compare two variances"}.
\item[\code{data.name}] a character string giving the names of the data.
\end{ldescription}
\end{Value}
\begin{SeeAlso}\relax
\code{\LinkA{bartlett.test}{bartlett.test}} for testing homogeneity of variances in
more than two samples from normal distributions;
\code{\LinkA{ansari.test}{ansari.test}} and \code{\LinkA{mood.test}{mood.test}} for two rank
based (nonparametric) two-sample tests for difference in scale.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
x <- rnorm(50, mean = 0, sd = 2)
y <- rnorm(30, mean = 1, sd = 1)
var.test(x, y)                  # Do x and y have the same variance?
var.test(lm(x ~ 1), lm(y ~ 1))  # The same.
\end{ExampleCode}
\end{Examples}

