这个包提供了常规的viNe建模、采样和测试算法。此外,还对一些常用的二元copulas程序进行了优化,以获得更宽的参数范围、更高的精度和更好的性能。
pyvine的Python项目详细描述
正则藤copula为依赖结构提供了丰富的模型。 建模。它结合了藤蔓结构和二元系 构造多个多元分布的copulas 用不同的尾依赖建立宽范围依赖模式 对不同的人来说。普通藤黄连的两个特例 而d-蔓黄连,已经被深入研究。
我们建议使用python包pyvine进行建模、采样和 测试更一般化的正则藤copula(r-vine for 短)。r-vine建模算法搜索r-vine结构 它最大化藤蔓树的依赖性,即,和的总和。 边上成对变量kendall's tau的绝对值 序列最小生成树的prim算法。这个 最大似然估计算法 估计为初始值,并使用l-bfgs-b算法 似然值优化。r-vine采样算法遍历所有 以递归方式从最后一棵树的藤结构边缘,以及 根据嵌套的 条件。拟合优度测试算法首先生成 罗森布拉特的转换数据,然后检验综合假设 h_0*:e~c*使用anderson-darling统计量,其中c*是 独立copula。bootstrap方法将产生 Anderson-Darling统计量的分布 调整后的p值。
计算copulas的相关函数,如累积函数 分布函数经常遇到溢出问题。我们 通过重新调查以下六个流行的 二元作品的家系:正常,学生T,克莱顿,贡贝尔, 弗兰克和乔·科普拉斯。上述相关函数的逼近 当计算中出现溢出时,给出了copula的个数。全部 这些在pyvine的子包bvcopula中实现,其中 子例程用fortran编写,并通过f2py封装到python中。 性能优良,精度高。
rvine copula建模示例如下:
# 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()
在Linux上编译和安装(在Windows上将“gnu95”替换为“mingw32):
$ python setup.py config_fc --opt="-fopenmp" build --fcompiler=gnu95 $ python setup.py install