How can I perform ‘Hierarchical Clustering’ by Absolute value of correlation?

I’m trying to do hierarchical clustering in MATLAB using ‘linkage’ and ‘pdist’ functions. I’m familiar with the functions, but I’m attempting to cluster by the absolute value of the correlation values.

The default for the ‘pdist’ function, ‘correlation’, would include both the positive and negatives, but I’m interested in grouping inverse relationships as well.

Does anyone know how I can achieve this?

NOTE:-

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

There are two ways in which this can be done:

First, notice that ‘pdist’ computes one minus the correlations among rows:

>> x
x =
1 2 3 4
2 3 2 3
1 2 3 4
4 3 2 1
>> pdist(x,'cor')
ans =
0.5528 0 2.0000 0.5528 1.4472 2.0000
>> 1-corr(x')
ans =
0 0.5528 0 2.0000
0.5528 0 0.5528 1.4472
0 0.5528 0 2.0000
2.0000 1.4472 2.0000 0

1) The first way is to compute the distance as one minus the absolute correlation, and compute linkage based on that.

>> D = pdist(x,'cor');>> linkage(D,'single')
ans =
1.0000 3.0000 0
2.0000 5.0000 0.5528
4.0000 6.0000 1.4472
>> C = 1-D % get correlation
C =
0.4472 1.0000 -1.0000 0.4472 -0.4472 -1.0000
>> D = 1-abs(C) % get 1-abs(correlation)
D =
0.5528 0 0 0.5528 0.5528 0
>> linkage(D,'single') % cluster using that
ans =
3.0000 4.0000 0
1.0000 5.0000 0
2.0000 6.0000 0.5528

Notice that points 1,3,4 are clustered with zero distance, even though the correlation with the point 4 is ‘-1’.

SEE COMPLETE ANSWER CLICK THE LINK

--

--

--

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

ENEM — Math score predictor

Basic data analysis in R- Part I- Univariate analysis

What we learnt from Ray Poynter’s sense-making with open-ended text

HOW TO LEARN PYTHON FOR DATA SCIENTISTS

Optimism Bias in Transport Planning

New York City Citi Bike Trip Pattern in March 2020

Occam’s Laser: Big Twitter and the Small Data Revolution

Denver City Exploration with Python

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Technical Source

Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

More from Medium

How can I use the “predictorImportance” function with models

A Deep Learning Based Hybrid Approach for Short-Term Forecasting of spread of COVID-19

Housing Price Prediction

Quick overview of few optimizers used for Neural Networks