| ggscreeplot | R Documentation |
Show how much variation each retained principal component
from rpca captures in the processed data. Plot individual
component variances, their proportions of total variance,
or the cumulative proportion to assess how much variation the retained
representation captures. The optional ggplot2 package is required.
ggscreeplot(rpcaObj, type = c("var", "ratio", "cum", "eigenvals"))
rpcaObj |
An object returned by |
type |
Character string selecting the vertical-axis
quantity. |
The horizontal axis follows the retained components in their fitted order. The variance and eigenvalue views show how much variation each component captures, in squared units of the processed input. The ratio view expresses each amount as a proportion of total variance; the cumulative view adds those proportions through each displayed component.
Both proportion views use rpcaObj$var as their denominator. This
total includes energy outside the retained components, so the cumulative
curve can end below one when the fit retains only a low-rank approximation.
The proportions lie between zero and one when total processed variance is
positive. They are undefined for an input with zero total processed
variance.
Interpretation follows the preprocessing used in rpca.
With center = FALSE, the quantities use uncentered sums of squares,
which include the contribution of any nonzero column means. They need not
equal variances computed after subtracting the means of the fitted score
columns.
A ggplot2 plot object. Print the object to draw the plot, or add layers, labels, and themes with ggplot2.
N. Benjamin Erichson
rpca, ggbiplot,
ggcorplot, ggindplot,
ggplot
if (requireNamespace("ggplot2", quietly = TRUE)) {
set.seed(42)
fit <- rpca(iris[, 1:4], k = 2, retx = FALSE)
# The curve uses all processed variance, including omitted components.
print(ggscreeplot(fit, type = "cum"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.