Goodness-of-fit tests for copulasΒΆ

The Cramer-von Mises and Kolmogorov-Smirnov tests below check whether a multivariate sample is drawn from a given copula. They compare the empirical copula built from the sample with the candidate copula, following the approach of [genest2009].

Let \vect{X}_1, \dots, \vect{X}_{\sampleSize} be a sample of dimension \inputDim \geq 2 with continuous margins and copula C. Since copulas are invariant under strictly increasing transformations of the margins, the tests work on the pseudo-observations

\hat{\vect{U}}_i = \left( \frac{R_{i,1} + 1}{\sampleSize + 1}, \dots,
    \frac{R_{i,\inputDim} + 1}{\sampleSize + 1} \right), \quad i = 1, \dots, \sampleSize,

where R_{i,j} is the rank of X_{i,j} among X_{1,j}, \dots, X_{\sampleSize,j}. The sample under test can therefore be either a sample from the copula itself (values in [0, 1]^\inputDim) or a raw observations sample: the pseudo-observations are computed internally from the ranks. Let C_{\sampleSize} be the empirical cumulative distribution function of the unknown copula C, defined by:

C_{\sampleSize}(\vect{u}) = \frac{1}{\sampleSize} \sum_{i=1}^{\sampleSize}
    \prod_{j=1}^\inputDim 1_{\hat{U}_{i,j} \leq u_j}, \quad \vect{u} \in [0, 1]^\inputDim.

Let C_{\vect{\theta}_{\sampleSize}} be the candidate copula: either a fully specified copula, or a copula whose parameters \vect{\theta}_{\sampleSize} have been estimated from the sample with a DistributionFactory (the estimated distribution must be a copula). Two statistics measure the distance between C_{\sampleSize} and C_{\vect{\theta}_{\sampleSize}}:

  • the Cramer-von Mises statistic

    S_{\sampleSize} = \sum_{i=1}^{\sampleSize} \left[
    C_{\sampleSize}(\hat{\vect{U}}_i) -
    C_{\vect{\theta}_{\sampleSize}}(\hat{\vect{U}}_i) \right]^2,

  • the Kolmogorov-Smirnov statistic

    T_{\sampleSize} = \max_{i=1, \dots, \sampleSize} \left|
    C_{\sampleSize}(\hat{\vect{U}}_i) -
    C_{\vect{\theta}_{\sampleSize}}(\hat{\vect{U}}_i) \right|.

Large values of these statistics lead to rejection of the null hypothesis \mathcal{H}_0 = \{ C \in \mathcal{C}_0 \} that the underlying copula belongs to the candidate family. Under \mathcal{H}_0, the asymptotic distributions of S_{\sampleSize} and T_{\sampleSize} depend on the unknown copula parameter, so they cannot be tabulated: the p-value is estimated with a parametric bootstrap. Bootstrap samples are drawn from the tested (or estimated) copula and the statistic is recomputed on each of them, re-estimating the parameters in the factory case, until the requested precision is reached. This follows the same adaptive Monte Carlo scheme as the The Kolmogorov-Smirnov goodness of fit test for continuous data with estimated parameters (Lilliefors test).

We fix a risk \alpha (type I error) and reject the candidate copula if the estimated p-value is lower than or equal to \alpha.