2017-07-26 63 views
0

我試圖通過使用svyfactanal()函數並獲得因子分數來運行因子分析。運行因子分析沒有問題。從svyfactanal提取因子分數

library(survey) 
factor1 <- svyfactanal(~ var1 + var2 + var3 ... + var12, 
         design = design, factors = 4, rotation = "promax", 
         scores = "regression") 

然而,當欲提取因子分數收到錯誤消息中的每個觀測:

data1 <- cbind(data, factor1$scores) 

錯誤data.frame(...,check.names = FALSE ): 參數意味着不同的行數:1297,0

然後我手動檢查因子分數,和我收到此消息:

factor1$scores 
# NULL 

有沒有辦法從svyfactanal()函數中提取這些分數?

回答

1

svyfactanal只是將一個不同的協方差矩陣傳遞給factanal。在factanal的文檔中,分數是$分數,例如(從幫助):

v1 <- c(1,1,1,1,1,1,1,1,1,1,3,3,3,3,3,4,5,6) 
v2 <- c(1,2,1,1,1,1,2,1,2,1,3,4,3,3,3,4,6,5) 
v3 <- c(3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,5,4,6) 
v4 <- c(3,3,4,3,3,1,1,2,1,1,1,1,2,1,1,5,6,4) 
v5 <- c(1,1,1,1,1,3,3,3,3,3,1,1,1,1,1,6,4,5) 
v6 <- c(1,1,1,2,1,3,3,3,4,3,1,1,1,2,1,6,5,4) 
m1 <- cbind(v1,v2,v3,v4,v5,v6) 
cor(m1) 
factanal(m1, factors = 3) # varimax is the default 
factanal(m1, factors = 3, rotation = "promax") 
# The following shows the g factor as PC1 
prcomp(m1) # signs may depend on platform 

## formula interface 
factanal(~v1+v2+v3+v4+v5+v6, factors = 3, 
     scores = "Bartlett")$scores 

如果你想僅僅是第一因子得分,你可以使用:

factanal(~v1+v2+v3+v4+v5+v6, factors = 3, 
     scores = "Bartlett")$scores[,1] 

,或者爲你的例子,是這樣的:

factor1scores <- factor1$scores[,1] 
data1 <- cbind(data, factor1scores)