Exercise

Covariance matrix

In this lab you will learn to draw observations from bivariate normal distributions, and explore the resulting data to familiarize yourself with relationships between two random variables.

Let us assume that \(X\) and \(Y\) are bivariate normally distributed. Get started by defining a covariance matrix. Suppose that the standard deviations are \(\sigma_{X} = 0.10\) and \(\sigma_{Y} = 0.05\), and that the correlation is \(\rho_{XY} = 0.9\).

Matrices can be created with the matrix() function. You should supply the values as the first argument and specify the dimensions with the nrow and ncol arguments. For example, matrix(c(-0.5, 0.5), nrow = 1, ncol = 2) creates a matrix with one row and two columns. By default, the matrix is filled column by column, but you can fill the matrix row by row by setting byrow = TRUE.

Instructions

100 XP
  • Compute the covariance between \(X\) and \(Y\) and assign it to sig_xy.
  • Construct the covariance matrix and assign it to Sigma_xy.