Copulas are a powerful statistical tool commonly used in the finance sector to generate samples from a given multivariate joint distribution.
The principal advantage of using those types of function over other methods is that copulas describe the multivariate joint distribution as his margin and the dependence structure between them,
which give the user the power to fine tune his model component by component.
For example, if you have two independent variables of known distribution
X_2 which interact to create a dependant
Y you can set
X_2 as the margin of the distribution of
Y and find the appropriate copula to simulate the interaction between the margins and fit the data.
In this post we’ll assume you never used copulas and are new to the subject, so we’ll see how to create a copula object and how to generate sample with the most commonly used copula.
In part 2 we’ll learn how to use a copula to estimate probability of a given event.
To be able to do those exercises, you must have installed the packages
copula. Also, if you never used the copula package before, you can find the
official documentation here.
Answers to the exercises are available here.
normalCopula() function from the
copula package to create a two dimensional Gaussian copula with a parameter of 0.9. Then create another Gaussian copula of parameter 0.2 and
look at the structure of both copulas.
rCopula() function to generate two samples of 500 points which distribution is the copulas from exercise 1.
Make a plot of the two samples from exercise 2. Having in mind that copula determine the dependence structure of a multivariate joint distribution, by looking at those plots,
can you tell which of those two copulas you should use to simulate a distribution with a strong dependence between the margins?
copula package offer two other ways to visualise a copula: the function
persp() give you the ability of doing a 3d plot of the copula and
contour() generate a
contour plot of a copula. Use those two functions to visualise the copula from exercise 1.
mvdc() function to create two multivariate joint distributions from the copula from exercise 1 with normal margins. Those margins should have a mean of 2 and 5 and a standard deviation of 3 and 1 respectively.
Then apply the
contour() to visualise the two distributions. Do the margins of the two distribution change in the two plots?
Repeat the steps of exercise 5, but this time creates two multivariate joint distributions with different margins. The first one must be a student distribution with 9 degrees of freedom and the second one should be an exponential distribution with a rate of 0.3.
How those plots different from those of exercise 5?
Sample 500 points from the multivariate joint distribution made with a Gaussian copula of parameter 0.9 you did in the exercise 5. Then use the
image2D() function from the
plot3d package to
plot the distribution of those points.
Create a two dimensional Clayton copula with a parameter of 15, then plot it using
contour(). Sample 500 points from this copula and plot them using
qplot(). Then follow the step of the exercise 5, but
this time use the Clayton copula you just created. Repeat this process, this time with a two dimensional Clayton copula with parameter of 1.
Repeat the exercise 8, but use a two dimensional Frank copula of parameter 19 and another of parameter 1. Take time to notice how the parameter affect the shape of the multivariate joint distribution.
Repeat the exercise 8, but use a two dimensional Gumbel copula of parameter 7 and another of parameter 1.1.