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
- Take the correlation matrix
Sand the distance matrixDfromXwithcle.ceandcle.de, throughcor_and_dist. Refuse each asset that the reader could not estimate withassert_distance_reader_rows. - Check with
assert_similarity_domainthatDlies in the domain thatcle.alg.simneeds. - Map
Dto the non-negative similaritySwithdistance_to_similarity, through the branch thatcle.alg.simselects. - Run the pipeline with
DBHTs, and keep only its last output, theClustering.Hclustdendrogramres. - Take the number of clusters
kfromresandDwithoptimal_number_clusters, through the branch thatcle.oncselects. - Wrap
res,S,Dandkin aClusters.
Arguments
cle: AClustersEstimatorwhose algorithm is aDBHT.X: Data matrix,observations × assetswhendimsis1andassets × observationswhendimsis2.branchorder: Order method for the dendrogram branches,:optimalby default,:barjosephor:r.DBHTsstates what each value does, and what another value does.dims: Dimension along which the computation runs.kwargs...: Keyword arguments that the method passes tocor_and_dist.
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.
Returns
clr::Clusters: DBHT clustering result.
Related