繁体   English   中英

基本 R 中的事实和 NA 处理

[英]factanal in Base R and handling of NAs

我有一个名为Ddata.frame显示在这里 我想在D的前8列中使用基础factanal中的事实 function 。

但是,我想知道为什么会出现以下错误: 'x' 必须仅在我设置了要删除的NA 'x' must contain finite values only

D <- read.csv("https://raw.githubusercontent.com/rnorouzian/i/master/SLI.csv", h = T)

pre <- D[1:8] # separate first 8 columns

factanal(pre, factors = 1, scores = "reg", na.action = na.omit) 

# Error in cov.wt(z) : 'x' must contain finite values only

文档指出na.action参数仅在公式作为x传递时适用。 如果要传递缺少值的data.frame ,则需要对其进行子集化。

pre <- D[complete.cases(D[1:8]),1:8] 

factanal(pre, factors = 1, scores = "reg" ) 

Call:
factanal(x = pre, factors = 1, scores = "reg")

Uniquenesses:
 Q1_a  Q2_a  Q3_a  Q4_a  Q5_a  Q6_a  Q7_a  Q8_a 
0.645 0.547 0.801 0.556 0.254 0.280 0.996 0.915 

Loadings:
     Factor1
Q1_a 0.596  
Q2_a 0.673  
Q3_a 0.446  
Q4_a 0.666  
Q5_a 0.863  
Q6_a 0.848  
Q7_a        
Q8_a 0.292  

               Factor1
SS loadings      3.006
Proportion Var   0.376

Test of the hypothesis that 1 factor is sufficient.
The chi square statistic is 17.83 on 20 degrees of freedom.
The p-value is 0.599 

或相同的结果:

factanal(as.formula(paste0("~", paste0(names(D[1:8]), collapse = " + "))), data = D, na.action = "na.omit", factors = 1, scores = "reg" )

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM