Exercise

# Simulate data

Let us continue by simulating observations from the bivariate normally distributed random variables \(X\) and \(Y\).

Notice that the second line in the R script on the right loads the `mvtnorm`

R package.
`mvtnorm`

is an R library, containing extra functionality (see mvtnorm documentation), which
makes it easy to simulate data from a bivariate (or more generally, a multivariate) normal
distribution. We will be using the `rmvnorm()`

function from the package.
If you would like to use the `mvtnorm`

package at home, use the `install.packages`

function to first install the package on your own computer.

You can supply the mean vector and the covariance matrix via the arguments
`mean`

and `sigma`

, of the `rmvnorm()`

function respectively. For instance, you can draw 10 observations
from a bivariate standard normal distribution with
`rmvnorm(10, mean = c(0, 0), sigma = diag(2))`

.

When you simulate data, it is often useful to have *reproducible* results. This
can be achieved by setting the seed of the random number generator beforehand
with the `set.seed()`

function. For more information, see the documentation on
random number generation.

Instructions

**100 XP**

- Simulate 100 observations from the bivariate normal distributed random variables \(X\) and \(Y\). Use the covariance matrix
`Sigma_xy`

from the previous exercise and suppose that the means are \(\mu_{X} = 0.05\) and \(\mu_{Y} = 0.025\). Assign the result to`xy_vals`

. - Have a look at the first few observations with the
`head()`

function.