CopulaCramerVonMises

CopulaCramerVonMises(*args)

Perform a Cramer-von Mises goodness-of-fit test for a copula.

Parameters:
sample2-d sequence of float

Tested sample of dimension strictly greater than 1. The test is rank-based, so the sample can either be a sample from the copula (values in [0, 1]^\inputDim) or a raw observations sample: pseudo-observations are computed internally from the ranks.

modelDistribution or DistributionFactory

Tested copula (isCopula() must be true, the factory must build a copula).

levelfloat, 0 < \alpha < 1, optional (default level = 0.05).

Risk of committing a Type I error, that is an incorrect rejection of a true null hypothesis.

Returns:
fitted_distDistribution

Estimated copula (if model is of type DistributionFactory).

test_resultTestResult

Test result.

Notes

Refer to Goodness-of-fit tests for copulas for notations.

Given a copula C_{\vect{\theta}_n} (fully specified, or estimated with the given factory), the Cramer-von Mises statistic is

S_n = \sum_{i=1}^n \left[C_n(\hat{\vect{U}}_i)
    - C_{\vect{\theta}_n}(\hat{\vect{U}}_i)\right]^2.

Large values of S_n lead to rejection of the null hypothesis. The p-value is estimated with a parametric bootstrap, see Goodness-of-fit tests for copulas.

The following ResourceMap keys are used:

  • FittingTest-CopulaMinimumSamplingSize (UnsignedInteger, default: 10): minimum number of bootstrap replications

  • FittingTest-CopulaMaximumSamplingSize (UnsignedInteger, default: 1000): maximum number of bootstrap replications

  • FittingTest-CopulaPrecision (Scalar, default: 0.01): target standard deviation of the estimated p-value

Examples

>>> import openturns as ot
>>> ot.RandomGenerator.SetSeed(0)
>>> copula = ot.GumbelCopula(3.0)
>>> sample = copula.getSample(100)
>>> ot.ResourceMap.SetAsUnsignedInteger('FittingTest-CopulaMaximumSamplingSize', 100)
>>> test_result = ot.FittingTest.CopulaCramerVonMises(sample, copula)
>>> test_result.getBinaryQualityMeasure()
True
>>> ot.ResourceMap.Reset()

Examples using the function

Select fitted copulas

Select fitted copulas