Skip to content

Instantly share code, notes, and snippets.

@monogenea
Created October 7, 2019 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monogenea/f3766aa0818a5dad5635edfdd964a1b3 to your computer and use it in GitHub Desktop.
Save monogenea/f3766aa0818a5dad5635edfdd964a1b3 to your computer and use it in GitHub Desktop.
# Perform SVD
mySVD <- svd(mat)
mySVD # the diagonal of Sigma mySVD$d is given as a vector
sigma <- matrix(0,4,4) # we have 4 PCs, no need for a 5th column
diag(sigma) <- mySVD$d # sigma is now our true sigma matrix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment