Mvt {mvtnorm} | R Documentation |
The Multivariate t Distribution
Description
These functions provide information about the multivariate
distribution with non-centrality parameter (or mode)
delta
,
scale matrix sigma
and degrees of freedom df
.
dmvt
gives the density and rmvt
generates random deviates.
Usage
rmvt(n, sigma = diag(2), df = 1, delta = rep(0, nrow(sigma)),
type = c("shifted", "Kshirsagar"), ...)
dmvt(x, delta = rep(0, p), sigma = diag(p), df = 1, log = TRUE,
type = "shifted", checkSymmetry = TRUE)
Arguments
x |
vector or matrix of quantiles. If |
n |
number of observations. |
delta |
the vector of noncentrality parameters of length n, for
|
sigma |
scale matrix, defaults to
|
df |
degrees of freedom. |
log |
|
type |
type of the noncentral multivariate |
checkSymmetry |
logical; if |
... |
additional arguments to |
Details
If denotes a random vector following a
distribution
with location vector
and scale matrix
(written
), the scale matrix (the argument
sigma
) is not equal to the covariance matrix
of
. If the degrees of freedom
(the
argument
df
) is larger than 2, then
. Furthermore,
in this case the correlation matrix
equals
the correlation matrix corresponding to the scale matrix
(which can be computed with
cov2cor()
). Note that the scale matrix is sometimes
referred to as “dispersion matrix”;
see McNeil, Frey, Embrechts (2005, p. 74).
For type = "shifted"
the density
is implemented, where
is a positive definite symmetric matrix (the matrix
sigma
above), is the
non-centrality vector and
are the degrees of freedom.
df=0
historically leads to the multivariate normal
distribution. From a mathematical point of view, rather
df=Inf
corresponds to the multivariate normal
distribution. This is (now) also allowed for rmvt()
and
dmvt()
.
Note that dmvt()
has default log = TRUE
, whereas
dmvnorm()
has default log = FALSE
.
References
McNeil, A. J., Frey, R., and Embrechts, P. (2005). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.
See Also
Examples
## basic evaluation
dmvt(x = c(0,0), sigma = diag(2))
## check behavior for df=0 and df=Inf
x <- c(1.23, 4.56)
mu <- 1:2
Sigma <- diag(2)
x0 <- dmvt(x, delta = mu, sigma = Sigma, df = 0) # default log = TRUE!
x8 <- dmvt(x, delta = mu, sigma = Sigma, df = Inf) # default log = TRUE!
xn <- dmvnorm(x, mean = mu, sigma = Sigma, log = TRUE)
stopifnot(identical(x0, x8), identical(x0, xn))
## X ~ t_3(0, diag(2))
x <- rmvt(100, sigma = diag(2), df = 3) # t_3(0, diag(2)) sample
plot(x)
## X ~ t_3(mu, Sigma)
n <- 1000
mu <- 1:2
Sigma <- matrix(c(4, 2, 2, 3), ncol=2)
set.seed(271)
x <- rep(mu, each=n) + rmvt(n, sigma=Sigma, df=3)
plot(x)
## Note that the call rmvt(n, mean=mu, sigma=Sigma, df=3) does *not*
## give a valid sample from t_3(mu, Sigma)! [and thus throws an error]
try(rmvt(n, mean=mu, sigma=Sigma, df=3))
## df=Inf correctly samples from a multivariate normal distribution
set.seed(271)
x <- rep(mu, each=n) + rmvt(n, sigma=Sigma, df=Inf)
set.seed(271)
x. <- rmvnorm(n, mean=mu, sigma=Sigma)
stopifnot(identical(x, x.))