Description Usage Arguments Details Value Author(s) References See Also Examples
Evaluate the density of a multivariate Student t distribution.
1 2 3 |
x |
(n, d)- |
df |
degrees of freedom (positive real number or |
loc |
location vector of dimension d (the number of columns
of |
scale |
covariance matrix of dimension (d, d). |
factor |
factorization matrix of the covariance matrix
|
log |
|
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.
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
McNeil, A. J., Frey, R., and Embrechts, P. (2015). Quantitative Risk Management: Concepts, Techniques, Tools. Princeton University Press.
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.))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.