Hi all,

I am trying to create a composite index on connectivity, by region (e.g. africa, european union, and latin america). I am doing this by through the use of the Principal Components Analysis (PCA).

In this case, I tried to implement PCA by region and consequently derive the eigenvalue estimates and convert it into variables under the condition that only the components whose eigenvalue is greater than 1 will be retained. Apparently, for some regions, it turns out that there are more than 1 components who qualify under the aforementioned condition. As such, upon converting the eigenvalues of the qualified components into separate variables, I tried to drop the others through the following command:

HTML Code:
       keep EvvAphys`i'* if EvvAphys`i'* > 1
However, I figured that "*" doesn't apparent work inside loops, thus stata returns the "ambiguous" error. In this case, I'd like to ask if there is a way to work around this.

Should it be helpful, there is the complete coding structure:

HTML Code:
global reg_physical regnorm_prop_hhinternet regnorm_rate_trainfra regnorm_score_elec 

foreach i in "apec" "afr" "eu" "lat" {
  pca $reg_physical if str_regn == "`i'"
    estat loadings, cnorm(eigen) 
      matrix Evphys`i' = e(Ev) 
      matrix EvAphys`i' = Evphys`i' // row, column 
      svmat EvAphys`i', names(egphys`i')
      keep EvvAphys`i'* if EvvAphys`i'* > 1  
      replace egphys`i'* = egphys`i'*[1] if egphys`i'* == . 

}
Thank you in advance for your help.