楼主: niuhuang5916
4697 4

[问答] 关于PCA和数据缺失的问题 [推广有奖]

  • 7关注
  • 0粉丝

已卖:4份资源

大专生

21%

还不是VIP/贵宾

-

威望
0
论坛币
1 个
通用积分
3.0000
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
801 点
帖子
21
精华
0
在线时间
65 小时
注册时间
2012-1-2
最后登录
2020-7-5

楼主
niuhuang5916 发表于 2014-2-7 13:46:11 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

插补数值mice函数如下:数据集dataname

library(mice)
X=mice(dataname,seed=1000)
Y=with(X,lm(a~b+c))
Z=pool(Y)
summary(Z)


请问我想用插补后的数据进行PCA主成分分析,怎么做呢?

虚心求教!


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:数据缺失 pca elibrary Library Summary

沙发
DM小菜鸟 发表于 2014-12-16 13:44:00
给你一个例子吧

pca
head(iris)
library(psych)
cortest.bartlett(cor(iris[,-5]), n=150)


kmo = function( data ){
   library(MASS)
   X <- cor(as.matrix(data))
   iX <- ginv(X)
   S2 <- diag(diag((iX^-1)))
   AIS <- S2%*%iX%*%S2 # anti-image covariance matrix
   IS <- X+AIS-2*S2 # image covariance matrix
   Dai <- sqrt(diag(diag(AIS)))
   IR <- ginv(Dai)%*%IS%*%ginv(Dai) # image correlation matrix
   AIR <- ginv(Dai)%*%AIS%*%ginv(Dai) # anti-image correlation matrix
   a <- apply((AIR - diag(diag(AIR)))^2, 2, sum)
   AA <- sum(a)
   b <- apply((X - diag(nrow(X)))^2, 2, sum)
   BB <- sum(b)
   MSA <- b/(b+a) # indiv. measures of sampling adequacy
   
   AIR <- AIR-diag(nrow(AIR))+diag(MSA) # Examine the anti-image of the
   # correlation matrix. That is the
   # negative of the partial correlations,
   # partialling out all other variables.
   
   kmo <- BB/(AA+BB) # overall KMO statistic
   
   # Reporting the conclusion
   if (kmo >= 0.00 && kmo < 0.50){
      test <- 'The KMO test yields a degree of common variance
    unacceptable for FA.'
   } else if (kmo >= 0.50 && kmo < 0.60){
      test <- 'The KMO test yields a degree of common variance miserable.'
   } else if (kmo >= 0.60 && kmo < 0.70){
      test <- 'The KMO test yields a degree of common variance mediocre.'
   } else if (kmo >= 0.70 && kmo < 0.80){
      test <- 'The KMO test yields a degree of common variance middling.'
   } else if (kmo >= 0.80 && kmo < 0.90){
      test <- 'The KMO test yields a degree of common variance meritorious.'
   } else {
      test <- 'The KMO test yields a degree of common variance marvelous.'
   }
   
   ans <- list( overall = kmo,
                report = test,
                individual = MSA,
                AIS = AIS,
                AIR = AIR )
   return(ans)
   
} # end of kmo()


kmo(iris[,-5])


iris.pr<-princomp(iris[,-5],cor=TRUE)
summary(iris.pr,loadings=TRUE)
plot(iris.pr,type="lines")


iris.pr$scores
scale(iris.pr$scores)

藤椅
niuhuang5916 发表于 2015-4-23 10:57:04
谢谢你。

板凳
niuhuang5916 发表于 2015-4-23 10:58:04
DM小菜鸟 发表于 2014-12-16 13:44
给你一个例子吧

pca
谢谢您!

报纸
kuaijiangji 发表于 2019-12-6 14:22:56
搭车请教个问题:缺失率是多少的时候,就考虑不把该变量纳入PCA中了呢,谢谢。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-25 23:20