DBHT Clustering

PortfolioOptimisers.clusterise — Method
clusterise(cle::ClustersEstimator{<:Any, <:Any, <:DBHT, <:Any}, X::MatNum;
           branchorder::Symbol = :optimal, dims::Int = 1, kwargs...)

Run Direct Bubble Hierarchical Tree (DBHT) clustering with a ClustersEstimator whose algorithm is a DBHT.

The method computes the similarity and distance matrices of the data matrix X with the estimators that cle holds, and it runs the DBHT pipeline on them. It returns a Clusters result that holds the dendrogram, the similarity and distance matrices, and the optimal number of clusters.

Algorithm

  1. Take the correlation matrix S and the distance matrix D from X with cle.ce and cle.de, through cor_and_dist. Refuse each asset that the reader could not estimate with assert_distance_reader_rows.
  2. Check with assert_similarity_domain that D lies in the domain that cle.alg.sim needs.
  3. Map D to the non-negative similarity S with distance_to_similarity, through the branch that cle.alg.sim selects.
  4. Run the pipeline with DBHTs, and keep only its last output, the Clustering.Hclust dendrogram res.
  5. Take the number of clusters k from res and D with optimal_number_clusters, through the branch that cle.onc selects.
  6. Wrap res, S, D and k in a Clusters.

Arguments

  • cle: A ClustersEstimator whose algorithm is a DBHT.
  • X: Data matrix, observations × assets when dims is 1 and assets × observations when dims is 2.
  • branchorder: Order method for the dendrogram branches, :optimal by default, :barjoseph or :r. DBHTs states what each value does, and what another value does.
  • dims: Dimension along which the computation runs.
  • kwargs...: Keyword arguments that the method passes to cor_and_dist.

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.

Returns

  • clr::Clusters: DBHT clustering result.

Related

source