# Prediction with Principal Component Analysis

I'm trying to predict GDP per capita from about 50 variables, and the PCA shows that the two principal components explain about 40% of the variance. But I want it to show how much of the variance in GDP per capita specifically, it explains. Because when I graph GDP per capita against predicted using the first two principal components, I get an R^2 of about 90%.

When I try setting up my PCA on R, I don't know how to specify that the point of this is to explain variation in GDP per capita (not the other variables.)

I have:
pca <- prcomp(allexceptgdppc, center = TRUE, scale = TRUE)
zpca <- predict(pca, all)

Maybe I need to specify the variable GDP per capita, instead of all, but it says I must use a dataframe.

Any help would be amazing, thanks so much.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.