Description Usage Arguments Details Value Author(s) Examples
View source: R/findElbowPoint.R
Find the elbow point in the curve of variance explained by each successive PC. This can be used to determine the number of PCs to retain.
1 | findElbowPoint(variance)
|
variance |
Numeric vector containing the variance explained by each PC. Should be monotonic decreasing. |
Find the elbow point in the curve of variance explained by each successive PC. This can be used to determine the number of PCs to retain.
An integer scalar specifying the number of PCs at the elbow point.
Aaron Lun
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | col <- 20
row <- 1000
mat <- matrix(rexp(col*row, rate = 1), ncol = col)
# Adding some structure to make it more interesting.
mat[1:100,1:3] <- mat[1:100,1:3] + 5
mat[1:100+100,3:6] <- mat[1:100+100,3:6] + 5
mat[1:100+200,7:10] <- mat[1:100+200,7:10] + 5
mat[1:100+300,11:15] <- mat[1:100+300,11:15] + 5
p <- pca(mat)
chosen <- findElbowPoint(p$variance)
plot(p$variance)
abline(v=chosen, col="red")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.