I would like to automatically select the number of factors after factor analysis (PCA). I mean the graphical selection method according to the Cattel criterion, which determines where the steepness of the graph ends:
Therefore, I want to check where the first steepness of the graph ends, withouth looking on plot. For any set of data (df) I have at my disposal percentages of explained variance, raw values square roots of the eigenvalues, and so on:
# df is my data set pca_results <- prcomp(df) # here i can get plot values plot_values <- pca_results$sdev # ... and change plot values to percents of variance explained variance_percents <- (pca_results$sdev^2 / sum(pca_results$sdev^2)) * 100 # i can take values higher than 1 (Kaiser's simple criterion) pca_number_of_factors <- length(plot_values[plot_values > 1]) # get some variance percents first_f_var_perc <- variance_percents second_f_var_perc <- variance_percents third_f_var_perc <- variance_percents # or mark steppness level PCA_steepness = 1 - second_f_var_perc / first_f_var_perc
I'm looking for a simple mathematical way to determine the first steepness collapse of a graph. Something like "number of factors" selected automatically in this way. Could someone help me in this regard?
Of course, I am aware of the disadvantages of this approach (for example, a few slopes of the graph), but I would just like to find out how it can be solved geometrically-numerically, because frankly, I don't have much in mind.