Learn R Programming

AnomalyDetection (version 0.1.2)

horns_curve: Horn's Parallel Analysis

Description

horns_curve computes the average eigenvalues produced by a Monte Carlo simulation that randomly generates a large number of matrices of size n x p, where each element is drawn from a standard normal probability distribution. If a data matrix or data frame is supplied n and p will be extracted from the data dimensions. Otherwise, n and p must be supplied.

Usage

horns_curve(data, n = NULL, p = NULL)

Arguments

data

numeric data

n

integer value representing number of rows (default = NULL)

p

integer value representing number of columns (default = NULL)

Value

A vector of length p with the computed average eigenvalues. The values can then be plotted or compared to the true eigenvalues of a dataset for a dimensionality 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

Run this code
# NOT RUN {
# Perform Horn's Parallel analysis with matrix n x p dimensions
x <- matrix(rnorm(200*3), ncol = 10)

# using data
horns_curve(x)

# using n & p inputs
horns_curve(data = NULL, n = 25, p = 10)

# Graph the scree line for a dimensionality assessment
horns_curve(x) %>%
  plot()

# }

Run the code above in your browser using DataLab