Description Usage Arguments Details Value Author(s) References See Also Examples
Generate vectors of random variates from the multivariate Student t distribution.
1 |
n |
sample size n (positive integer). |
loc |
location vector of dimension d. |
scale |
covariance matrix of dimension (d, d). |
df |
degrees of freedom (positive real number or |
factor |
factorization matrix of the covariance matrix
|
Internally used is factor
, so scale
is not required
to be provided if factor
is given.
The default factorization used to obtain factor
is the Cholesky
decomposition. To this end, scale
needs to have full rank.
See factorize()
for other options.
The number of rows of factor
are the dimension d of
the sample. Typically (but not necessarily), factor
is square.
rStudent()
returns an (n, d)-matrix
containing n samples of the d-dimensional 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.
dStudent()
, pStudent()
, factorize()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## 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))
## Draw random variates and compare
df <- 3.5
n <- 1000
set.seed(157)
X <- rStudent(n, df = df, scale = P) # providing scale
set.seed(157)
X. <- rStudent(n, df = df, factor = chol(P)) # providing directly the factor
stopifnot(all.equal(X, X.))
## Univariate case
set.seed(157)
X.1d <- rStudent(n, df = df, factor = 1/2)
set.seed(157)
X.1d. <- rStudent(n, df = df, factor = 1)/2 # manual scaling
stopifnot(all.equal(X.1d, X.1d.))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.