1、加载数据并做主成分分析:
data9.3<- c(1.000, 0.846, 0.805, 0.859, 0.473, 0.398, 0.301, 0.382,
0.846, 1.000, 0.881, 0.826, 0.376, 0.326, 0.277, 0.277,
0.805, 0.881, 1.000, 0.801, 0.380, 0.319, 0.237, 0.345,
0.859, 0.826, 0.801, 1.000, 0.436, 0.329, 0.327, 0.365,
0.473, 0.376, 0.380, 0.436, 1.000, 0.762, 0.730, 0.629,
0.398, 0.326, 0.319, 0.329, 0.762, 1.000, 0.583, 0.577,
0.301, 0.277, 0.237, 0.327, 0.730, 0.583, 1.000, 0.539,
0.382, 0.415, 0.345, 0.365, 0.629, 0.577, 0.539, 1.000)
names<-c("身高 x1", "手臂长 x2", "上肢长 x3", "下肢长 x4", "体重 x5",
"颈围 x6", "胸围 x7", "胸宽 x8")
data<-matrix(data9.3, nrow=8, dimnames=list(names, names))
data.pr<-princomp(data,cor=TRUE)#
summary(data.pr,loadings=TRUE)
两个主成分的时候累计贡献率为90.5%,已经满足,再看碎石图:
接近大于1的有两个,所以因子数量等于2
2、下面做因子分析:
源码:
data9.3<- c(1.000, 0.846, 0.805, 0.859, 0.473, 0.398, 0.301, 0.382,
0.846, 1.000, 0.881, 0.826, 0.376, 0.326, 0.277, 0.277,
0.805, 0.881, 1.000, 0.801, 0.380, 0.319, 0.237, 0.345,
0.859, 0.826, 0.801, 1.000, 0.436, 0.329, 0.327, 0.365,
0.473, 0.376, 0.380, 0.436, 1.000, 0.762, 0.730, 0.629,
0.398, 0.326, 0.319, 0.329, 0.762, 1.000, 0.583, 0.577,
0.301, 0.277, 0.237, 0.327, 0.730, 0.583, 1.000, 0.539,
0.382, 0.415, 0.345, 0.365, 0.629, 0.577, 0.539, 1.000)
names<-c("身高 x1", "手臂长 x2", "上肢长 x3", "下肢长 x4", "体重 x5",
"颈围 x6", "胸围 x7", "胸宽 x8")
data<-matrix(data9.3, nrow=8, dimnames=list(names, names))
data.pr<-princomp(data,cor=TRUE)#
summary(data.pr,loadings=TRUE)
screeplot(data.pr,type='lines')
factanal(factors=2,covmat=data)