rmatnorm | R Documentation |
Random generation for the matrix-variate Normal distribution. See https://en.wikipedia.org/wiki/Matrix_normal_distribution.
rmatnorm(n = 1, M, U, V, pivot = c(U = "auto", V = "auto"))
n |
number of observations |
M |
mean matrix; if |
U |
between-row covariance matrix |
V |
between-column covariance matrix |
pivot |
2-element vector with values TRUE/FALSE/"auto", where TRUE (FALSE) means using pivoting (or not) for Choleski decomposition of U and/or V (see |
array
Timothee Flutre
## Not run: set.seed(1859)
Sigma <- matrix(c(3,2,2,4), nrow=2, ncol=2)
rho <- Sigma[2,1] / prod(sqrt(diag(Sigma)))
samples <- rmatnorm(n=100, M=matrix(0, nrow=10^3, ncol=2),
U=diag(10^3), V=Sigma)
tmp <- t(apply(samples, 3, function(mat){
c(var(mat[,1]), var(mat[,2]), cor(mat[,1], mat[,2]))
}))
summary(tmp) # corresponds well to Sigma
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.