Learn R Programming

STATegRa (version 1.0.0)

PCA.selection: Selection of optimal number of components using PCA

Description

Function to select the number of optimal components using Principal Components Analysis. There are four different criterions to select the number of components: accumulated variance explained, the individual explained variance of each component, the absolute value of its variability or just a fixed number of components.

Usage

PCA.selection(Data,fac.sel,varthreshold=NULL,nvar=NULL,PCnum=NULL)

Arguments

Data
Matrix with data. Samples has to be in columns and variables in rows
fac.sel
Criterium for selecting number of components. The posible option are: "%accum", "single%", "rel.abs" and "fixed.num"
varthreshold
Threshold for the selection of components in "%accum", "single%" criterions
nvar
Threshold applied when the option "rel.abs" is selected
PCnum
Fixed number of components to select when the option"fixed.num" is selected

Value

The function returns a list with the following components:
PCAres
A list containing the results of the PCA decomposition
numComps
Number of selected components applying the selected criterion
The components of PCAres list are the following:
eigen
Eigen values of the decomposition
var.exp
Explained variance of each component
scores
Matrix of scores
loadings
Matrix of loadings

See Also

modelSelection

Examples

Run this code
data(STATegRa_S3)
ps <- PCA.selection(Data=Block2.PCA,fac.sel="single%",varthreshold=0.03)
ps$numComps

Run the code above in your browser using DataLab