【问题标题】:Object 'w' not found error in factor analysis with package 'psych'使用包“psych”进行因子分析时未发现对象“w”错误
【发布时间】:2014-08-18 00:31:27
【问题描述】:

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

我正在对一些调查问题进行因子分析,我预计会出现一些潜在的结构。我正在运行主轴或 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有什么建议吗?

【问题讨论】:

  • 我想将问题发送到 SO 网站,因为它纯粹与 R 相关。如果您提供 data - 让这里的人们能够在R 或他们喜欢的其他程序中检查它 - 这将证明这个问题是统计的。 (始终显示数据表。)

标签: r categorical-data factor-analysis


【解决方案1】:

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

【讨论】:

  • 这应该作为对原始帖子的评论发布,这不是完整的答案。
【解决方案2】:

我逐行浏览了代码。似乎 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", 
    ...)
}

【讨论】:

    猜你喜欢
    • 2013-03-23
    • 1970-01-01
    • 2013-02-02
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多