MVT {mixAK} | R Documentation |
Multivariate Student t distribution
Description
Density and random generation for the multivariate Student t distribution
with location equal to mu
, precision matrix equal to Q
(or scale
matrix equal to Sigma
).
Mentioned functions implement the multivariate Student t distribution with a density given by
%
p(\boldsymbol{z}) =
\frac{\Gamma\bigl(\frac{\nu+p}{2}\bigr)}{\Gamma\bigl(\frac{\nu}{2}\bigr)\,\nu^{\frac{p}{2}}\,\pi^{\frac{p}{2}}}\,
\bigl|\Sigma\bigr|^{-\frac{1}{2}}\,
\Bigl\{1 + \frac{(\boldsymbol{z} -
\boldsymbol{\mu})'\Sigma^{-1}(\boldsymbol{z} -
\boldsymbol{\mu})}{\nu}\Bigr\}^{-\frac{\nu+p}{2}},
where p
is the dimension, \nu > 0
degrees of
freedom, \boldsymbol{\mu}
the location parameter and
\Sigma
the scale matrix.
For \nu > 1
, the mean in equal to
\boldsymbol{\mu}
,
for \nu > 2
, the covariance matrix is equal to
\frac{\nu}{\nu - 2}\Sigma
.
Usage
dMVT(x, df, mu=0, Q=1, Sigma, log=FALSE)
rMVT(n, df, mu=0, Q=1, Sigma)
Arguments
df |
degrees of freedom of the multivariate Student t distribution. |
mu |
vector of the location parameter. |
Q |
precision (inverted scale) matrix of the multivariate Student
t distribution. Ignored if |
Sigma |
scale matrix of the multivariate Student t
distribution. If |
n |
number of observations to be sampled. |
x |
vector or matrix of the points where the density should be evaluated. |
log |
logical; if |
Value
Some objects.
Value for dMVT
A vector with evaluated values of the (log-)density
Value for rMVT
A list with the components:
- x
vector or matrix with sampled values
- log.dens
vector with the values of the log-density evaluated in the sampled values
Author(s)
Arnošt Komárek arnost.komarek@mff.cuni.cz
See Also
Examples
set.seed(1977)
### Univariate central t distribution
z <- rMVT(10, df=1, mu=0, Q=1)
ldz <- dMVT(z$x, df=1, log=TRUE)
boxplot(as.numeric(z$x))
cbind(z$log.dens, ldz, dt(as.numeric(z$x), df=1, log=TRUE))
### Multivariate t distribution
mu <- c(1, 2, 3)
Sigma <- matrix(c(1, 1, -1.5, 1, 4, 1.8, -1.5, 1.8, 9), nrow=3)
Q <- chol2inv(chol(Sigma))
nu <- 3
z <- rMVT(1000, df=nu, mu=mu, Sigma=Sigma)
apply(z$x, 2, mean) ## should be close to mu
((nu - 2) / nu) * var(z$x) ## should be close to Sigma
dz <- dMVT(z$x, df=nu, mu=mu, Sigma=Sigma)
ldz <- dMVT(z$x, df=nu, mu=mu, Sigma=Sigma, log=TRUE)
### Compare with mvtnorm package
#require(mvtnorm)
#ldz2 <- dmvt(z$x, sigma=Sigma, df=nu, delta=mu, log=TRUE)
#plot(z$log.dens, ldz2, pch=21, col="red3", bg="orange", xlab="mixAK", ylab="mvtnorm")
#plot(ldz, ldz2, pch=21, col="red3", bg="orange", xlab="mixAK", ylab="mvtnorm")