copulas.multivariate.tree module
Multivariate trees module.
- class copulas.multivariate.tree.CenterTree(random_state=None)[source]
Bases:
TreeTree for a C-vine copula.
- get_anchor()[source]
Find anchor variable with highest sum of dependence with the rest.
- Returns:
Anchor variable.
- Return type:
int
- tree_type = 0
- class copulas.multivariate.tree.DirectTree(random_state=None)[source]
Bases:
TreeDirectTree class.
- tree_type = 1
- class copulas.multivariate.tree.Edge(index, left, right, copula_name, copula_theta)[source]
Bases:
objectRepresents an edge in the copula.
- classmethod from_dict(edge_dict)[source]
Create a new instance from a parameters dictionary.
- Parameters:
params (dict) – Parameters of the Edge, in the same format as the one returned by the
to_dictmethod.- Returns:
Instance of the edge defined on the parameters.
- Return type:
- classmethod get_child_edge(index, left_parent, right_parent)[source]
Construct a child edge from two parent edges.
- classmethod get_conditional_uni(left_parent, right_parent)[source]
Identify pair univariate value from parents.
- get_likelihood(uni_matrix)[source]
Compute likelihood given a U matrix.
- Parameters:
uni_matrix (numpy.array) – Matrix to compute the likelihood.
- Returns:
likelihood and conditional values.
- Return type:
tuple (np.ndarray, np.ndarray, np.array)
- is_adjacent(another_edge)[source]
Check if two edges are adjacent.
- Parameters:
another_edge (Edge) – edge object of another edge
- Returns:
True if the two edges are adjacent.
- Return type:
bool
- class copulas.multivariate.tree.RegularTree(random_state=None)[source]
Bases:
TreeRegularTree class.
- tree_type = 2
- class copulas.multivariate.tree.Tree(random_state=None)[source]
Bases:
MultivariateHelper class to instantiate a single tree in the vine model.
- fit(index, n_nodes, tau_matrix, previous_tree, edges=None)[source]
Fit this tree object.
- Parameters:
index (int) – index of the tree.
n_nodes (int) – number of nodes in the tree.
tau_matrix (numpy.array) – kendall’s tau matrix of the data, shape (n_nodes, n_nodes).
previous_tree (Tree) – tree object of previous level.
- fitted = False
- classmethod from_dict(tree_dict, previous=None)[source]
Create a new instance from a parameters dictionary.
- Parameters:
params (dict) – Parameters of the Tree, in the same format as the one returned by the
to_dictmethod.- Returns:
Instance of the tree defined on the parameters.
- Return type:
- get_adjacent_matrix()[source]
Get adjacency matrix.
- Returns:
adjacency matrix
- Return type:
numpy.ndarray
- get_likelihood(uni_matrix)[source]
Compute likelihood of the tree given an U matrix.
- Parameters:
uni_matrix (numpy.array) – univariate matrix to evaluate likelihood on.
- Returns:
likelihood of the current tree, next level conditional univariate matrix
- Return type:
tuple[float, numpy.array]
- get_tau_matrix()[source]
Get tau matrix for adjacent pairs.
- Returns:
tau matrix for the current tree
- Return type:
tau (numpy.ndarray)
- to_dict()[source]
Return a dict with the parameters to replicate this Tree.
- Returns:
Parameters of this Tree.
- Return type:
dict
- tree_type = None