% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/simplexreg_var.R
\name{variance.simplex}
\alias{variance.simplex}
\title{Variance Function of the Simplex Distribution}
\usage{
variance.simplex(mu, sigma2)
}
\arguments{
\item{mu}{Numeric scalar or vector of mean parameters (\eqn{0 < \mu < 1}).
If a vector, must be the same length as \code{sigma2} or recyclable.}

\item{sigma2}{Numeric scalar or vector of dispersion parameters
(\eqn{\sigma^2 > 0}).
If a vector, must be the same length as \code{mu} or recyclable.}
}
\value{
A numeric scalar or vector of variance values.
}
\description{
Computes the variance of the simplex distribution as a function
of the mean parameter \eqn{\mu} and dispersion parameter \eqn{\sigma^2}.
}
\details{
The variance function for the simplex distribution is given by:
\deqn{Var(Y) = \mu(1-\mu) - \frac{1}{\sqrt{2\sigma^2}} \exp(a) \Gamma(0.5, a),}
where \eqn{a = \frac{1}{2\sigma^2[\mu(1-\mu)]^2}} and \eqn{\Gamma(0.5, a)}
is the upper incomplete gamma function.

For large values of \eqn{a} (> 700), an asymptotic approximation is used
to avoid numerical overflow:
\deqn{Var(Y) \approx \mu(1-\mu) - \frac{1}{\sqrt{2\sigma^2}} \sqrt{\frac{1}{a}}.}
}
\examples{
# Single value
variance.simplex(mu = 0.5, sigma2 = 0.1)

# Vector of values
mu_vec <- c(0.3, 0.5, 0.7)
sigma2_vec <- c(0.1, 0.15, 0.2)
variance.simplex(mu = mu_vec, sigma2 = sigma2_vec)

}
\references{
Jørgensen, B. (1997). \emph{The Theory of Dispersion Models}.
Chapman and Hall, London.

Song, P. X.-K. and Tan, M. (2000).
Marginal models for longitudinal continuous proportional data.
\emph{Biometrics}, \bold{56}(2), 496--502.
\doi{10.1111/j.0006-341X.2000.00496.x}
}
