rcopula 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rcopula-0.1.0/.gitignore +219 -0
- rcopula-0.1.0/LICENSE +21 -0
- rcopula-0.1.0/NOTICE +85 -0
- rcopula-0.1.0/PKG-INFO +289 -0
- rcopula-0.1.0/README.md +227 -0
- rcopula-0.1.0/examples/01_construction_and_sampling.py +68 -0
- rcopula-0.1.0/examples/02_sklar_and_frechet_bounds.py +93 -0
- rcopula-0.1.0/examples/03_dependence_measures.py +89 -0
- rcopula-0.1.0/examples/04_tail_dependence.py +80 -0
- rcopula-0.1.0/examples/05_fitting.py +71 -0
- rcopula-0.1.0/examples/06_goodness_of_fit.py +110 -0
- rcopula-0.1.0/examples/07_risk_aggregation.py +103 -0
- rcopula-0.1.0/examples/08_cdo_tranches.py +145 -0
- rcopula-0.1.0/examples/09_basket_options.py +139 -0
- rcopula-0.1.0/examples/10_pairs_trading.py +99 -0
- rcopula-0.1.0/examples/11_copula_garch.py +116 -0
- rcopula-0.1.0/examples/12_operational_risk.py +143 -0
- rcopula-0.1.0/examples/13_hydrology_return_periods.py +163 -0
- rcopula-0.1.0/examples/14_asymmetric_dependence.py +156 -0
- rcopula-0.1.0/examples/15_vine_copulas.py +149 -0
- rcopula-0.1.0/examples/16_diagnostic_plots.py +188 -0
- rcopula-0.1.0/examples/17_science_and_engineering.py +157 -0
- rcopula-0.1.0/examples/18_machine_learning.py +213 -0
- rcopula-0.1.0/examples/19_time_varying_dependence.py +213 -0
- rcopula-0.1.0/examples/20_discrete_margins.py +220 -0
- rcopula-0.1.0/examples/21_quasi_random_sampling.py +179 -0
- rcopula-0.1.0/examples/22_archimedean_internals.py +184 -0
- rcopula-0.1.0/examples/23_nested_archimedean.py +218 -0
- rcopula-0.1.0/examples/24_ties_and_rounding.py +224 -0
- rcopula-0.1.0/examples/25_pairs_selection.py +229 -0
- rcopula-0.1.0/examples/26_vine_tutorial.py +271 -0
- rcopula-0.1.0/examples/27_model_criticism.py +278 -0
- rcopula-0.1.0/examples/README.md +61 -0
- rcopula-0.1.0/examples/_common.py +28 -0
- rcopula-0.1.0/examples/figures/01_contour_clayton.png +0 -0
- rcopula-0.1.0/examples/figures/02_surface_frank.png +0 -0
- rcopula-0.1.0/examples/figures/03_tail_concentration.png +0 -0
- rcopula-0.1.0/examples/figures/04_kendall_plots.png +0 -0
- rcopula-0.1.0/examples/figures/05_pickands.png +0 -0
- rcopula-0.1.0/examples/figures/06_vine_trees.png +0 -0
- rcopula-0.1.0/examples/figures/07_nested_tree.png +0 -0
- rcopula-0.1.0/examples/figures/08_tau_heatmap.png +0 -0
- rcopula-0.1.0/examples/figures/09_scatter_matrix.png +0 -0
- rcopula-0.1.0/pyproject.toml +104 -0
- rcopula-0.1.0/rcopula/__init__.py +214 -0
- rcopula-0.1.0/rcopula/bootstrap.py +566 -0
- rcopula-0.1.0/rcopula/core/__init__.py +7 -0
- rcopula-0.1.0/rcopula/core/archimedean.py +1246 -0
- rcopula-0.1.0/rcopula/core/base.py +423 -0
- rcopula-0.1.0/rcopula/core/elliptical.py +547 -0
- rcopula-0.1.0/rcopula/core/empirical.py +269 -0
- rcopula-0.1.0/rcopula/core/extreme_value.py +623 -0
- rcopula-0.1.0/rcopula/core/measures.py +197 -0
- rcopula-0.1.0/rcopula/core/other.py +600 -0
- rcopula-0.1.0/rcopula/credit.py +414 -0
- rcopula-0.1.0/rcopula/datasets.py +446 -0
- rcopula-0.1.0/rcopula/dependence.py +502 -0
- rcopula-0.1.0/rcopula/derivatives.py +873 -0
- rcopula-0.1.0/rcopula/discrete.py +731 -0
- rcopula-0.1.0/rcopula/distribution.py +246 -0
- rcopula-0.1.0/rcopula/dynamic.py +1283 -0
- rcopula-0.1.0/rcopula/fit/__init__.py +21 -0
- rcopula-0.1.0/rcopula/fit/api.py +578 -0
- rcopula-0.1.0/rcopula/fit/mvdc.py +393 -0
- rcopula-0.1.0/rcopula/fit/results.py +169 -0
- rcopula-0.1.0/rcopula/fit/variance.py +492 -0
- rcopula-0.1.0/rcopula/garch.py +685 -0
- rcopula-0.1.0/rcopula/gof/__init__.py +15 -0
- rcopula-0.1.0/rcopula/gof/api.py +421 -0
- rcopula-0.1.0/rcopula/gof/statistics.py +134 -0
- rcopula-0.1.0/rcopula/htest/__init__.py +25 -0
- rcopula-0.1.0/rcopula/htest/api.py +653 -0
- rcopula-0.1.0/rcopula/insurance.py +407 -0
- rcopula-0.1.0/rcopula/kendall.py +459 -0
- rcopula-0.1.0/rcopula/plots.py +887 -0
- rcopula-0.1.0/rcopula/portfolio.py +477 -0
- rcopula-0.1.0/rcopula/risk.py +571 -0
- rcopula-0.1.0/rcopula/sampling.py +342 -0
- rcopula-0.1.0/rcopula/select.py +541 -0
- rcopula-0.1.0/rcopula/serialize.py +359 -0
- rcopula-0.1.0/rcopula/special/__init__.py +24 -0
- rcopula-0.1.0/rcopula/special/combinatorics.py +142 -0
- rcopula-0.1.0/rcopula/special/debye.py +213 -0
- rcopula-0.1.0/rcopula/special/logexp.py +194 -0
- rcopula-0.1.0/rcopula/special/mvtnorm.py +525 -0
- rcopula-0.1.0/rcopula/special/stable.py +414 -0
- rcopula-0.1.0/rcopula/statarb.py +576 -0
- rcopula-0.1.0/rcopula/structural/__init__.py +42 -0
- rcopula-0.1.0/rcopula/structural/khoudraji.py +411 -0
- rcopula-0.1.0/rcopula/structural/marginal.py +213 -0
- rcopula-0.1.0/rcopula/structural/mixture.py +311 -0
- rcopula-0.1.0/rcopula/structural/nested.py +532 -0
- rcopula-0.1.0/rcopula/structural/opower.py +304 -0
- rcopula-0.1.0/rcopula/structural/rotated.py +423 -0
- rcopula-0.1.0/rcopula/transforms.py +654 -0
- rcopula-0.1.0/rcopula/vine.py +635 -0
- rcopula-0.1.0/tests/conftest.py +29 -0
- rcopula-0.1.0/tests/golden/archimedean.json +1 -0
- rcopula-0.1.0/tests/golden/elliptical.json +1 -0
- rcopula-0.1.0/tests/golden/empirical.json +1 -0
- rcopula-0.1.0/tests/golden/extreme_value.json +1 -0
- rcopula-0.1.0/tests/golden/fitting.json +1 -0
- rcopula-0.1.0/tests/golden/gof.json +1 -0
- rcopula-0.1.0/tests/golden/htest.json +1 -0
- rcopula-0.1.0/tests/golden/other.json +1 -0
- rcopula-0.1.0/tests/golden/transforms.json +1 -0
- rcopula-0.1.0/tests/test_archimedean.py +506 -0
- rcopula-0.1.0/tests/test_datasets.py +283 -0
- rcopula-0.1.0/tests/test_derivatives.py +571 -0
- rcopula-0.1.0/tests/test_discrete.py +395 -0
- rcopula-0.1.0/tests/test_docs.py +185 -0
- rcopula-0.1.0/tests/test_dynamic.py +559 -0
- rcopula-0.1.0/tests/test_elliptical.py +332 -0
- rcopula-0.1.0/tests/test_empirical_and_mvdc.py +255 -0
- rcopula-0.1.0/tests/test_ergonomics.py +404 -0
- rcopula-0.1.0/tests/test_examples.py +54 -0
- rcopula-0.1.0/tests/test_extreme_value.py +148 -0
- rcopula-0.1.0/tests/test_fit_joint.py +183 -0
- rcopula-0.1.0/tests/test_fitting.py +491 -0
- rcopula-0.1.0/tests/test_garch.py +438 -0
- rcopula-0.1.0/tests/test_gof.py +344 -0
- rcopula-0.1.0/tests/test_golden_archimedean.py +235 -0
- rcopula-0.1.0/tests/test_golden_elliptical.py +138 -0
- rcopula-0.1.0/tests/test_golden_extreme_value.py +139 -0
- rcopula-0.1.0/tests/test_golden_other.py +159 -0
- rcopula-0.1.0/tests/test_htest.py +412 -0
- rcopula-0.1.0/tests/test_insurance.py +229 -0
- rcopula-0.1.0/tests/test_kendall.py +275 -0
- rcopula-0.1.0/tests/test_literature.py +530 -0
- rcopula-0.1.0/tests/test_nested.py +306 -0
- rcopula-0.1.0/tests/test_numerical_limits.py +421 -0
- rcopula-0.1.0/tests/test_other.py +304 -0
- rcopula-0.1.0/tests/test_plots.py +411 -0
- rcopula-0.1.0/tests/test_risk_and_credit.py +371 -0
- rcopula-0.1.0/tests/test_sampling.py +236 -0
- rcopula-0.1.0/tests/test_select.py +298 -0
- rcopula-0.1.0/tests/test_special_debye.py +167 -0
- rcopula-0.1.0/tests/test_special_logexp.py +190 -0
- rcopula-0.1.0/tests/test_statarb.py +327 -0
- rcopula-0.1.0/tests/test_structural.py +899 -0
- rcopula-0.1.0/tests/test_transforms_and_portfolio.py +792 -0
- rcopula-0.1.0/tests/test_vine.py +303 -0
- rcopula-0.1.0/tools/rgolden/00_setup.R +10 -0
- rcopula-0.1.0/tools/rgolden/01_families.R +133 -0
- rcopula-0.1.0/tools/rgolden/02_other.R +51 -0
- rcopula-0.1.0/tools/rgolden/03_extreme_value.R +55 -0
- rcopula-0.1.0/tools/rgolden/04_empirical.R +36 -0
- rcopula-0.1.0/tools/rgolden/05_fitting.R +49 -0
- rcopula-0.1.0/tools/rgolden/06_gof.R +29 -0
- rcopula-0.1.0/tools/rgolden/07_htest.R +30 -0
- rcopula-0.1.0/tools/rgolden/08_transforms.R +24 -0
- rcopula-0.1.0/tools/rgolden/run_all.sh +16 -0
rcopula-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
# Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
# uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
# poetry.lock
|
|
109
|
+
# poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
# pdm.lock
|
|
116
|
+
# pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
# pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# Redis
|
|
135
|
+
*.rdb
|
|
136
|
+
*.aof
|
|
137
|
+
*.pid
|
|
138
|
+
|
|
139
|
+
# RabbitMQ
|
|
140
|
+
mnesia/
|
|
141
|
+
rabbitmq/
|
|
142
|
+
rabbitmq-data/
|
|
143
|
+
|
|
144
|
+
# ActiveMQ
|
|
145
|
+
activemq-data/
|
|
146
|
+
|
|
147
|
+
# SageMath parsed files
|
|
148
|
+
*.sage.py
|
|
149
|
+
|
|
150
|
+
# Environments
|
|
151
|
+
.env
|
|
152
|
+
.envrc
|
|
153
|
+
.venv
|
|
154
|
+
env/
|
|
155
|
+
venv/
|
|
156
|
+
ENV/
|
|
157
|
+
env.bak/
|
|
158
|
+
venv.bak/
|
|
159
|
+
|
|
160
|
+
# Spyder project settings
|
|
161
|
+
.spyderproject
|
|
162
|
+
.spyproject
|
|
163
|
+
|
|
164
|
+
# Rope project settings
|
|
165
|
+
.ropeproject
|
|
166
|
+
|
|
167
|
+
# mkdocs documentation
|
|
168
|
+
/site
|
|
169
|
+
|
|
170
|
+
# mypy
|
|
171
|
+
.mypy_cache/
|
|
172
|
+
.dmypy.json
|
|
173
|
+
dmypy.json
|
|
174
|
+
|
|
175
|
+
# Pyre type checker
|
|
176
|
+
.pyre/
|
|
177
|
+
|
|
178
|
+
# pytype static type analyzer
|
|
179
|
+
.pytype/
|
|
180
|
+
|
|
181
|
+
# Cython debug symbols
|
|
182
|
+
cython_debug/
|
|
183
|
+
|
|
184
|
+
# PyCharm
|
|
185
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
186
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
188
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
189
|
+
# .idea/
|
|
190
|
+
|
|
191
|
+
# Abstra
|
|
192
|
+
# Abstra is an AI-powered process automation framework.
|
|
193
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
194
|
+
# Learn more at https://abstra.io/docs
|
|
195
|
+
.abstra/
|
|
196
|
+
|
|
197
|
+
# Visual Studio Code
|
|
198
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
199
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
200
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
201
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
202
|
+
# .vscode/
|
|
203
|
+
# Temporary file for partial code execution
|
|
204
|
+
tempCodeRunnerFile.py
|
|
205
|
+
|
|
206
|
+
# Ruff stuff:
|
|
207
|
+
.ruff_cache/
|
|
208
|
+
|
|
209
|
+
# PyPI configuration file
|
|
210
|
+
.pypirc
|
|
211
|
+
|
|
212
|
+
# Marimo
|
|
213
|
+
marimo/_static/
|
|
214
|
+
marimo/_lsp/
|
|
215
|
+
__marimo__/
|
|
216
|
+
|
|
217
|
+
# Streamlit
|
|
218
|
+
.streamlit/secrets.toml
|
|
219
|
+
site/
|
rcopula-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Chris Bell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
rcopula-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
rcopula — NOTICE
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
Relationship to the R `copula` package
|
|
5
|
+
--------------------------------------
|
|
6
|
+
|
|
7
|
+
`rcopula` reproduces the *functionality* of the R package `copula` (Marius Hofert,
|
|
8
|
+
Ivan Kojadinovic, Martin Maechler, Jun Yan), which is licensed under GPL (>= 3).
|
|
9
|
+
|
|
10
|
+
`rcopula` is licensed under the MIT License and is **not** a derivative work of
|
|
11
|
+
the R package. Specifically:
|
|
12
|
+
|
|
13
|
+
1. **No R source code was translated into this project.** Every algorithm is
|
|
14
|
+
implemented from its originating published paper. Each module docstring cites
|
|
15
|
+
the reference it was implemented from.
|
|
16
|
+
|
|
17
|
+
2. **The R package is used only as a behavioural test oracle.** The scripts under
|
|
18
|
+
`tools/rgolden/` are original work written for this project; they merely *call*
|
|
19
|
+
the R package to record its numeric outputs into `tests/golden/`. Comparing
|
|
20
|
+
outputs is a black-box conformance test, not copying.
|
|
21
|
+
|
|
22
|
+
3. **Names, signatures and numerical results are not copyrightable.** Matching an
|
|
23
|
+
API and matching the values a published algorithm produces does not create a
|
|
24
|
+
derivative work.
|
|
25
|
+
|
|
26
|
+
Anyone contributing to `rcopula` must follow the clean-room rule documented in
|
|
27
|
+
`CONTRIBUTING.md`.
|
|
28
|
+
|
|
29
|
+
Primary references implemented
|
|
30
|
+
------------------------------
|
|
31
|
+
|
|
32
|
+
- Nelsen, R. B. (2006). *An Introduction to Copulas*, 2nd ed. Springer.
|
|
33
|
+
- Joe, H. (2014). *Dependence Modeling with Copulas*. Chapman & Hall/CRC.
|
|
34
|
+
- Hofert, M., Kojadinovic, I., Maechler, M., Yan, J. (2018).
|
|
35
|
+
*Elements of Copula Modeling with R*. Springer.
|
|
36
|
+
- Genest, C., Ghoudi, K., Rivest, L.-P. (1995). A semiparametric estimation
|
|
37
|
+
procedure of dependence parameters in multivariate families of distributions.
|
|
38
|
+
*Biometrika* 82(3), 543–552. [maximum pseudo-likelihood + its asymptotic variance]
|
|
39
|
+
- Genest, C., Rémillard, B., Beaudoin, D. (2009). Goodness-of-fit tests for
|
|
40
|
+
copulas: A review and a power study. *Insurance: Mathematics and Economics*
|
|
41
|
+
44(2), 199–213. [Sn, SnB, SnC; parametric bootstrap]
|
|
42
|
+
- Genest, C., Huang, W., Dufour, J.-M. (2013). A regularized goodness-of-fit test
|
|
43
|
+
for copulas. *Journal de la Société Française de Statistique* 154(1), 64–77. [Rn]
|
|
44
|
+
- Kojadinovic, I. (2017). Some copula inference procedures adapted to the presence
|
|
45
|
+
of ties. *Computational Statistics & Data Analysis* 112, 24–41. [ties handling]
|
|
46
|
+
- Hofert, M. (2011). Efficiently sampling nested Archimedean copulas.
|
|
47
|
+
*Computational Statistics & Data Analysis* 55(1), 57–70.
|
|
48
|
+
[exponentially tilted stable double-rejection sampling]
|
|
49
|
+
- Hofert, M. (2008). Sampling Archimedean copulas. *Computational Statistics &
|
|
50
|
+
Data Analysis* 52(12), 5163–5174.
|
|
51
|
+
- Marshall, A. W., Olkin, I. (1988). Families of multivariate distributions.
|
|
52
|
+
*JASA* 83(403), 834–841. [frailty / mixture sampling algorithm]
|
|
53
|
+
- McNeil, A. J., Nešlehová, J. (2009). Multivariate Archimedean copulas,
|
|
54
|
+
d-monotone functions and l1-norm symmetric distributions.
|
|
55
|
+
*Annals of Statistics* 37(5B), 3059–3097. [radial part]
|
|
56
|
+
- Segers, J., Sibuya, M., Tsukahara, H. (2017). The empirical beta copula.
|
|
57
|
+
*Journal of Multivariate Analysis* 155, 35–51.
|
|
58
|
+
- Gudendorf, G., Segers, J. (2011). Nonparametric estimation of multivariate
|
|
59
|
+
extreme-value copulas. *Journal of Statistical Planning and Inference* 141(9),
|
|
60
|
+
3073–3085. [Pickands, CFG, Hall–Tajvidi estimators]
|
|
61
|
+
- Grønneberg, S., Hjort, N. L. (2014). The copula information criteria.
|
|
62
|
+
*Scandinavian Journal of Statistics* 41(2), 436–459. [cross-validation]
|
|
63
|
+
- Genz, A., Bretz, F. (2009). *Computation of Multivariate Normal and t
|
|
64
|
+
Probabilities*. Springer Lecture Notes in Statistics 195.
|
|
65
|
+
- Chambers, J. M., Mallows, C. L., Stuck, B. W. (1976). A method for simulating
|
|
66
|
+
stable random variables. *JASA* 71(354), 340–344.
|
|
67
|
+
- Devroye, L. (2009). Random variate generation for exponentially and polynomially
|
|
68
|
+
tilted stable distributions. *ACM TOMACS* 19(4), 1–20.
|
|
69
|
+
- Kemp, A. W. (1981). Efficient generation of logarithmically distributed
|
|
70
|
+
pseudo-random variables. *Applied Statistics* 30(3), 249–253.
|
|
71
|
+
- Khoudraji, A. (1995). *Contributions à l'étude des copules et à la modélisation
|
|
72
|
+
des valeurs extrêmes bivariées*. PhD thesis, Université Laval.
|
|
73
|
+
- Mashal, R., Zeevi, A. (2002). Beyond correlation: Extreme co-movements between
|
|
74
|
+
financial assets. Columbia University working paper. [itau.mpl for t copulas]
|
|
75
|
+
- Dissmann, J., Brechmann, E. C., Czado, C., Kurowicka, D. (2013). Selecting and
|
|
76
|
+
estimating regular vine copulae and application to financial returns.
|
|
77
|
+
*Computational Statistics & Data Analysis* 59, 52–69.
|
|
78
|
+
|
|
79
|
+
Bundled datasets
|
|
80
|
+
----------------
|
|
81
|
+
|
|
82
|
+
Datasets under `rcopula/datasets/` are redistributed for reproducibility of the
|
|
83
|
+
worked examples. Each carries its original source citation in
|
|
84
|
+
`rcopula/datasets/SOURCES.md`. They originate from published academic work and
|
|
85
|
+
are included under the same terms as their original publication.
|
rcopula-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: rcopula
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Copula modelling in Python: a full-featured replication of R's `copula` package.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Chrisebell24/python-copula
|
|
6
|
+
Project-URL: Repository, https://github.com/Chrisebell24/python-copula
|
|
7
|
+
Project-URL: Issues, https://github.com/Chrisebell24/python-copula/issues
|
|
8
|
+
Author-email: Chris Bell <chris.e.bell24@gmail.com>
|
|
9
|
+
License: MIT License
|
|
10
|
+
|
|
11
|
+
Copyright (c) 2026 Chris Bell
|
|
12
|
+
|
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
in the Software without restriction, including without limitation the rights
|
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
|
21
|
+
copies or substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
+
SOFTWARE.
|
|
30
|
+
License-File: LICENSE
|
|
31
|
+
License-File: NOTICE
|
|
32
|
+
Keywords: archimedean,copula,dependence,risk,sklar,statistics,tail dependence,vine copula
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Financial and Insurance Industry
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
37
|
+
Classifier: Programming Language :: Python :: 3
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
42
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
43
|
+
Classifier: Typing :: Typed
|
|
44
|
+
Requires-Python: >=3.10
|
|
45
|
+
Requires-Dist: matplotlib>=3.7
|
|
46
|
+
Requires-Dist: numpy>=1.24
|
|
47
|
+
Requires-Dist: pandas>=2.0
|
|
48
|
+
Requires-Dist: scipy>=1.10
|
|
49
|
+
Provides-Extra: dev
|
|
50
|
+
Requires-Dist: mpmath>=1.3; extra == 'dev'
|
|
51
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
52
|
+
Requires-Dist: pytest-cov>=5.0; extra == 'dev'
|
|
53
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
54
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
55
|
+
Provides-Extra: docs
|
|
56
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
57
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
58
|
+
Requires-Dist: mkdocstrings[python]>=0.26; extra == 'docs'
|
|
59
|
+
Provides-Extra: garch
|
|
60
|
+
Requires-Dist: arch>=6.0; extra == 'garch'
|
|
61
|
+
Description-Content-Type: text/markdown
|
|
62
|
+
|
|
63
|
+
# rcopula
|
|
64
|
+
|
|
65
|
+
**Copula modelling in Python — a full-featured replication of R's [`copula`](https://cran.r-project.org/package=copula) package, verified against it numerically.**
|
|
66
|
+
|
|
67
|
+
[](https://github.com/Chrisebell24/python-copula/actions/workflows/ci.yml)
|
|
68
|
+
[](LICENSE)
|
|
69
|
+
|
|
70
|
+
> **Status: pre-1.0, under active development.** The API may change before 1.0.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Why this exists
|
|
75
|
+
|
|
76
|
+
R's `copula` package is the most complete copula toolkit in any language. Python's options
|
|
77
|
+
are fragmented, and roughly **60–70% of R `copula`'s statistical surface has no Python
|
|
78
|
+
equivalent at all**:
|
|
79
|
+
|
|
80
|
+
- no multiplier-bootstrap goodness-of-fit anywhere;
|
|
81
|
+
- no nested Archimedean copulas anywhere, because they need an exponentially
|
|
82
|
+
tilted stable sampler that does not exist in NumPy, SciPy or any copula package;
|
|
83
|
+
- no Khoudraji device, general rotation wrapper, or arbitrary-copula mixtures;
|
|
84
|
+
- no Kendall distribution function `K`, no general Rosenblatt transform;
|
|
85
|
+
- **not one Python package returns standard errors for a fitted copula**;
|
|
86
|
+
- families missing under one API: Joe, AMH, Plackett, FGM, Marshall–Olkin, Galambos,
|
|
87
|
+
Hüsler–Reiss, Tawn, t-EV, Fréchet bounds.
|
|
88
|
+
|
|
89
|
+
`rcopula` closes that gap, and proves it: every deterministic quantity is checked against
|
|
90
|
+
fixtures generated by running the real R package — **and separately against the
|
|
91
|
+
definitions themselves**, so agreeing with R cannot be mistaken for being right.
|
|
92
|
+
|
|
93
|
+
It also goes past R where the gap was worth closing:
|
|
94
|
+
|
|
95
|
+
- **time-varying copulas** — Patton (2006) and score-driven (GAS) recursions, plus
|
|
96
|
+
Engle's DCC for a correlation matrix that moves;
|
|
97
|
+
- **discrete and mixed margins** — the exact inclusion-exclusion likelihood, with the
|
|
98
|
+
identifiability caveat stated rather than buried;
|
|
99
|
+
- **vines** — R/C/D, in pure NumPy;
|
|
100
|
+
- **automatic family selection**, **JSON serialization**, and **bootstrap confidence
|
|
101
|
+
intervals** with measured coverage.
|
|
102
|
+
|
|
103
|
+
## What copulas are for
|
|
104
|
+
|
|
105
|
+
Sklar's theorem says any joint distribution splits cleanly into **its margins** and **a
|
|
106
|
+
copula** that carries all the dependence. That separation is the whole point:
|
|
107
|
+
|
|
108
|
+
- **Model dependence and margins independently.** Fit each margin however you like — a
|
|
109
|
+
GARCH residual distribution, a kernel density, a fitted Gamma — then fit the dependence
|
|
110
|
+
structure separately.
|
|
111
|
+
- **Dependence measures that don't lie.** Kendall's τ and Spearman's ρ are invariant under
|
|
112
|
+
monotone marginal transforms; Pearson correlation is not. Pearson also reports ~0 for
|
|
113
|
+
strongly dependent pairs (e.g. `y = x²`).
|
|
114
|
+
- **Tail dependence.** Gaussian dependence says extreme joint events are essentially
|
|
115
|
+
impossible. Real markets disagree. A t or Clayton copula prices joint crashes correctly;
|
|
116
|
+
a Gaussian one does not. This distinction is not cosmetic — it changes VaR materially.
|
|
117
|
+
|
|
118
|
+
### Choosing a family
|
|
119
|
+
|
|
120
|
+
| If your data look like… | Use |
|
|
121
|
+
|---|---|
|
|
122
|
+
| Symmetric dependence, no joint extremes | `GaussianCopula` |
|
|
123
|
+
| Symmetric dependence **with** joint extremes in both tails | `StudentCopula` |
|
|
124
|
+
| Joint crashes but not joint booms (lower-tail dependence) | `ClaytonCopula` |
|
|
125
|
+
| Joint booms but not joint crashes (upper-tail dependence) | `GumbelCopula`, `JoeCopula` |
|
|
126
|
+
| Flexible middle, negative dependence allowed, no tail dependence | `FrankCopula` |
|
|
127
|
+
| Weak dependence only (τ ∈ [−0.18, 0.33]) | `AMHCopula` |
|
|
128
|
+
| Asymmetric tails | `KhoudrajiCopula`, `RotatedCopula` |
|
|
129
|
+
| Block / hierarchical group structure | `NestedArchimedean` |
|
|
130
|
+
| High-dimensional, pair-specific dependence | `VineCopula` |
|
|
131
|
+
|
|
132
|
+
## Install
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
pip install rcopula
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Quick start
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import rcopula as rc
|
|
142
|
+
from scipy import stats
|
|
143
|
+
|
|
144
|
+
# Construct and sample
|
|
145
|
+
cop = rc.ClaytonCopula(theta=2.0, dim=3)
|
|
146
|
+
u = cop.rvs(1000, random_state=42)
|
|
147
|
+
|
|
148
|
+
cop.pdf(u) # density
|
|
149
|
+
cop.cdf(u) # distribution function
|
|
150
|
+
cop.tau() # Kendall's tau -> 0.5
|
|
151
|
+
cop.lambda_() # TailDependence(lower=0.7071, upper=0.0)
|
|
152
|
+
|
|
153
|
+
# Calibrate from a target dependence
|
|
154
|
+
rc.GumbelCopula.from_tau(0.5) # theta = 2.0
|
|
155
|
+
|
|
156
|
+
# Fit, with standard errors
|
|
157
|
+
res = rc.fit(rc.GumbelCopula(dim=2), u[:, :2], method="mpl")
|
|
158
|
+
print(res.summary())
|
|
159
|
+
|
|
160
|
+
# Attach margins (Sklar, second direction)
|
|
161
|
+
mv = rc.CopulaDistribution(
|
|
162
|
+
cop, margins=[stats.norm(1, 2), stats.expon(scale=1 / 3), stats.gamma(2)]
|
|
163
|
+
)
|
|
164
|
+
x = mv.rvs(1000, random_state=0)
|
|
165
|
+
|
|
166
|
+
# Goodness of fit
|
|
167
|
+
rc.gof_test(rc.ClaytonCopula(dim=3), x, simulation="mult")
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
## Datasets
|
|
171
|
+
|
|
172
|
+
Nothing is bundled: R `copula`'s datasets are GPL-3 and this package is MIT, so
|
|
173
|
+
copying them in would be a licence conflict. Instead the loader ships URLs,
|
|
174
|
+
licences and SHA-256 digests, and fetches permissively-licensed sources on first
|
|
175
|
+
use.
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
flood = rc.datasets.load("nwis_peaks") # USGS, public domain
|
|
179
|
+
wine = rc.datasets.load("uci_wine_quality_red") # UCI, CC BY 4.0
|
|
180
|
+
flood.attrs["citation"]
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Five sources: USGS annual peak flows and NOAA GHCN-Daily (both live endpoints, so
|
|
184
|
+
unpinnable), and three static UCI tables — abalone, red wine quality and NASA
|
|
185
|
+
aerofoil self-noise — whose SHA-256 is checked on every fetch. A test asserts no
|
|
186
|
+
data file is ever committed.
|
|
187
|
+
|
|
188
|
+
## Examples
|
|
189
|
+
|
|
190
|
+
Twenty-seven scripts in [`examples/`](examples/), each of which **runs and asserts
|
|
191
|
+
its own claims** — so they cannot drift out of date without failing:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
python examples/04_tail_dependence.py # what tau does not tell you
|
|
195
|
+
python examples/13_hydrology_return_periods.py
|
|
196
|
+
pytest tests/test_examples.py # run them all
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
They cover the R book chapters; applied finance (CDO tranches, basket and CMS
|
|
200
|
+
spread options, pairs trading, copula-GARCH, operational risk); hydrology,
|
|
201
|
+
climate compound extremes, structural reliability and survival analysis; the
|
|
202
|
+
statistics and machine-learning uses (mutual information, robust covariance,
|
|
203
|
+
synthetic data, conditional independence); vines; the nine diagnostic plots;
|
|
204
|
+
time-varying dependence; count data; quasi-random sampling; Archimedean
|
|
205
|
+
internals at d = 100; nested trees; and what rounding does to a rank statistic.
|
|
206
|
+
|
|
207
|
+
## Coming from R?
|
|
208
|
+
|
|
209
|
+
The API is Pythonic (scipy/statsmodels verbs), but R's option strings are preserved so you
|
|
210
|
+
can paste them across.
|
|
211
|
+
|
|
212
|
+
| R | `rcopula` |
|
|
213
|
+
|---|---|
|
|
214
|
+
| `claytonCopula(2, dim = 3)` | `rc.ClaytonCopula(theta=2, dim=3)` |
|
|
215
|
+
| `rCopula(n, cop)` | `cop.rvs(n)` |
|
|
216
|
+
| `dCopula(u, cop)` / `pCopula(u, cop)` | `cop.pdf(u)` / `cop.cdf(u)` |
|
|
217
|
+
| `tau(cop)` / `rho(cop)` / `lambda(cop)` | `cop.tau()` / `cop.rho()` / `cop.lambda_()` |
|
|
218
|
+
| `iTau(claytonCopula(), 0.5)` | `rc.ClaytonCopula.from_tau(0.5)` |
|
|
219
|
+
| `fitCopula(cop, u, method = "mpl")` | `rc.fit(cop, u, method="mpl")` |
|
|
220
|
+
| `pobs(x)` | `rc.pseudo_obs(x)` |
|
|
221
|
+
| `mvdc(cop, margins, paramMargins)` | `rc.CopulaDistribution(cop, margins=[...])` |
|
|
222
|
+
| `fitMvdc(x, mvdc, start)` | `rc.fit_joint(mv, x)` — margins and copula together |
|
|
223
|
+
| `cCopula(u, cop)` | `rc.rosenblatt(cop, u)` |
|
|
224
|
+
| `gofCopula(cop, x, simulation = "mult")` | `rc.gof_test(cop, x, simulation="mult")` |
|
|
225
|
+
| `gofT2stat(u1, u2)` | `rc.gof_two_sample(x, y)` — did the dependence change? |
|
|
226
|
+
| `dependogram(x, d)` | `rc.dependogram(x)` — which subsets are dependent |
|
|
227
|
+
| `rotCopula(cop, flip)` | `rc.RotatedCopula(cop, flip)` / `rc.survival(cop)` |
|
|
228
|
+
| `khoudrajiCopula(c1, c2, shapes)` | `rc.KhoudrajiCopula(c1, c2, shapes)` |
|
|
229
|
+
| `mixCopula(list(c1, c2), w)` | `rc.MixtureCopula([c1, c2], w)` |
|
|
230
|
+
| `opower(cop, alpha)` | `rc.opower(cop, alpha)` — a second dial on the tails |
|
|
231
|
+
| `margCopula(cop, keep)` | `rc.marginal_copula(cop, [0, 3])` |
|
|
232
|
+
| `fitLambda(x)` | `rc.fit_lambda(x)` — tail dependence without a family |
|
|
233
|
+
| `onacopula("G", C(1.5, , list(C(4, 1:3))))` | `rc.NestedArchimedean(rc.GumbelCopula(1.5), ...)` |
|
|
234
|
+
| `enacopula(u, cop, method = "etau")` | `rc.fit_nested(structure, u)` |
|
|
235
|
+
| *(VineCopula::RVineStructureSelect)* | `rc.fit_vine(u, structure="D")` |
|
|
236
|
+
| `retstable(n, V0, h, alpha)` | `rcopula.special.stable.retstable(...)` |
|
|
237
|
+
| `pK(t, cop, d)` / `qK` / `dK` / `rK` | `rc.kendall_cdf/ppf/pdf/rvs(cop, ...)` |
|
|
238
|
+
| `Kn(u, x)` | `rc.kendall_empirical(x, u)` |
|
|
239
|
+
| `xvCopula(cop, x, k)` | `rc.cross_validate(cop, x, k)` |
|
|
240
|
+
| `contour(cop, dCopula)` / `persp(...)` | `rc.plots.contour(cop)` / `rc.plots.surface(cop)` |
|
|
241
|
+
| `pairsRosenblatt(...)` | `rc.plots.pairs_rosenblatt(cop, u)` — *where* a fit fails |
|
|
242
|
+
| *(no equivalent)* | `rc.select_copula(u)` — rank every admissible family |
|
|
243
|
+
| *(no equivalent)* | `rc.plots.tail_concentration(u, [c1, c2])` — where families disagree |
|
|
244
|
+
| *(no equivalent)* | `rc.dynamic.fit_dynamic(u, cop)` — Patton / GAS time-varying dependence |
|
|
245
|
+
| *(no equivalent)* | `rc.dynamic.fit_dcc(u)` — Engle's dynamic conditional correlation |
|
|
246
|
+
| *(no equivalent)* | `rc.discrete.fit_discrete(x, cop, margins)` — exact likelihood for counts |
|
|
247
|
+
| *(no equivalent)* | `rc.bootstrap.bootstrap_measure(u, "tau")` — BCa intervals, `n_jobs=` |
|
|
248
|
+
| *(no equivalent)* | `rc.serialize.to_json(cop)` — a model file you can read and diff |
|
|
249
|
+
| *(no equivalent)* | `rc.statarb.select_pairs(returns)` — rank every pair, six criteria |
|
|
250
|
+
| *(no equivalent)* | `rc.statarb.select_partners(returns, "AAPL")` — vine quadruples |
|
|
251
|
+
| `rtrafo` / inverse `cCopula` | `rc.inverse_rosenblatt(cop, z)` |
|
|
252
|
+
| `rAntitheticVariates` | `rc.sampling.antithetic_rvs(cop, n)` |
|
|
253
|
+
| `rLatinHypercube` | `rc.sampling.latin_hypercube_rvs(cop, n)` |
|
|
254
|
+
| *(qrng vignette)* | `rc.sampling.quasi_rvs(cop, n)` — Sobol/Halton through the copula |
|
|
255
|
+
| `htrafo(u, cop)` | `rc.htrafo(cop, u)` |
|
|
256
|
+
|
|
257
|
+
There is a [vine copula tutorial](https://chrisebell24.github.io/python-copula/vines/)
|
|
258
|
+
that reproduces Aas et al. (2009) equation by equation — the D-vine and C-vine
|
|
259
|
+
factorisations agree with the printed formulas to 2e-15, and the paper's count of
|
|
260
|
+
"12 D-vines and 12 C-vines" in four dimensions is reproduced by enumeration.
|
|
261
|
+
|
|
262
|
+
The full translation table, an API reference, and the notes on where R is the
|
|
263
|
+
less accurate side are in the [documentation](https://chrisebell24.github.io/python-copula/)
|
|
264
|
+
(`make docs` to read it locally).
|
|
265
|
+
|
|
266
|
+
## How parity is verified
|
|
267
|
+
|
|
268
|
+
R's RNG cannot be matched bit-for-bit by NumPy, so verification splits in two:
|
|
269
|
+
|
|
270
|
+
- **Deterministic quantities** — densities, CDFs, generators, Pickands functions, τ/ρ/λ,
|
|
271
|
+
`iTau`/`iRho`, Rosenblatt transforms, the Kendall function, and every GoF *statistic* —
|
|
272
|
+
must match R to ~1e-10.
|
|
273
|
+
- **RNG-dependent quantities** — R's random draws are **exported to CSV and fed into
|
|
274
|
+
Python**, making everything downstream deterministic. Fitted parameters must match to
|
|
275
|
+
~1e-6 and standard errors to ~1e-5. Only bootstrap p-values remain stochastic, and those
|
|
276
|
+
are checked statistically.
|
|
277
|
+
|
|
278
|
+
Fixtures live in `tests/golden/` and are committed, so CI needs no R. Regenerate with
|
|
279
|
+
`make golden`. A published parity report lists every replicated function and its maximum
|
|
280
|
+
observed deviation.
|
|
281
|
+
|
|
282
|
+
## License and relationship to R `copula`
|
|
283
|
+
|
|
284
|
+
`rcopula` is MIT. R's `copula` is GPL-3. **No R source code was translated into this
|
|
285
|
+
project** — every algorithm is implemented from its originating published paper, and the R
|
|
286
|
+
package is used solely as a black-box test oracle. See [`NOTICE`](NOTICE) and
|
|
287
|
+
[`CONTRIBUTING.md`](CONTRIBUTING.md).
|
|
288
|
+
|
|
289
|
+
`rcopula` is not affiliated with or endorsed by the authors of the R `copula` package.
|