Dear all,
I am using Stata 13.1 on Windows and created a dissimilarity matrix using SQ-Ados, see my code below.
My goal is to validate the Wards clustering with clustermat stop. How can I perform clustermat stop based on the Wards clusters? Do I need to use sqclusterdat, return first and then apply clustermat stop? It is unclear to me what would be the correct input for variables in the clustermat stop syntax.
Many thanks for your help.
I am using Stata 13.1 on Windows and created a dissimilarity matrix using SQ-Ados, see my code below.
Code:
* Use specified csv as input
import delimited using C:\Users\04BAJ\Documents\Stata\170703_CFO_SQ_v01.csv, delimiters (";")
* Prepare data for SQ analysis
reshape long year, i(id) j(order)
encode year, generate(value)
drop year
sqset value id order, trim
* Input substitution cost matrix
matrix input sub = (0.000,0.274,0.332,0.606,0.394,0.668,0.726,1.000\0.274,0.000,0.606,0.332,0.668,0.394,1.000,0.726\0.332,0.606,0.000,0.274,0.726,1.000,0.394,0.668\0.606,0.332,0.274, 0.000,1.000,0.726,0.668,0.394\0.394,0.668,0.726,1.000,0.000,0.274,0.332,0.606\0.668,0.394,1.000,0.726,0.274,0.000,0.606,0.332\0.726,1.000,0.394,0.668,0.332,0.606,0.000,0.274\ 1.000, 0.726,0.668,0.394,0.606,0.332,0.274,0.000)
* Perform full SQ Analysis with specified substitution and in/del cost
sqom, full indelcost(0.49) subcost(sub)
* Save dissimilarity matrix to file and replace existing file
sqom save SQdist, replace
* Prepare data for clustering
sqclusterdat
* Perform clustering of the dissimilarity matrix using Wards
clustermat wardslinkage SQdist, name(wards) add
* Calculate Calinski stopping rules for cluster 2 to 10 as generated by Wards and name resulting matrix Calinski
clustermat stop, variables(value) rule(calinski) groups(2/10) matrix(calinski)
Many thanks for your help.

Comment