Skip to main content
Log in

pyvine: The Python Package for Regular Vine Copula Modeling, Sampling and Testing

  • Published:
Communications in Mathematics and Statistics Aims and scope Submit manuscript

Abstract

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 extensively investigated in the literature. 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 in a sequential way. The maximum likelihood estimation algorithm takes the sequential estimations as initial values and uses L-BFGS-B algorithm for the likelihood value optimization. R-vine sampling algorithm traverses all edges of the 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 \({\varvec{E}}\) and then tests the hypothesis \(H_0^*: {\varvec{E}} \sim C_{\perp }\) by using Anderson–Darling statistic, where \(C_{\perp }\) is the independence copula. Bootstrap method is used to compute an adjusted p-value of the empirical distribution of replications of Anderson–Darling statistic. The computing of related functions of copulas such as cumulative distribution functions, H-functions and inverse H-functions often meets with the problem of overflow. We solve this problem by reinvestigating the following six families of bivariate copulas: Normal, Student t, Clayton, Gumbel, Frank and Joe’s copulas. Approximations of the above related functions of copulas are given when the overflow occurs in the computation. All these are implemented in a subpackage bvcopula, in which subroutines are written in Fortran and wrapped into Python and, hence, good performance is guaranteed.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10
Fig. 11
Fig. 12
Fig. 13
Fig. 14
Fig. 15

Similar content being viewed by others

