Exercise - Simulating the Bivariate Normal Distribution

Write an R function called rbinorm() that uses rnorm() to generate draws from a bivariate, i.e. two-dimensional, normal distribution. Your function should take three arguments: n_draws is the number of simulation draws, mean_vec is a vector of length two specifying the mean of each component, and var_mat is a \((2\times 2)\) variance-covariance matrix. Read the documentation for the R function stopifnot() and use it to throw an error if var is not positive definite. Your function should return an nreps by 2 matrix containing the desired draws. You may not use function chol(): I want you to do everything “by hand.” Check your work by drawing a large number of simulations, calculating the sample means and variance-covariance matrices, and plotting the marginal and joint distribution.