Created
October 7, 2019 19:03
-
-
Save monogenea/10e7250d2c038cfa30f8c3c305941a0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Compare PCA scores with the SVD's U*Sigma | |
theoreticalScores <- mySVD$u %*% sigma | |
all(round(myPCA$x,5) == round(theoreticalScores,5)) # TRUE | |
# Compare PCA loadings with the SVD's V | |
all(round(myPCA$rotation,5) == round(mySVD$v,5)) # TRUE | |
# Show that mat == U*Sigma*t(V) | |
recoverMatSVD <- theoreticalScores %*% t(mySVD$v) | |
all(round(mat,5) == round(recoverMatSVD,5)) # TRUE | |
# Show that mat == scores*t(loadings) | |
recoverMatPCA <- myPCA$x %*% t(myPCA$rotation) | |
all(round(mat,5) == round(recoverMatPCA,5)) # TRUE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment