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
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'* == . }
0 Response to Using loops in Matrix
Post a Comment