selkarlis: Heuristic selection of the dimension of a PCA model with the...

View source: R/selkarlis.R

selkarlisR Documentation

Heuristic selection of the dimension of a PCA model with the Karlis et al. method

Description

The function helps selecting the dimension (i.e. nb. components) of a PCA model using the method proposed by Karlis et al. 2003.

The method is a modified version of the Guttman-Kaiser rule (see function selkaiser). The input matrix X is centered and scaled internally to the function. The eigenvalues are compared to the mean eigenvalue (= 1) plus an approximate standard error that accounts for estimation uncertainty (see Karlis et al. 2003).

Usage


selkarlis(X, ncomp, algo = NULL,
    plot = TRUE,
    xlab = "Nb. components", ylab = NULL,
    ...)

Arguments

X

A n x p matrix or data frame of variables.

ncomp

The maximal number of PCA scores (= components = latent variables) to be calculated.

algo

A function (algorithm) implementing a PCA. Default to NULL: if n < p, pca_eigenk is used; in the other case, pca_eigen is used.

plot

Logical. If TRUE (default), the results are plotted.

xlab

Label for the x-axis of the plot.

ylab

Label for the y-axis of the plot.

...

Optionnal arguments to pass in the function defined in algo.

Value

A list of several items, see the examples. Output opt is the selected number of components.

References

Karlis, D., Saporta, G., Spinakis, A., 2003. A Simple Rule for the Selection of Principal Components. Communications in Statistics - Theory and Methods 32, 643–666. https://doi.org/10.1081/STA-120018556

Examples


data(datoctane)
X <- datoctane$X
## removing outliers
zX <- X[-c(25:26, 36:39), ]
plotsp(zX)

ncomp <- 30
selkarlis(zX, ncomp = ncomp)


mlesnoff/rnirs documentation built on April 24, 2023, 4:17 a.m.