Regular vine copula provides rich models for dependence structure modeling. It combines vine structures and families of bivariate copulas to construct a number of multivariate distributions that can model a wide range dependence patterns with different tail dependence for different pairs. Two special cases of regular vine copulas, C-vine and D-vine copulas, have been deeply investigated.
We propose the Python package, pyvine, for modeling, sampling and testing a more generalized regular vine copula (R-vine for short). R-vine modeling algorithm searches for the R-vine structure which maximizes the vine tree dependence, i.e., the sum of the absolute values of kendall’s tau for paired variables on edges using PRIM algorithm of minimum-spanning-tree in a sequential way. The maximum likelihood estimation algorithm takes the sequential estimation as initial value and uses L-BFGS-B algorithm for the likelihood value optimization. R-vine sampling algorithm traverses all the edges of vine structure from the last tree in a recursive way, and generates the marginal samples on each edge according to some nested conditions. Goodness-of-fit testing algorithm first generates Rosenblatt’s transformed data E, then tests the composite hypothesis H_0*: E ~ C* by using Anderson-Darling statistic, where C* is the independence copula. Bootstrap method will generate the empirical distribution of Anderson-Darling statistic replications to compute an adjusted P-value.
The computing of related functions of copulas such as cumulative distribution functions often meets with the problem of overflow. We solve this problem by reinvestigating the following six popular families of bivariate opulas: Normal, Student t, Clayton, Gumbel, Frank and Joe copulas. Approximations of the above related functions of copulas are given when the overflow occurs in the computations. All these are implemented in a subpackage bvcopula of pyvine, in which subroutines are written in Fortran and wrapped into Python via f2py and good performance and high precision are both guaranteed.
An example for Rvine copula modeling is given as below:
# Example
import pandas as ps
import pyvine as pv
## read the data and do rank transformation
dat = ps.read_csv("data.csv",index_col = 0, parse_dates = 0)
cp_dat = dat.rank() / ( len(dat) + 1 )
## initialize R-vine object named rv
rv = pv.Rvine(cp_dat)
## sequential estimation for rv. 'structure' accepts 'r' for R-vine,
## 'c' for C-vine and 'd' for D-vine, 'familyset' accepts list of
## integers from 1 to 6, 'threads_num' accepts integer specifying number
## of threads using for taking mle on edges of the same vine tree
## simultaneously.
rv.modeling(structure = 'r', familyset = [1,2,3,4,5,6], threads_num = 2)
## maximum likelihood estimation for rv. 'disp' controls the printing
## of ratio of progress of iterating for L-BFGS-B algorithm, 'threads_num'
## specifies the number of threads using for computing loglikelihood value
## for each edge in the same vine tree.
rv.mle(disp=False, threads_num = 2)
## plot the R-vine structure for modeled object rv. All the vine trees will
## be plotted as default.
rv.plot()
## display the result of estimation on each edge. 'ndigits' controls number
## of decimal digits for result.
rv.res(ndigits = 3)
## testing
rv.test()
To compile and install on linux (substitute ‘gnu95’ with ‘mingw32’ on Windows):
$ python setup.py config_fc --opt="-fopenmp" build --fcompiler=gnu95 $ python setup.py install
Metadata
Release files for pyvine 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyvine-0.5.0.tar.gz | 398.2 kB | Without provenance | Details for pyvine-0.5.0.tar.gz |
Release files / pyvine-0.5.0.tar.gz
| Download URL | pyvine-0.5.0.tar.gz |
|---|---|
| Size | 398.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20811c953fdf79caa3b3ea02c7b1c6328286b90390922ac23b8fc78619d2c11f
|
|
BLAKE2b-256 checksum How to use checksums |
144abcda963f67f3cb20b1d6227a98055309c6ad53ca08799f61653bdcbfade8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for pyvine 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.