#コレスポンデンス分析 y<-matrix(c(62,12,91,23,15,8,21,61,81,5,89,4, 38,27,47,15,18,13,17,39,31,8,55,44, 26,24,22,11,43,41,5,22,27,9,37,85, 3,2,6,1,2,0,0,2,1,0,2,152),ncol=12,byrow=TRUE) colnames(y)<-c("信頼","個性的","庶民的","性能悪い","デザイン","センス","品質","シンプル","品揃え","飽きない","安い","知らない") rownames(y)<-c("ダイソ-","キャンドゥ","セリア","ワッツ") sum(y) margin.table(y,margin=1) margin.table(y,margin=2) prop.table(y, margin=1) 100*prop.table(y, margin=1) round(100*prop.table(y, margin=1),1)  library(MASS) y.ca <- corresp(y, nf=2) summary(y.ca) y.ca$Freq y.ca$cor y.eig <- y.ca$cor^2 round(100*y.eig / sum(y.eig),2) y.ca$cscore  y.ca$rscore  biplot(y.ca) #店舗属性 探索的因子分析・確認的因子分析・SEM x<-read.delim("clipboard") result <- factanal(x, factors=3, rotation="promax", scores="regression") model.cfa <- ' haiti =~ haiti3 kougaku=~kougaku1+kougaku2 kinnitu=~kinnitu2+kinnitu3 sinazoroe=~sinazoroe1+sinazoroe2' fit<-cfa(model.cfa,data=x) summary(fit,standardized=T,fit.measures=T) modindices(fit,sort=T) model.sem <- ' haiti =~ haiti3 kougaku=~kougaku1+kougaku2 kinnitu=~kinnitu2+kinnitu3 sinazoroe=~sinazoroe1+sinazoroe2 riyouhindo~haiti+kougaku+kinnitu+sinazoroe+can.do+daiso+seria' fit <-sem(model.sem, data=x, estimator="ML",meanstructure=TRUE,int.ov.free=T,auto.var=TRUE, auto.fix.first=TRUE,auto.cov.lv.x=TRUE) summary(object=fit) summary(object=fit, fit.measure=TRUE) standardizedSolution(object=fit) predict(object=fit) #消費者特性 探索的因子分析・確認的因子分析・SEM x<-read.delim("clipboard") result <- factanal(x, factors=6, rotation="promax", scores="regression") model.cfa <- ' sinnkisei=~sinnkisei1+sinnkisei2+sinnkisei3 kasyobunn=~kasyobunn1+kasyobunn2 opinionn=~opinionn1+opinionn2 hinnsitu=~hinnsitu2+hinnsitu3 doutyou=~doutyou1+doutyou2+doutyou3 seihinnkannyo=~seihinnkannyo1+seihinnkannyo2 osyare=~osyare1+osyare2+osyare3' fit<-cfa(model.cfa,data=x) summary(fit,standardized=T,fit.measures=T) modindices(fit,sort=T) model.sem <- ' sinnkisei=~sinnkisei1+sinnkisei2+sinnkisei3 kasyobunn=~kasyobunn1+kasyobunn2 opinionn=~opinionn1+opinionn2 hinnsitu=~hinnsitu2+hinnsitu3 doutyou=~doutyou1+doutyou2+doutyou3 seihinnkannyo=~seihinnkannyo1+seihinnkannyo2 osyare=~osyare1+osyare2+osyare3 riyouhindo~sinnkisei+kasyobunn+opinionn+hinnsitu+doutyou+seihinnkannyo+osyare+seibetu' fit <-sem(model.sem, data=x, estimator="ML",meanstructure=TRUE,int.ov.free=T,auto.var=TRUE, auto.fix.first=TRUE,auto.cov.lv.x=TRUE) summary(object=fit) summary(object=fit, fit.measure=TRUE) standardizedSolution(object=fit) predict(object=fit) #店舗属性重回帰分析 x0<-read.delim("clipboard") x<-read.delim("clipboard") x1<-factanal(x, factors = 3, rotation = "promax",scores="regression")# x1$scores x2<-data.frame(x0,x1$scores)#x0(元データ)とx1を合成 summary(lm(riyouhindo~ Factor1+Factor2+Factor3,x2)) #消費者特性重回帰分析 y0<-read.delim("clipboard") y<-read.delim("clipboard") y1<-factanal(y, factors = 6, rotation = "promax",scores="regression") y1$scores y2<-data.frame(y0,y1$scores) edit(y2) summary(lm(riyouhindo~ Factor1+Factor2+Factor3+Factor4+Factor5+Factor6+seibetu,y2))