R/af.fa.r

#' Function af.fa
#' 
#' Factor analysis of data.frame.
#' @param data Numeric data.frame.
#' @details Factor analysis of data.frame.
#' @keywords modeling
#' @export
#' @examples
#' af.fa(data.frame(x=rnorm(100),y=rnorm(100)+scale(1:100),z=rnorm(100)+scale(1:100)));plotFA(fa)

af.fa <- function (data, nfactors = NULL, rotate = "varimax", fm = "pa", 
    plot = T, ...) 
{
    if (is.null(nfactors)) {
        fap = psych::fa.parallel(data, plot = F, show.legend = F)
        nfactors = max(1, fap$nfact)
    }
    fa = psych::fa(cor(data), rotate = rotate, fm = fm, nfactors = nfactors, 
        ...)
    if (plot) 
        plotFA(fa)
    return(fa)
}
AndreasFischer1985/quantqual documentation built on June 20, 2022, 4:55 p.m.