Learn R Programming

CreditMetrics (version 0.0-2)

cm.rnorm.cor: Computation of correlated standard normal distributed random numbers

Description

cm.rnorm.cor computes correlated standard normal distributed random numbers. This function uses a correlation matrix rho and later the cholesky decompositon in order to get correlated random numbers.

Usage

cm.rnorm.cor(N, n, rho)

Arguments

N
number of simulations
n
number of simulated random numbers
rho
correlation matrix

Value

The function returns N simulations with n simulated random numbers each, which include the correlation matrix rho.

Details

This function computes standard normal distributed random numbers, which include the correlation matrix rho. One has a random matrix $Y$ which is $N(0,1)$ distributed. With the linear transformation $X = \mu + A Y$ one gets $X$, which is $N(\mu, A A^T)$ distributed. If $X$ should have the correlation matrix $\Sigma$. By using the cholesky decomposition the matrix $A$ can be computed from $\Sigma$.

References

Glasserman, Paul, Monte Carlo Methods in Financial Engineering, Springer 2004

See Also

eigen, chol, cm.rnorm

Examples

Run this code
  N <- 3
  n <- 50000
  firmnames <- c("firm 1", "firm 2", "firm 3")
  
  # correlation matrix
  rho <- matrix(c(  1, 0.4, 0.6,
                  0.4,   1, 0.5,
                  0.6, 0.5,   1), 3, 3, dimnames = list(firmnames, firmnames),
                  byrow = TRUE)
  
  cm.rnorm.cor(N, n, rho)

Run the code above in your browser using DataLab