draw_U {SimSurvNMarker} | R Documentation |
Samples from a Multivariate Normal Distribution
Description
Simulates from a multivariate normal distribution and returns a matrix with appropriate dimensions.
Usage
draw_U(Psi_chol, n_y)
Arguments
Psi_chol |
Cholesky decomposition of the covariance matrix. |
n_y |
number of markers. |
Examples
library(SimSurvNMarker)
set.seed(1)
n_y <- 2L
K <- 3L * n_y
Psi <- drop(rWishart(1, K, diag(K)))
Psi_chol <- chol(Psi)
# example
dim(draw_U(Psi_chol, n_y))
samples <- replicate(100, draw_U(Psi_chol, n_y))
samples <- t(apply(samples, 3, c))
colMeans(samples) # ~ zeroes
cov(samples) # ~ Psi
[Package SimSurvNMarker version 0.1.3 Index]