Dear all,

I am currently having some issues grouping some data from my dataset. The thing is that i'm trying to use Cluster Analysis with some of my variables to agroup them into 3 different groups (high innovation, medium innovation and low innovation companies) hierarchically ordered from high to low scores but im having some issues in the process since most of the scores resulted mixes. ¿How can I solve this?

Here is and example of how I need the variables to be grouped:
Array


And this are the result I get it according to my do-file:
Array


This is the do-file i am using to do so

Code:
clear all
ssc install asdoc
set mem 500m
use "C:\Users\PC Victor\Desktop\MCES\MODELO\STATA\BD_prueba1.dta", clear

putdocx begin


///////////////////HOMOGENEIZAR DATOS/////////////////////////
***IAIT****

 replace Acceso_Internet =0 if Acceso_Internet ==2
 replace Acceso_Extranet =0 if Acceso_Extranet ==2
 replace Acceso_Intranet =0 if Acceso_Intranet ==2
 replace Disp_Computo =0 if Disp_Computo ==2
 replace Tareas_Int_Bancos =0 if Tareas_Int_Bancos ==2
 replace Tareas_Int_Tramites =0 if Tareas_Int_Tramites ==2
 replace Tareas_Int_CompVent =0 if Tareas_Int_CompVent ==2
 replace Tareas_Int_Busqueda =0 if Tareas_Int_Busqueda ==2
 replace Tareas_Int_Gestión =0 if Tareas_Int_Gestión ==2
 
 
 
 ***IGIO******
 
 replace Efect_AI_Univ_13 =0 if Efect_AI_Univ_13 ==2
 replace Efect_AI_Emp_13 =0 if Efect_AI_Emp_13 ==2
 replace Efect_AI_Clientes_13 =0 if Efect_AI_Clientes_13 ==2
 replace Efect_AI_CP_13 =0 if Efect_AI_CP_13 ==2
 replace Disp_Pers_13 =0 if Disp_Pers_13 ==2
 replace Fin_AI_Pro_13 =0 if Fin_AI_Pro_13 ==2
 replace Fin_AI_Cre_13 =0 if Fin_AI_Cre_13 ==2
 replace Fin_AI_Apoyo_13 =0 if Fin_AI_Apoyo_13 ==2
 replace Fin_AI_Otros_13 =0 if Fin_AI_Otros_13 ==2
 replace Efect_ProtInd_Registros_13 =0 if Efect_ProtInd_Registros_13 ==2
 replace Efect_ProtInd_Contrat_13 =0 if Efect_ProtInd_Contrat_13 ==2
 
 ******CREAR INDICES*****
 
  generate long ITEM1 = 0
  generate long ITEM2 = 0
  generate long ITEM3 = 0
  generate long ITEM4 = 0
  generate long ITEM5 = 0
  generate long ITEM6 = 0
  generate long ITEM7 = 0
  generate long ITEM8 = 0
  generate long ITEM9 = 0
  generate long ITEM10 = 0
  generate long ITEM11 = 0
  generate long ITEM12 = 0
  generate long ITEM13 = 0
  generate long ITEM14 = 0
  generate long ITEM15 = 0
  generate long ITEM16 = 0
  generate long ITEM17 = 0
  generate long ITEM18 = 0
  generate long ITEM19 = 0
  generate long ITEM20 = 0
/////////////VALORES DE ITEMS///////////////
***IAIT***

  replace ITEM1 =1 if Disp_Computo ==1
  replace ITEM2 =3 if Tareas_Int_Bancos ==1
  replace ITEM3 =3 if Tareas_Int_Tramites ==1
  replace ITEM4 =3 if Tareas_Int_CompVent ==1
  replace ITEM5 =3 if Tareas_Int_Busqueda ==1
  replace ITEM6 =3 if Tareas_Int_Gestión ==1
  replace ITEM7 =2 if Acceso_Internet ==1
  replace ITEM8 =2 if Acceso_Extranet ==1
  replace ITEM9 =2 if Acceso_Intranet ==1
  
***IGIO******

  replace ITEM10 = 1 if Efect_AI_Univ_13 ==1
  replace ITEM11 = 1 if Efect_AI_Emp_13 ==1
  replace ITEM12 = 1 if Efect_AI_Clientes_13 ==1
  replace ITEM13 = 1 if Efect_AI_CP_13 ==1
  replace ITEM14 = 4 if Efect_ProtInd_Registros_13 ==1
  replace ITEM15 = 4 if Efect_ProtInd_Contrat_13 ==1
  replace ITEM16 =3 if Fin_AI_Pro_13 ==1
  replace ITEM17 =3 if Fin_AI_Cre_13 ==1
  replace ITEM18 =3 if Fin_AI_Apoyo_13 ==1
  replace ITEM19 =3 if Fin_AI_Otros_13 ==1
  replace ITEM20 =2 if Disp_Pers_13 ==1
  
  
  generate long SUM_IAIT = ITEM1+ ITEM2+ITEM3+ITEM4+ITEM5+ITEM6+ITEM7+ITEM8+ITEM9
  generate long SUM_IGIO = ITEM10+ITEM11+ITEM12+ITEM13+ITEM14+ITEM15+ITEM16+ITEM17+ITEM18+ITEM19+ITEM20
  
  
  generate long IAIT = 4.54545454545455 * SUM_IAIT
  generate long IGIO = 3.846153846 * SUM_IGIO
  generate long IIET = 2.083333333 * SUM_IAIT + SUM_IGIO
  
 ******INDICADORES DE DESEMPEÑO*********
 drop if Prod_Brut_Tot ==.
 drop if Remu_Tot ==.
 drop if Consumo_Int ==.
 drop if Val_Ag_Cens_Brut ==.
 drop if Pers_Ocup_Tot ==.
 drop if Ingresos_Aloj ==.
 
 
 generate long Utilidades = Prod_Brut_Tot - Remu_Tot - Consumo_Int
 generate long Productividad =  Val_Ag_Cens_Brut / Pers_Ocup_Tot
 generate long Ingresosxhab = Ingresos_Aloj / Hab_Tot_Hot+ Hab_Tot_Mot+ Hab_Tot_Cab+ Hab_Tot_TP+ Hab_Tot_Trailer+ Hab_Tot_Camp+ Hab_Tot_BB+ Hab_Tot_Pos+ Hab_Tot_Hos+ Hab_Tot_Otros /365  

