Learn R Programming

prettyGraphs (version 2.2.0)

prettyScree: prettyScree

Description

prettyScree creates simple, crisp, publication-style scree plots and ``tests'' for SVD-based analyses.

Usage

prettyScree(
  eigs,
  retain.col = "mediumorchid4",
  dismiss.col = "gray",
  perc.exp = 1,
  n.comps = NULL,
  broken.stick = TRUE,
  kaiser = TRUE,
  main = ""
)

Value

comps.tests

a matrix with boolean values. Rows indicate which criteria are used, and columns correspond to components. If TRUE, a component is considered ``retained'' by that test/criteria. If FALSE, the component is ``dismissed'' according to that test/criteria.

Arguments

eigs

a vector of positive eigenvalues.

retain.col

a color for components that are kept.

dismiss.col

a color for components that are dismissed.

perc.exp

a value between 0 and 1. Used to retain components that explain perc.comp * 100 variance. Note: perc.exp retains cumsum(explained variance) < (perc.exp * 100) + 1 component.

n.comps

a value between 1 and length(eigs). Used to retain n.comps number of components.

broken.stick

a boolean. If TRUE (default), the broken-stick test is performed (see details).

kaiser

a boolean. If TRUE (default), all components with eigenvalues greater than the mean(eigs) are retained.

main

A title to be placed at the top of the graph.

Author

Derek Beaton

Details

prettyScree visualizes the distribution of eigenvalues/explained variance from SVD-based analyses. Further, prettyScree performs several rudimentary ``tests''. Two rudimentary criteria are implemented: 1) user selected explained variance, and 2) user selected number of components. Additionally, two rudimentary ``tests'' are implemented: 1) the ``broken-stick'' distribution of variance model, and 2) the ``Kaiser criterion'' where all components that explain more variance than the mean are kept.

prettyScree colors components that ``pass'' all selected tests with retain.col. Any components that do not pass tests are colored by a more transparent version of retain.col. Components that do not meet any criteria for retention are colored by dismiss.col.

prettyScree should be considered ``under development'' as of 12.09.2013. The function works, but we will be adding more features in the near future.

References

Cangelosi, R., & Goriely, A. (2007). Component retention in principal component analysis with application to cDNA microarray data. Biology direct, 2(2), 1--21.

Peres-Neto, P. R., Jackson, D. A., & Somers, K. M. (2005). How many principal components? Stopping rules for determining the number of non-trivial axes revisited. Computational Statistics & Data Analysis, 49(4), 974--997.

See Also

Also see (some of) the other packages that perform a wide array of SVD-based analyses: ExPosition, FactoMineR, ca, ade4

Examples

Run this code

	prcomp.res <- prcomp(USArrests, scale = TRUE)
	prettyScree(prcomp.res$sdev^2)
	##or
	princomp.res <- princomp(USArrests, cor = TRUE)	
	prettyScree(princomp.res$sdev^2)

Run the code above in your browser using DataLab