Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MATH377: Financial and Actuarial Modelling in R

Tutorial 5

Exercise  1.  Let X = (X1, X2) be a bivariate normal distributed random vector with mean vector µ = (1.5, 1) and covariance matrix

Σ =  

a) Evaluate the density function of X at x = (1, 1) and x = (0, 2).

b) Compute P( −2 ≤ X1  ≤ 4, X2  > 1).

c) Plot the 3D surface of this bivariate normal density and its contours. Hint: You can modify the code in the lecture notes to plot the log-likelihood of a normal distribution. However, to use outer() you may need to pass a function similar to this one:  f  <-  function(x, y)  dmvnorm(cbind(x, y), mu  ,  sigma). Finally, use the functions contour() and persp() to create the plots.

d) Generate 5000 observation from X and create a scatter plot for the generated sample.

e)  Compute the empirical mean vector, covariance matrix, correlation matrix, Kendall’s tau, and Spearman’s rho for the generated sample in d).

f) Compute the correlation matrix P of X.

g) Construct a Gaussian copula object with correlation matrix in f).

h) Compute Kendall’s tau for the copula in g). How does it compare with the empirical Kendall’s tau in e)?

i)  Construct a multivariate distribution with the copula in h) and marginals X1  ∼ N(1.5, 2) and X2 ∼ N(1, 4). Note that you have constructed exactly your original distribution.

j) Verify that your multivariate distribution in i) is correct by evaluating the joint density at x = (1, 1) (it should be the same value as in a)).

k) Use contour() and persp() to visualize your distribution in j).

X1  ∼ Gamma(3, 2) and X2  ∼ Gamma(5, 1.5).  We will use three different copulas to do so:  Gumbel, Clayton, and Gaussian.

a) Find parameters values for the Gumbel, Clayton, and Gaussian copulas such that ρτ  = 0.6.

b) Construct three copula objects corresponding to the models in a).

c) Verify that your parameters in a) are correct by computing Kendall’s tau for the objects in b).

d) Compute the coefficients of upper tail dependence for the three copula models in b).

e) Using   your   copulas   in   b),   construct   three   multivariate   distributions   with   marginals X1 ∼ Gamma(3, 2) and X2 ∼ Gamma(5, 1.5).

f) Simulate 10000 observations from each one of the three models in e) and create scatter plots with the simulated samples.

g)  Compute the sum of rows for each one of the simulated data sets.  Note that, in fact, we are generating three different samples from X1 + X2 .

h) Compute the 95% empirical quantile for the three generated data sets in g). Compare and conclude.