How could I get the factor scores in factor analysis for a new observartion in R? I would like to get factor scores for a new observation from a factor analysis 2-factor problem, I've tried to use factor.scores(object_of_fact_analysis,new_observation) to get factor scores but this command only allow object_of_fact_analysis as fa (the output of factor analysis using this command) and I used that as principal object from psych lib (I estimated the parameters of factor analysis by PCA).
To be more clear see my code bellow:
> object_of_fact_analysis=principal(data, nfactors=2, rotate="varimax", 
                          covar=FALSE, scores=TRUE,  
                          method="regression", cor="cor")
> new_observation=c(110, 98, 105, 15, 18, 12, 35)
> factor.scores(new_observation, f=object_of_fact_analysis)

and I got:
 Error in if (dim(x)[1] == dim(f)[1]) { : argument is of length zero

Can anyone please help me, I wouldn't like to use fa because it doesn't use PCA to estimate the factor model.
 A: Use factanal instead of principal for performing the factor analysis. This function also offers the computation of scores by providing the parameter scores="regression". This will compute the socres for the training data only, though.
If you want to compute scores for new data $\vec{x}$, you must directly compute them over the score formula
$$\vec{q} = \Lambda^T R^{-1} \vec{x}$$
where $\Lambda$ are the factor loadings and $R$ the correlation matrix. In R:
fa <- factanal(x.train, factors=k, rotation="promax")
lambda.inv <- solve(fa$correlation) %*% fa$loadings
mus <- colMean(x.train)
sigmas <- apply(x, 2, sd)
scale(x.test, mus, sigmas)  %*% lmabda.inv

A: I know this one but I really need use principal because my professor ask me for use it. Although principal's lib name it as "principal component analysis" it evaluates the loadings of factors using PCA analysis. –
Davi Américo
Aug 31 at 9:04
I wonder if your professor really understand the subtle but important difference between the principal component scores (from PCA) and the corresponding factor scores (from factor analysis).  By looking at the help manual information for either psych::principal or stats::princomp, both would give you the principal component scores.  However, no one can provide you with "factor" scores from a PCA because PCA can only give you the principal component scores.  You may need to check this with your professor to clarify exactly what he/she was asking you to do.
Good luck,
John
