TABLE OF CONTENTS


simSurvival/MYmvrnorm [ Functions ]

NAME

    MYmvrnorm  --- multivariate normal random variates

FUNCTION

Generate multivariate normal variables. This is a plug-in replacement for mvrnorm from MASS, but it uses the Cholesky factorization method, so that the numbers from the equivalent C routine are identical.

SYNOPSIS

488 MYmvrnorm <- function (n = 1, mu, Sigma) 

INPUTS

    n      number of variables to generate
    mu     mean vector
    Signma covariance matrix

OUTPUTS

    A matrix (or vector) of multivariate normal numbers.

SOURCE

491 {
492     l <- length(mu)
493     candnorm <- matrix(rnorm(n * l), nrow = n)
494     out <- candnorm%*%chol(Sigma, pivot = TRUE)
495     out <- out + rep(mu, rep(n, l)) 
496     if(n == 1) out <- as.numeric(out)
497     out
498 }