#探索的因子分析 install.packages(c("lavaan","semTools","semPlot")) X <- read.csv("book5-3.csv", header=T) factanal(X,factors=9,rotation="promax") #確認的因子分析 X <- read.csv("book5-5.csv", header=T) X.model.cfa <- ' f1 =~ taiikukai1+taiikukai2+taiikukai3 f2 =~ kyousou1+kyousou2+kyousou3 f3 =~ dentou1+dentou2+dentou3 f4 =~ kizuna1+kizuna2+kizuna3 f5 =~ shutaisei1+shutaisei2+shutaisei3+shutaisei4 f6 =~ ishi1+ishi2+ishi4 f7 =~ rita1+rita2+rita3 f8 =~ tasseikan1+tasseikan2 f9 =~ keni1+keni3 f10 =~ sex f11 =~ koukoudantai f12 =~ hindo f13 =~ manzoku f14 =~ koukai' library(lavaan) fit <-cfa(model=X.model.cfa,data=X,estimator="ML") summary(fit, fit.measures=TRUE,standardized=T,rsquare=T) #共分散構造分析 XX.model.sem <- ' f1 =~ taiikukai1+taiikukai2+taiikukai3 f2 =~ kyousou1+kyousou2+kyousou3 f3 =~ dentou1+dentou2+dentou3 f4 =~ kizuna1+kizuna2+kizuna3 f5 =~ shutaisei1+shutaisei2+shutaisei3+shutaisei4 f6 =~ ishi1+ishi2+ishi4 f7 =~ rita1+rita2+rita3 f8 =~ tasseikan1+tasseikan2 f9 =~ keni1+keni3' library(lavaan) fit1<-sem(model=XX.model.sem,data=X,estimator="ML") summary(object=fit1) summary(fit1, fit.measures=TRUE,standardized=T,rsquare=T) #コンジョイント(勧誘特性) library(conjoint) experiment<-expand.grid(katuyaku=c("aru","nai"), ibento=c("ari","nashi"), hiritu=c("takai","hutuu","hikui"), sukejuru=c("meikaku","yayameikaku","nashi")) design caEncodedDesign(design) cor(caEncodedDesign(design)) X <- read.csv("book-kan1.csv", header=T) tprefm<-X tlevn<-as.matrix(c("aru","nai","ari","nashi","takai","hutuu","hikui","meikaku","yayameikaku","nashi")) Conjoint(tprefm,tprof,tlevn) #コンジョイント(部活動特性) library(conjoint) experiment<-expand.grid( jisseki=c("aru","nai"), soubu=c("120","20"), shinro=c("ari","nashi"), kankyou=c("yoi","warui")) design <- caFactorialDesign(data=experiment,type="orthogonal") design caEncodedDesign(design) cor(caEncodedDesign(design)) X <- read.csv("book-bu1.csv", header=T) tprefm<-X tprof<-caEncodedDesign(design) tlevn<-as.matrix(c("aru","nai","120","20","ari","nashi","yoi","warui")) Conjoint(tprefm,tprof,tlevn) #二項ロジスティック回帰分析 X<-read.csv("tuika1.csv", header=T, fileEncoding="utf-8") logi3<-glm(dantai~daigaku+daigakuigai+baito+asobu+utikomu+nakama+kennkou+koibito+nomikai+seika,data=X,family=binomial) summary(logi3)