Variable hierarchy using my own metric (MATLAB)?
I have 7 variables: A, B, C, D, E, F and G. I have developed my own assignment exponent that compares 2 variables and returns a scalar number. The closer the metric is between two variables, the closer these variables are. For example, if I compare A and B and get 2.2, compare A and C and get 3.3, then A and B are more similar than A and C.
I want to prepare a hierarchy map, perhaps something like a cluster or tree diagram, that will display the similarities if I assign all combinations of similarities.
I know that in MATLAB this is done through the bind function, but the bind function in MATLAB gives me preliminary metrics to compare, such as "Euclidean". I don't need this, I just want to enter my own metrics and map out the distances.
Does anyone have any idea how this can be done?
source to share
Matlab's pdist function allows you to compute an individual pairwise distance metric if you provide a function descriptor for the function you use to compute the distance.
The syntax is simple
my_distance = pdist (pairs, @your_function)
where pairs is the data matrix containing your pairs and @your_function is a handle to the custom distance metric function that you define.
For specific syntax requirements for a custom remote function see the Matlab documentation for pdist .
Then you can use the distance calculated in the hierarchical clustering procedures of the Statistics and Machine Learning toolkit, which I assumed you have because you mentioned the relationship
source to share