Skip to main content

No project description provided

Project description

VineCopulas

github repo badge github license badge Documentation Status PyPI version

VineCopulas is a Python package that is able to:

  • Fit both bivariate and vine copulas
  • Simulate from both bivariate and vine copulas
  • Allow for both discrete as well as continuous input data
  • Draw conditional samples for any variables of interest with the use of bivariate copulas and different vine structures

Installation

pip install vinecopulas

Getting Started

Get started by testing checking out the package functionality using the Abalone example data.

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
from vinecopulas.marginals import *
from vinecopulas.bivariate import *

datapath = 'https://raw.githubusercontent.com/VU-IVM/vinecopula/develop/doc/sample_data.csv'
df = pd.read_csv(datapath)
df.head()

Transform the data to pseudo data and fit a survival gumbel copula between two variables. Use the fitted copula to generate random samples.

x = np.array(df)[:,:-1]
u =  pseudodata(x) # computes the pseudodata
cop = 4 # copula 4 is the gumbel copula with 180 degree rotation
par = fit(cop, u[:,:2]) # fit the variables in the first 2 columns 
n = len(u) # number of samples to generate 
ur = random(cop, par, n) # generate random samples
# plot
plt.scatter(u[:,0],u[:,1], label = 'Data')
plt.scatter(ur[:,0], ur[:,1], alpha = 0.5, label = 'Random')
plt.xlabel('$u_1$')
plt.ylabel('$u_2$')
plt.legend()

Fit a vine copula between multiple variables in the data, considering all possible copulas available in the package.

cops = list(range(1,16)) # fit vine copula according to these copulas
M, P, C = fit_vinecop(u, cops, vine = 'R') # fit R-vine
plotvine(M,variables = list(df.columns[:-1]), plottitle = 'R-Vine') # plot structure

For more examples, please have a look at the documentation.

Contribution Guidelines


Please look at our Contributing Guidelines if you are interested in contributing to this package.

Asking Questions and Reporting Issues

If you encounter any bugs or issues while using VineCopulas, please report them by opening an issue in the GitHub repository. Be sure to provide detailed information about the problem, such as steps to reproduce it, including operating system and Python version.

If you have any suggestions for improvements, or questions, please also raise an issue.

Citing the Package


If you use the VineCopulas package in your work, please cite:

Claassen, J. N., Koks, E. E., de Ruiter, M. C., Ward, P. J., & Jäger, W. S. (2024). VineCopulas: an open-source Python package for vine copula modelling. Journal of Open Source Software, 9(101), 6728. https://doi.org/10.21105/joss.06728

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vinecopulas-2.0.2.tar.gz (51.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

VineCopulas-2.0.2-py3-none-any.whl (45.1 kB view details)

Uploaded Python 3

File details

Details for the file vinecopulas-2.0.2.tar.gz.

File metadata

  • Download URL: vinecopulas-2.0.2.tar.gz
  • Upload date:
  • Size: 51.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for vinecopulas-2.0.2.tar.gz
Algorithm Hash digest
SHA256 cdd0945b8e468748e0cb7d1077af8a5979481fa89c5a8a65a7c1888467ee9631
MD5 697aa3800b1710da029b96f84040ac08
BLAKE2b-256 a13a1bede96fcc4f1256f0eee8aa5af9f0915256ff28595d2c0870b509e4b0f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for vinecopulas-2.0.2.tar.gz:

Publisher: release.yml on VU-IVM/VineCopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file VineCopulas-2.0.2-py3-none-any.whl.

File metadata

  • Download URL: VineCopulas-2.0.2-py3-none-any.whl
  • Upload date:
  • Size: 45.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for VineCopulas-2.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1e7ab072c05b6a5b068454e94c6284bae9af4fbb2446fb34c8c499c2693436bb
MD5 af07618bab2a26bd6037fa5124a1be21
BLAKE2b-256 882be18d613eb02e275db2c28a7b1e6dc7580b4489658cc36eece77870a35e82

See more details on using hashes here.

Provenance

The following attestation bundles were made for VineCopulas-2.0.2-py3-none-any.whl:

Publisher: release.yml on VU-IVM/VineCopulas

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page