1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/n_factors.R
\name{n_factors}
\alias{n_factors}
\alias{n_components}
\title{Number of components/factors to retain in PCA/FA}
\usage{
n_factors(
x,
type = "FA",
rotation = "varimax",
algorithm = "default",
package = c("nFactors", "psych"),
cor = NULL,
safe = TRUE,
n_max = NULL,
...
)
n_components(
x,
type = "PCA",
rotation = "varimax",
algorithm = "default",
package = c("nFactors", "psych"),
cor = NULL,
safe = TRUE,
...
)
}
\arguments{
\item{x}{A data frame.}
\item{type}{Can be \code{"FA"} or \code{"PCA"}, depending on what you want to do.}
\item{rotation}{Only used for VSS (Very Simple Structure criterion, see
\code{\link[psych:VSS]{psych::VSS()}}). The rotation to apply. Can be \code{"none"}, \code{"varimax"},
\code{"quartimax"}, \code{"bentlerT"}, \code{"equamax"}, \code{"varimin"}, \code{"geominT"} and
\code{"bifactor"} for orthogonal rotations, and \code{"promax"}, \code{"oblimin"},
\code{"simplimax"}, \code{"bentlerQ"}, \code{"geominQ"}, \code{"biquartimin"} and \code{"cluster"}
for oblique transformations.}
\item{algorithm}{Factoring method used by VSS. Can be \code{"pa"} for Principal
Axis Factor Analysis, \code{"minres"} for minimum residual (OLS) factoring,
\code{"mle"} for Maximum Likelihood FA and \code{"pc"} for Principal Components.
\code{"default"} will select \code{"minres"} if \code{type = "FA"} and \code{"pc"} if
\code{type = "PCA"}.}
\item{package}{Package from which respective methods are used. Can be
\code{"all"} or a vector containing \code{"nFactors"}, \code{"psych"}, \code{"PCDimension"},
\code{"fit"} or \code{"EGAnet"}. Note that \code{"fit"} (which actually also relies on the
\code{psych} package) and \code{"EGAnet"} can be very slow for bigger datasets. Thus,
the default is \code{c("nFactors", "psych")}. You must have the respective
packages installed for the methods to be used.}
\item{cor}{An optional correlation matrix that can be used (note that the
data must still be passed as the first argument). If \code{NULL}, will
compute it by running \code{cor()} on the passed data.}
\item{safe}{If \code{TRUE}, the function will run all the procedures in try
blocks, and will only return those that work and silently skip the ones
that may fail.}
\item{n_max}{If set to a value (e.g., \code{10}), will drop from the results all
methods that suggest a higher number of components. The interpretation becomes
'from all the methods that suggested a number lower than n_max, the results
are ...'.}
\item{...}{Arguments passed to or from other methods.}
}
\value{
A data frame.
}
\description{
This function runs many existing procedures for determining how many factors
to retain/extract from factor analysis (FA) or dimension reduction (PCA). It
returns the number of factors based on the maximum consensus between methods.
In case of ties, it will keep the simplest model and select the solution
with the fewer factors.
}
\details{
\code{n_components()} is actually an alias for \code{n_factors()}, with
different defaults for the function arguments.
}
\note{
There is also a
\href{https://easystats.github.io/see/articles/parameters.html}{\code{plot()}-method}
implemented in the \href{https://easystats.github.io/see/}{\strong{see}-package}.
\code{n_components()} is a convenient short-cut for \code{n_factors(type = "PCA")}.
}
\examples{
\dontshow{if (require("PCDimension", quietly = TRUE) && require("nFactors", quietly = TRUE) && require("EGAnet", quietly = TRUE) && require("psych", quietly = TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf}
library(parameters)
n_factors(mtcars, type = "PCA")
result <- n_factors(mtcars[1:5], type = "FA")
as.data.frame(result)
summary(result)
\donttest{
# Setting package = 'all' will increase the number of methods (but is slow)
n_factors(mtcars, type = "PCA", package = "all")
n_factors(mtcars, type = "FA", algorithm = "mle", package = "all")
}
\dontshow{\}) # examplesIf}
}
\references{
\itemize{
\item Bartlett, M. S. (1950). Tests of significance in factor analysis.
British Journal of statistical psychology, 3(2), 77-85.
\item Bentler, P. M., & Yuan, K. H. (1996). Test of linear trend in
eigenvalues of a covariance matrix with application to data analysis.
British Journal of Mathematical and Statistical Psychology, 49(2), 299-312.
\item Cattell, R. B. (1966). The scree test for the number of factors.
Multivariate behavioral research, 1(2), 245-276.
\item Finch, W. H. (2019). Using Fit Statistic Differences to Determine the
Optimal Number of Factors to Retain in an Exploratory Factor Analysis.
Educational and Psychological Measurement.
\item Zoski, K. W., & Jurs, S. (1996). An objective counterpart to the
visual scree test for factor analysis: The standard error scree.
Educational and Psychological Measurement, 56(3), 443-451.
\item Zoski, K., & Jurs, S. (1993). Using multiple regression to determine
the number of factors to retain in factor analysis. Multiple Linear
Regression Viewpoints, 20(1), 5-9.
\item Nasser, F., Benson, J., & Wisenbaker, J. (2002). The performance of
regression-based variations of the visual scree for determining the number
of common factors. Educational and psychological measurement, 62(3),
397-419.
\item Golino, H., Shi, D., Garrido, L. E., Christensen, A. P., Nieto, M.
D., Sadana, R., & Thiyagarajan, J. A. (2018). Investigating the performance
of Exploratory Graph Analysis and traditional techniques to identify the
number of latent factors: A simulation and tutorial.
\item Golino, H. F., & Epskamp, S. (2017). Exploratory graph analysis: A
new approach for estimating the number of dimensions in psychological
research. PloS one, 12(6), e0174035.
\item Revelle, W., & Rocklin, T. (1979). Very simple structure: An
alternative procedure for estimating the optimal number of interpretable
factors. Multivariate Behavioral Research, 14(4), 403-414.
\item Velicer, W. F. (1976). Determining the number of components from the
matrix of partial correlations. Psychometrika, 41(3), 321-327.
}
}
|