1

How do I go about calculating an index/score from principal component analysis?

Here is a reproducible example

set.seed(1)
dat <- data.frame(
  Diet = sample(1:2),
  Outcome1 = sample(1:10),
  Outcome2 = sample(11:20),
  Outcome3 = sample(21:30),
  Response1 = sample(31:40),
  Response2 = sample(41:50),
  Response3 = sample(51:60)
)

ir.pca <- prcomp(dat[,3:5], center = TRUE, scale. = TRUE) 

summary(ir.pca)

loadings <- ir.pca$rotation

scores <- ir.pca$x

correlations <- t(loadings)*ir.pca$sdev

This generates three principal components. Could I use these to calculate a score or an index called 'Response Index' for each row in the above data?

camille
  • 16,432
  • 18
  • 38
  • 60
DiscoR
  • 247
  • 2
  • 11

0 Answers0