######################################################### #Sawtooth Software #Analysis of Traditional Conjoint Using Excel: An Introductory Example #http://www.sawtoothsoftware.com/ #http://www.sawtoothsoftware.com/download/techpap/caexcel.pdf ######################################################### source("http://blue.zero.jp/yokumura/R/conjoint/conjoint.txt") ##(a) データの読み込み dat <- read.csv("http://blue.zero.jp/yokumura/R/conjoint/traditional.csv",header=F,row.names="V1") ###(b) シンプルなlmにて dat2 <- dat dat2[,1] <- factor(dat2[,1]) dat2[,2] <- factor(dat2[,2]) dat2[,3] <- factor(dat2[,3]) reg1 <- lm(V5~V2 + V3 + V4, data=dat2) summary(reg1) ##(c) ダミー変数を指定した上で dat3 <- data.frame( model.matrix(~dat2$V2-1), model.matrix(~dat2$V3-1), model.matrix(~dat2$V4-1), dat2$V5 ) dat4 <- dat3[,c(-1,-4,-6)] reg2 <- lm(dat4[,6] ~ dat4[,1] + dat4[,2] + dat4[,3] + dat4[,4] + dat4[,5]) summary(reg2) ##(d) オリジナル関数を使った場合(解釈の簡単の為に,負の符号は出ないようにしている) #conjoint.txtには,コンジョイント分析を自動実行するプログラムが記載されている #(最小二乗法・評定尺度値 限定). #使い方は, #conjoint(data) #と入力するだけである. #dataの中身は,最後の行に測定値,残りの行に直交表を記載しておくだけで良い dat$V2 <- factor(dat$V2,labels=c("A","B","C")) dat$V3 <- factor(dat$V3,labels=c("Red","Blue")) dat$V4 <- factor(dat$V4,labels=c("$50","$100","$150")) names(dat) <- c("Brand","Color","Price","Preference") dat conjoint(dat,graph=F) #グラフを出力しない conjoint(dat,graph=T) #グラフを出力