Learn R Programming

mixAK (version 2.2)

MVT: 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

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 is given.
Sigma
scale matrix of the multivariate Student t distribution. If Sigma is supplied, precision is computed from $\Sigma$ as $Q = \Sigma^{-1}$.
n
number of observations to be sampled.

Value

  • Some objects.

See Also

dt, Mvt.

Examples

Run this code
set.seed(1977)

### Univariate central t distribution
z <- rMVT(10, df=1, mu=0, Q=1)
boxplot(as.numeric(z$x))
cbind(z$log.dens, 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            

### Compare with mvtnorm package
#require(mvtnorm)
#ldz <- dmvt(z$x, sigma=Sigma, df=nu, delta=mu, log=TRUE)
#plot(z$log.dens, ldz, pch=21, col="red3", bg="orange", xlab="mixAK", ylab="mvtnorm")

Run the code above in your browser using DataLab