copulas.multivariate.vine module¶
VineCopula module.

class
copulas.multivariate.vine.
VineCopula
(*args, **kwargs)[source]¶ Bases:
copulas.multivariate.base.Multivariate
Vine copula model.
A \(vine\) is a graphical representation of one factorization of the nvariate probability distribution in terms of \(n(n − 1)/2\) bivariate copulas by means of the chain rule.
It consists of a sequence of levels and as many levels as variables. Each level consists of a tree (no isolated nodes and no loops) satisfying that if it has \(n\) nodes there must be \(n − 1\) edges.
Each node in tree \(T_1\) is a variable and edges are couplings of variables constructed with bivariate copulas.
Each node in tree \(T_{k+1}\) is a coupling in \(T_{k}\), expressed by the copula of the variables; while edges are couplings between two vertices that must have one variable in common, becoming a conditioning variable in the bivariate copula. Thus, every level has one node less than the former. Once all the trees are drawn, the factorization is the product of all the nodes.
 Parameters
vine_type (str) – type of the vine copula, could be ‘center’,’direct’,’regular’
random_state (int or np.random.RandomState) – Random seed or RandomState to use.

model
¶ Distribution to compute univariates.

u_matrix
¶ Univariates.
 Type
numpy.array

n_sample
¶ Number of samples.
 Type
int

n_var
¶ Number of variables.
 Type
int

columns
¶ Names of the variables.
 Type
pandas.Series

tau_mat
¶ Kendall correlation parameters for data.
 Type
numpy.array

truncated
¶ Max level used to build the vine.
 Type
int

depth
¶ Vine depth.
 Type
int

ppfs
¶ percent point functions from the univariates used by this vine.
 Type
list[callable]

fit
(X, *args, **kwargs)¶

classmethod
from_dict
(vine_dict)[source]¶ Create a new instance from a parameters dictionary.
 Parameters
params (dict) – Parameters of the Vine, in the same format as the one returned by the
to_dict
method. Returns
Instance of the Vine defined on the parameters.
 Return type
Vine

sample
(*args, **kwargs)¶

to_dict
()[source]¶ Return a dict with the parameters to replicate this Vine.
 Returns
Parameters of this Vine.
 Return type
dict

train_vine
(tree_type)[source]¶ Build the vine.
For the construction of the first tree \(T_1\), assign one node to each variable and then couple them by maximizing the measure of association considered. Different vines impose different constraints on this construction. When those are applied different trees are achieved at this level.
Select the copula that best fits to the pair of variables coupled by each edge in \(T_1\).
Let \(C_{ij}(u_i , u_j )\) be the copula for a given edge \((u_i, u_j)\) in \(T_1\). Then for every edge in \(T_1\), compute either
\[\begin{split}{v^1}_{ji} = \\frac{\\partial C_{ij}(u_i, u_j)}{\\partial u_j}\end{split}\]or similarly \({v^1}_{ij}\), which are conditional cdfs. When finished with all the edges, construct the new matrix with \(v^1\) that has one less column u.
Set k = 2.
Assign one node of \(T_k\) to each edge of \(T_ {k−1}\). The structure of \(T_{k−1}\) imposes a set of constraints on which edges of \(T_k\) are realizable. Hence the next step is to get a linked list of the accesible nodes for every node in \(T_k\).
As in step 1, nodes of \(T_k\) are coupled maximizing the measure of association considered and satisfying the constraints impose by the kind of vine employed plus the set of constraints imposed by tree \(T_{k−1}\).
Select the copula that best fit to each edge created in \(T_k\).
Recompute matrix \(v_k\) as in step 4, but taking \(T_k\) and \(vk−1\) instead of \(T_1\) and u.
Set \(k = k + 1\) and repeat from (5) until all the trees are constructed.
 Parameters
tree_type (str or TreeTypes) – Type of trees to use.