{ "cells": [ { "cell_type": "markdown", "id": "9c79834c", "metadata": {}, "source": [ "# Bivariate Copulas \n", "\n", "## General Introduction to Copulas\n", "\n", "A copula is a method used to describe the dependence structure between several random variables, which have been widely used in research fields, such as finance and hydrology. While some other multivariate distributions, for instance a multivariate normal, allows only for a symmetric dependence structure with univariate and multivariate marginal distributions also being normal, copulas can model the joint distribution of multiple random variables separately from their marginal distributions.\n", "\n", "The Copula is a multivariate distribution with all univariate margins being uniform on $[0,1]$ (Joe, 2014). Sklar's Theorem states that any multivariate joint distribution function can be decomposed into marginal distributions and a copula function that describes the dependence structure between the variables (Sklar, 1959).\n", "\n", "**Sklar's Theorem:** Let $F$ be the joint distribution function of a multivariate random vector $(X_1, X_2, \\ldots, X_n)$, with marginal distribution functions $F_1, F_2, \\ldots, F_n$ for each variable. Then, there exists a copula function $C: [0,1]^n \\rightarrow [0,1]$ such that for all $(x_1, x_2, \\ldots, x_n)$ in the support of $F$, we have:\n", "\n", "$$\n", "F(x_1, x_2, \\ldots, x_n) = C(F_1(x_1), F_2(x_2), \\ldots, F_n(x_n)), \\quad \\mathbf{x}\\in R^n\n", "\\tag{1}\n", "$$\n", "\n", "In this tutorial we will further explain bivariate copulas with the use of an example dataset \n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "29080d38", "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "from vinecopulas.marginals import *\n", "from vinecopulas.bivariate import *\n", "from matplotlib import cm" ] }, { "cell_type": "markdown", "id": "842a5eb2", "metadata": {}, "source": [ "## Data\n", "\n", "The data used as an example is the Abalone dataset from the [UCI database](http://archive.ics.uci.edu/ml/datasets/Abalone) and has also been showcased in a chapter on vine copula based modelling by Czado and Nagler (2021). The data set contains measurements on diameter, length, and several types of weight (whole, shucked, viscera and shell) of abalones, a type of marine snail. For this example, only data on the female snails are included and are loaded in below." ] }, { "cell_type": "code", "execution_count": 2, "id": "82151e8d", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
| \n", " | whole | \n", "shuck | \n", "vis | \n", "shell | \n", "diameter | \n", "length | \n", "rings | \n", "
|---|---|---|---|---|---|---|---|
| 0 | \n", "0.6770 | \n", "0.2565 | \n", "0.1415 | \n", "0.21 | \n", "0.420 | \n", "0.530 | \n", "9 | \n", "
| 1 | \n", "0.7775 | \n", "0.2370 | \n", "0.1415 | \n", "0.33 | \n", "0.415 | \n", "0.530 | \n", "20 | \n", "
| 2 | \n", "0.7680 | \n", "0.2940 | \n", "0.1495 | \n", "0.26 | \n", "0.425 | \n", "0.545 | \n", "16 | \n", "
| 3 | \n", "0.8945 | \n", "0.3145 | \n", "0.1510 | \n", "0.32 | \n", "0.440 | \n", "0.550 | \n", "19 | \n", "
| 4 | \n", "0.6065 | \n", "0.1940 | \n", "0.1475 | \n", "0.21 | \n", "0.380 | \n", "0.525 | \n", "14 | \n", "