Hello, I'm trying to calculate the Silhouette coefficient after applying a cluster analysis, I'm using the following code:
egen idvar = seq(), from(1) to(`=_N') block(1)
gen dist = .
replace dist = sqrt((age - age[_N])^2 + (monthly_expenses - monthly_expenses[_N])^2)
gen silhouette_var = .
silhouette silhouette_var, idvar(idvar) distmat(dist) cluster(Groups)
As you can see the "dist" variable is created, but when calculating the coefficient, the program says it can't find it. Does anyone have any idea what the error is?
Comment