第14章 主成分和因子分析
主成分分析
主成分分析((Principal Component Analysis郊艘,PCA)是一種數(shù)據(jù)降維技巧,它能將大量相關(guān)變量轉(zhuǎn)化為一組很少的不相關(guān)變量铲觉,這些無關(guān)變量稱為主成分(原來變量的線性組合)。整體思想就是化繁為簡美莫,抓住問題關(guān)鍵菜拓,也就是降維思想。
主成分分析法是通過恰當(dāng)?shù)臄?shù)學(xué)變換,使新變量——主成分成為原變量的線性組合索昂,并選取少數(shù)幾個(gè)在變差總信息量中比例較大的主成分來分析事物的一種方法建车。主成分在變差信息量中的比例越大,它在綜合評(píng)價(jià)中的作用就越大椒惨。
因子分析
探索性因子分析法(Exploratory Factor Analysis缤至,EFA)是一系列用來發(fā)現(xiàn)一組變量的潛在結(jié)構(gòu)的方法。它通過尋找一組更小的康谆、潛在的或隱藏的結(jié)構(gòu)來解釋已觀測到的领斥、顯式的變量間的關(guān)系。
PCA與EFA模型間的區(qū)別
參見圖14-1沃暗。主成分(PC1和PC2)是觀測變量(X1到X5)的線性組合月洛。形成線性組合的權(quán)重都是通過最大化各主成分所解釋的方差來獲得,同時(shí)還要保證個(gè)主成分間不相關(guān)孽锥。相反嚼黔,因子(F1和F2)被當(dāng)做是觀測變量的結(jié)構(gòu)基礎(chǔ)或“原因”,而不是它們的線性組合惜辑。
14.1 R中的主成分和因子分析
R的基礎(chǔ)安裝包提供了PCA和EFA的函數(shù)唬涧,分別為princomp()和factanal()。
最常見的分析步驟
(1)數(shù)據(jù)預(yù)處理韵丑。PCA和EFA都根據(jù)觀測變量間的相關(guān)性來推導(dǎo)結(jié)果爵卒。用戶可以輸入原始數(shù)據(jù)矩陣或者相關(guān)系數(shù)矩陣到principal()和fa()函數(shù)中。若輸入初始數(shù)據(jù)撵彻,相關(guān)系數(shù)矩陣將會(huì)被自動(dòng)計(jì)算钓株,在計(jì)算前請(qǐng)確保數(shù)據(jù)中沒有缺失值。
(2)選擇因子模型陌僵。判斷是PCA(數(shù)據(jù)降維)還是EFA(發(fā)現(xiàn)潛在結(jié)構(gòu))更符合你的研究目標(biāo)轴合。如果選擇EFA方法,你還需要選擇一種估計(jì)因子模型的方法(如最大似然估計(jì))碗短。
(3)判斷要選擇的主成分/因子數(shù)目受葛。
(4)選擇主成分/因子。
(5)旋轉(zhuǎn)主成分/因子偎谁。
(6)解釋結(jié)果总滩。
(7)計(jì)算主成分或因子得分。
14.2 主成分分析
PCA的目標(biāo)是用一組較少的不相關(guān)變量代替大量相關(guān)變量巡雨,同時(shí)盡可能保留初始變量的信息闰渔,這些推導(dǎo)所得的變量稱為主成分,它們是觀測變量的線性組合铐望。如第一主成分為:
它是k個(gè)觀測變量的加權(quán)組合冈涧,對(duì)初始變量集的方差解釋性最大茂附。第二主成分也是初始變量的線性組合,對(duì)方差的解釋性排第二督弓,同時(shí)與第一主成分正交(不相關(guān))营曼。后面每一個(gè)主成分都最大化它對(duì)方差的解釋程度,同時(shí)與之前所有的主成分都正交愚隧。理論上來說蒂阱,你可以選取與變量數(shù)相同的主成分,但從實(shí)用的角度來看狂塘,我們都希望能用較少的主成分來近似全變量集蒜危。
主成分與原始變量之間的關(guān)系
(1)主成分保留了原始變量絕大多數(shù)信息。
(2)主成分的個(gè)數(shù)大大少于原始變量的數(shù)目睹耐。
(3)各個(gè)主成分之間互不相關(guān)蜈亩。
(4)每個(gè)主成分都是原始變量的線性組合振湾。
數(shù)據(jù)集USJudgeRatings包含了律師對(duì)美國高等法院法官的評(píng)分。數(shù)據(jù)框包含43個(gè)觀測铃辖,12個(gè)變量新思。
USJudgeRatings # 查看數(shù)據(jù)集窖梁。
## CONT INTG DMNR DILG CFMG DECI PREP FAMI ORAL WRIT PHYS RTEN
## AARONSON,L.H. 5.7 7.9 7.7 7.3 7.1 7.4 7.1 7.1 7.1 7.0 8.3 7.8
## ALEXANDER,J.M. 6.8 8.9 8.8 8.5 7.8 8.1 8.0 8.0 7.8 7.9 8.5 8.7
## ARMENTANO,A.J. 7.2 8.1 7.8 7.8 7.5 7.6 7.5 7.5 7.3 7.4 7.9 7.8
## BERDON,R.I. 6.8 8.8 8.5 8.8 8.3 8.5 8.7 8.7 8.4 8.5 8.8 8.7
## BRACKEN,J.J. 7.3 6.4 4.3 6.5 6.0 6.2 5.7 5.7 5.1 5.3 5.5 4.8
## BURNS,E.B. 6.2 8.8 8.7 8.5 7.9 8.0 8.1 8.0 8.0 8.0 8.6 8.6
## CALLAHAN,R.J. 10.6 9.0 8.9 8.7 8.5 8.5 8.5 8.5 8.6 8.4 9.1 9.0
## COHEN,S.S. 7.0 5.9 4.9 5.1 5.4 5.9 4.8 5.1 4.7 4.9 6.8 5.0
## DALY,J.J. 7.3 8.9 8.9 8.7 8.6 8.5 8.4 8.4 8.4 8.5 8.8 8.8
## DANNEHY,J.F. 8.2 7.9 6.7 8.1 7.9 8.0 7.9 8.1 7.7 7.8 8.5 7.9
## DEAN,H.H. 7.0 8.0 7.6 7.4 7.3 7.5 7.1 7.2 7.1 7.2 8.4 7.7
## DEVITA,H.J. 6.5 8.0 7.6 7.2 7.0 7.1 6.9 7.0 7.0 7.1 6.9 7.2
## DRISCOLL,P.J. 6.7 8.6 8.2 6.8 6.9 6.6 7.1 7.3 7.2 7.2 8.1 7.7
## GRILLO,A.E. 7.0 7.5 6.4 6.8 6.5 7.0 6.6 6.8 6.3 6.6 6.2 6.5
## HADDEN,W.L.JR. 6.5 8.1 8.0 8.0 7.9 8.0 7.9 7.8 7.8 7.8 8.4 8.0
## HAMILL,E.C. 7.3 8.0 7.4 7.7 7.3 7.3 7.3 7.2 7.1 7.2 8.0 7.6
## HEALEY.A.H. 8.0 7.6 6.6 7.2 6.5 6.5 6.8 6.7 6.4 6.5 6.9 6.7
## HULL,T.C. 7.7 7.7 6.7 7.5 7.4 7.5 7.1 7.3 7.1 7.3 8.1 7.4
## LEVINE,I. 8.3 8.2 7.4 7.8 7.7 7.7 7.7 7.8 7.5 7.6 8.0 8.0
## LEVISTER,R.L. 9.6 6.9 5.7 6.6 6.9 6.6 6.2 6.0 5.8 5.8 7.2 6.0
## MARTIN,L.F. 7.1 8.2 7.7 7.1 6.6 6.6 6.7 6.7 6.8 6.8 7.5 7.3
## MCGRATH,J.F. 7.6 7.3 6.9 6.8 6.7 6.8 6.4 6.3 6.3 6.3 7.4 6.6
## MIGNONE,A.F. 6.6 7.4 6.2 6.2 5.4 5.7 5.8 5.9 5.2 5.8 4.7 5.2
## MISSAL,H.M. 6.2 8.3 8.1 7.7 7.4 7.3 7.3 7.3 7.2 7.3 7.8 7.6
## MULVEY,H.M. 7.5 8.7 8.5 8.6 8.5 8.4 8.5 8.5 8.4 8.4 8.7 8.7
## NARUK,H.J. 7.8 8.9 8.7 8.9 8.7 8.8 8.9 9.0 8.8 8.9 9.0 9.0
## O'BRIEN,F.J. 7.1 8.5 8.3 8.0 7.9 7.9 7.8 7.8 7.8 7.7 8.3 8.2
## O'SULLIVAN,T.J. 7.5 9.0 8.9 8.7 8.4 8.5 8.4 8.3 8.3 8.3 8.8 8.7
## PASKEY,L. 7.5 8.1 7.7 8.2 8.0 8.1 8.2 8.4 8.0 8.1 8.4 8.1
## RUBINOW,J.E. 7.1 9.2 9.0 9.0 8.4 8.6 9.1 9.1 8.9 9.0 8.9 9.2
## SADEN.G.A. 6.6 7.4 6.9 8.4 8.0 7.9 8.2 8.4 7.7 7.9 8.4 7.5
## SATANIELLO,A.G. 8.4 8.0 7.9 7.9 7.8 7.8 7.6 7.4 7.4 7.4 8.1 7.9
## SHEA,D.M. 6.9 8.5 7.8 8.5 8.1 8.2 8.4 8.5 8.1 8.3 8.7 8.3
## SHEA,J.F.JR. 7.3 8.9 8.8 8.7 8.4 8.5 8.5 8.5 8.4 8.4 8.8 8.8
## SIDOR,W.J. 7.7 6.2 5.1 5.6 5.6 5.9 5.6 5.6 5.3 5.5 6.3 5.3
## SPEZIALE,J.A. 8.5 8.3 8.1 8.3 8.4 8.2 8.2 8.1 7.9 8.0 8.0 8.2
## SPONZO,M.J. 6.9 8.3 8.0 8.1 7.9 7.9 7.9 7.7 7.6 7.7 8.1 8.0
## STAPLETON,J.F. 6.5 8.2 7.7 7.8 7.6 7.7 7.7 7.7 7.5 7.6 8.5 7.7
## TESTO,R.J. 8.3 7.3 7.0 6.8 7.0 7.1 6.7 6.7 6.7 6.7 8.0 7.0
## TIERNEY,W.L.JR. 8.3 8.2 7.8 8.3 8.4 8.3 7.7 7.6 7.5 7.7 8.1 7.9
## WALL,R.A. 9.0 7.0 5.9 7.0 7.0 7.2 6.9 6.9 6.5 6.6 7.6 6.6
## WRIGHT,D.B. 7.1 8.4 8.4 7.7 7.5 7.7 7.8 8.2 8.0 8.1 8.3 8.1
## ZARRILLI,K.J. 8.6 7.4 7.0 7.5 7.5 7.7 7.4 7.2 6.9 7.0 7.8 7.1
str(USJudgeRatings) # 查看數(shù)據(jù)集結(jié)構(gòu)。
## 'data.frame': 43 obs. of 12 variables:
## $ CONT: num 5.7 6.8 7.2 6.8 7.3 6.2 10.6 7 7.3 8.2 ...
## $ INTG: num 7.9 8.9 8.1 8.8 6.4 8.8 9 5.9 8.9 7.9 ...
## $ DMNR: num 7.7 8.8 7.8 8.5 4.3 8.7 8.9 4.9 8.9 6.7 ...
## $ DILG: num 7.3 8.5 7.8 8.8 6.5 8.5 8.7 5.1 8.7 8.1 ...
## $ CFMG: num 7.1 7.8 7.5 8.3 6 7.9 8.5 5.4 8.6 7.9 ...
## $ DECI: num 7.4 8.1 7.6 8.5 6.2 8 8.5 5.9 8.5 8 ...
## $ PREP: num 7.1 8 7.5 8.7 5.7 8.1 8.5 4.8 8.4 7.9 ...
## $ FAMI: num 7.1 8 7.5 8.7 5.7 8 8.5 5.1 8.4 8.1 ...
## $ ORAL: num 7.1 7.8 7.3 8.4 5.1 8 8.6 4.7 8.4 7.7 ...
## $ WRIT: num 7 7.9 7.4 8.5 5.3 8 8.4 4.9 8.5 7.8 ...
## $ PHYS: num 8.3 8.5 7.9 8.8 5.5 8.6 9.1 6.8 8.8 8.5 ...
## $ RTEN: num 7.8 8.7 7.8 8.7 4.8 8.6 9 5 8.8 7.9 ...
14.2.1 判斷主成分的個(gè)數(shù)
用來判斷PCA中需要多少個(gè)主成分的準(zhǔn)則:
?根據(jù)先驗(yàn)經(jīng)驗(yàn)和理論知識(shí)判斷主成分?jǐn)?shù)夹囚;
?根據(jù)要解釋變量方差的積累值的閾值來判斷需要的主成分?jǐn)?shù)纵刘;
?通過檢查變量間k × k的相關(guān)系數(shù)矩陣來判斷保留的主成分?jǐn)?shù)。
最常見的是基于特征值的方法荸哟。每個(gè)主成分都與相關(guān)系數(shù)矩陣的特征值相關(guān)聯(lián)假哎,第一主成分與最大的特征值相關(guān)聯(lián),第二主成分與第二大的特征值相關(guān)聯(lián)鞍历,依此類推舵抹。
Kaiser-Harris準(zhǔn)則建議保留特征值大于1的主成分,特征值小于1的成分所解釋的方差比包含在單個(gè)變量中的方差更少劣砍。Cattell碎石檢驗(yàn)則繪制了特征值與主成分?jǐn)?shù)的圖形惧蛹。這類圖形可以清晰地展示圖形彎曲狀況,在圖形變化最大處之上的主成分都可保留刑枝。最后香嗓,你還可以進(jìn)行模擬,依據(jù)與初始矩陣相同大小的隨機(jī)數(shù)據(jù)矩陣來判斷要提取的特征值装畅。若基于真實(shí)數(shù)據(jù)的某個(gè)特征值大于一組隨機(jī)數(shù)據(jù)矩陣相應(yīng)的平均特征值靠娱,那么該主成分可以保留。該方法稱作平行分析洁灵。
library(psych) # 調(diào)用psych包饱岸。
fa.parallel(USJudgeRatings[,-1], fa = "pc", n.iter = 100, show.legend = FALSE, main = "Scree plot with parallel analysis") # 碎石圖判斷主成分個(gè)數(shù)掺出。
abline(h=1,lwd=1,col="green") # 添加特征值準(zhǔn)則線。
圖形解讀:線段和x符號(hào)組成的圖(藍(lán)色線):特征值曲線苫费;
紅色虛線:根據(jù)100個(gè)隨機(jī)數(shù)據(jù)矩陣推導(dǎo)出來的平均特征值曲線汤锨;
綠色實(shí)線:特征值準(zhǔn)則線(即:y=1的水平線)
判別標(biāo)準(zhǔn):特征值大于平均特征值,且大于y=1的特征值準(zhǔn)則線百框,被認(rèn)為是可保留的主成分闲礼。根據(jù)判別標(biāo)準(zhǔn),保留1個(gè)主成分即可铐维。
fa.parallel函數(shù)學(xué)習(xí)
fa.parallel(data,n.obs=,fa=”pc”/”both”,n.iter=100,show.legend=T/F)
data:原始數(shù)據(jù)數(shù)據(jù)框柬泽;
n.obs:當(dāng)data是相關(guān)系數(shù)矩陣時(shí),給出原始數(shù)據(jù)(非原始變量)個(gè)數(shù)嫁蛇,data是原始數(shù)據(jù)矩陣時(shí)忽略此參數(shù)锨并;
fa:“pc”為僅計(jì)算主成分,“fa”為因子分析睬棚,“both”為計(jì)算主成分及因子第煮;
n.iter:模擬平行分析次數(shù);
show.legend:顯示圖例抑党。
14.2.2 提取主成分
principal(r, nfactors = , rotate = , scores = )
r:相關(guān)系數(shù)矩陣或原始數(shù)據(jù)矩陣包警;
nfactors:設(shè)定主成分?jǐn)?shù)(默認(rèn)為1);
rotate:指定旋轉(zhuǎn)的方法底靠,默認(rèn)最大方差旋轉(zhuǎn)(varimax)害晦。
scores:設(shè)定是否需要計(jì)算主成分得分(默認(rèn)不需要)。
library(psych) # 調(diào)用psych包暑中。
pc <- principal(USJudgeRatings[,-1], nfactors = 1) # 提取1個(gè)主成分壹瘟。
pc # 返回結(jié)果。
## Principal Components Analysis
## Call: principal(r = USJudgeRatings[, -1], nfactors = 1)
## Standardized loadings (pattern matrix) based upon correlation matrix
## PC1 h2 u2 com
## INTG 0.92 0.84 0.1565 1
## DMNR 0.91 0.83 0.1663 1
## DILG 0.97 0.94 0.0613 1
## CFMG 0.96 0.93 0.0720 1
## DECI 0.96 0.92 0.0763 1
## PREP 0.98 0.97 0.0299 1
## FAMI 0.98 0.95 0.0469 1
## ORAL 1.00 0.99 0.0091 1
## WRIT 0.99 0.98 0.0196 1
## PHYS 0.89 0.80 0.2013 1
## RTEN 0.99 0.97 0.0275 1
##
## PC1
## SS loadings 10.13
## Proportion Var 0.92
##
## Mean item complexity = 1
## Test of the hypothesis that 1 component is sufficient.
##
## The root mean square of the residuals (RMSR) is 0.04
## with the empirical chi square 6.21 with prob < 1
##
## Fit based upon off diagonal values = 1
PC1欄包含了成分載荷痒芝,指觀測變量與主成分的相關(guān)系數(shù)俐筋。如果提取不止一個(gè)主成分,那么還將會(huì)有PC2严衬、PC3等欄澄者。成分載荷(component loadings)可用來解釋主成分的含義,解釋主成分與各變量的相關(guān)程度请琳。
h2欄為成分公因子方差粱挡,即主成分對(duì)每個(gè)變量的方差解釋度。
u2欄為成分唯一性俄精,即方差無法被主成分解釋的部分(1-h2)询筏。
SS loadings包含了與主成分相關(guān)聯(lián)的特征值,其含義是與特定主成分相關(guān)聯(lián)的標(biāo)準(zhǔn)化后的方差值竖慧,即可以通過它來看90%的方差可以被多少個(gè)成分解釋嫌套,從而選出主成分(即可使用nfactors=原始變量個(gè)數(shù)來把所有特征值查出逆屡,當(dāng)然也可以直接通過eigen函數(shù)對(duì)它的相關(guān)矩陣進(jìn)行查特征值)。
Proportion Var表示每個(gè)主成分對(duì)整個(gè)數(shù)據(jù)集的解釋程度踱讨。
Cumulative Var表示各主成分解釋程度之和魏蔗。
Proportion Explained及Cumulative Proportion分別為按現(xiàn)有總解釋方差百分比劃分主成分及其累積百分比。
結(jié)果解讀:第一主成分(PC1)與每個(gè)變量都高度相關(guān)痹筛,也就是說莺治,它是一個(gè)可用來進(jìn)行一般性評(píng)價(jià)的維度。ORAL變量99.1%的方差都可以被PC1來解釋帚稠,僅僅有0.91%的方差不能被PC1解釋谣旁。第一主成分解釋了11個(gè)變量92%的方差。
head(Harman23.cor) # 查看數(shù)據(jù)集Harman23.cor
## $cov
## height arm.span forearm lower.leg weight bitro.diameter
## height 1.000 0.846 0.805 0.859 0.473 0.398
## arm.span 0.846 1.000 0.881 0.826 0.376 0.326
## forearm 0.805 0.881 1.000 0.801 0.380 0.319
## lower.leg 0.859 0.826 0.801 1.000 0.436 0.329
## weight 0.473 0.376 0.380 0.436 1.000 0.762
## bitro.diameter 0.398 0.326 0.319 0.329 0.762 1.000
## chest.girth 0.301 0.277 0.237 0.327 0.730 0.583
## chest.width 0.382 0.415 0.345 0.365 0.629 0.577
## chest.girth chest.width
## height 0.301 0.382
## arm.span 0.277 0.415
## forearm 0.237 0.345
## lower.leg 0.327 0.365
## weight 0.730 0.629
## bitro.diameter 0.583 0.577
## chest.girth 1.000 0.539
## chest.width 0.539 1.000
##
## $center
## [1] 0 0 0 0 0 0 0 0
##
## $n.obs
## [1] 305
library(psych) # 調(diào)用psych包滋早。
fa.parallel(Harman23.cor$cov, n.obs=302, fa="pc", n.iter=100, show.legend=FALSE, main="Scree plot with parallel analysis") # 判定主成分?jǐn)?shù)量榄审。
結(jié)果解讀:通過碎石圖可以判定選擇的主成分個(gè)數(shù)為2個(gè)。
library(psych) # 調(diào)用psych包杆麸。
pc1 <- principal(Harman23.cor$cov, nfactors=2, rotate="none") # 提取2個(gè)主成分瘟判。
pc1 # 返回提取主成分的結(jié)果。
## Principal Components Analysis
## Call: principal(r = Harman23.cor$cov, nfactors = 2, rotate = "none")
## Standardized loadings (pattern matrix) based upon correlation matrix
## PC1 PC2 h2 u2 com
## height 0.86 -0.37 0.88 0.123 1.4
## arm.span 0.84 -0.44 0.90 0.097 1.5
## forearm 0.81 -0.46 0.87 0.128 1.6
## lower.leg 0.84 -0.40 0.86 0.139 1.4
## weight 0.76 0.52 0.85 0.150 1.8
## bitro.diameter 0.67 0.53 0.74 0.261 1.9
## chest.girth 0.62 0.58 0.72 0.283 2.0
## chest.width 0.67 0.42 0.62 0.375 1.7
##
## PC1 PC2
## SS loadings 4.67 1.77
## Proportion Var 0.58 0.22
## Cumulative Var 0.58 0.81
## Proportion Explained 0.73 0.27
## Cumulative Proportion 0.73 1.00
##
## Mean item complexity = 1.7
## Test of the hypothesis that 2 components are sufficient.
##
## The root mean square of the residuals (RMSR) is 0.05
##
## Fit based upon off diagonal values = 0.99
結(jié)果解讀:從結(jié)果Proportion Var: 0.58和0.22可以判定角溃,第一主成分解釋了身體測量指標(biāo)58%的方差,而第二主成分解釋了22%篮撑,兩者總共解釋了81%的方差减细。對(duì)于高度變量,兩者則共解釋了其88%的方差赢笨。
14.2.3 主成分旋轉(zhuǎn)
旋轉(zhuǎn)是一系列將成分載荷陣變得更容易解釋的數(shù)學(xué)方法未蝌,它們盡可能地對(duì)成分去噪。旋轉(zhuǎn)方法有兩種:使選擇的成分保持不相關(guān)(正交旋轉(zhuǎn))茧妒,和讓它們變得相關(guān)(斜交旋轉(zhuǎn))萧吠。旋轉(zhuǎn)方法也會(huì)依據(jù)去噪定義的不同而不同。最流行的正交旋轉(zhuǎn)是方差極大旋轉(zhuǎn)桐筏,它試圖對(duì)載荷陣的列進(jìn)行去噪纸型,使得每個(gè)成分只是由一組有限的變量來解釋(即載荷陣每列只有少數(shù)幾個(gè)很大的載荷,其他都是很小的載荷)梅忌。 結(jié)果列表中列的名字都從PC變成了RC狰腌,以表示成分被旋轉(zhuǎn)。
library(psych) # 調(diào)用psych包牧氮。
rc <- principal(Harman23.cor$cov, nfactors=2, rotate="varimax") # 主成分?jǐn)?shù)判定琼腔,采用旋轉(zhuǎn)。
rc # 返回結(jié)果踱葛。
## Principal Components Analysis
## Call: principal(r = Harman23.cor$cov, nfactors = 2, rotate = "varimax")
## Standardized loadings (pattern matrix) based upon correlation matrix
## RC1 RC2 h2 u2 com
## height 0.90 0.25 0.88 0.123 1.2
## arm.span 0.93 0.19 0.90 0.097 1.1
## forearm 0.92 0.16 0.87 0.128 1.1
## lower.leg 0.90 0.22 0.86 0.139 1.1
## weight 0.26 0.88 0.85 0.150 1.2
## bitro.diameter 0.19 0.84 0.74 0.261 1.1
## chest.girth 0.11 0.84 0.72 0.283 1.0
## chest.width 0.26 0.75 0.62 0.375 1.2
##
## RC1 RC2
## SS loadings 3.52 2.92
## Proportion Var 0.44 0.37
## Cumulative Var 0.44 0.81
## Proportion Explained 0.55 0.45
## Cumulative Proportion 0.55 1.00
##
## Mean item complexity = 1.1
## Test of the hypothesis that 2 components are sufficient.
##
## The root mean square of the residuals (RMSR) is 0.05
##
## Fit based upon off diagonal values = 0.99
14.2.4 獲取主成分得分
當(dāng)scores = TRUE時(shí)丹莲,主成分得分存儲(chǔ)在principal()函數(shù)返回對(duì)象的scores元素中光坝。
library(psych) # 調(diào)用psych包。
pc2 <-principal(USJudgeRatings[,-1], nfactors=1, score=TRUE) # 獲取成分得分甥材。
head(pc2$scores) # 查看成分得分盯另。
## PC1
## AARONSON,L.H. -0.1857981
## ALEXANDER,J.M. 0.7469865
## ARMENTANO,A.J. 0.0704772
## BERDON,R.I. 1.1358765
## BRACKEN,J.J. -2.1586211
## BURNS,E.B. 0.7669406
cor(USJudgeRatings$CONT,pc$scores) # 獲取評(píng)分的相關(guān)系數(shù)。
## PC1
## [1,] -0.008815895
rc <- principal(Harman23.cor$cov, nfactors = 2, rotate = "varimax") # 獲取主成分得分的系數(shù)擂达。
round(unclass(rc$weights),2) # 返回結(jié)果土铺。
## RC1 RC2
## height 0.28 -0.05
## arm.span 0.30 -0.08
## forearm 0.30 -0.09
## lower.leg 0.28 -0.06
## weight -0.06 0.33
## bitro.diameter -0.08 0.32
## chest.girth -0.10 0.34
## chest.width -0.04 0.27
14.3 探索性因子分析
如果你的目標(biāo)是尋求可解釋觀測變量的潛在隱含變量,可使用因子分析板鬓。
EFA的目標(biāo)是通過發(fā)掘隱藏在數(shù)據(jù)下的一組較少的悲敷、更為基本的無法觀測的變量,來解釋一
組可觀測變量的相關(guān)性俭令。這些虛擬的后德、無法觀測的變量稱作因子。(每個(gè)因子被認(rèn)為可解釋多個(gè)
觀測變量間共有的方差抄腔,因此準(zhǔn)確來說瓢湃,它們應(yīng)該稱作公共因子。)
其中是第i個(gè)可觀測變量(i = 1…k)赫蛇,
是公共因子(j = 1…p)绵患,并且p<k。
是
變量獨(dú)有的部分(無法被公共因子解釋)悟耘。
可認(rèn)為是每個(gè)因子對(duì)復(fù)合而成的可觀測變量的貢獻(xiàn)值落蝙。
ability.cov # 查看數(shù)據(jù)集。
## $cov
## general picture blocks maze reading vocab
## general 24.641 5.991 33.520 6.023 20.755 29.701
## picture 5.991 6.700 18.137 1.782 4.936 7.204
## blocks 33.520 18.137 149.831 19.424 31.430 50.753
## maze 6.023 1.782 19.424 12.711 4.757 9.075
## reading 20.755 4.936 31.430 4.757 52.604 66.762
## vocab 29.701 7.204 50.753 9.075 66.762 135.292
##
## $center
## [1] 0 0 0 0 0 0
##
## $n.obs
## [1] 112
options(digits = 2) # 設(shè)置數(shù)值顯示的小數(shù)點(diǎn)位數(shù)暂幼。
covariances <- ability.cov$cov # 提取協(xié)方差矩陣的cov筏勒。
correlations <- cov2cor(covariances) # 將協(xié)方差矩陣轉(zhuǎn)化為相關(guān)系數(shù)矩陣。
correlations # 返回轉(zhuǎn)化的結(jié)果旺嬉。
## general picture blocks maze reading vocab
## general 1.00 0.47 0.55 0.34 0.58 0.51
## picture 0.47 1.00 0.57 0.19 0.26 0.24
## blocks 0.55 0.57 1.00 0.45 0.35 0.36
## maze 0.34 0.19 0.45 1.00 0.18 0.22
## reading 0.58 0.26 0.35 0.18 1.00 0.79
## vocab 0.51 0.24 0.36 0.22 0.79 1.00
14.3.1 判斷需提取的公共因子數(shù)
library(psych) # 調(diào)用psych包管行。
covariances <- ability.cov$cov # 提取協(xié)方差矩陣的cov。
correlations <- cov2cor(covariances) # 將協(xié)方差矩陣轉(zhuǎn)化為相關(guān)系數(shù)矩陣邪媳。
fa.parallel(correlations,n.obs = 112,fa = "both",n.iter = 100, main = "Scree plots with paralled analysis") # 判斷要提取的因子數(shù)捐顷。
碎石檢驗(yàn)的前兩個(gè)特征值(三角形)都在拐角處之上,并且大于基于100次模擬數(shù)據(jù)矩陣的特征值均值雨效。對(duì)于EFA套菜,Kaiser-Harris準(zhǔn)則的特征值數(shù)大于0,而不是1设易。
結(jié)果解讀:PCA結(jié)果建議提取一個(gè)或者兩個(gè)成分逗柴,EFA建議提取兩個(gè)因子。
14.3.2 提取公共因子
fa(r, nfactors=, n.obs=, rotate=, scores=, fm=)
? r是相關(guān)系數(shù)矩陣或者原始數(shù)據(jù)矩陣顿肺;
? nfactors設(shè)定提取的因子數(shù)(默認(rèn)為1)戏溺;
? n.obs是觀測數(shù)(輸入相關(guān)系數(shù)矩陣時(shí)需要填寫)渣蜗;
? rotate設(shè)定旋轉(zhuǎn)的方法(默認(rèn)互變異數(shù)最小法);
? scores設(shè)定是否計(jì)算因子得分(默認(rèn)不計(jì)算)旷祸;
? fm設(shè)定因子化方法(默認(rèn)極小殘差法)耕拷。
與PCA不同,提取公共因子的方法很多托享,包括最大似然法(ml)骚烧、主軸迭代法(pa)、加權(quán)最小二乘法(wls)闰围、廣義加權(quán)最小二乘法(gls)和最小殘差法(minres)赃绊。統(tǒng)計(jì)學(xué)家青睞使用最大似然法,因?yàn)樗辛己玫慕y(tǒng)計(jì)性質(zhì)羡榴。
fa <- fa(correlations, nfactors = 2, rotate = "none", fm = "pa") # 提取兩個(gè)公共因子碧查。
fa # 返回結(jié)果。
## Factor Analysis using method = pa
## Call: fa(r = correlations, nfactors = 2, rotate = "none", fm = "pa")
## Standardized loadings (pattern matrix) based upon correlation matrix
## PA1 PA2 h2 u2 com
## general 0.75 0.07 0.57 0.432 1.0
## picture 0.52 0.32 0.38 0.623 1.7
## blocks 0.75 0.52 0.83 0.166 1.8
## maze 0.39 0.22 0.20 0.798 1.6
## reading 0.81 -0.51 0.91 0.089 1.7
## vocab 0.73 -0.39 0.69 0.313 1.5
##
## PA1 PA2
## SS loadings 2.75 0.83
## Proportion Var 0.46 0.14
## Cumulative Var 0.46 0.60
## Proportion Explained 0.77 0.23
## Cumulative Proportion 0.77 1.00
##
## Mean item complexity = 1.5
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 2.5
## The degrees of freedom for the model are 4 and the objective function was 0.07
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.06
##
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## PA1 PA2
## Correlation of (regression) scores with factors 0.96 0.92
## Multiple R square of scores with factors 0.93 0.84
## Minimum correlation of possible factor scores 0.86 0.68
結(jié)果解讀:兩個(gè)因子的Proportion Var分別為0.46和0.14校仑,兩個(gè)因子解釋了六個(gè)心理學(xué)測試60%的方差忠售。
14.3.3 因子旋轉(zhuǎn)
fa.varimax <- fa(correlations, nfactors = 2, rotate = "varimax", fm = "pa") # 正交旋轉(zhuǎn)提取因子。
fa.varimax # 返回結(jié)果迄沫。
## Factor Analysis using method = pa
## Call: fa(r = correlations, nfactors = 2, rotate = "varimax", fm = "pa")
## Standardized loadings (pattern matrix) based upon correlation matrix
## PA1 PA2 h2 u2 com
## general 0.49 0.57 0.57 0.432 2.0
## picture 0.16 0.59 0.38 0.623 1.1
## blocks 0.18 0.89 0.83 0.166 1.1
## maze 0.13 0.43 0.20 0.798 1.2
## reading 0.93 0.20 0.91 0.089 1.1
## vocab 0.80 0.23 0.69 0.313 1.2
##
## PA1 PA2
## SS loadings 1.83 1.75
## Proportion Var 0.30 0.29
## Cumulative Var 0.30 0.60
## Proportion Explained 0.51 0.49
## Cumulative Proportion 0.51 1.00
##
## Mean item complexity = 1.3
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 2.5
## The degrees of freedom for the model are 4 and the objective function was 0.07
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.06
##
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## PA1 PA2
## Correlation of (regression) scores with factors 0.96 0.92
## Multiple R square of scores with factors 0.91 0.85
## Minimum correlation of possible factor scores 0.82 0.71
結(jié)果解讀:閱讀和詞匯在第一因子上載荷較大稻扬,畫圖、積木圖案和迷宮在第二因子上載荷較大羊瘩,非語言的普通智力測量在兩個(gè)因子上載荷較為平均腐螟,這表明存在一個(gè)語言智力因子和一個(gè)非語言智力因子。
fa.promax <- fa(correlations, nfactors = 2, rotate = "promax", fm = "pa") # 斜交旋轉(zhuǎn)提取因子困后。
fa.promax # 返回結(jié)果。
## Factor Analysis using method = pa
## Call: fa(r = correlations, nfactors = 2, rotate = "promax", fm = "pa")
## Standardized loadings (pattern matrix) based upon correlation matrix
## PA1 PA2 h2 u2 com
## general 0.37 0.48 0.57 0.432 1.9
## picture -0.03 0.63 0.38 0.623 1.0
## blocks -0.10 0.97 0.83 0.166 1.0
## maze 0.00 0.45 0.20 0.798 1.0
## reading 1.00 -0.09 0.91 0.089 1.0
## vocab 0.84 -0.01 0.69 0.313 1.0
##
## PA1 PA2
## SS loadings 1.83 1.75
## Proportion Var 0.30 0.29
## Cumulative Var 0.30 0.60
## Proportion Explained 0.51 0.49
## Cumulative Proportion 0.51 1.00
##
## With factor correlations of
## PA1 PA2
## PA1 1.00 0.55
## PA2 0.55 1.00
##
## Mean item complexity = 1.2
## Test of the hypothesis that 2 factors are sufficient.
##
## The degrees of freedom for the null model are 15 and the objective function was 2.5
## The degrees of freedom for the model are 4 and the objective function was 0.07
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.06
##
## Fit based upon off diagonal values = 0.99
## Measures of factor score adequacy
## PA1 PA2
## Correlation of (regression) scores with factors 0.97 0.94
## Multiple R square of scores with factors 0.93 0.88
## Minimum correlation of possible factor scores 0.86 0.77
正交旋轉(zhuǎn)和斜交旋轉(zhuǎn)的不同之處衬廷。
對(duì)于正交旋轉(zhuǎn)摇予,因子分析的重點(diǎn)在于因子結(jié)構(gòu)矩陣(變量與因子的相關(guān)系數(shù)),而對(duì)于斜交旋轉(zhuǎn)吗跋,因子分析會(huì)考慮三個(gè)矩陣:因子結(jié)構(gòu)矩陣侧戴、因子模式矩陣和因子關(guān)聯(lián)矩陣。
因子模式矩陣即標(biāo)準(zhǔn)化的回歸系數(shù)矩陣跌宛。它列出了因子預(yù)測變量的權(quán)重酗宋。因子關(guān)聯(lián)矩陣即因子相關(guān)系數(shù)矩陣。
fsm <- function(oblique) {
if (class(oblique)[2]=="fa" & is.null(oblique$Phi)) {
warning("Object doesn't look like oblique EFA")
} else {
P <- unclass(oblique$loading)
F <- P %*% oblique$Phi
colnames(F) <- c("PA1", "PA2")
return(F)
}
} # 構(gòu)建函數(shù)fsm疆拘。
fsm(fa.promax) # 通過fsm函數(shù)獲取變量和因子間的相關(guān)系數(shù)蜕猫。
## PA1 PA2
## general 0.64 0.69
## picture 0.32 0.61
## blocks 0.43 0.91
## maze 0.25 0.45
## reading 0.95 0.46
## vocab 0.83 0.45
factor.plot(fa.promax, labels=rownames(fa.promax$loadings)) # 繪制正交或者斜交結(jié)果的圖形。
圖形解讀:詞匯和閱讀在第一個(gè)因子(PA1)上載荷較大哎迄,而積木圖案回右、畫圖和迷宮在第二個(gè)因子(PA2)上載荷較大隆圆。普通智力測驗(yàn)在兩個(gè)因子上較為平均。
fa.diagram(fa.promax, simple=FALSE) # 兩因子斜交旋轉(zhuǎn)結(jié)果圖翔烁。
14.3.4 因子得分
fa.promax$weights # 通過二因子斜交旋轉(zhuǎn)法獲得用來計(jì)算因子得分的權(quán)重渺氧。
## PA1 PA2
## general 0.078 0.211
## picture 0.020 0.090
## blocks 0.037 0.702
## maze 0.027 0.035
## reading 0.743 0.030
## vocab 0.177 0.036
與可精確計(jì)算的主成分得分不同,因子得分只是估計(jì)得到的蹬屹。它的估計(jì)方法有多種侣背,fa()函數(shù)使用的是回歸方法。
14.3.5 其他與 EFA 相關(guān)的包
R包含了其他許多對(duì)因子分析非常有用的軟件包慨默。FactoMineR包不僅提供了PCA和EFA方法贩耐,還包含潛變量模型。它有許多此處我們并沒考慮的參數(shù)選項(xiàng)业筏,比如數(shù)值型變量和類別型變量的使用方法憔杨。FAiR包使用遺傳算法來估計(jì)因子分析模型,它增強(qiáng)了模型參數(shù)估計(jì)能力蒜胖,能夠處理不等式的約束條件消别,GPArotation包則提供了許多因子旋轉(zhuǎn)方法。最后台谢,還有nFactors包寻狂,它提供了用來判斷因子數(shù)目的許多復(fù)雜方法。
14.4 其他潛變量模型
14.5 小結(jié)
實(shí)戰(zhàn)練習(xí)
主成分分析
1.數(shù)據(jù)導(dǎo)入
數(shù)據(jù)結(jié)構(gòu):對(duì)10株玉米進(jìn)行了生物學(xué)性狀考察朋沮,考察指標(biāo)有株高蛇券,穗位,莖粗樊拓,穗長纠亚,禿頂,穗粗筋夏,穗行數(shù)蒂胞,行粒數(shù)。
df20 <- read.table(file = "D:/Documents/R wd/df20.csv", header = T, sep = ",") # 數(shù)據(jù)導(dǎo)入条篷。
df20 # 查看數(shù)據(jù)骗随。
## 株號(hào) 株高.cm. 穗位.cm. 莖粗.cm. 穗長.cm. 禿頂.cm. 穗粗.cm. 穗行數(shù).行.
## 1 1 237 90 14 21 2.5 52 18
## 2 2 233 88 16 19 3.0 44 18
## 3 3 229 84 15 20 2.0 50 12
## 4 4 245 80 17 20 0.0 47 16
## 5 5 230 70 14 15 4.0 46 16
## 6 6 215 70 13 18 4.0 46 16
## 7 7 210 84 11 18 6.0 48 14
## 8 8 208 85 12 18 3.0 47 14
## 9 9 229 90 15 18 2.5 46 14
## 10 10 232 87 17 18 2.0 47 16
## 行粒數(shù).粒.
## 1 34
## 2 35
## 3 37
## 4 36
## 5 35
## 6 23
## 7 23
## 8 24
## 9 32
## 10 31
- 判斷主成分?jǐn)?shù)量
library(psych) # 調(diào)用psych包。
df20.cor <- cor(df20[,-1]) # 計(jì)算相關(guān)矩陣赴叹。
fa.parallel(df20[,-1], fa = "pc", n.iter = 100, show.legend = FALSE, main = "Scree plot with parallel analysis") # 碎石檢驗(yàn)判斷主成分個(gè)數(shù)鸿染。
abline(h=1,lty=1,lwd=2,col="green") # 添加特征值準(zhǔn)則線。
結(jié)果解讀:選擇2個(gè)主成分即可保留樣本大量信息乞巧。
3.提取主成分
df20.df <- principal(df20[,-1], nfactors = 2, score = T, rotate = "varimax") # 提取2個(gè)主成分涨椒。
df20.df # 返回結(jié)果。
## Principal Components Analysis
## Call: principal(r = df20[, -1], nfactors = 2, rotate = "varimax", scores = T)
## Standardized loadings (pattern matrix) based upon correlation matrix
## RC1 RC2 h2 u2 com
## 株高.cm. 0.95 0.17 0.93 0.066 1.1
## 穗位.cm. 0.12 0.72 0.53 0.471 1.1
## 莖粗.cm. 0.96 0.01 0.93 0.073 1.0
## 穗長.cm. 0.27 0.84 0.79 0.213 1.2
## 禿頂.cm. -0.81 -0.32 0.76 0.242 1.3
## 穗粗.cm. -0.14 0.80 0.65 0.349 1.1
## 穗行數(shù).行. 0.46 -0.18 0.24 0.758 1.3
## 行粒數(shù).粒. 0.85 0.19 0.75 0.248 1.1
##
## RC1 RC2
## SS loadings 3.51 2.07
## Proportion Var 0.44 0.26
## Cumulative Var 0.44 0.70
## Proportion Explained 0.63 0.37
## Cumulative Proportion 0.63 1.00
##
## Mean item complexity = 1.1
## Test of the hypothesis that 2 components are sufficient.
##
## The root mean square of the residuals (RMSR) is 0.1
## with the empirical chi square 5.9 with prob < 0.95
##
## Fit based upon off diagonal values = 0.95
結(jié)果解讀:主成分1可解釋44%的方差,主成分2解釋了26%的方差丢烘,合計(jì)解釋了70%的方差柱宦。
4.獲取主成分得分
dft <- round(unclass(df20.df$weights),2) # 獲取主成分得分。
dft # 返回結(jié)果播瞳。
## RC1 RC2
## 株高.cm. 0.27 -0.01
## 穗位.cm. -0.04 0.36
## 莖粗.cm. 0.29 -0.10
## 穗長.cm. -0.01 0.41
## 禿頂.cm. -0.21 -0.08
## 穗粗.cm. -0.13 0.43
## 穗行數(shù).行. 0.16 -0.15
## 行粒數(shù).粒. 0.24 0.01
5.主成分方程
PC1 = 0.27株高 - 0.04
穗位 + 0.29
莖粗 - 0.01
穗長 - 0.21
禿頂 - 0.13
穗粗 + 0.16
穗行數(shù) + 0.24
行粒數(shù)
PC2 = -0.01株高 + 0.36
穗位 - 0.10
莖粗 + 0.41
穗長 - 0.08
禿頂 + 0.43
穗粗 - 0.15
穗行數(shù) + 0.01
行粒數(shù)
plot(df20.df) # 主成分分析可視化
圖形解讀:此圖反映了變量與主成分的關(guān)系掸刊,三個(gè)藍(lán)點(diǎn)對(duì)應(yīng)的RC2值較高,點(diǎn)上的標(biāo)號(hào)2赢乓,4忧侧,6對(duì)應(yīng)變量名穗位,穗長牌芋,穗粗蚓炬,說明第2主成分主要解釋了這些變量,與這些變量相關(guān)性強(qiáng)躺屁;黑點(diǎn)分別對(duì)應(yīng)株高肯夏,莖粗,穗行數(shù)犀暑,行粒數(shù)驯击,說明第一主成分與這些變量相關(guān)性強(qiáng),第一主成分主要解釋的也是這些變量耐亏,而5號(hào)點(diǎn)禿頂對(duì)于兩個(gè)主成分均沒有顯示好的相關(guān)性徊都。
因子分析
- 判斷因子數(shù)量
library(psych) # 調(diào)用psych包。
df20.cor <- cor(df20[,-1]) # 計(jì)算相關(guān)矩陣广辰。
fa.parallel(df20[,-1], fa = "fa", n.iter = 100, show.legend = FALSE, main = "Scree plot with parallel analysis") # 碎石檢驗(yàn)判斷主成分個(gè)數(shù)暇矫。
abline(h=0,lty=1,lwd=2,col="green") # 添加特征值準(zhǔn)則線。
圖解:可以看到需要提取4個(gè)因子择吊。
2.提取因子
df20.df1 <- fa(df20.cor, nfactors = 4, rotate = "promax",fm="ml") # 最大似然法提取4個(gè)因子李根。
df20.df1 # 返回結(jié)果。
## Factor Analysis using method = ml
## Call: fa(r = df20.cor, nfactors = 4, rotate = "promax", fm = "ml")
## Standardized loadings (pattern matrix) based upon correlation matrix
## ML1 ML2 ML3 ML4 h2 u2 com
## 株高.cm. 0.97 -0.06 0.19 0.14 1.00 0.0050 1.1
## 穗位.cm. -0.04 0.60 -0.02 0.02 0.35 0.6467 1.0
## 莖粗.cm. 0.87 0.09 0.03 -0.32 1.00 0.0049 1.3
## 穗長.cm. -0.01 0.88 0.12 0.31 0.98 0.0169 1.3
## 禿頂.cm. -0.68 -0.39 0.14 0.19 0.85 0.1493 1.9
## 穗粗.cm. 0.04 0.18 -0.06 0.73 0.63 0.3709 1.1
## 穗行數(shù).行. 0.02 0.05 0.97 -0.09 0.97 0.0327 1.0
## 行粒數(shù).粒. 1.03 -0.23 -0.07 0.26 0.87 0.1321 1.2
##
## ML1 ML2 ML3 ML4
## SS loadings 3.24 1.45 1.04 0.92
## Proportion Var 0.41 0.18 0.13 0.11
## Cumulative Var 0.41 0.59 0.72 0.83
## Proportion Explained 0.49 0.22 0.16 0.14
## Cumulative Proportion 0.49 0.71 0.86 1.00
##
## With factor correlations of
## ML1 ML2 ML3 ML4
## ML1 1.00 0.43 0.24 -0.09
## ML2 0.43 1.00 -0.01 0.21
## ML3 0.24 -0.01 1.00 -0.04
## ML4 -0.09 0.21 -0.04 1.00
##
## Mean item complexity = 1.3
## Test of the hypothesis that 4 factors are sufficient.
##
## The degrees of freedom for the null model are 28 and the objective function was 7.5
## The degrees of freedom for the model are 2 and the objective function was 0.34
##
## The root mean square of the residuals (RMSR) is 0.03
## The df corrected root mean square of the residuals is 0.11
##
## Fit based upon off diagonal values = 1
## Measures of factor score adequacy
## ML1 ML2 ML3 ML4
## Correlation of (regression) scores with factors 1.00 0.99 0.98 0.98
## Multiple R square of scores with factors 1.00 0.98 0.97 0.97
## Minimum correlation of possible factor scores 0.99 0.96 0.94 0.93
結(jié)果解讀:因子1到4解釋了80%的方差几睛。
3.獲取因子得分
df20.df1$weights # 返回得分房轿。
## ML1 ML2 ML3 ML4
## 株高.cm. 0.63292 -0.5131 0.2709 1.4293
## 穗位.cm. -0.00017 0.0188 -0.0030 -0.0029
## 莖粗.cm. 0.38640 0.6016 -0.2073 -1.6872
## 穗長.cm. 0.01902 0.9569 -0.0025 0.3491
## 禿頂.cm. -0.01549 -0.0600 0.0467 0.0328
## 穗粗.cm. 0.00723 0.0018 -0.0174 0.0642
## 穗行數(shù).行. -0.12547 -0.0308 0.9377 -0.2525
## 行粒數(shù).粒. 0.03649 -0.0440 -0.0546 0.0999
- 可視化
factor.plot(df20.df1,labels=rownames(df20.df1$loadings)) # 可視化。
fa.diagram(df20.df1,simple = TRUE) # 因子分析可視化
圖解:可以看出枉长,因子1和因子2的相關(guān)系數(shù)為0.4,行粒數(shù)琼讽,株高必峰,莖粗,禿頂在因子1的載荷較大钻蹬,穗長吼蚁,穗位在因子2上的載荷較大;因子3只有穗行數(shù)相關(guān),因子4只有穗粗相關(guān)肝匆。
參考資料:
- 《R語言實(shí)戰(zhàn)》(中文版)粒蜈,人民郵電出版社,2013.
- 如何理解主成分分析法 (PCA)旗国,https://zhuanlan.zhihu.com/p/170398464
- 主成分分析法枯怖,https://blog.csdn.net/weixin_43914260/article/details/99585202