Principal component analysis and exploratory factor analysis are common methods used to explore and simplify multivariable complex relationships, which can solve the problem of multivariable data with over-complexity of information.
PCA: A data dimensionality reduction technique that transforms a large number of related variables into a small set of unrelated variables called principal components
Exploratory factor Analysis EFA: a way to discover the potential structure of a set of variables by looking for a smaller, potentially hidden structure that reveals the relationships between observed and explicit variables.
The PCA and EFA functions provided in the R base installation package are Princoomp () and factanal () respectively, and the psych package also provides the relevant functions, which provide a richer and more useful option than the underlying function.
Principal Component Analysis:
Determine the number of principal components: 1) prior knowledge, 2) The threshold value of the accumulated value of the variance of the variable is interpreted to determine the required primary score, 3) check the k*k correlation coefficient matrix between variables to determine the retention of the main score
Principal (R, Nfactors=, rotate=, score =)
R is the correlation coefficient matrix or the original data matrix
Nfactors Setting the main score
Rotate specifies the method of rotation (default, maximum variance rotation)
Scores setting whether to calculate the principal component score (not required by default)
Library (Psych) #这个例子只有一个主成分 # Delete the cont variable (subscript-1), generate three evaluation indicators Fa.parallel (usjudgeratings[,-1],fa= ' pc ', n.iter=100, Show.legend = FALSE) #图中表明选择一个主成分便可, then use the principal () function to pick out the corresponding main component PC <-Principal (usjudgeratings[,-1],nfactors = 1, Scores=true) pc# get the ingredient score from the raw data pc$scores# This example has 2 main components Fa.parallel (harman23.cor$cov,n.obs=302,fa= ' pc ', n.iter=100, Show.legend = FALSE) rc <-principal (harman23.cor$cov,nfactors=2,rotate= "VariMAX", Scores=true) rc# principal component analysis based on the correlation coefficient matrix, Raw data not available round (Unclass (rc$weights), 2) Attach (Harman23.cor) #利用以下公式 #pc1 = 0.28*cov$height + 0.30*arm.span + 0.30*foream + 0.29*lower.leg-0.0#6*weight-0.08*bitro.diameter-0.10*chest.girth-0.04*chest.width
Exploratory factor Analysis:
The EFA goal is to uncover the relevance of a set of observable variables by discovering a small set of less-than-observable variables hidden in the data. These virtual, observable variables are called factors.
The library (psych) options (digits=2) #数据集ability. CoV provides a covariance matrix of variables covariances<-ability.cov$cov# Using Cov2cor to convert it to the correlation coefficient matrix Correlations<-cov2cor (covariances) correlations# determine the number of primers to extract fa.parallel (Correlations,n.obs = 112,fa= "Both", n.iter=100) #用fa函数获取相应的结果fa <-fa (correlations, nfactors=2,rotate= "None", fm= ' pa ') FA
[Reading notes] R language Combat (14) principal component and factor analysis