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

View source: R/selhorn.R

selhornR Documentation

Heuristic selection of the dimension of a PCA model with the Horn method

Description

The function helps selecting the dimension (i.e. nb. components) of a PCA model using the method proposed by Horn 1965.

The input matrix X is centered and scaled internally to the function. The eigenvalues are compared to the mean eigenvalues of a given number of random matrices of same size as X and with uncorrelated structure. The random matrices are built from the standart normal distribution (Dinno 2009).

Usage


selhorn(X, ncomp, algo = NULL,
    nrep = 10,
    plot = TRUE,
    xlab = "Nb. components", ylab = NULL,
    print = TRUE,
    ...)

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.

nrep

Number of random matrices built.

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.

print

Logical. If TRUE (default), fitting information are printed.

...

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

Dinno, A., 2009. Exploring the Sensitivity of Horn’s Parallel Analysis to the Distributional Form of Random Data. Multivariate Behavioral Research 44, 362-388. https://doi.org/10.1080/00273170902938969

Horn, J.L., 1965. A rationale and test for the number of factors in factor analysis. Psychometrika 30, 179-185. https://doi.org/10.1007/BF02289447

Jackson, D.A., 1993. Stopping Rules in Principal Components Analysis: A Comparison of Heuristical and Statistical Approaches. Ecology 74, 2204-2214. https://doi.org/10.2307/1939574

Examples


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

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


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