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.
Similar content being viewed by others
References
Aas, K., Czado, C., Frigessi, A., Bakken, H.: Pair-copula constructions of multiple dependence. Insur. Math. Econ. 44, 182–198 (2009)
Acar, E., Genest, C., Nešlehová, J.: Beyond simplified pair-copula constructions. J. Multivar. Anal. 110, 74–90 (2012)
Bedford, T., Cooke, R.M.: Probability density decomposition for conditionally dependent random variables modeled by vines. Ann. Math. Artif. Intell. 32, 245–268 (2001)
Bedford, T., Cooke, R.M.: Vines—a new graphical model for dependent random variables. Ann Stat 30, 1031–1068 (2002)
Brechmann, E.C., Schepsmeier, U.: Modeling dependence with C- and D-vine copulas: the R package CDvine. J. Stat. Softw 52, 1–27 (2013)
Brent, R.: Algorithms for Minimization Without Derivatives. Prentice Hall, Englewood Cliffs (1973)
Breymann, W., Dias, A., Embrechts, P.: Dependence structures for multivariate high-frequency data in finance. Quant. Finance 3, 1–14 (2003)
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)
Czado, C., Schepsmeier, U., Min, A.: Maximum likelihood estimation of mixed C-vines with application to exchange rates. Stat. Model. 12, 229–255 (2012)
Daul, S., De Giorgi, E., Lindskog, F., McNeil, A.: Using the grouped t-copula. Risk Mag. 16, 73–76 (2003)
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)
Dobrić, J., Schmid, F.: A goodness of fit test for copulas based on Rosenblatt’s transformation. Comput. Stat. Data Anal. 51, 4633–4642 (2007)
Donnelly, T.: Algorithm 462: bivariate normal distribution. Commun. ACM 16, 638 (1973)
Fang, H., Fang, K., Kotz, S.: The meta-elliptical distributions with given marginals. J. Multivar. Anal. 82, 1–16 (2002)
Genz, A.: Numerical computation of rectangular bivariate and trivariate normal and t probabilities. Stat. Comput. 14, 151–160 (2004)
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)
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)
Hofert, M., Kojadinovic, I., Maechler, M., Yan, J.: Copula: multivariate dependence with copulas. http://CRAN.R-project.org/package=copula (2012)
Hofert, M., Maechler, M.: Nested Archimedean copulas meet R: the nacopula package. J. Stat. Softw. 39(9), 1–20 (2011)
Hunter, John D.: Matplotlib: a 2D graphics environment. Comput. Sci. Eng. 9(3), 90–95 (2007)
Joe, H.: Parametric families of multivariate distributions with given margins. J. Multivar. Anal. 46, 262–282 (1993)
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)
Joe, H.: Multivariate Models and Dependence Concepts. Chapmann & Hall, London (1997)
Jones, E., Oliphant, T., Peterson, P., et al.: SciPy: open source scientific tools for Python. http://www.scipy.org/ (2001)
Knight, W.R.: A computer method for calculating Kendall’s tau with ungrouped data. J. Am. Stat. Assoc. 61(314), 436–439 (1966)
Kojadinovic, I., Yan, J.: Modeling multivariate distributions with continuous margins using the copula R package. J. Stat. Softw. 34(9), 1–20 (2010)
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)
Lambda Foundry: pandas: Python data analysis library. http://pandas.pydata.org/ (2012)
Marsaglia, G., Marsaglia, J.: Evaluating the Anderson–Darling distribution. J. Stat. Softw. 9, 1–5 (2004)
Nápoles, O.M.: Chapter 9: Counting vines. In: Kurowicka, D., Joe, H. (eds.) Dependence Modeling, pp. 189–218. World Scientific, Singapore (2011)
Peterson, P.: F2PY: a tool for connecting Fortran and Python programs. Int. J. Comput. Sci. Eng. 4(4), 296–305 (2009)
Piessens, R., Doncker-Kapenga, E.D., Überhuber, C.W.: QUADPACK: A Subroutine Package for Automatic Integration. Springer, Berlin (1983)
Prim, R.C.: Shortest connection networks and some generalizations. Bell Lab Tech. J. 36, 1389–1401 (1957)
R Core Team: R: a Language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. http://www.R-project.org/ (2012)
Rosenblatt, M.: Remarks on a multivariate transformation. Ann. Math. Stat. 23, 470–472 (1952)
Savu, C., Trede, M.: Hierarchical Archimedean copulas. In: International Conference on High Frequency Finance. Konstanz, Germany (2006)
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)
Whelan, N.: Sampling from Archimedean copulas. Quant. Finance 4, 339–352 (2004)
Yan, J.: Enjoy the joy of copulas: with a package copula. J. Stat. Softw. 21(4), 1–21 (2007)
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)
Acknowledgements
This work was supported by the NNSF of China (Nos. 11371340, 71871208).
Author information
Authors and Affiliations
Corresponding author
Rights and permissions
About this article
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
Received:
Revised:
Accepted:
Published:
Issue Date:
DOI: https://doi.org/10.1007/s40304-019-00195-2
Keywords
- Regular vine copula
- Dependence structure
- Multivariate modeling
- Multivariate sampling
- Rosenblatt’s transformation
- Anderson–Darling test
- Bivariate copula
- Python