rmatrixnorm | R Documentation |
Density and random generation for the matrix variate normal distribution
rmatrixnorm(
n,
mean,
L = diag(dim(as.matrix(mean))[1]),
R = diag(dim(as.matrix(mean))[2]),
U = L %*% t(L),
V = t(R) %*% R,
list = FALSE,
array = NULL,
force = FALSE
)
dmatrixnorm(
x,
mean = matrix(0, p, n),
L = diag(p),
R = diag(n),
U = L %*% t(L),
V = t(R) %*% R,
log = FALSE
)
n |
number of observations to generate - must be a positive integer. |
mean |
|
L |
|
R |
|
U |
|
V |
|
list |
Defaults to |
array |
If |
force |
If TRUE, will take the input of |
x |
quantile for density |
log |
logical; if TRUE, probabilities p are given as log(p). |
rmatrixnorm
returns either a list of
n
p \times q
matrices or
a p \times q \times n
array.
dmatrixnorm
returns the density at x
.
Gupta, Arjun K, and Daya K Nagar. 1999. Matrix Variate Distributions. Vol. 104. CRC Press. ISBN:978-1584880462
rmatrixt()
, rmatrixinvt()
,
rnorm()
and stats::Distributions()
set.seed(20180202)
# a draw from a matrix variate normal with a certain mean
# and row-wise covariance
rmatrixnorm(
n = 1, mean = matrix(c(100, 0, -100, 0, 25, -1000), nrow = 2),
L = matrix(c(2, 1, 0, .1), nrow = 2), list = FALSE
)
set.seed(20180202)
# another way of specifying this - note the output is equivalent
A <- rmatrixnorm(
n = 10, mean = matrix(c(100, 0, -100, 0, 25, -1000), nrow = 2),
L = matrix(c(2, 1, 0, .1), nrow = 2), list = TRUE
)
A[[1]]
# demonstrating the dmatrixnorm function
dmatrixnorm(A[[1]],
mean = matrix(c(100, 0, -100, 0, 25, -1000), nrow = 2),
L = matrix(c(2, 1, 0, .1), nrow = 2), log = TRUE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.