Using R, how can I create and index using principal components?

Viewed 1397

I have already done PCA analysis- and obtained three principal components- but I don´t know how to transform these into an index. I know, for example, in Stata there ir a command " predict index, score" but I am not finding the way to do this in R. What I want to do is to create a socioeconomic index, from variables such as level of education, internet access, etc, using PCA. Thank you!

1 Answers

In general, I use the PCA scores as an index. See an example below:

# Load the psych package, you could also use princomp in the stats package
library(psych)

# Example data
df <- data.frame(x1 = rnorm(100, 0, .5)
                 , x2 = rnorm(100, 0, 1)
                 , x3 = rnorm(100, .02, 1)
)


# run the PCA
PCA_results <- principal(df, nfactors = 1)

# add our PCA scores as an index
df$index <- PCA_results$scores 

You could rescale the scores if you want them to be on a 0-1 scale.

Related