% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/stats_hotellingsT2.R
\name{hotellingsT2}
\alias{hotellingsT2}
\title{Hotelling T^2 Statistic}
\usage{
hotellingsT2(X, alpha = 0.95)
}
\arguments{
\item{X}{Numeric matrix with observations in rows and variables (dimensions)
in columns.}

\item{alpha}{Numeric scalar. Confidence level for the T^2 region. Default is 0.95.}
}
\value{
A named \code{list} with elements:
\describe{
\item{center}{Numeric vector of column means.}
\item{cov}{Sample covariance matrix.}
\item{c2}{Squared radius of the Hotelling T^2 region.}
}
}
\description{
Computes the Hotelling T^2 statistic defining a multivariate
confidence region for a set of observations. The region corresponds to an
ellipsoid in p-dimensional space and is commonly visualised as an ellipse
in two-dimensional (OPLS) score plots.
}
\details{
The Hotelling T^2 region is defined as
\deqn{(x - \mu)^T S^{-1} (x - \mu) \le c^2}
where \eqn{c^2 = (p (n - 1) / (n - p)) F_{p, n-p}(\alpha)}.
}
\examples{
set.seed(1)
X <- matrix(rnorm(200), ncol = 2)
t2 <- hotellingsT2(X)
ell <- ellipse2d(t2)
plot(X, asp = 1)
lines(ell$x, ell$y, col = "red", lwd = 2)
}
