大家使用R语言做因子分析时,相信很多人是采用《R语言实战》上面的代码使用fa.parallel和fa这两个函数,但是fa.parallel这个函数经常输出警告:“The estimated weights for the factor scores are probably incorrect. Try a different factor extraction method.”我今天在做因子分析的时候将这个警告输出的代码定位在fa.stats这个函数里面
R2 <- diag(t(w) %*% f)
if (is.null(fm)) {
if (prod(R2) < 0) {
message("In factor.stats: The factor scoring weights matrix is probably singular -- Factor score estimate results are likely incorrect.\\n Try a different factor extraction method\\n")
R2[abs(R2) > 1] <- NA
R2[R2 <= 0] <- NA
}
if ((max(R2, na.rm = TRUE) > (1 + .Machine$double.eps))) {
message("The estimated weights for the factor scores are probably incorrect. Try a different factor extraction method.")
解决这个问题的方法也很简单,我们只要尝试其他的抽取因子的方法即可:
fm参数介绍:
Factoring method fm="minres" will do a minimum residual as will fm="uls". Both of these use a first derivative. fm="ols" differs very slightly from "minres" in that it minimizes the entire residual matrix using an OLS procedure but uses the empirical first derivative. This will be slower. fm="wls" will do a weighted least squares (WLS) solution, fm="gls" does a generalized weighted least squares (GLS), fm="pa" will do the principal factor solution, fm="ml" will do a maximum likelihood factor analysis. fm="minchi" will minimize the sample size weighted chi square when treating pairwise correlations with different number of subjects per pair. fm ="minrank" will do a minimum rank factor analysis. "old.min" will do minimal residual the way it was done prior to April, 2017 (see discussion below). fm="alpha" will do alpha factor analysis as described in Kaiser and Coffey (1965)
尝试其他的方法,直到警告消失为止。