References

  1. Aas, K., Czado, C., Frigessi, A., Bakken, H.: Pair-copula constructions of multiple dependence. Insur. Math. Econ. 44, 182–198 (2009)

    Article  MathSciNet  Google Scholar 

  2. Acar, E., Genest, C., Nešlehová, J.: Beyond simplified pair-copula constructions. J. Multivar. Anal. 110, 74–90 (2012)

    Article  MathSciNet  Google Scholar 

  3. Bedford, T., Cooke, R.M.: Probability density decomposition for conditionally dependent random variables modeled by vines. Ann. Math. Artif. Intell. 32, 245–268 (2001)

    Article  MathSciNet  Google Scholar 

  4. Bedford, T., Cooke, R.M.: Vines—a new graphical model for dependent random variables. Ann Stat 30, 1031–1068 (2002)

    Article  MathSciNet  Google Scholar 

  5. Brechmann, E.C., Schepsmeier, U.: Modeling dependence with C- and D-vine copulas: the R package CDvine. J. Stat. Softw 52, 1–27 (2013)

    Article  Google Scholar 

  6. Brent, R.: Algorithms for Minimization Without Derivatives. Prentice Hall, Englewood Cliffs (1973)

    MATH  Google Scholar 

  7. Breymann, W., Dias, A., Embrechts, P.: Dependence structures for multivariate high-frequency data in finance. Quant. Finance 3, 1–14 (2003)

    Article  MathSciNet  Google Scholar 

  8. Chapeau-Blondeau, F., Monir, A.: Numerical evaluation of the Lambert \(W\) function and application to generation of generalized Gaussian noise with exponent \(1/2\). IEEE Trans. Signal Process. 50, 2160–2165 (2002)

    Article  MathSciNet  Google Scholar 

  9. Czado, C., Schepsmeier, U., Min, A.: Maximum likelihood estimation of mixed C-vines with application to exchange rates. Stat. Model. 12, 229–255 (2012)

    Article  MathSciNet  Google Scholar 

  10. Daul, S., De Giorgi, E., Lindskog, F., McNeil, A.: Using the grouped t-copula. Risk Mag. 16, 73–76 (2003)

    Google Scholar 

  11. Dißmann, J., Brechmann, E.C., Czado, C., Kurowicka, D.: Selecting and estimating regular vine copulae and application to financial returns. Comput. Stat. Data Anal. 59, 52–69 (2013)

    Article  MathSciNet  Google Scholar 

  12. Dobrić, J., Schmid, F.: A goodness of fit test for copulas based on Rosenblatt’s transformation. Comput. Stat. Data Anal. 51, 4633–4642 (2007)

    Article  MathSciNet  Google Scholar 

  13. Donnelly, T.: Algorithm 462: bivariate normal distribution. Commun. ACM 16, 638 (1973)

    Article  Google Scholar 

  14. Fang, H., Fang, K., Kotz, S.: The meta-elliptical distributions with given marginals. J. Multivar. Anal. 82, 1–16 (2002)

    Article  MathSciNet  Google Scholar 

  15. Genz, A.: Numerical computation of rectangular bivariate and trivariate normal and t probabilities. Stat. Comput. 14, 151–160 (2004)

    Article  MathSciNet  Google Scholar 

  16. Haff, I.H., Aas, K., Frigessi, A.: On the simplified pair-copula construction—simply useful or too simplistic? J. Multivar. Anal. 101, 1296–1310 (2010)

    Article  MathSciNet  Google Scholar 

  17. Hagberg, A.A., Schult, D.A., Swart, P.J.: Exploring network structure, dynamics, and function using NetworkX. In: Proceedings of the 7th Python in Science Conference (SciPy2008), pp. 11–15. Pasadena, CA USA (2008)

  18. Hofert, M., Kojadinovic, I., Maechler, M., Yan, J.: Copula: multivariate dependence with copulas. http://CRAN.R-project.org/package=copula (2012)

  19. Hofert, M., Maechler, M.: Nested Archimedean copulas meet R: the nacopula package. J. Stat. Softw. 39(9), 1–20 (2011)

    Article  Google Scholar 

  20. Hunter, John D.: Matplotlib: a 2D graphics environment. Comput. Sci. Eng. 9(3), 90–95 (2007)

    Article  Google Scholar 

  21. Joe, H.: Parametric families of multivariate distributions with given margins. J. Multivar. Anal. 46, 262–282 (1993)

    Article  MathSciNet  Google Scholar 

  22. Joe, H.: Families of \(m\)-variate distributions with given margins and \(m(m-1)/2\) bivariate dependence parameters. In: Distributions with Fixed Marginals and Related Topics, L. Rüschendorf, B. Schweizer and M.D. Taylor (eds.), vol. 28, pp. 120–141. Lecture Notes—Monograph Series, Institute of Mathematical Statistics, Hayward, CA (1996)

  23. Joe, H.: Multivariate Models and Dependence Concepts. Chapmann & Hall, London (1997)

    Book  Google Scholar 

  24. Jones, E., Oliphant, T., Peterson, P., et al.: SciPy: open source scientific tools for Python. http://www.scipy.org/ (2001)

  25. Knight, W.R.: A computer method for calculating Kendall’s tau with ungrouped data. J. Am. Stat. Assoc. 61(314), 436–439 (1966)

    Article  Google Scholar 

  26. Kojadinovic, I., Yan, J.: Modeling multivariate distributions with continuous margins using the copula R package. J. Stat. Softw. 34(9), 1–20 (2010)

    Article  Google Scholar 

  27. Kurowicka, D., Cooke, R.M.: Distribution—free continuous bayesian belief nets. In: Fourth International Conference on Mathematical Methods in Reliability Methodology and Practice. Santa Fe, New Mexico (2004)

  28. Lambda Foundry: pandas: Python data analysis library. http://pandas.pydata.org/ (2012)

  29. Marsaglia, G., Marsaglia, J.: Evaluating the Anderson–Darling distribution. J. Stat. Softw. 9, 1–5 (2004)

    Article  Google Scholar 

  30. Nápoles, O.M.: Chapter 9: Counting vines. In: Kurowicka, D., Joe, H. (eds.) Dependence Modeling, pp. 189–218. World Scientific, Singapore (2011)

    Google Scholar 

  31. Peterson, P.: F2PY: a tool for connecting Fortran and Python programs. Int. J. Comput. Sci. Eng. 4(4), 296–305 (2009)

    Google Scholar 

  32. Piessens, R., Doncker-Kapenga, E.D., Überhuber, C.W.: QUADPACK: A Subroutine Package for Automatic Integration. Springer, Berlin (1983)

    Book  Google Scholar 

  33. Prim, R.C.: Shortest connection networks and some generalizations. Bell Lab Tech. J. 36, 1389–1401 (1957)

    Article  Google Scholar 

  34. R Core Team: R: a Language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. http://www.R-project.org/ (2012)

  35. Rosenblatt, M.: Remarks on a multivariate transformation. Ann. Math. Stat. 23, 470–472 (1952)

    Article  MathSciNet  Google Scholar 

  36. Savu, C., Trede, M.: Hierarchical Archimedean copulas. In: International Conference on High Frequency Finance. Konstanz, Germany (2006)

  37. Schepsmeier, U., Stoeber, J., Brechmann, E.C., Graeler, B., Nagler, T., Erhardt, T.: VineCopula: statistical inference of vine copulas. https://cran.r-project.org/web/packages/VineCopula/index.html (2018)

  38. Whelan, N.: Sampling from Archimedean copulas. Quant. Finance 4, 339–352 (2004)

    Article  MathSciNet  Google Scholar 

  39. Yan, J.: Enjoy the joy of copulas: with a package copula. J. Stat. Softw. 21(4), 1–21 (2007)

    Article  Google Scholar 

  40. Zhu, C., Byrd, R.H., Lu, P., Nocedal, J.: Algorithm 778: L-BFGS-B: Fortran subroutines for large-scale bound-constrained optimization. ACM Trans. Math. Softw. 23(4), 550–560 (1997)

    Article  MathSciNet  Google Scholar 

Download references

Acknowledgements

This work was supported by the NNSF of China (Nos. 11371340, 71871208).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Zhenfei Yuan.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Yuan, Z., Hu, T. pyvine: The Python Package for Regular Vine Copula Modeling, Sampling and Testing. Commun. Math. Stat. 9, 53–86 (2021). https://doi.org/10.1007/s40304-019-00195-2

Download citation

  • Received:

  • Revised:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s40304-019-00195-2

Keywords

Mathematics Subject Classification

Navigation