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
- Compute the correlation matrix
Sand the distance matrixDfromXwithnte.nte.deandnte.nte.ce. Refuse each asset that the reader could not estimate withassert_distance_reader_rows. - Build the tree
GoverDwith the entry point ofcalc_weighted_adjacency_graphthat takesalg. Read its weighted adjacency matrixAwithcalc_weighted_adjacency. - Resolve
nte.nte.sepwithresolve_separation, against the structure thatseparation_graphmakes fromG. Read the hop countnfrom the resolved separation. - Add up the matrix of pseudo-distances
Pas the sum ofD^i - A^ioveri in 0:n. - Set the diagonal of
Pto zero. Give the symmetric matrix,SandDto_clusterise.
Arguments
nte: Network clustering estimator, whoseNetworkEstimatorbuilds a minimum spanning tree.X: Data matrixobservations × assetsif thedimskeyword does not exist ordims = 1,assets × observationswhendims = 2.dims: Dimension along which the computation runs.branchorder: Order method for the dendrogram branches,:optimalby default.branch_ordered_hclustandDBHTsstate what each value does.kwargs...: Keyword arguments for the estimators ofnte.
Validation
- No diagonal entry of
DisNaN. Raises aDistanceReaderRefusalErrorthat names the columns of the assets that the reader could not estimate. A fit catches it and drops those assets. - Throws a
DomainErrorif an off-diagonal entry ofDis negative orNaN, throughgraph_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
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
- Compute the correlation matrix and the distance matrix
DfromXwithnte.nte.deandnte.nte.ce. CheckDagainst the domain ofnte.nte.algwithassert_similarity_domain. - Convert the pair to the similarity matrix
Swithdistance_to_similarity. - Build the triangulated maximally filtered graph
GoverSwith the entry point ofcalc_weighted_adjacency_graphthat takesalg. Read its weighted adjacency matrixRpmwithcalc_weighted_adjacency. - Resolve
nte.nte.sepwithresolve_separation, against the structure thatseparation_graphmakes fromG. Read the hop countnfrom the resolved separation. - Add up the matrix of pseudo-distances
Pas the sum ofS^i - Rpm^ioveri in 0:n. - Set the diagonal of
Pto zero. Give the symmetric matrix,SandDto_clusterise.
Arguments
nte: Network clustering estimator, whoseNetworkEstimatorbuilds a PMFG from a similarity matrix.X: Data matrixobservations × assetsif thedimskeyword does not exist ordims = 1,assets × observationswhendims = 2.dims: Dimension along which the computation runs.branchorder: Order method for the dendrogram branches,:optimalby default.branch_ordered_hclustandDBHTsstate what each value does.kwargs...: Keyword arguments for the estimators ofnte.
Validation
- No diagonal entry of
DisNaN. Raises aDistanceReaderRefusalErrorthat names the columns of the assets that the reader could not estimate. A fit catches it and drops those assets. - Throws a
DomainErrorifDleaves the domain ofnte.nte.alg, throughassert_similarity_domain. - Throws a
DomainErrorif a zero weight removes an edge of the triangulated maximally filtered graph, throughassert_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