#因子分析
options(digits=2)
covariances <- ability.cov$cov
#將協方差矩陣轉化為相關係數矩陣
correlations <- cov2cor(covariances)
#第一步:判斷需提取的公共因子數
library(psych)
covariances <- ability.cov$cov
correlations <- cov2cor(covariances)
fa.parallel(correlations, n.obs=112, fa="both", n.iter=100,
main="scree plots with parallel analysis")
fa(correlations, nfactors=2, rotate="none", fm="pa")
fa.varimax <- fa(correlations, nfactors=2, rotate="varimax", fm="pa")
fa.varimax
fa.promax <- fa(correlations, nfactors=1, rotate="promax", fm="pa")
fa.promax
#因子結構矩陣
fsm <- function(oblique) else
}fsm(fa.varimax)
現在你可以看到變數與因子間的相關係數。將它們與正交旋轉所得因子載荷陣相比,你會發
現該載荷陣列的噪音比較大,這是因為之前你允許潛在因子相關。雖然斜交方法更為複雜,但模
型將更符合真實資料。
使用factor.plot()或fa.diagram()函式,你可以繪製正交或者斜交結果的圖形。來看
以下**:
factor.plot(fa.promax, labels=rownames(fa.promax$loadings))
相比pca,efa並不那麼關注計算因子得分。在fa()函式中新增score = true選項(原始
資料可得時)便可很輕鬆地獲得因子得分。另外還可以得到得分係數(標準化的回歸權重),它
在返回物件的weights元素中。
對於ability.cov資料集,通過二因子斜交旋轉法便可獲得用來計算因子得分的權重:
fa.promax$weights
[,1] [,2]
general 0.080 0.210
picture 0.021 0.090
blocks 0.044 0.695
maze 0.027 0.035
reading 0.739 0.044
vocab 0.176 0.039
與可精確計算的主成分得分不同,因子得分只是估計得到的。它的估計方法有多種,fa()
函式使用的是回歸方法
R做因子分析
factanal x,factors,data null,covmat null,n.obs na,subset,na.actionstart null,scores c none regression bartlett rotation varimax control null,其中x是資料的公式...
因子分析聚類R
1.因子分析 a read.csv f 2014.csv head a x scale a 1 library mvstats fac1 factpc x,4,rot varimax fac0 factpc x,4 主成分法,因子分析 fac0 vars 求方差及貢獻率 fac1 factpc x,...
R語言探索性因子分析練習
主要依據 r實戰 用自己的資料做探索,反正這文章也沒人看哈哈哈。涉及到的包 psych gparotation 載入資料 data read.csv d from r sem in r study1.csv header true,sep data str data 生成相關係數矩陣 corlibr...