Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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(z) = (Gamma((nu+p)/2)/(Gamma(nu/2) * nu^(p/2) * pi^(p/2))) * |Sigma|^(-1/2) * (1 + ((z - mu)'*Sigma^(-1)*(z - mu)) / nu)^(-(nu+p)/2),

where p is the dimension, nu > 0 degrees of freedom, mu the location parameter and Sigma the scale matrix.

For nu > 1, the mean in equal to mu, for nu > 2, the covariance matrix is equal to (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 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.

x

vector or matrix of the points where the density should be evaluated.

log

logical; if TRUE, log-density is computed

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)

See Also

dt, Mvt.

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")

mixAK

Multivariate Normal Mixture Models and Mixtures of Generalized Linear Mixed Models Including Model Based Clustering

v5.3
GPL (>= 3)
Authors
Arnošt Komárek <arnost.komarek@mff.cuni.cz>
Initial release
2020-06-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.