簡體   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