0

I wanted to determine the values of those red arrows created by the biplot() with the usage of prcomp() function. I would like to determine arrows length and position to compare them more accurately. Here is the code that I use:

df <- read.csv(file = "data/PCA_data_all.csv", sep = ",")
df <- df %>%
  separate(model_name, into = c("Make"), sep = " ", remove = FALSE)
df <- df %>%
  select(-model_name)
df[,2:31] <- scale(df[,2:31])
brand.mean <- aggregate(df[,2:31], list(df[,1]), mean)
row.names(brand.mean) <- brand.mean$Group.1
brand.mean <- brand.mean[,-1]
rating.pc <- prcomp(brand.mean, scale=TRUE)
plot(rating.pc, type="l")
biplot(rating.pc, main="Brand Positioning", cex=c(0.5, 0.5))

From what I understand biplot() itself doesn't let you see those values which is a shame :/

Phil
  • 7,287
  • 3
  • 36
  • 66
Axton
  • 83
  • 5

1 Answers1

1

The coordinates of the arrow heads are "nothing but" the variables' loadings on the two principle components shown in the biplot (plus some proportional scaling* to fit with the observations' scores in the same plot).

If rating.pc is your prcomp result, you will get the loadings from rating.pc$rotation. For example, a prcomp result pc with four principal components will return this structure of loadings:

> pc$rotation
                     PC1         PC2         PC3        PC4
Sepal.Length  0.36138659 -0.65658877  0.58202985  0.3154872
Sepal.Width  -0.08452251 -0.73016143 -0.59791083 -0.3197231
Petal.Length  0.85667061  0.17337266 -0.07623608 -0.4798390
Petal.Width   0.35828920  0.07548102 -0.54583143  0.7536574

... from which angle and length in, e.g., the PC1 x PC2 - plane are readily calculated and compared.

* for details, enter stats:::biplot.prcomp

I_O
  • 4,983
  • 2
  • 2
  • 15