1

A trainer did this in a video. He just gave a quick explanation that he does this because of R's default nature. However, I have never seen this application before. Is it correct, and why he does this?

pca <- prcomp(data, scale=TRUE)
pca$rotation <- -pca$rotation
pca$x        <- -pca$x
StupidWolf
  • 45,075
  • 17
  • 40
  • 72
Maria
  • 47
  • 4

2 Answers2

0

It's a bit odd, there's nothing to do with R's nature etc. It might have something to do with the data, and what the pca is used for. Since the data is scaled, by adding taking the negative, you are just flipping the principal component scores:

data = iris[,1:4]
pca <- prcomp(data, scale=TRUE)

par(mfrow=c(1,2))
plot(pca$x[,1:2],col=factor(iris$Species),main="original")
plot(-pca$x[,1:2],col=factor(iris$Species),main="negative")

enter image description here

If you use it for regression etc.. it doesn't really quite matter.

StupidWolf
  • 45,075
  • 17
  • 40
  • 72
0

The PCA is an unsupervised-learning algorithm and it doesn't identify the information about the group.

You should use the rotation matrix to try to undestand better the results.

This why?

Because you assumed that underlying factors are orthonormal. The solution is a set of factor with unique variances. The maximum likelihood solution is an orthogonal transformation of the factor. It makes sense to rotate the matrix to maximises ease of interpretation.

If you want to deep the argument about the factor analysis, I suggest you to visit this. The link that I wrote above is the official page of the FactoMiner package. Here, instead, you can find the videos (that the autor of the package did) about explanation of the FactoMiner package and all the functions about the factor analysis and so on.

Earl Mascetti
  • 1,278
  • 3
  • 16
  • 31