Dear all,
I an trying to perform a PCA analysis by company on panel data.
The goal is to create an index out of multiple variables for each company which should use the same variable name (aware_pca_test) for all companies.
Currently my code looks like this
The loop seems to work, but the pca always creates the same value. Am i not looping correctly through the values for í'?
Any advice would be most appreciated.
Thanks and best,
Micha
I an trying to perform a PCA analysis by company on panel data.
The goal is to create an index out of multiple variables for each company which should use the same variable name (aware_pca_test) for all companies.
Currently my code looks like this
Code:
levelsof gvkey, local(gvkeys) gen aware_pca_final =. foreach i of local gvkeys{ pca Awareness_score womexposure_score if gvkey == `i' rotate predict aware_pca_test replace aware_pca_final = aware_pca_test if gvkey == `i' drop aware_pca_test }
Any advice would be most appreciated.
Thanks and best,
Micha
Comment