I would like to cluster categorical variables, instead of observations. And then build a dendogram with those. On the documentation of "cluster" it says:
And then on the documentation of cluster linkage there is an example that looks like my case, Example 3.

now, i need to do the same with my dataset.
I have tried to follow the example above, but I get stuck every time. Who can suggest the correct syntax?
thank you for your attention!
Clustering variables instead of observations
Sometimes you want to cluster variables rather than observations, so you can use thecluster
command. One approach to clustering variables in Stata is to usexpose(see [D]xpose) to transpose
the variables and observations and then to usecluster. Another approach is to use thematrix
dissimilaritycommand with thevariablesoption (see [MV]matrix dissimilarity) to produce
a dissimilarity matrix for the variables. This matrix is then passed toclustermatto obtain the
hierarchical clustering. See [MV]clustermat.
Sometimes you want to cluster variables rather than observations, so you can use thecluster
command. One approach to clustering variables in Stata is to usexpose(see [D]xpose) to transpose
the variables and observations and then to usecluster. Another approach is to use thematrix
dissimilaritycommand with thevariablesoption (see [MV]matrix dissimilarity) to produce
a dissimilarity matrix for the variables. This matrix is then passed toclustermatto obtain the
hierarchical clustering. See [MV]clustermat.
now, i need to do the same with my dataset.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(S2_KAT S4 Q27A MENTALITY CITY EU NATO COALITION LEFTRIGHT MONEY CLASS END_MONTH) 6 4 2 0 1 2 1 2 1 3 1 . 3 2 1 1 1 1 1 1 1 2 2 1 6 2 1 1 1 2 2 1 2 3 1 . 3 4 . 1 2 2 2 1 . 4 1 2 3 4 2 0 1 2 . 2 . 4 1 . 6 3 2 0 2 . . . 2 1 2 . 5 3 . 0 1 2 2 2 2 2 2 1 5 4 2 0 2 . . 2 2 4 1 2 5 2 1 . 1 2 2 . . 3 1 1 4 3 1 1 2 2 2 1 2 3 2 . 3 3 1 1 1 2 2 1 1 4 2 2 4 4 1 1 2 2 2 1 1 4 1 . 6 4 1 1 2 2 2 1 2 3 1 . 4 2 2 . 1 2 2 2 2 2 2 1 5 2 . 1 1 . . . . 2 1 1 4 3 . 0 1 1 1 . 1 2 1 1 5 2 2 . 1 1 1 . 2 1 2 . 6 4 2 0 1 . . 1 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2 2 . . 6 3 1 . 3 2 2 1 2 1 1 1 3 2 2 1 2 2 2 2 . 2 1 1 6 3 1 . 1 2 2 1 2 1 2 . 3 4 1 1 3 2 2 1 2 4 1 2 2 4 . 1 2 2 2 . 1 1 1 1 5 2 . 1 1 2 1 . . 1 2 1 3 2 1 . 1 2 2 1 . 4 1 2 2 3 1 1 1 . . 1 2 3 1 1 5 3 2 0 1 2 2 2 1 1 1 1 6 3 1 . 1 2 2 1 2 1 2 . 3 4 . 0 3 . . 1 . 1 1 1 2 3 1 1 2 2 2 1 . 4 1 2 2 2 1 . 1 2 2 1 2 1 2 . 6 3 2 0 2 . . 2 1 3 1 . 4 4 1 . 3 2 2 1 2 2 1 . 6 4 1 1 3 2 2 1 . 1 1 2 3 4 1 1 1 2 2 1 . 3 1 . 2 4 . . 1 2 . . . 1 1 . 3 2 . . 2 1 1 . 1 1 . 2 6 3 1 0 2 2 2 . . 3 1 1 5 4 2 . 2 . . . . 2 1 . 6 4 1 . 1 2 2 1 2 2 1 . 3 4 2 . 1 . 1 1 . 4 1 2 5 3 1 . 3 1 1 1 2 1 2 1 5 4 1 1 2 2 1 2 . 1 2 . 6 2 2 . 2 . . 2 1 3 1 1 5 3 2 0 2 2 2 2 2 4 1 2 6 3 1 1 3 2 2 1 1 3 1 . 3 4 2 1 2 2 2 1 2 2 2 1 3 4 1 1 1 2 2 1 . 2 1 1 3 2 1 . 3 1 1 2 1 1 2 1 6 3 . . 2 2 2 . 2 . 2 . 6 4 1 1 3 2 2 1 2 3 1 2 6 3 2 1 2 1 1 2 2 1 2 1 5 4 1 1 1 2 2 1 2 4 1 2 6 3 2 1 3 2 2 2 1 1 2 1 2 2 2 . 3 1 1 1 1 1 2 1 2 3 . 1 2 . . 1 . 1 2 1 3 4 1 1 2 2 2 1 2 4 2 . end label values S2_KAT labels1 label def labels1 2 "18-29", modify label def labels1 3 "30-39", modify label def labels1 4 "40-49", modify label def labels1 5 "50-59", modify label def labels1 6 "60 a viac", modify label values S4 labels3 label def labels3 2 "bez_maturity", modify label def labels3 3 "maturita", modify label def labels3 4 "vysokoskolske", modify label values Q27A labels49 label def labels49 1 "Ivan Korčok", modify label def labels49 2 "Peter Pellegrini", modify label values MENTALITY MENTALITY label def MENTALITY 0 "SK not backward", modify label def MENTALITY 1 "SK backward", modify label values CITY CITY label def CITY 1 "Village (up to 4999)", modify label def CITY 2 "City (from 5000)", modify label def CITY 3 "more than 100000", modify label values EU EU label def EU 1 "NO EU", modify label def EU 2 "PRO EU", modify label values NATO NATO label def NATO 1 "NO NATO", modify label def NATO 2 "PRO NATO", modify label values COALITION COALITION label def COALITION 1 "Opposition", modify label def COALITION 2 "In Power", modify label values LEFTRIGHT LEFTRIGHT label def LEFTRIGHT 1 "Left", modify label def LEFTRIGHT 2 "right", modify label values MONEY MONEY label def MONEY 1 "up to 1050 eur", modify label def MONEY 2 "1 051 € to 1 400 €", modify label def MONEY 3 "1 401 € to 2 500 €", modify label def MONEY 4 "more than 2501 eur", modify label values CLASS CLASS label def CLASS 1 "White collars", modify label def CLASS 2 "Workers", modify label values END_MONTH END_MONTH label def END_MONTH 1 "Difficult", modify label def END_MONTH 2 "Easy", modify
thank you for your attention!
Comment