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

  • Zhenfei YuanEmail author
  • Taizhong Hu


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.


Regular vine copula Dependence structure Multivariate modeling Multivariate sampling Rosenblatt’s transformation Anderson–Darling test Bivariate copula Python 

Mathematics Subject Classification

62E17 62H20 



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


  1. 1.
    Aas, K., Czado, C., Frigessi, A., Bakken, H.: Pair-copula constructions of multiple dependence. Insur. Math. Econ. 44, 182–198 (2009)MathSciNetCrossRefzbMATHGoogle Scholar
  2. 2.
    Acar, E., Genest, C., Nešlehová, J.: Beyond simplified pair-copula constructions. J. Multivar. Anal. 110, 74–90 (2012)MathSciNetCrossRefzbMATHGoogle Scholar
  3. 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)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Bedford, T., Cooke, R.M.: Vines—a new graphical model for dependent random variables. Ann Stat 30, 1031–1068 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  5. 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)CrossRefGoogle Scholar
  6. 6.
    Brent, R.: Algorithms for Minimization Without Derivatives. Prentice Hall, Englewood Cliffs (1973)zbMATHGoogle Scholar
  7. 7.
    Breymann, W., Dias, A., Embrechts, P.: Dependence structures for multivariate high-frequency data in finance. Quant. Finance 3, 1–14 (2003)MathSciNetCrossRefzbMATHGoogle Scholar
  8. 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)MathSciNetCrossRefzbMATHGoogle Scholar
  9. 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)MathSciNetCrossRefGoogle Scholar
  10. 10.
    Daul, S., De Giorgi, E., Lindskog, F., McNeil, A.: Using the grouped t-copula. Risk Mag. 16, 73–76 (2003)Google Scholar
  11. 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) MathSciNetCrossRefzbMATHGoogle Scholar
  12. 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)MathSciNetCrossRefzbMATHGoogle Scholar
  13. 13.
    Donnelly, T.: Algorithm 462: bivariate normal distribution. Commun. ACM 16, 638 (1973)CrossRefGoogle Scholar
  14. 14.
    Fang, H., Fang, K., Kotz, S.: The meta-elliptical distributions with given marginals. J. Multivar. Anal. 82, 1–16 (2002)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Genz, A.: Numerical computation of rectangular bivariate and trivariate normal and t probabilities. Stat. Comput. 14, 151–160 (2004)MathSciNetCrossRefGoogle Scholar
  16. 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)MathSciNetCrossRefzbMATHGoogle Scholar
  17. 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)Google Scholar
  18. 18.
    Hofert, M., Kojadinovic, I., Maechler, M., Yan, J.: Copula: multivariate dependence with copulas. (2012)
  19. 19.
    Hofert, M., Maechler, M.: Nested Archimedean copulas meet R: the nacopula package. J. Stat. Softw. 39(9), 1–20 (2011)CrossRefGoogle Scholar
  20. 20.
    Hunter, John D.: Matplotlib: a 2D graphics environment. Comput. Sci. Eng. 9(3), 90–95 (2007)CrossRefGoogle Scholar
  21. 21.
    Joe, H.: Parametric families of multivariate distributions with given margins. J. Multivar. Anal. 46, 262–282 (1993)MathSciNetCrossRefzbMATHGoogle Scholar
  22. 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)Google Scholar
  23. 23.
    Joe, H.: Multivariate Models and Dependence Concepts. Chapmann & Hall, London (1997)CrossRefzbMATHGoogle Scholar
  24. 24.
    Jones, E., Oliphant, T., Peterson, P., et al.: SciPy: open source scientific tools for Python. (2001)
  25. 25.
    Knight, W.R.: A computer method for calculating Kendall’s tau with ungrouped data. J. Am. Stat. Assoc. 61(314), 436–439 (1966)CrossRefzbMATHGoogle Scholar
  26. 26.
    Kojadinovic, I., Yan, J.: Modeling multivariate distributions with continuous margins using the copula R package. J. Stat. Softw. 34(9), 1–20 (2010)CrossRefGoogle Scholar
  27. 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)Google Scholar
  28. 28.
    Lambda Foundry: pandas: Python data analysis library. (2012)
  29. 29.
    Marsaglia, G., Marsaglia, J.: Evaluating the Anderson–Darling distribution. J. Stat. Softw. 9, 1–5 (2004)CrossRefGoogle Scholar
  30. 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. 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. 32.
    Piessens, R., Doncker-Kapenga, E.D., Überhuber, C.W.: QUADPACK: A Subroutine Package for Automatic Integration. Springer, Berlin (1983)CrossRefzbMATHGoogle Scholar
  33. 33.
    Prim, R.C.: Shortest connection networks and some generalizations. Bell Lab Tech. J. 36, 1389–1401 (1957)CrossRefGoogle Scholar
  34. 34.
    R Core Team: R: a Language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. (2012)
  35. 35.
    Rosenblatt, M.: Remarks on a multivariate transformation. Ann. Math. Stat. 23, 470–472 (1952)MathSciNetCrossRefzbMATHGoogle Scholar
  36. 36.
    Savu, C., Trede, M.: Hierarchical Archimedean copulas. In: International Conference on High Frequency Finance. Konstanz, Germany (2006)Google Scholar
  37. 37.
    Schepsmeier, U., Stoeber, J., Brechmann, E.C., Graeler, B., Nagler, T., Erhardt, T.: VineCopula: statistical inference of vine copulas. (2018)
  38. 38.
    Whelan, N.: Sampling from Archimedean copulas. Quant. Finance 4, 339–352 (2004)MathSciNetCrossRefzbMATHGoogle Scholar
  39. 39.
    Yan, J.: Enjoy the joy of copulas: with a package copula. J. Stat. Softw. 21(4), 1–21 (2007)CrossRefGoogle Scholar
  40. 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)MathSciNetCrossRefzbMATHGoogle Scholar

Copyright information

© School of Mathematical Sciences, University of Science and Technology of China and Springer-Verlag GmbH Germany, part of Springer Nature 2019

Authors and Affiliations

  1. 1.Department of Statistics and Finance, School of ManagementUniversity of Science and Technology of ChinaHefeiChina

Personalised recommendations