dStudent: Density of a Multivariate Student t Distribution In student: Multivariate Student t Distribution

Description

Evaluate the density of a multivariate Student t distribution.

Usage

 ```1 2 3``` ```dStudent(x, df, loc = rep(0, d), scale, factor = tryCatch(factorize(scale), error = function(e) e), log = FALSE) ```

Arguments

 `x` (n, d)-`matrix` of evaluation points. `df` degrees of freedom (positive real number or `Inf` in which case the density of a multivariate normal distribution with mean vector `loc` and covariance matrix `scale` is evaluated). `loc` location vector of dimension d (the number of columns of `x`). `scale` covariance matrix of dimension (d, d). `factor` factorization matrix of the covariance matrix `scale`. A `matrix` R with d rows such that R^T R equals `scale`. Although not tested (for efficiency reasons), R (thus `factor`) has to be upper triangular (otherwise the determinant of `scale` involved in the density is not computed correctly). Also note that `factor` can be `NULL` or inherit from `"error"` in which case the degenerate density is computed as `Inf` at `loc` and 0 everywhere else. `log` `logical` indicating whether the logarithm of the density is to be computed.

Details

Internally used is `factor`, so `scale` is not required to be provided if `factor` is given.

The default factorization used is the Cholesky decomposition. To this end, `scale` needs to have full rank.

Value

`dStudent()` returns an n-`vector` with the density values (default) or log-density values (if `log`) of the multivariate Student t distribution with `df` degrees of freedom, location vector `loc` and scale matrix `scale` (a covariance matrix).

Marius Hofert

References

McNeil, A. J., Frey, R., and Embrechts, P. (2015). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.

`pStudent()`, `rStudent()`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27``` ```## Generate a random correlation matrix in three dimensions d <- 3 set.seed(271) A <- matrix(runif(d * d), ncol = d) P <- cov2cor(A %*% t(A)) ## Evaluate t_{3.5} density df <- 3.5 x <- matrix(1:12/12, ncol = d) # evaluation points dt <- dStudent(x, df = df, scale = P) stopifnot(all.equal(dt, c(0.013266542, 0.011967156, 0.010760575, 0.009648682), tol = 1e-7)) ## Evaluate normal density dn <- dStudent(x, df = Inf, scale = P) stopifnot(all.equal(dn, c(0.013083858, 0.011141923, 0.009389987, 0.007831596), tol = 1e-7)) ## Missing data x[3,2] <- NA x[4,3] <- NA dt <- dStudent(x, df = df, scale = P) stopifnot(is.na(dt) == rep(c(FALSE, TRUE), each = 2)) ## Univariate case x <- matrix(1:10/10, ncol = 1) dt <- dStudent(x, df = df, factor = 1) dt. <- dt(as.vector(x), df = df) stopifnot(all.equal(dt, dt.)) ```