0

这些页面上有很多关于因子分析的问题。我浏览了它们,但似乎没有什么相似之处,所以希望有人能提供帮助。

我正在对一些调查问题进行因子分析,我预计会出现一些潜在的结构。我正在运行主轴或minres遇到相同的问题,如下所述。

我的数据集包含许多离散变量和编码为 的合理数量的缺失变量NA,但即使在删除所有NA问题后仍然存在:

minres.out <- factor.minres(r = res, nfactors = 5, residuals=F, rotate = "varimax", n.obs=NA, scores=F, SMC=T, missing=F, min.err=0.001, ,max.iter=50, symmetric=T,warnings=T,fm="minres")
  minres.out

minres.out2 <- fa(r = res, nfactors = 5, residuals=F, rotate = "oblimin", n.obs=NA, scores=F, SMC=T, missing=F, impute="median",min.err=0.001, ,max.iter=50, symmetric=T,warnings=T,fm="minres", alpha=0.1, p=0.05,oblique.scores=F, use="pairwise")
  minres.out2

第一个使用已弃用的版本并给我一个警告,但它有效。第二个给我以下错误:

Error in factor.scores(x.matrix, f = Structure, method = scores) : 
  object 'w' not found

我的数据中没有对象w,但我并不真正理解这个对象首先是什么意思。

跑步traceback()给了我:

3: factor.scores(x.matrix, f = Structure, method = scores)
2: fac(r = r, nfactors = nfactors, n.obs = n.obs, rotate = rotate, 
       scores = scores, residuals = residuals, SMC = SMC, covar = covar, 
       missing = FALSE, impute = impute, min.err = min.err, max.iter = max.iter, 
       symmetric = symmetric, warnings = warnings, fm = fm, alpha = alpha, 
       oblique.scores = oblique.scores, np.obs = np.obs, use = use, 
       ...)
1: fa(r = res, nfactors = 5, residuals = F, rotate = "oblimin", 
       n.obs = NA, scores = F, SMC = T, missing = F, impute = "median", 
       min.err = 0.001, , max.iter = 50, symmetric = T, warnings = T, 
       fm = "minres", alpha = 0.1, p = 0.05, oblique.scores = F, 
       use = "pairwise")

对我不是很有启发。对此有何建议w

4

2 回答 2

1

我逐行浏览了代码。似乎scores不能作为参数传递给factor.scores函数。它通过一个 switch 语句并且没有任何分支激活,所以你最终没有w导致它失败的值。您可以尝试将以下愚蠢的修复复制并粘贴到您的 R 会话中,然后再次运行您的代码:

fa <- function(r, nfactors = 1, n.obs = NA, n.iter = 1, rotate = "oblimin", 
    scores = "regression", residuals = FALSE, SMC = TRUE, covar = FALSE, 
    missing = FALSE, impute = "median", min.err = 0.001, max.iter = 50, 
    symmetric = TRUE, warnings = TRUE, fm = "minres", alpha = 0.1, 
    p = 0.05, oblique.scores = FALSE, np.obs = NULL, use = "pairwise", 
    ...){

scores <- c("a","b")
psych::fa(r, nfactors = 1, n.obs = NA, n.iter = 1, rotate = "oblimin", 
    scores = "regression", residuals = FALSE, SMC = TRUE, covar = FALSE, 
    missing = FALSE, impute = "median", min.err = 0.001, max.iter = 50, 
    symmetric = TRUE, warnings = TRUE, fm = "minres", alpha = 0.1, 
    p = 0.05, oblique.scores = FALSE, np.obs = NULL, use = "pairwise", 
    ...)
}
于 2014-06-27T01:12:10.497 回答
-1

我有同样的错误。我的原因是因为我试图将“回归”传递给分数而不是“回归”。因此,请确保您传递给分数的内容是可接受的参数选项。

于 2016-07-01T15:13:00.130 回答