Computes the average eigenvalues produced by a Monte Carlo simulation that randomly generates a large number of nxp matrices of standard normal deviates.

horns_curve(data, n, p, nsim = 1000L)

Arguments

data

A matrix or data frame.

n

Integer specifying the number of rows.

p

Integer specifying the number of columns.

nsim

Integer specifying the number of Monte Carlo simulations to run. Default is 1000.

Value

A vector of length p containing the averaged eigenvalues. The values can then be plotted or compared to the true eigenvalues from a dataset for a dimensionality reduction assessment.

References

J. L. Horn, "A rationale and test for the number of factors in factor analysis," Psychometrika, vol. 30, no. 2, pp. 179-185, 1965.

Examples

# Perform Horn's Parallel analysis with matrix n x p dimensions x <- matrix(rnorm(200 * 10), ncol = 10) horns_curve(x)
#> [1] 1.4101301 1.2833549 1.1824088 1.0973557 1.0211361 0.9482947 0.8806428 #> [8] 0.8098271 0.7381270 0.6545347
horns_curve(n = 200, p = 10)
#> [1] 1.4106276 1.2772393 1.1798234 1.0963995 1.0196483 0.9475956 0.8772685 #> [8] 0.8093003 0.7386109 0.6543157
plot(horns_curve(x)) # scree plot