By Mic
Here I am again with part 2. If you would like to read part 1 of this short tutorial on copulas, please click here.
In this second post I am going to select a copula model, fit it to a test dataset, evaluate the fitting and generate random observations from the fitted multivariate distribution. Furthermore I am going to show how to measure correlation using Spearman’s Rho and Kendall’s Tau. In order to run the code in this post you need the following packages: copula and VineCopula.
The dataset
For this example I am going to use a test dataset. You can download it from this link. This test dataset contains two variables, x and y, characterized by a strong left tail correlation.
By visually inspecting the plot of x versus y you can easily notice that low values of x tends to be highly correlated with low values of y.
The x and y distributions
First of all, let’s study the marginals separately. Coming up with an estimate of the marginal distributions for both x and y should not be that hard. In order to do this, a quick check to the histogram of both variables could provide some insights.
A good glimpse at the chart of each variable is important in order to get a grasp of what distribution could be a better fit. It looks like a Gamma distribution could do both for x and y. This is just a quick guess, obviously it would be necessary to dig deeper and inspect the data further before making such a claim, however this is not the focus of this post. Moving on pretty fast and assuming the distribution assumption is correct, the only thing left is to estimate the parameters. Let’s …read more
Source:: r-bloggers.com