Phylogeny Clustering

PortfolioOptimisers.clusterise — Method
clusterise(nte::NetworkClustersEstimator{<:NetworkEstimator{<:Any, <:Any,
                                                            <:AbstractTreeType,
                                                            <:HopCount}},
           X::MatNum; dims::Int = 1, branchorder::Symbol = :optimal, kwargs...)

Cluster the assets over a minimum spanning tree, and return a Clusters result.

The method builds the tree from the distance matrix. It adds up the symmetric matrix of pseudo-distances P as $\sum_{i=0}^{n}(\mathbf{D}^i - \mathbf{A}^i)$ over the hop count n. _clusterise then clusters P and selects the number of clusters.

$\mathbf{A}$ is the matrix of calc_weighted_adjacency, read from the graph of calc_weighted_adjacency_graph through the method that takes G. This method reads the same structure as every other consumer of a network. $\mathbf{A}$ carries weights, and not 0 and 1. The polarity of the tree branch is the distance, so $\mathbf{D}^i - \mathbf{A}^i$ subtracts a quantity of the same kind. The method uses the entry point that takes alg, because it already holds D. It keeps the graph, so that a budget rule resolves over it and the distance is not computed again.

The method admits only a hop count

The fourth type parameter is bound to HopCount, so a PathLength separation fails at dispatch. nte.nte.sep.n.val indexes the sum of powers, and a matrix power counts edges. A radius has no equivalent of $\mathbf{D}^i - \mathbf{A}^i$, so the refusal is correct, and it is not a missing method. phylogeny_matrix has a method for a radius, so the two consumers of a network are different here on purpose.

Algorithm

  1. Compute the correlation matrix S and the distance matrix D from X with nte.nte.de and nte.nte.ce. Refuse each asset that the reader could not estimate with assert_distance_reader_rows.
  2. Build the tree G over D with the entry point of calc_weighted_adjacency_graph that takes alg. Read its weighted adjacency matrix A with calc_weighted_adjacency.
  3. Resolve nte.nte.sep with resolve_separation, against the structure that separation_graph makes from G. Read the hop count n from the resolved separation.
  4. Add up the matrix of pseudo-distances P as the sum of D^i - A^i over i in 0:n.
  5. Set the diagonal of P to zero. Give the symmetric matrix, S and D to _clusterise.

Arguments

  • nte: Network clustering estimator, whose NetworkEstimator builds a minimum spanning tree.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which the computation runs.
  • branchorder: Order method for the dendrogram branches, :optimal by default. branch_ordered_hclust and DBHTs state what each value does.
  • kwargs...: Keyword arguments for the estimators of nte.

Validation

  • No diagonal entry of D is NaN. Raises a DistanceReaderRefusalError that names the columns of the assets that the reader could not estimate. A fit catches it and drops those assets.
  • Throws a DomainError if an off-diagonal entry of D is negative or NaN, through graph_weight_matrix.

Returns

  • clr::Clusters: Clustering result. It holds the clustering, the similarity matrix, the distance matrix, the matrix of pseudo-distances and the number of clusters.

Related

source
PortfolioOptimisers.clusterise — Method
clusterise(nte::NetworkClustersEstimator{<:NetworkEstimator{<:Any, <:Any,
                                                            <:AbstractNonNegativeSimilarityMatrixAlgorithm,
                                                            <:HopCount}},
           X::MatNum; dims::Int = 1, branchorder::Symbol = :optimal, kwargs...)

Cluster the assets over a planar maximally filtered graph (PMFG), and return a Clusters result.

The method builds the PMFG from the similarity matrix with PMFG_T2s. It adds up the symmetric matrix of pseudo-distances P as $\sum_{i=0}^{n}(\mathbf{S}^i - \mathbf{A}^i)$ over the hop count n. _clusterise then clusters P and selects the number of clusters.

$\mathbf{A}$ is the matrix of calc_weighted_adjacency, read from the graph as in the tree method. The polarity of this branch is the similarity, so $\mathbf{S}^i - \mathbf{A}^i$ also subtracts a quantity of the same kind. The method uses the entry point that takes alg, because it already holds S, and it keeps the graph for the same reason as the tree method.

The method admits only a hop count

The fourth type parameter is bound to HopCount, so a PathLength separation fails at dispatch. A matrix power counts edges, and a radius has no equivalent of the sum of powers, as in the tree method.

Algorithm

  1. Compute the correlation matrix and the distance matrix D from X with nte.nte.de and nte.nte.ce. Check D against the domain of nte.nte.alg with assert_similarity_domain.
  2. Convert the pair to the similarity matrix S with distance_to_similarity.
  3. Build the triangulated maximally filtered graph G over S with the entry point of calc_weighted_adjacency_graph that takes alg. Read its weighted adjacency matrix Rpm with calc_weighted_adjacency.
  4. Resolve nte.nte.sep with resolve_separation, against the structure that separation_graph makes from G. Read the hop count n from the resolved separation.
  5. Add up the matrix of pseudo-distances P as the sum of S^i - Rpm^i over i in 0:n.
  6. Set the diagonal of P to zero. Give the symmetric matrix, S and D to _clusterise.

Arguments

  • nte: Network clustering estimator, whose NetworkEstimator builds a PMFG from a similarity matrix.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • dims: Dimension along which the computation runs.
  • branchorder: Order method for the dendrogram branches, :optimal by default. branch_ordered_hclust and DBHTs state what each value does.
  • kwargs...: Keyword arguments for the estimators of nte.

Validation

  • No diagonal entry of D is NaN. Raises a DistanceReaderRefusalError that names the columns of the assets that the reader could not estimate. A fit catches it and drops those assets.
  • Throws a DomainError if D leaves the domain of nte.nte.alg, through assert_similarity_domain.
  • Throws a DomainError if a zero weight removes an edge of the triangulated maximally filtered graph, through assert_pmfg_weights.

Returns

  • clr::Clusters: Clustering result. It holds the clustering, the similarity matrix, the distance matrix, the matrix of pseudo-distances and the number of clusters.

Related

source