25  Workshop Activities

In this lab, you will learn how to:

Exercise 1: Correlated Normal Variable via Cholesky

  1. Use the Cholesky decomposition to simulate 5000 bivariate normal random vector with the following information: \[ \Sigma = \begin{pmatrix} 1 & 0.8 \\ 0.8 & 1 \end{pmatrix}, \quad \mu = \begin{pmatrix}0 \\ 0\end{pmatrix}, \quad \rho = 0.8. \]
  2. What is the approximate sample correlation between \(X_1\) and \(X_2\)?
  3. Plot \(X_1\) against \(X_2\). Why is the cloud elliptical rather than circular?
  4. What role does the Cholesky factor play in the simulation?

Exercise 2: Linear Transformations of Random Vectors

Suppose \(\mathbf{X} \sim N(\mu, \Sigma)\), and define

\[ \mathbf{Y} = A\mathbf{X} + \mathbf{b}, \]

where

\[ A = \begin{pmatrix} 1 & 0 \\ -1 & 2 \end{pmatrix}, \qquad \mathbf{b} = \begin{pmatrix} 0 \\ 1 \end{pmatrix}. \]

  1. Generate \(\mathbf{X}\) from Exercise 1, then apply the transformation above.
  2. Plot the transformed \(Y_1\) against \(Y_2\). Compare it with the plot of original \(X_1\) against \(X_2\). How has the location and the shape of the cloud changed?
  3. Compute the sample mean of \(\mathbf{Y}\). Is it close to \(A\mu + b\)?

Exercise 3: Simulating from a Multivariate Normal Distribution

Tip

You may also simulate multivariate normal data directly using mvrnorm() from the MASS package.

  1. Generate 5000 observations from \[ \mu = \begin{pmatrix} 1 \\ 2 \end{pmatrix}, \qquad \Sigma = \begin{pmatrix} 4 & 1 \\ 1 & 1 \end{pmatrix}. \]

  2. Compare the sample mean with \(\mu\).

  3. Compare the sample covariance matrix with \(\Sigma\).

  4. Why do the sample quantities differ slightly from the theoretical values?

Exercise 4: From Correlated Normals to Uniform Variables

A key step in copula simulation is transforming normal variables into uniforms using the normal CDF.

If \(Z \sim N(0,1)\), then

\[ U = \Phi(Z) \sim \text{Uniform}(0,1). \]

  1. Transform the correlated normals from Exercise 1 into uniforms.
  2. Plot the histogram for \(U_1\) and \(U_2\). Briefly explain the shape.
  3. Plot \(U_1\) against \(U_2\). Are \(U_1\) and \(U_2\) independent?
  4. What feature of the original variables is preserved after applying pnorm()?

Exercise 5: Gaussian Copula (Normal-Exponential)

  1. simulate:

    • \(X \sim N(0,1)\)
    • \(Y \sim \text{Exp}(1)\)

    using a Gaussian copula with dependence parameter \(\rho = 0.7\). To do this, first generate a latent bivariate normal vector \[ (Z_1, Z_2)^\top \sim N(\mathbf 0, \Sigma), \] where \[ \mathbf 0 = \begin{pmatrix} 0\\ 0 \end{pmatrix}, \qquad \Sigma = \begin{pmatrix} 1 & 0.7\\ 0.7 & 1 \end{pmatrix}. \] Then transform \[ U_1 = \Phi(Z_1), \qquad U_2 = \Phi(Z_2), \] and finally set \[ X = \Phi^{-1}(U_1), \qquad Y = F^{-1}_{\text{Exp}(1)}(U_2). \]

  2. Plot histogram for \(X\) and \(Y\). Briefly explain the shape.

  3. Plot \(X\) against \(Y\). Briefly explain the dependence structure.

  4. How is copula-based model different from a multivariate normal model?

Exercise 6: Gaussian Copula (Gamma-Beta)

  1. Simulate dependent variables with:
    • \(X \sim \text{Gamma}(2,1)\)
    • \(Y \sim \text{Beta}(2,5)\) using Gaussian copula with dependence parameter \(\rho = 0.6\).
  2. Plot histogram for \(X\) and \(Y\). Briefly explain the shape.
  3. Plot \(X\) against \(Y\). Briefly explain the dependence structure.

Exercise 7: Gaussian Copula (Normal-Exponential-Gamma)

  1. Simulate three dependent variables:
    • \(X_1 \sim N(0,1)\)
    • \(X_2 \sim \text{Exp}(1)\)
    • \(X_3 \sim \text{Gamma}(3,2)\)
    • using a Gaussian copula with correlation matrix \[ \Sigma = \begin{pmatrix} 1 & 0.6 & 0.3 \\ 0.6 & 1 & 0.5 \\ 0.3 & 0.5 & 1 \end{pmatrix}. \]
  2. Plot marginal histograms and pairwise scatterplots.
  3. Check the sample correlation matrix.