1 读取数据
5个专家给10个公司打分
c1=c(76.5,81.5,76, 75.8, 71.7, 85, 79.2, 80.3, 84.4, 76.5,
70.6, 73 ,67.6 ,68.1 ,78.5 ,94 ,94 ,87.5, 89.5, 92,
90.7, 87.3, 91, 81.5, 80, 84.6, 66.9, 68.8, 64.8, 66.4,
77.5 ,73.6 ,70.9 ,69.8 ,74.8 ,57.7, 60.4, 57.4, 60.8, 65,
85.6, 68.5, 70, 62.2, 76.5, 70, 69.2, 71.7, 64.9, 68.9)
summary(c1)
mydata=matrix(c1,nrow=10)
mydata
##把各指标和公司命名
colnames(mydata)=paste("X",1:ncol(mydata),seq="")
rownames(mydata)=paste("com",1:nrow(mydata),seq="")
mydata
2 选择主成分最优数
2.1 fa
##先画碎石图,观察最优主成分个数
my=fa.parallel(mydata,fa="both",n.obs=10,n.iter=100,main="碎石图")
my
2.2 principal
###########旋转型
myr=principal(mydata,nfactors =5,rotate="varimax")
myr
3 各项的打分
myr$Vaccounted###各主成分方差信息
myr$Vaccounted["Proportion Explained",]
myr$scores
myr$loadings
4 得分的加权平均
###各公司信用评分————得分的加权平均
score_weights=myr$Vaccounted[2,]
credit=apply(myr$scores,1,function(x) weighted.mean(x,score_weights))
credit
#排序
score_sort=sort(credit,decreasing=T)
score_sort