asdoc mean Productividad Ingresosxhab Utilidades IAIT IGIO IIET, save(propuesta5)
asdoc summarize Productividad Ingresosxhab Utilidades IAIT IGIO IIET, save(propuesta5)
asdoc correlate Productividad Ingresosxhab Utilidades IAIT IGIO IIET, save(propuesta5)
asdoc spearman Productividad Ingresosxhab Utilidades IAIT IGIO IIET, save(propuesta5)
  
***** CLUSTER ******************
///////POR GRUPOS DE INNOVACIÓN///////
cluster singlelinkage IAIT IGIO IIET Utilidades Productividad Ingresosxhab, measure(L2) name(CLUS_PRUE1)
cluster generate CLUS_GR1 = groups(3), name(CLUS_PRUE1) ties(error)

cluster kmeans Utilidades Productividad  Ingresosxhab IAIT IGIO IIET, k(3) measure(L2) name(K_MEDIAS) start(krandom)
asdoc table K_MEDIAS , contents(freq mean Productividad mean Ingresosxhab mean Utilidades) dec(2), save(propuesta5)
asdoc table K_MEDIAS , contents(freq mean IAIT mean IGIO mean IIET ) dec(2), save(propuesta5)

cluster averagelinkage Utilidades Productividad Ingresosxhab IAIT IGIO IIET, measure(L2) name(clus_enlaceprom)
cluster generate clus_enlaceprom_grup = groups(3), name(clus_enlaceprom) ties(error)
asdoc table clus_enlaceprom_grup , contents(freq mean Productividad mean Ingresosxhab mean Utilidades ) dec(2), save(propuesta5)
asdoc table clus_enlaceprom_grup , contents(freq mean IAIT mean IGIO mean IIET ) dec(2), save(propuesta5)

cluster wardslinkage Utilidades Productividad Ingresosxhab IAIT IGIO IIET, measure(L2) name(CLU_ward)
cluster generate CLUSTER_WARD = groups(3), name(CLU_ward) ties(error)
asdoc table CLUSTER_WARD , contents(freq mean Utilidades mean Productividad mean Ingresosxhab ) dec(2), save(propuesta5)
asdoc table CLUSTER_WARD , contents(freq mean IAIT mean IGIO mean IIET) dec(2), save(propuesta5)

cluster singlelinkage IAIT IGIO IIET, measure(L2) name(clus_innov)
cluster generate CLUSTER_VAR_INNOV = groups(3), name(clus_innov) ties(error)
asdoc table CLUSTER_VAR_INNOV , contents(freq mean Utilidades mean Productividad mean Ingresosxhab) dec(2), save(propuesta5)
asdoc table CLUSTER_VAR_INNOV , contents(freq mean IAIT mean IGIO mean IIET) dec(2), save(propuesta5)


asdoc table CLUS_GR1, contents(freq mean Productividad mean Ingresosxhab mean Utilidades ) dec(2), save(propuesta5)
asdoc table CLUS_GR1, contents(freq mean IAIT mean IGIO mean IIET ) dec(2), save(propuesta5)
 
 //////POR CATEGORÍA////////////////////////
 asdoc table Categoría, contents(freq mean Productividad mean Ingresosxhab mean Utilidades ) dec(2), save(propuesta5)
 asdoc table Categoría, contents(freq mean IAIT mean IGIO mean IIET ) dec(2), save(propuesta5)
 
 
  
  /////POR TAMAÑO////////////////
 generate long Categoría_Personal = 0
 replace Categoría_Personal =1 if Pers_Ocup_Tot <=10
 replace Categoría_Personal =2 if Pers_Ocup_Tot >10 & Pers_Ocup_Tot <51
 replace Categoría_Personal =3 if Pers_Ocup_Tot >51 & Pers_Ocup_Tot <101
 replace Categoría_Personal =4 if Pers_Ocup_Tot >101
 
 asdoc table Categoría_Personal, contents(freq mean Productividad mean Ingresosxhab mean Utilidades ) dec(2), save(propuesta5)
 asdoc table Categoría_Personal, contents(freq mean IAIT mean IGIO mean IIET ) dec(2), save(propuesta5)
I really appreciate any help you can provide.


Thank you