rstatisticspsychfactor-analysis

R Psych package: extract factor number from fa.parallel function


I conducted a parallel analysis with the Psych package in R. I want to extract the number of factors from the output of fa.parallel() function, and save it to a variable for further processing. I checked the document but did not find how to do it.

My code is like:

fa.parallel(cor(data), n.obs=nrow(data), fa="fa", n.iter=100, main="Scree plots with parallel analysis")

Output is a scree plot with:

Parallel analysis suggests that the number of factors =  2  and the number of components =  NA 

I want to extract "2" in this case. How should I achieve it?

Thanks in advance.


Solution

  • This document psych: Procedures for Psychological, Psychometric, and Personality Research(P160) lists the return values of fa.parallel function. Among them, nfact is the number of factors with eigen values > eigen values of random data -- what we want.

    So the code to extract number of factors suggested from fa.parallel function is like this:

    parallel <- fa.parallel(cor(data), n.obs=nrow(data), fa="fa", n.iter=100, main="Scree plots with parallel analysis")
    parallel$nfact #number of factors