Multivariate Student t distribution
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.
dMVT(x, df, mu=0, Q=1, Sigma, log=FALSE) rMVT(n, df, mu=0, Q=1, Sigma)
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 |
Some objects.
A vector with evaluated values of the (log-)density
A list with the components:
vector or matrix with sampled values
vector with the values of the log-density evaluated in the sampled values
Arnošt Komárek arnost.komarek[AT]mff.cuni.cz
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")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.