关于这些页面的因子分析的很多问题。我浏览过它们,但似乎没有什么相似,所以希望有人可以提供帮助。
我正在对一些调查问题进行因子分析,我预计会出现一些潜在的结构。我正在运行主轴或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
的任何建议吗?
答案 0 :(得分: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",
...)
}
答案 1 :(得分:-1)
我有同样的错误。我的成功是因为我试图将“回归”传递给分数而不是“回归”。因此,请确保您传递给分数的内容是可接受的参数选项。