knitr::opts_chunk$set(echo = TRUE)
if(!require("tidyverse")) {install.packages("tidyverse"); library("tidyverse")}
if(!require("haven")) {install.packages("haven"); library("haven")}
if(!require("Hmisc")) {install.packages("Hmisc"); library("Hmisc")}
if(!require("sjlabelled")) {install.packages("sjlabelled"); library("sjlabelled")}
if(!require("DescTools")) {install.packages("DescTools"); library("DescTools")}
if(!require("DoE.base")) {install.packages("DoE.base"); library("DoE.base")}
if(!require("forcats")) {install.packages("forcats"); library("forcats")}
if(!require("conjoint")) {install.packages("conjoint"); library("conjoint")}
if(!require("rlist")) {install.packages("rlist"); library("rlist")}
if(!require("cowplot")) {install.packages("cowplot"); library("cowplot")}
# clean up working environment
rm(list = ls())
# Creating a fractional Design for Testing | Orthogonal
test.design <- DoE.base::oa.design(nlevels = c(3,3,2,2,3,3))
## The columns of the array have been used in order of appearance.
## For designs with relatively few columns,
## the properties can sometimes be substantially improved
## using option columns with min3 or even min34.
FracDesign <- as.data.frame(test.design)
names(FracDesign) <- c("Flavor", "Size", "Superfoods", "Filling", "Packaging", "Price")
levels(FracDesign$Flavor) <- c("fruity", "nutty", "mixed")
levels(FracDesign$Size) <- c("5g","10g","15g")
levels(FracDesign$Superfoods) <- c("contains no superfoods","contains superfoods")
levels(FracDesign$Filling) <- c("creamy", "liquid")
levels(FracDesign$Packaging) <- c("individually wrapped in foil","individually wrapped in paper","not individually wrapped")
levels(FracDesign$Price) <- c("5.99 EUR","6.99 EUR","7.99 EUR")
rm(test.design)
# Save in Excel
write_excel_csv(FracDesign, "FracDesign.csv")
# Create all theoretically possible combinations
experiment <- expand.grid(
Flavor = c("fruity", "nutty", "mixed"),
Size = c("5g","10g","15g"),
Superfoods = c("contains no superfoods","contains Superfoods"),
Filling = c("creamy", "liquid"),
Packaging = c("individually wrapped in foil","individually wrapped in paper","not individually wrapped"),
Price = c("5.99 EUR","6.99 EUR","7.99 EUR")
)
# choose designs type: e.g., orthogonal design, fractional design,determine number of cards by parameter 'cards' (e.g. here 22 to create 4 more cards for holdout + 2 more cards for simulation)
# orthogonal design
ortho.design <- caFactorialDesign(data = experiment,
type = "orthogonal",
# cards = 22,
seed = 123)
# fractional design
frac.design <- caFactorialDesign(data = experiment,
type = "fractional",
# cards = 22,
seed = 123)
# Print design
print(ortho.design); print(cor(caEncodedDesign(ortho.design)));
## Flavor Size Superfoods Filling Packaging
## 1 fruity 5g contains no superfoods creamy individually wrapped in foil
## 8 nutty 15g contains no superfoods creamy individually wrapped in foil
## 23 nutty 10g contains no superfoods liquid individually wrapped in foil
## 30 mixed 5g contains Superfoods liquid individually wrapped in foil
## 47 nutty 5g contains Superfoods creamy individually wrapped in paper
## 51 mixed 10g contains Superfoods creamy individually wrapped in paper
## 61 fruity 15g contains no superfoods liquid individually wrapped in paper
## 63 mixed 15g contains no superfoods liquid individually wrapped in paper
## 77 nutty 10g contains no superfoods creamy not individually wrapped
## 85 fruity 10g contains Superfoods creamy not individually wrapped
## 102 mixed 5g contains Superfoods liquid not individually wrapped
## 106 fruity 15g contains Superfoods liquid not individually wrapped
## 119 nutty 5g contains Superfoods creamy individually wrapped in foil
## 134 nutty 15g contains no superfoods liquid individually wrapped in foil
## 139 fruity 10g contains Superfoods liquid individually wrapped in foil
## 141 mixed 10g contains Superfoods liquid individually wrapped in foil
## 148 fruity 10g contains no superfoods creamy individually wrapped in paper
## 154 fruity 5g contains Superfoods creamy individually wrapped in paper
## 164 nutty 5g contains no superfoods liquid individually wrapped in paper
## 168 mixed 10g contains no superfoods liquid individually wrapped in paper
## 183 mixed 5g contains no superfoods creamy not individually wrapped
## 187 fruity 15g contains no superfoods creamy not individually wrapped
## 197 nutty 15g contains Superfoods creamy not individually wrapped
## 216 mixed 15g contains Superfoods liquid not individually wrapped
## 222 mixed 10g contains no superfoods creamy individually wrapped in foil
## 225 mixed 15g contains no superfoods creamy individually wrapped in foil
## 232 fruity 15g contains Superfoods creamy individually wrapped in foil
## 244 fruity 5g contains Superfoods liquid individually wrapped in foil
## 266 nutty 10g contains Superfoods creamy individually wrapped in paper
## 270 mixed 15g contains Superfoods creamy individually wrapped in paper
## 271 fruity 5g contains no superfoods liquid individually wrapped in paper
## 287 nutty 15g contains Superfoods liquid individually wrapped in paper
## 291 mixed 5g contains no superfoods creamy not individually wrapped
## 308 nutty 5g contains no superfoods liquid not individually wrapped
## 310 fruity 10g contains no superfoods liquid not individually wrapped
## 320 nutty 10g contains Superfoods liquid not individually wrapped
## Price
## 1 5.99 EUR
## 8 5.99 EUR
## 23 5.99 EUR
## 30 5.99 EUR
## 47 5.99 EUR
## 51 5.99 EUR
## 61 5.99 EUR
## 63 5.99 EUR
## 77 5.99 EUR
## 85 5.99 EUR
## 102 5.99 EUR
## 106 5.99 EUR
## 119 6.99 EUR
## 134 6.99 EUR
## 139 6.99 EUR
## 141 6.99 EUR
## 148 6.99 EUR
## 154 6.99 EUR
## 164 6.99 EUR
## 168 6.99 EUR
## 183 6.99 EUR
## 187 6.99 EUR
## 197 6.99 EUR
## 216 6.99 EUR
## 222 7.99 EUR
## 225 7.99 EUR
## 232 7.99 EUR
## 244 7.99 EUR
## 266 7.99 EUR
## 270 7.99 EUR
## 271 7.99 EUR
## 287 7.99 EUR
## 291 7.99 EUR
## 308 7.99 EUR
## 310 7.99 EUR
## 320 7.99 EUR
## Flavor Size Superfoods Filling Packaging Price
## Flavor 1 0 0 0 0 0
## Size 0 1 0 0 0 0
## Superfoods 0 0 1 0 0 0
## Filling 0 0 0 1 0 0
## Packaging 0 0 0 0 1 0
## Price 0 0 0 0 0 1
print(frac.design); print(cor(caEncodedDesign(frac.design)))
## Flavor Size Superfoods Filling Packaging
## 6 mixed 10g contains no superfoods creamy individually wrapped in foil
## 46 fruity 5g contains Superfoods creamy individually wrapped in paper
## 92 nutty 5g contains no superfoods liquid not individually wrapped
## 106 fruity 15g contains Superfoods liquid not individually wrapped
## 133 fruity 15g contains no superfoods liquid individually wrapped in foil
## 138 mixed 5g contains Superfoods liquid individually wrapped in foil
## 162 mixed 15g contains Superfoods creamy individually wrapped in paper
## 176 nutty 10g contains Superfoods liquid individually wrapped in paper
## 181 fruity 5g contains no superfoods creamy not individually wrapped
## 186 mixed 10g contains no superfoods creamy not individually wrapped
## 227 nutty 5g contains Superfoods creamy individually wrapped in foil
## 260 nutty 15g contains no superfoods creamy individually wrapped in paper
## 273 mixed 5g contains no superfoods liquid individually wrapped in paper
## 274 fruity 10g contains no superfoods liquid individually wrapped in paper
## 301 fruity 10g contains Superfoods creamy not individually wrapped
## 324 mixed 15g contains Superfoods liquid not individually wrapped
## Price
## 6 5.99 EUR
## 46 5.99 EUR
## 92 5.99 EUR
## 106 5.99 EUR
## 133 6.99 EUR
## 138 6.99 EUR
## 162 6.99 EUR
## 176 6.99 EUR
## 181 6.99 EUR
## 186 6.99 EUR
## 227 7.99 EUR
## 260 7.99 EUR
## 273 7.99 EUR
## 274 7.99 EUR
## 301 7.99 EUR
## 324 7.99 EUR
## Flavor Size Superfoods Filling Packaging Price
## Flavor 1.00000000 0.00000000 0.00000000 0.00000000 -0.18490007 0.09245003
## Size 0.00000000 1.00000000 0.07559289 0.07559289 0.10894096 0.10894096
## Superfoods 0.00000000 0.07559289 1.00000000 0.00000000 0.00000000 0.00000000
## Filling 0.00000000 0.07559289 0.00000000 1.00000000 0.00000000 0.00000000
## Packaging -0.18490007 0.10894096 0.00000000 0.00000000 1.00000000 -0.02564103
## Price 0.09245003 0.10894096 0.00000000 0.00000000 -0.02564103 1.00000000
# Save in Excel
write_excel_csv(ortho.design, "ortho_design.csv")
write_excel_csv(frac.design, "frac_design.csv")
write_excel_csv(experiment, "experiment_allcombinations.csv")
# Generate data
mydatc9_case_design <- data.frame(ID = c(1:22),
Flavor = c(2, 2, 1, 1, 1, 3, 1, 1, 1, 2, 2, 3, 1, 1, 3, 3, 3, 3, 2, 1, 3, 1),
Size = c(1, 1, 1, 1, 3, 3, 1, 2, 2, 3, 2, 2, 3, 1, 1, 1, 2, 1, 1, 3, 1, 2),
Superfoods = c(1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 0),
Filling = c(2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 2, 1, 2, 1, 2),
Packaging = c(3, 2, 1, 1, 3, 1, 1, 3, 2, 1, 1, 1, 2, 1, 3, 2, 1, 3, 1, 2, 3, 2),
Price = c(5.99, 7.99, 6.99, 5.99, 6.99, 7.99, 7.99, 7.99, 5.99, 5.99, 6.99, 5.99, 5.99, 5.99, 5.99, 6.99, 5.99, 5.99, 5.99, 6.99, 6.99, 7.99),
STATUS_ = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2),
CARD_ = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2))
# Set labels
mydatc9_case_design$Flavor <- factor(mydatc9_case_design$Flavor,
levels = c(1:3),
labels = c("fruity",
"nutty",
"mixed"))
mydatc9_case_design$Size <- factor(mydatc9_case_design$Size,
levels = c(1:3),
labels = c("5g",
"10g",
"15g"))
mydatc9_case_design$Superfoods <- factor(mydatc9_case_design$Superfoods,
levels = c(0:1),
labels = c("contains no superfoods",
"contains superfoods"))
mydatc9_case_design$Filling <- factor(mydatc9_case_design$Filling,
levels = c(1:2),
labels = c("creamy",
"liquid"))
mydatc9_case_design$Packaging <- factor(mydatc9_case_design$Packaging,
levels = c(1:3),
labels = c("individually wrapped in foil",
"individually wrapped in paper",
"not individally wrapped"))
mydatc9_case_design$Price <- factor(mydatc9_case_design$Price,
levels = c(5.99, 6.99, 7.99),
labels = c("5.99 EUR",
"6.99 EUR",
"7.99 EUR"))
mydatc9_case_design$STATUS_ <- factor(mydatc9_case_design$STATUS_,
levels = c(0:2),
labels = c("Design",
"Holdout",
"Simulation"))
print(mydatc9_case_design)
## ID Flavor Size Superfoods Filling Packaging
## 1 1 nutty 5g contains superfoods liquid not individally wrapped
## 2 2 nutty 5g contains no superfoods liquid individually wrapped in paper
## 3 3 fruity 5g contains superfoods liquid individually wrapped in foil
## 4 4 fruity 5g contains no superfoods liquid individually wrapped in foil
## 5 5 fruity 15g contains no superfoods liquid not individally wrapped
## 6 6 mixed 15g contains superfoods liquid individually wrapped in foil
## 7 7 fruity 5g contains no superfoods creamy individually wrapped in foil
## 8 8 fruity 10g contains superfoods creamy not individally wrapped
## 9 9 fruity 10g contains superfoods liquid individually wrapped in paper
## 10 10 nutty 15g contains superfoods creamy individually wrapped in foil
## 11 11 nutty 10g contains no superfoods creamy individually wrapped in foil
## 12 12 mixed 10g contains no superfoods liquid individually wrapped in foil
## 13 13 fruity 15g contains no superfoods creamy individually wrapped in paper
## 14 14 fruity 5g contains superfoods creamy individually wrapped in foil
## 15 15 mixed 5g contains no superfoods creamy not individally wrapped
## 16 16 mixed 5g contains superfoods creamy individually wrapped in paper
## 17 17 mixed 10g contains superfoods liquid individually wrapped in foil
## 18 18 mixed 5g contains superfoods liquid not individally wrapped
## 19 19 nutty 5g contains no superfoods creamy individually wrapped in foil
## 20 20 fruity 15g contains no superfoods liquid individually wrapped in paper
## 21 21 mixed 5g contains superfoods creamy not individally wrapped
## 22 22 fruity 10g contains no superfoods liquid individually wrapped in paper
## Price STATUS_ CARD_
## 1 5.99 EUR Design 1
## 2 7.99 EUR Design 2
## 3 6.99 EUR Design 3
## 4 5.99 EUR Design 4
## 5 6.99 EUR Design 5
## 6 7.99 EUR Design 6
## 7 7.99 EUR Design 7
## 8 7.99 EUR Design 8
## 9 5.99 EUR Design 9
## 10 5.99 EUR Design 10
## 11 6.99 EUR Design 11
## 12 5.99 EUR Design 12
## 13 5.99 EUR Design 13
## 14 5.99 EUR Design 14
## 15 5.99 EUR Design 15
## 16 6.99 EUR Design 16
## 17 5.99 EUR Holdout 17
## 18 5.99 EUR Holdout 18
## 19 5.99 EUR Holdout 19
## 20 6.99 EUR Holdout 20
## 21 6.99 EUR Simulation 1
## 22 7.99 EUR Simulation 2
# Generate data
mydatc9_case_pref <- data.frame(Respondent = c(1, 2, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40),
Stimulus01 = c(3, 13, 3, 3, 3, 13, 3, 13, 13, 13, 14, 3, 3, 3, 3, 3, 14, 13, 13, 13, 13, 3, 3, 3, 3, 3, 13, 14, 13, 13, 13, 3, 3, 3, 3, 3, 13, 13, 14, 13, 13),
Stimulus02 = c(19, 8, 19, 18, 19, 8, 19, 8, 9, 8, 8, 19, 19, 19, 19, 18, 8, 8, 8, 8, 9, 19, 19, 19, 19, 18, 8, 8, 8, 8, 8, 19, 19, 19, 19, 18, 9, 8, 8, 8, 8),
Stimulus03 = c(7, 20, 6, 7, 7, 20, 7, 20, 20, 20, 20, 7, 7, 6, 7, 7, 20, 20, 20, 20, 20, 7, 7, 6, 7, 7, 20, 20, 20, 20, 20, 7, 7, 6, 7, 7, 20, 20, 20, 20, 20),
Stimulus04 = c(10, 19, 10, 10, 10, 19, 10, 19, 19, 19, 19, 10, 10, 10, 10, 10, 19, 19, 19, 19, 19, 10, 10, 10, 10, 10, 19, 19, 19, 19, 19, 10, 10, 10, 10, 10, 19, 19, 19, 19, 19),
Stimulus05 = c(9, 5, 9, 9, 9, 6, 9, 7, 6, 6, 6, 9, 9, 9, 9, 9, 6, 6, 5, 7, 6, 9, 9, 9, 9, 9, 6, 6, 6, 5, 7, 9, 9, 9, 9, 9, 6, 6, 6, 6, 5),
Stimulus06 = c(20, 10, 20, 20, 20, 10, 20, 10, 10, 9, 10, 20, 20, 20, 20, 20, 10, 10, 10, 10, 10, 20, 20, 20, 20, 20, 9, 10, 10, 10, 10, 20, 20, 20, 20, 20, 10, 9, 10, 10, 10),
Stimulus07 = c(12, 14, 12, 12, 12, 14, 12, 14, 14, 14, 13, 12, 12, 12, 12, 12, 13, 14, 14, 14, 14, 12, 12, 12, 12, 12, 14, 13, 14, 14, 14, 12, 12, 12, 12, 12, 14, 14, 13, 14, 14),
Stimulus08 = c(1, 11, 1, 1, 1, 11, 1, 11, 11, 11, 11, 1, 1, 1, 1, 1, 11, 11, 11, 11, 11, 1, 1, 1, 1, 1, 11, 11, 11, 11, 11, 1, 1, 1, 1, 1, 11, 11, 11, 11, 11),
Stimulus09 = c(6, 17, 7, 6, 6, 17, 6, 17, 17, 17, 17, 6, 6, 7, 6, 6, 17, 17, 17, 17, 17, 6, 6, 7, 6, 6, 17, 17, 17, 17, 17, 6, 6, 7, 6, 6, 17, 17, 17, 17, 17),
Stimulus10 = c(16, 1, 16, 16, 16, 1, 15, 1, 1, 1, 1, 16, 16, 16, 15, 16, 1, 1, 1, 1, 1, 16, 16, 16, 15, 16, 1, 1, 1, 1, 1, 16, 16, 16, 15, 16, 1, 1, 1, 1, 1),
Stimulus11 = c(17, 3, 17, 17, 17, 3, 17, 3, 3, 3, 3, 17, 17, 17, 17, 17, 3, 3, 3, 3, 3, 17, 17, 17, 17, 17, 3, 3, 3, 3, 3, 17, 17, 17, 17, 17, 3, 3, 3, 3, 3),
Stimulus12 = c(15, 9, 15, 15, 15, 9, 16, 9, 8, 10, 9, 15, 15, 15, 16, 15, 9, 9, 9, 9, 8, 15, 15, 15, 16, 15, 10, 9, 9, 9, 9, 15, 15, 15, 16, 15, 8, 10, 9, 9, 9),
Stimulus13 = c(14, 2, 14, 14, 14, 2, 14, 2, 2, 2, 2, 14, 14, 14, 14, 14, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 2, 2, 2, 2, 2, 14, 14, 14, 14, 14, 2, 2, 2, 2, 2),
Stimulus14 = c(5, 16, 5, 5, 4, 16, 5, 16, 16, 16, 16, 5, 4, 5, 5, 5, 16, 16, 16, 16, 16, 5, 4, 5, 5, 5, 16, 16, 16, 16, 16, 5, 4, 5, 5, 5, 16, 16, 16, 16, 16),
Stimulus15 = c(4, 6, 4, 4, 5, 5, 4, 5, 5, 5, 5, 4, 5, 4, 4, 4, 5, 5, 6, 5, 5, 4, 5, 4, 4, 4, 5, 5, 5, 6, 5, 4, 5, 4, 4, 4, 5, 5, 5, 5, 6),
Stimulus16 = c(8, 12, 8, 8, 8, 12, 8, 12, 12, 12, 12, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12, 8, 8, 8, 8, 8, 12, 12, 12, 12, 12),
Holdout01 = c(11, 15, 11, 11, 11, 15, 11, 15, 15, 15, 15, 11, 11, 11, 11, 11, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 15, 15, 15, 15, 15, 11, 11, 11, 11, 11, 15, 15, 15, 15, 15),
Holdout02 = c(2, 18, 2, 2, 2, 18, 2, 18, 18, 18, 18, 2, 2, 2, 2, 2, 18, 18, 18, 18, 18, 2, 2, 2, 2, 2, 18, 18, 18, 18, 18, 2, 2, 2, 2, 2, 18, 18, 18, 18, 18),
Holdout03 = c(13, 4, 13, 13, 13, 4, 13, 4, 4, 4, 4, 13, 13, 13, 13, 13, 4, 4, 4, 4, 4, 13, 13, 13, 13, 13, 4, 4, 4, 4, 4, 13, 13, 13, 13, 13, 4, 4, 4, 4, 4),
Holdout04 = c(18, 7, 18, 19, 18, 7, 18, 6, 7, 7, 7, 18, 18, 18, 18, 19, 7, 7, 7, 6, 7, 18, 18, 18, 18, 19, 7, 7, 7, 7, 6, 18, 18, 18, 18, 19, 7, 7, 7, 7, 7))
# Display generated data
print(mydatc9_case_pref)
## Respondent Stimulus01 Stimulus02 Stimulus03 Stimulus04 Stimulus05 Stimulus06
## 1 1 3 19 7 10 9 20
## 2 2 13 8 20 19 5 10
## 3 3 3 19 6 10 9 20
## 4 4 3 18 7 10 9 20
## 5 5 3 19 7 10 9 20
## 6 5 13 8 20 19 6 10
## 7 6 3 19 7 10 9 20
## 8 7 13 8 20 19 7 10
## 9 8 13 9 20 19 6 10
## 10 9 13 8 20 19 6 9
## 11 10 14 8 20 19 6 10
## 12 11 3 19 7 10 9 20
## 13 12 3 19 7 10 9 20
## 14 13 3 19 6 10 9 20
## 15 14 3 19 7 10 9 20
## 16 15 3 18 7 10 9 20
## 17 16 14 8 20 19 6 10
## 18 17 13 8 20 19 6 10
## 19 18 13 8 20 19 5 10
## 20 19 13 8 20 19 7 10
## 21 20 13 9 20 19 6 10
## 22 21 3 19 7 10 9 20
## 23 22 3 19 7 10 9 20
## 24 23 3 19 6 10 9 20
## 25 24 3 19 7 10 9 20
## 26 25 3 18 7 10 9 20
## 27 26 13 8 20 19 6 9
## 28 27 14 8 20 19 6 10
## 29 28 13 8 20 19 6 10
## 30 29 13 8 20 19 5 10
## 31 30 13 8 20 19 7 10
## 32 31 3 19 7 10 9 20
## 33 32 3 19 7 10 9 20
## 34 33 3 19 6 10 9 20
## 35 34 3 19 7 10 9 20
## 36 35 3 18 7 10 9 20
## 37 36 13 9 20 19 6 10
## 38 37 13 8 20 19 6 9
## 39 38 14 8 20 19 6 10
## 40 39 13 8 20 19 6 10
## 41 40 13 8 20 19 5 10
## Stimulus07 Stimulus08 Stimulus09 Stimulus10 Stimulus11 Stimulus12 Stimulus13
## 1 12 1 6 16 17 15 14
## 2 14 11 17 1 3 9 2
## 3 12 1 7 16 17 15 14
## 4 12 1 6 16 17 15 14
## 5 12 1 6 16 17 15 14
## 6 14 11 17 1 3 9 2
## 7 12 1 6 15 17 16 14
## 8 14 11 17 1 3 9 2
## 9 14 11 17 1 3 8 2
## 10 14 11 17 1 3 10 2
## 11 13 11 17 1 3 9 2
## 12 12 1 6 16 17 15 14
## 13 12 1 6 16 17 15 14
## 14 12 1 7 16 17 15 14
## 15 12 1 6 15 17 16 14
## 16 12 1 6 16 17 15 14
## 17 13 11 17 1 3 9 2
## 18 14 11 17 1 3 9 2
## 19 14 11 17 1 3 9 2
## 20 14 11 17 1 3 9 2
## 21 14 11 17 1 3 8 2
## 22 12 1 6 16 17 15 14
## 23 12 1 6 16 17 15 14
## 24 12 1 7 16 17 15 14
## 25 12 1 6 15 17 16 14
## 26 12 1 6 16 17 15 14
## 27 14 11 17 1 3 10 2
## 28 13 11 17 1 3 9 2
## 29 14 11 17 1 3 9 2
## 30 14 11 17 1 3 9 2
## 31 14 11 17 1 3 9 2
## 32 12 1 6 16 17 15 14
## 33 12 1 6 16 17 15 14
## 34 12 1 7 16 17 15 14
## 35 12 1 6 15 17 16 14
## 36 12 1 6 16 17 15 14
## 37 14 11 17 1 3 8 2
## 38 14 11 17 1 3 10 2
## 39 13 11 17 1 3 9 2
## 40 14 11 17 1 3 9 2
## 41 14 11 17 1 3 9 2
## Stimulus14 Stimulus15 Stimulus16 Holdout01 Holdout02 Holdout03 Holdout04
## 1 5 4 8 11 2 13 18
## 2 16 6 12 15 18 4 7
## 3 5 4 8 11 2 13 18
## 4 5 4 8 11 2 13 19
## 5 4 5 8 11 2 13 18
## 6 16 5 12 15 18 4 7
## 7 5 4 8 11 2 13 18
## 8 16 5 12 15 18 4 6
## 9 16 5 12 15 18 4 7
## 10 16 5 12 15 18 4 7
## 11 16 5 12 15 18 4 7
## 12 5 4 8 11 2 13 18
## 13 4 5 8 11 2 13 18
## 14 5 4 8 11 2 13 18
## 15 5 4 8 11 2 13 18
## 16 5 4 8 11 2 13 19
## 17 16 5 12 15 18 4 7
## 18 16 5 12 15 18 4 7
## 19 16 6 12 15 18 4 7
## 20 16 5 12 15 18 4 6
## 21 16 5 12 15 18 4 7
## 22 5 4 8 11 2 13 18
## 23 4 5 8 11 2 13 18
## 24 5 4 8 11 2 13 18
## 25 5 4 8 11 2 13 18
## 26 5 4 8 11 2 13 19
## 27 16 5 12 15 18 4 7
## 28 16 5 12 15 18 4 7
## 29 16 5 12 15 18 4 7
## 30 16 6 12 15 18 4 7
## 31 16 5 12 15 18 4 6
## 32 5 4 8 11 2 13 18
## 33 4 5 8 11 2 13 18
## 34 5 4 8 11 2 13 18
## 35 5 4 8 11 2 13 18
## 36 5 4 8 11 2 13 19
## 37 16 5 12 15 18 4 7
## 38 16 5 12 15 18 4 7
## 39 16 5 12 15 18 4 7
## 40 16 5 12 15 18 4 7
## 41 16 6 12 15 18 4 7
[Note: Results and data diverge slightly from SPSS results in the book. Core statements and directions of effects consistent]
# library (conjoint)
# mylevels <- factor(c("fruity", "nutty", "mixed","5g","10g","15g","contains no superfoods","contains superfoods","creamy", "liquid","individually wrapped in foil","individally wrapped in paper","not individually wrapped","5.99 EUR","6.99 EUR","7.99 EUR"), ordered = FALSE)
#
# mylevels <- forcats::fct_relevel(mylevels,c("fruity", "nutty", "mixed","5g","10g","15g","contains no superfoods","contains superfoods","creamy", "liquid","individually wrapped in foil","individally wrapped in paper","not individually wrapped","5.99 EUR","6.99 EUR","7.99 EUR"))
# Releveling of factors
mydatc9_case_design$Flavor <- forcats::fct_relevel(mydatc9_case_design$Flavor, "mixed")
mydatc9_case_design$Size <- forcats::fct_relevel(mydatc9_case_design$Size, "15g")
mydatc9_case_design$Superfoods <- forcats::fct_relevel(mydatc9_case_design$Superfoods, "contains superfoods")
mydatc9_case_design$Filling <- forcats::fct_relevel(mydatc9_case_design$Filling, "liquid")
mydatc9_case_design$Packaging <- forcats::fct_relevel(mydatc9_case_design$Packaging, "not individually wrapped")
## Warning: Unknown levels in `f`: not individually wrapped
mylevels <- c(levels(mydatc9_case_design$Flavor),
levels(mydatc9_case_design$Size),
levels(mydatc9_case_design$Superfoods),
levels(mydatc9_case_design$Filling),
levels(mydatc9_case_design$Packaging),
levels(mydatc9_case_design$Price))
# CJA estimates all based on ranked preference data AND with effect coding in each case.
testCJA <- conjoint::Conjoint(mydatc9_case_pref[-c(5),-c(1,18:21)],
mydatc9_case_design[c(1:16),c(2:7)],
mylevels,
y.type = "rank")
##
## Call:
## lm(formula = frml)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7,8172 -5,1203 0,0172 4,8734 8,5734
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7,30365 0,23638 30,898 < 2e-16 ***
## factor(x$Flavor)1 -0,08021 0,30750 -0,261 0,794302
## factor(x$Flavor)2 -0,38958 0,26224 -1,486 0,137884
## factor(x$Size)1 0,69583 0,30750 2,263 0,023984 *
## factor(x$Size)2 -0,91042 0,26224 -3,472 0,000553 ***
## factor(x$Superfoods)1 -0,08906 0,19668 -0,453 0,650825
## factor(x$Filling)1 -1,61406 0,19668 -8,207 1,29e-15 ***
## factor(x$Packaging)1 -2,23542 0,26224 -8,524 < 2e-16 ***
## factor(x$Packaging)2 -0,90417 0,30750 -2,940 0,003399 **
## factor(x$Price)1 0,82708 0,26224 3,154 0,001688 **
## factor(x$Price)2 0,36146 0,30750 1,175 0,240252
## ---
## Signif. codes: 0 '***' 0,001 '**' 0,01 '*' 0,05 '.' 0,1 ' ' 1
##
## Residual standard error: 4,976 on 629 degrees of freedom
## Multiple R-squared: 0,265, Adjusted R-squared: 0,2533
## F-statistic: 22,68 on 10 and 629 DF, p-value: < 2,2e-16
## [1] "Part worths (utilities) of levels (model parameters for whole sample):"
## levnms utls
## 1 intercept 7,3036
## 2 mixed -0,0802
## 3 fruity -0,3896
## 4 nutty 0,4698
## 5 15g 0,6958
## 6 5g -0,9104
## 7 10g 0,2146
## 8 contains superfoods -0,0891
## 9 contains no superfoods 0,0891
## 10 liquid -1,6141
## 11 creamy 1,6141
## 12 individually wrapped in foil -2,2354
## 13 individually wrapped in paper -0,9042
## 14 not individally wrapped 3,1396
## 15 5.99 EUR 0,8271
## 16 6.99 EUR 0,3615
## 17 7.99 EUR -1,1885
## [1] "Average importance of factors (attributes):"
## [1] 21,83 26,47 14,91 11,48 18,32 7,00
## [1] Sum of average importance: 100,01
## [1] "Chart of average factors importance"
# Each result printed
[Note: Slightly different, ratios and basic message are similar].
# Analogous to: Figure 9.19 Relative attribute importance for the joint estimation
IMP_combined <- conjoint::caImportance(y = mydatc9_case_pref[-c(5),-c(1,18:21)],
x = mydatc9_case_design[c(1:16),c(2:7)])
print(cbind(colnames(mydatc9_case_design)[2:7],IMP_combined));
## IMP_combined
## [1,] "Flavor" "21.83"
## [2,] "Size" "26.47"
## [3,] "Superfoods" "14.91"
## [4,] "Filling" "11.48"
## [5,] "Packaging" "18.32"
## [6,] "Price" "7"
barplot(IMP_combined,
names.arg = c("Flavor", "Size", "Superfoods", "Filling", "Packaging", "Price"),
main = "Relative Importance | Attributes",
cex.main = 1,
cex.lab = 1,
cex.axis = 1)
[Note: There are divergent results here].
# Estimated utility paramter per proband
conjoint::caPartUtilities(y = mydatc9_case_pref[-c(5),-c(1,18:21)],
x = mydatc9_case_design[c(1:16),c(2:7)],
z = mylevels)
## intercept mixed fruity nutty 15g 5g 10g contains superfoods
## [1,] 11.417 0.583 -3.167 2.583 3.750 -2.500 -1.250 -2.125
## [2,] 8.083 -0.250 3.500 -3.250 -4.833 4.167 0.667 2.125
## [3,] 11.458 0.583 -3.167 2.583 3.708 -2.667 -1.042 -2.125
## [4,] 11.312 0.667 -3.083 2.417 3.792 -2.583 -1.208 -2.063
## [5,] 8.125 -0.458 3.667 -3.208 -4.625 4.000 0.625 2.125
## [6,] 11.417 0.833 -3.167 2.333 3.500 -2.500 -1.000 -2.250
## [7,] 8.229 -0.500 3.750 -3.250 -4.458 3.917 0.542 2.063
## [8,] 8.167 -0.708 3.667 -2.958 -4.583 4.167 0.417 2.125
## [9,] 8.083 -0.458 3.667 -3.208 -4.875 4.000 0.875 2.000
## [10,] 8.167 -0.500 3.500 -3.000 -4.625 4.000 0.625 2.250
## [11,] 11.417 0.583 -3.167 2.583 3.750 -2.500 -1.250 -2.125
## [12,] 11.500 0.792 -3.333 2.542 3.750 -2.500 -1.250 -2.250
## [13,] 11.458 0.583 -3.167 2.583 3.708 -2.667 -1.042 -2.125
## [14,] 11.417 0.833 -3.167 2.333 3.500 -2.500 -1.000 -2.250
## [15,] 11.312 0.667 -3.083 2.417 3.792 -2.583 -1.208 -2.063
## [16,] 8.167 -0.500 3.500 -3.000 -4.625 4.000 0.625 2.250
## [17,] 8.125 -0.458 3.667 -3.208 -4.625 4.000 0.625 2.125
## [18,] 8.083 -0.250 3.500 -3.250 -4.833 4.167 0.667 2.125
## [19,] 8.229 -0.500 3.750 -3.250 -4.458 3.917 0.542 2.063
## [20,] 8.167 -0.708 3.667 -2.958 -4.583 4.167 0.417 2.125
## [21,] 11.417 0.583 -3.167 2.583 3.750 -2.500 -1.250 -2.125
## [22,] 11.500 0.792 -3.333 2.542 3.750 -2.500 -1.250 -2.250
## [23,] 11.458 0.583 -3.167 2.583 3.708 -2.667 -1.042 -2.125
## [24,] 11.417 0.833 -3.167 2.333 3.500 -2.500 -1.000 -2.250
## [25,] 11.312 0.667 -3.083 2.417 3.792 -2.583 -1.208 -2.063
## [26,] 8.083 -0.458 3.667 -3.208 -4.875 4.000 0.875 2.000
## [27,] 8.167 -0.500 3.500 -3.000 -4.625 4.000 0.625 2.250
## [28,] 8.125 -0.458 3.667 -3.208 -4.625 4.000 0.625 2.125
## [29,] 8.083 -0.250 3.500 -3.250 -4.833 4.167 0.667 2.125
## [30,] 8.229 -0.500 3.750 -3.250 -4.458 3.917 0.542 2.063
## [31,] 11.417 0.583 -3.167 2.583 3.750 -2.500 -1.250 -2.125
## [32,] 11.500 0.792 -3.333 2.542 3.750 -2.500 -1.250 -2.250
## [33,] 11.458 0.583 -3.167 2.583 3.708 -2.667 -1.042 -2.125
## [34,] 11.417 0.833 -3.167 2.333 3.500 -2.500 -1.000 -2.250
## [35,] 11.312 0.667 -3.083 2.417 3.792 -2.583 -1.208 -2.063
## [36,] 8.167 -0.708 3.667 -2.958 -4.583 4.167 0.417 2.125
## [37,] 8.083 -0.458 3.667 -3.208 -4.875 4.000 0.875 2.000
## [38,] 8.167 -0.500 3.500 -3.000 -4.625 4.000 0.625 2.250
## [39,] 8.125 -0.458 3.667 -3.208 -4.625 4.000 0.625 2.125
## [40,] 8.083 -0.250 3.500 -3.250 -4.833 4.167 0.667 2.125
## contains no superfoods liquid creamy individually wrapped in foil
## [1,] 2.125 0.750 -0.750 3.167
## [2,] -2.125 2.250 -2.250 1.500
## [3,] 2.125 0.750 -0.750 3.000
## [4,] 2.063 0.688 -0.688 3.250
## [5,] -2.125 2.375 -2.375 1.500
## [6,] 2.250 0.875 -0.875 3.167
## [7,] -2.063 2.438 -2.438 1.417
## [8,] -2.125 2.375 -2.375 1.333
## [9,] -2.000 2.375 -2.375 1.500
## [10,] -2.250 2.500 -2.500 1.333
## [11,] 2.125 0.750 -0.750 3.167
## [12,] 2.250 0.750 -0.750 3.000
## [13,] 2.125 0.750 -0.750 3.000
## [14,] 2.250 0.875 -0.875 3.167
## [15,] 2.063 0.688 -0.688 3.250
## [16,] -2.250 2.500 -2.500 1.333
## [17,] -2.125 2.375 -2.375 1.500
## [18,] -2.125 2.250 -2.250 1.500
## [19,] -2.063 2.438 -2.438 1.417
## [20,] -2.125 2.375 -2.375 1.333
## [21,] 2.125 0.750 -0.750 3.167
## [22,] 2.250 0.750 -0.750 3.000
## [23,] 2.125 0.750 -0.750 3.000
## [24,] 2.250 0.875 -0.875 3.167
## [25,] 2.063 0.688 -0.688 3.250
## [26,] -2.000 2.375 -2.375 1.500
## [27,] -2.250 2.500 -2.500 1.333
## [28,] -2.125 2.375 -2.375 1.500
## [29,] -2.125 2.250 -2.250 1.500
## [30,] -2.063 2.438 -2.438 1.417
## [31,] 2.125 0.750 -0.750 3.167
## [32,] 2.250 0.750 -0.750 3.000
## [33,] 2.125 0.750 -0.750 3.000
## [34,] 2.250 0.875 -0.875 3.167
## [35,] 2.063 0.688 -0.688 3.250
## [36,] -2.125 2.375 -2.375 1.333
## [37,] -2.000 2.375 -2.375 1.500
## [38,] -2.250 2.500 -2.500 1.333
## [39,] -2.125 2.375 -2.375 1.500
## [40,] -2.125 2.250 -2.250 1.500
## individually wrapped in paper not individally wrapped 5.99 EUR 6.99 EUR
## [1,] 2.167 -5.333 -1.667 -0.542
## [2,] -0.250 -1.250 0.000 -0.375
## [3,] 2.375 -5.375 -1.500 -0.750
## [4,] 2.000 -5.250 -1.583 -0.458
## [5,] -0.250 -1.250 -0.167 -0.167
## [6,] 2.167 -5.333 -1.667 -0.542
## [7,] -0.333 -1.083 -0.250 0.000
## [8,] -0.042 -1.292 -0.333 -0.208
## [9,] -0.250 -1.250 0.000 -0.125
## [10,] -0.292 -1.042 0.000 -0.125
## [11,] 2.167 -5.333 -1.667 -0.542
## [12,] 2.125 -5.125 -1.667 -0.542
## [13,] 2.375 -5.375 -1.500 -0.750
## [14,] 2.167 -5.333 -1.667 -0.542
## [15,] 2.000 -5.250 -1.583 -0.458
## [16,] -0.292 -1.042 0.000 -0.125
## [17,] -0.250 -1.250 -0.167 -0.167
## [18,] -0.250 -1.250 0.000 -0.375
## [19,] -0.333 -1.083 -0.250 0.000
## [20,] -0.042 -1.292 -0.333 -0.208
## [21,] 2.167 -5.333 -1.667 -0.542
## [22,] 2.125 -5.125 -1.667 -0.542
## [23,] 2.375 -5.375 -1.500 -0.750
## [24,] 2.167 -5.333 -1.667 -0.542
## [25,] 2.000 -5.250 -1.583 -0.458
## [26,] -0.250 -1.250 0.000 -0.125
## [27,] -0.292 -1.042 0.000 -0.125
## [28,] -0.250 -1.250 -0.167 -0.167
## [29,] -0.250 -1.250 0.000 -0.375
## [30,] -0.333 -1.083 -0.250 0.000
## [31,] 2.167 -5.333 -1.667 -0.542
## [32,] 2.125 -5.125 -1.667 -0.542
## [33,] 2.375 -5.375 -1.500 -0.750
## [34,] 2.167 -5.333 -1.667 -0.542
## [35,] 2.000 -5.250 -1.583 -0.458
## [36,] -0.042 -1.292 -0.333 -0.208
## [37,] -0.250 -1.250 0.000 -0.125
## [38,] -0.292 -1.042 0.000 -0.125
## [39,] -0.250 -1.250 -0.167 -0.167
## [40,] -0.250 -1.250 0.000 -0.375
## 7.99 EUR
## [1,] 2.208
## [2,] 0.375
## [3,] 2.250
## [4,] 2.042
## [5,] 0.333
## [6,] 2.208
## [7,] 0.250
## [8,] 0.542
## [9,] 0.125
## [10,] 0.125
## [11,] 2.208
## [12,] 2.208
## [13,] 2.250
## [14,] 2.208
## [15,] 2.042
## [16,] 0.125
## [17,] 0.333
## [18,] 0.375
## [19,] 0.250
## [20,] 0.542
## [21,] 2.208
## [22,] 2.208
## [23,] 2.250
## [24,] 2.208
## [25,] 2.042
## [26,] 0.125
## [27,] 0.125
## [28,] 0.333
## [29,] 0.375
## [30,] 0.250
## [31,] 2.208
## [32,] 2.208
## [33,] 2.250
## [34,] 2.208
## [35,] 2.042
## [36,] 0.542
## [37,] 0.125
## [38,] 0.125
## [39,] 0.333
## [40,] 0.375
# caRankToScore(mydatc9_case_pref[-c(5),-c(1,18:21)])
# conjoint::ShowAllSimulations(sym = mydatc9_case_design[c(17:20),c(2:7)],
# y = mydatc9_case_pref[-c(5),-c(1,18:21)],
# x = mydatc9_case_design[c(1:16),c(2:7)])
#
#
# conjoint::caLogit(sym = mydatc9_case_design[c(19:20),c(2:7)],
# # y = mydatc9_case_pref[-c(5),-c(1,18:21)],
# y = trans.prefdatacollected,
# x = mydatc9_case_design[c(1:16),c(2:7)])
# 41 # 21 (20 cards incl. HoldOut) # ranking
prefdatacollected <- mydatc9_case_pref
trans.prefdatacollected <- t(prefdatacollected[-c(5),-c(1,18:21)])
trans.prefdatacollected <- as.data.frame(trans.prefdatacollected) %>% rownames_to_column(., var = "Stimulus")
colnames(trans.prefdatacollected) <- c("Stimulus", paste0("Person", 1:40))
# convert ranking into rating
trans.prefdatacollected[, c(2:41)] <- psych::reverse.code(keys = c(rep(-1,40)),
trans.prefdatacollected[, c(2:41)],
mini = 1,
maxi = 20)
# Experimental design data (stimuli)
designdataCJA <- mydatc9_case_design[c(1:16),c(2:7)]
# Compute linear regression for each person
mycalcdata.CJA <- cbind(designdataCJA,trans.prefdatacollected)
# Releveling of factors
mycalcdata.CJA$Flavor <- forcats::fct_relevel(mycalcdata.CJA$Flavor, "mixed")
mycalcdata.CJA$Size <- forcats::fct_relevel(mycalcdata.CJA$Size, "15g")
mycalcdata.CJA$Superfoods <- forcats::fct_relevel(mycalcdata.CJA$Superfoods, "contains superfoods")
mycalcdata.CJA$Filling <- forcats::fct_relevel(mycalcdata.CJA$Filling, "liquid")
mycalcdata.CJA$Packaging <- forcats::fct_relevel(mycalcdata.CJA$Packaging, "not individually wrapped")
## Warning: Unknown levels in `f`: not individually wrapped
library(rlist)
Regressions <- list()
for (person in 8:ncol(mycalcdata.CJA)) {
model <- lm(mycalcdata.CJA[,person] ~
Flavor +
Size +
Superfoods +
Filling +
Packaging +
as.numeric(Price),
# MASS::contr.sdif
# contrasts = list(Flavor = contr.sum,
# Size = contr.sum,
# Superfoods = contr.sum,
# Filling = contr.sum,
# Packaging = contr.sum
# ),
data = mycalcdata.CJA)
Regressions <- rlist::list.append(Regressions, model)
}
# Display results; Indivudal regression for each proband
print(Regressions)
## [[1]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.5833 3.1667 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.1250 -0.7500 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[2]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1553 0.2500 -3.5000 4.8333
## Size2 Superfoods1 Filling1 Packaging1
## -4.1667 -2.1250 -2.2500 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.1364
##
##
## [[3]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.0189 -0.5833 3.1667 -3.7083
## Size2 Superfoods1 Filling1 Packaging1
## 2.6667 2.1250 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.3750 -1.7727
##
##
## [[4]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1458 -0.6667 3.0833 -3.7917
## Size2 Superfoods1 Filling1 Packaging1
## 2.5833 2.0625 -0.6875 -3.2500
## Packaging2 as.numeric(Price)
## -2.0000 -1.7500
##
##
## [[5]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.3144 0.4583 -3.6667 4.6250
## Size2 Superfoods1 Filling1 Packaging1
## -4.0000 -2.1250 -2.3750 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.2273
##
##
## [[6]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.8333 3.1667 -3.5000
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.8750 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[7]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2708 0.5000 -3.7500 4.4583
## Size2 Superfoods1 Filling1 Packaging1
## -3.9167 -2.0625 -2.4375 -1.4167
## Packaging2 as.numeric(Price)
## 0.3333 -0.2500
##
##
## [[8]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.63258 0.70833 -3.66667 4.58333
## Size2 Superfoods1 Filling1 Packaging1
## -4.16667 -2.12500 -2.37500 -1.33333
## Packaging2 as.numeric(Price)
## 0.04167 -0.40909
##
##
## [[9]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.99621 0.45833 -3.66667 4.87500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.00000 -2.37500 -1.50000
## Packaging2 as.numeric(Price)
## 0.25000 -0.04545
##
##
## [[10]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.91288 0.50000 -3.50000 4.62500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.25000 -2.50000 -1.33333
## Packaging2 as.numeric(Price)
## 0.29167 -0.04545
##
##
## [[11]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.5833 3.1667 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.1250 -0.7500 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[12]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1780 -0.7917 3.3333 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.1250 -1.8636
##
##
## [[13]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.0189 -0.5833 3.1667 -3.7083
## Size2 Superfoods1 Filling1 Packaging1
## 2.6667 2.1250 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.3750 -1.7727
##
##
## [[14]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.8333 3.1667 -3.5000
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.8750 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[15]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1458 -0.6667 3.0833 -3.7917
## Size2 Superfoods1 Filling1 Packaging1
## 2.5833 2.0625 -0.6875 -3.2500
## Packaging2 as.numeric(Price)
## -2.0000 -1.7500
##
##
## [[16]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.91288 0.50000 -3.50000 4.62500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.25000 -2.50000 -1.33333
## Packaging2 as.numeric(Price)
## 0.29167 -0.04545
##
##
## [[17]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.3144 0.4583 -3.6667 4.6250
## Size2 Superfoods1 Filling1 Packaging1
## -4.0000 -2.1250 -2.3750 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.2273
##
##
## [[18]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1553 0.2500 -3.5000 4.8333
## Size2 Superfoods1 Filling1 Packaging1
## -4.1667 -2.1250 -2.2500 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.1364
##
##
## [[19]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2708 0.5000 -3.7500 4.4583
## Size2 Superfoods1 Filling1 Packaging1
## -3.9167 -2.0625 -2.4375 -1.4167
## Packaging2 as.numeric(Price)
## 0.3333 -0.2500
##
##
## [[20]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.63258 0.70833 -3.66667 4.58333
## Size2 Superfoods1 Filling1 Packaging1
## -4.16667 -2.12500 -2.37500 -1.33333
## Packaging2 as.numeric(Price)
## 0.04167 -0.40909
##
##
## [[21]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.5833 3.1667 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.1250 -0.7500 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[22]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1780 -0.7917 3.3333 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.1250 -1.8636
##
##
## [[23]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.0189 -0.5833 3.1667 -3.7083
## Size2 Superfoods1 Filling1 Packaging1
## 2.6667 2.1250 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.3750 -1.7727
##
##
## [[24]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.8333 3.1667 -3.5000
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.8750 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[25]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1458 -0.6667 3.0833 -3.7917
## Size2 Superfoods1 Filling1 Packaging1
## 2.5833 2.0625 -0.6875 -3.2500
## Packaging2 as.numeric(Price)
## -2.0000 -1.7500
##
##
## [[26]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.99621 0.45833 -3.66667 4.87500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.00000 -2.37500 -1.50000
## Packaging2 as.numeric(Price)
## 0.25000 -0.04545
##
##
## [[27]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.91288 0.50000 -3.50000 4.62500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.25000 -2.50000 -1.33333
## Packaging2 as.numeric(Price)
## 0.29167 -0.04545
##
##
## [[28]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.3144 0.4583 -3.6667 4.6250
## Size2 Superfoods1 Filling1 Packaging1
## -4.0000 -2.1250 -2.3750 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.2273
##
##
## [[29]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1553 0.2500 -3.5000 4.8333
## Size2 Superfoods1 Filling1 Packaging1
## -4.1667 -2.1250 -2.2500 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.1364
##
##
## [[30]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2708 0.5000 -3.7500 4.4583
## Size2 Superfoods1 Filling1 Packaging1
## -3.9167 -2.0625 -2.4375 -1.4167
## Packaging2 as.numeric(Price)
## 0.3333 -0.2500
##
##
## [[31]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.5833 3.1667 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.1250 -0.7500 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[32]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1780 -0.7917 3.3333 -3.7500
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.1250 -1.8636
##
##
## [[33]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.0189 -0.5833 3.1667 -3.7083
## Size2 Superfoods1 Filling1 Packaging1
## 2.6667 2.1250 -0.7500 -3.0000
## Packaging2 as.numeric(Price)
## -2.3750 -1.7727
##
##
## [[34]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.2614 -0.8333 3.1667 -3.5000
## Size2 Superfoods1 Filling1 Packaging1
## 2.5000 2.2500 -0.8750 -3.1667
## Packaging2 as.numeric(Price)
## -2.1667 -1.8636
##
##
## [[35]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1458 -0.6667 3.0833 -3.7917
## Size2 Superfoods1 Filling1 Packaging1
## 2.5833 2.0625 -0.6875 -3.2500
## Packaging2 as.numeric(Price)
## -2.0000 -1.7500
##
##
## [[36]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.63258 0.70833 -3.66667 4.58333
## Size2 Superfoods1 Filling1 Packaging1
## -4.16667 -2.12500 -2.37500 -1.33333
## Packaging2 as.numeric(Price)
## 0.04167 -0.40909
##
##
## [[37]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.99621 0.45833 -3.66667 4.87500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.00000 -2.37500 -1.50000
## Packaging2 as.numeric(Price)
## 0.25000 -0.04545
##
##
## [[38]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 12.91288 0.50000 -3.50000 4.62500
## Size2 Superfoods1 Filling1 Packaging1
## -4.00000 -2.25000 -2.50000 -1.33333
## Packaging2 as.numeric(Price)
## 0.29167 -0.04545
##
##
## [[39]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.3144 0.4583 -3.6667 4.6250
## Size2 Superfoods1 Filling1 Packaging1
## -4.0000 -2.1250 -2.3750 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.2273
##
##
## [[40]]
##
## Call:
## lm.default(formula = mycalcdata.CJA[, person] ~ Flavor + Size +
## Superfoods + Filling + Packaging + as.numeric(Price), data = mycalcdata.CJA)
##
## Coefficients:
## (Intercept) Flavor1 Flavor2 Size1
## 13.1553 0.2500 -3.5000 4.8333
## Size2 Superfoods1 Filling1 Packaging1
## -4.1667 -2.1250 -2.2500 -1.5000
## Packaging2 as.numeric(Price)
## 0.2500 -0.1364
#
# summary(Regressions[[1]])
#
# levels(mycalcdata.CJA$Flavor)
# levels(mycalcdata.CJA$Size)
# levels(mycalcdata.CJA$Superfoods)
# levels(mycalcdata.CJA$Filling)
# levels(mycalcdata.CJA$Packaging)
# levels(mycalcdata.CJA$Price)
# Create dataframe with Partworth values
vars <- c("Intercept",
rep("Flavor",3),
rep("Size",3),
rep("Superfoods",2),
rep("Filling", 2),
rep("Packaging",3),
rep("Price",1))
lvls <- c("Intercept",
as.character(levels(mycalcdata.CJA$Flavor)),
as.character(levels(mycalcdata.CJA$Size)),
as.character(levels(mycalcdata.CJA$Superfoods)),
as.character(levels(mycalcdata.CJA$Filling)),
as.character(levels(mycalcdata.CJA$Packaging)),
"Price")
Results <- data.frame(Variable = vars, Levels = lvls)
# Number of probands used
n = 40
for (person in 1:n) {
c <- as.vector(Regressions[[person]]$coefficients)
coef <- c(c[1],0,c[2:3],0,c[4:5],0,c[6],0,c[7],0,c[8:9],c[10])
Results[,paste("Person",person,sep = "")] <- round(coef, digits = 1)
}
# Calculate averages
Results[,"Average"] <- round(rowMeans(Results[,-c(1,2)]),digits = 1)
print(Results);print(Results[,c(1,2,ncol(Results))])
## Variable Levels Person1 Person2 Person3 Person4
## 1 Intercept Intercept 13.3 13.2 13.0 13.1
## 2 Flavor mixed 0.0 0.0 0.0 0.0
## 3 Flavor fruity -0.6 0.3 -0.6 -0.7
## 4 Flavor nutty 3.2 -3.5 3.2 3.1
## 5 Size 15g 0.0 0.0 0.0 0.0
## 6 Size 5g -3.7 4.8 -3.7 -3.8
## 7 Size 10g 2.5 -4.2 2.7 2.6
## 8 Superfoods contains superfoods 0.0 0.0 0.0 0.0
## 9 Superfoods contains no superfoods 2.1 -2.1 2.1 2.1
## 10 Filling liquid 0.0 0.0 0.0 0.0
## 11 Filling creamy -0.8 -2.3 -0.7 -0.7
## 12 Packaging individually wrapped in foil 0.0 0.0 0.0 0.0
## 13 Packaging individually wrapped in paper -3.2 -1.5 -3.0 -3.2
## 14 Packaging not individally wrapped -2.2 0.2 -2.4 -2.0
## 15 Price Price -1.9 -0.1 -1.8 -1.7
## Person5 Person6 Person7 Person8 Person9 Person10 Person11 Person12 Person13
## 1 13.3 13.3 13.3 13.6 13.0 12.9 13.3 13.2 13.0
## 2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 3 0.5 -0.8 0.5 0.7 0.5 0.5 -0.6 -0.8 -0.6
## 4 -3.7 3.2 -3.7 -3.7 -3.7 -3.5 3.2 3.3 3.2
## 5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 6 4.6 -3.5 4.5 4.6 4.9 4.6 -3.7 -3.7 -3.7
## 7 -4.0 2.5 -3.9 -4.2 -4.0 -4.0 2.5 2.5 2.7
## 8 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 9 -2.1 2.3 -2.1 -2.1 -2.0 -2.3 2.1 2.3 2.1
## 10 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 11 -2.4 -0.9 -2.4 -2.4 -2.4 -2.5 -0.8 -0.7 -0.7
## 12 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 13 -1.5 -3.2 -1.4 -1.3 -1.5 -1.3 -3.2 -3.0 -3.0
## 14 0.2 -2.2 0.3 0.0 0.2 0.3 -2.2 -2.1 -2.4
## 15 -0.2 -1.9 -0.2 -0.4 0.0 0.0 -1.9 -1.9 -1.8
## Person14 Person15 Person16 Person17 Person18 Person19 Person20 Person21
## 1 13.3 13.1 12.9 13.3 13.2 13.3 13.6 13.3
## 2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 3 -0.8 -0.7 0.5 0.5 0.3 0.5 0.7 -0.6
## 4 3.2 3.1 -3.5 -3.7 -3.5 -3.7 -3.7 3.2
## 5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 6 -3.5 -3.8 4.6 4.6 4.8 4.5 4.6 -3.7
## 7 2.5 2.6 -4.0 -4.0 -4.2 -3.9 -4.2 2.5
## 8 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 9 2.3 2.1 -2.3 -2.1 -2.1 -2.1 -2.1 2.1
## 10 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 11 -0.9 -0.7 -2.5 -2.4 -2.3 -2.4 -2.4 -0.8
## 12 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 13 -3.2 -3.2 -1.3 -1.5 -1.5 -1.4 -1.3 -3.2
## 14 -2.2 -2.0 0.3 0.2 0.2 0.3 0.0 -2.2
## 15 -1.9 -1.7 0.0 -0.2 -0.1 -0.2 -0.4 -1.9
## Person22 Person23 Person24 Person25 Person26 Person27 Person28 Person29
## 1 13.2 13.0 13.3 13.1 13.0 12.9 13.3 13.2
## 2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 3 -0.8 -0.6 -0.8 -0.7 0.5 0.5 0.5 0.3
## 4 3.3 3.2 3.2 3.1 -3.7 -3.5 -3.7 -3.5
## 5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 6 -3.7 -3.7 -3.5 -3.8 4.9 4.6 4.6 4.8
## 7 2.5 2.7 2.5 2.6 -4.0 -4.0 -4.0 -4.2
## 8 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 9 2.3 2.1 2.3 2.1 -2.0 -2.3 -2.1 -2.1
## 10 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 11 -0.7 -0.7 -0.9 -0.7 -2.4 -2.5 -2.4 -2.3
## 12 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 13 -3.0 -3.0 -3.2 -3.2 -1.5 -1.3 -1.5 -1.5
## 14 -2.1 -2.4 -2.2 -2.0 0.2 0.3 0.2 0.2
## 15 -1.9 -1.8 -1.9 -1.7 0.0 0.0 -0.2 -0.1
## Person30 Person31 Person32 Person33 Person34 Person35 Person36 Person37
## 1 13.3 13.3 13.2 13.0 13.3 13.1 13.6 13.0
## 2 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 3 0.5 -0.6 -0.8 -0.6 -0.8 -0.7 0.7 0.5
## 4 -3.7 3.2 3.3 3.2 3.2 3.1 -3.7 -3.7
## 5 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 6 4.5 -3.7 -3.7 -3.7 -3.5 -3.8 4.6 4.9
## 7 -3.9 2.5 2.5 2.7 2.5 2.6 -4.2 -4.0
## 8 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 9 -2.1 2.1 2.3 2.1 2.3 2.1 -2.1 -2.0
## 10 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 11 -2.4 -0.8 -0.7 -0.7 -0.9 -0.7 -2.4 -2.4
## 12 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
## 13 -1.4 -3.2 -3.0 -3.0 -3.2 -3.2 -1.3 -1.5
## 14 0.3 -2.2 -2.1 -2.4 -2.2 -2.0 0.0 0.2
## 15 -0.2 -1.9 -1.9 -1.8 -1.9 -1.7 -0.4 0.0
## Person38 Person39 Person40 Average
## 1 12.9 13.3 13.2 13.2
## 2 0.0 0.0 0.0 0.0
## 3 0.5 0.5 0.3 -0.1
## 4 -3.5 -3.7 -3.5 -0.4
## 5 0.0 0.0 0.0 0.0
## 6 4.6 4.6 4.8 0.7
## 7 -4.0 -4.0 -4.2 -0.9
## 8 0.0 0.0 0.0 0.0
## 9 -2.3 -2.1 -2.1 -0.1
## 10 0.0 0.0 0.0 0.0
## 11 -2.5 -2.4 -2.3 -1.6
## 12 0.0 0.0 0.0 0.0
## 13 -1.3 -1.5 -1.5 -2.2
## 14 0.3 0.2 0.2 -0.9
## 15 0.0 -0.2 -0.1 -0.9
## Variable Levels Average
## 1 Intercept Intercept 13.2
## 2 Flavor mixed 0.0
## 3 Flavor fruity -0.1
## 4 Flavor nutty -0.4
## 5 Size 15g 0.0
## 6 Size 5g 0.7
## 7 Size 10g -0.9
## 8 Superfoods contains superfoods 0.0
## 9 Superfoods contains no superfoods -0.1
## 10 Filling liquid 0.0
## 11 Filling creamy -1.6
## 12 Packaging individually wrapped in foil 0.0
## 13 Packaging individually wrapped in paper -2.2
## 14 Packaging not individally wrapped -0.9
## 15 Price Price -0.9
# Save results
write.csv(Results, "Results.csv")
# Get averages and visualize them for each variable
Results[,"Average"] <- round(rowMeans(Results[,-c(1,2)]),digits = 1)
# Flavor
gg1 <- Results[,c(1,2,ncol(Results))] %>%
filter(Levels %in% levels(mydatc9_case_design$Flavor)) %>%
ggplot(., aes(x = Levels, y = Average, group = 1)) +
geom_point() +
geom_line() +
ggtitle("Flavor") +
theme(axis.text.x = element_text(angle = 10, hjust = 1, size = 8)) +
theme(axis.text.y = element_text(hjust = 1, size = 8)) +
theme(title = element_text(hjust = 1, size = 8))
# Size
gg2 <- Results[,c(1,2,ncol(Results))] %>%
filter(Levels %in% levels(mydatc9_case_design$Size)) %>%
ggplot(., aes(x = Levels, y = Average, group = 1)) +
geom_point() +
geom_line() +
ggtitle("Size") +
theme(axis.text.x = element_text(angle = 10, hjust = 1, size = 8)) +
theme(axis.text.y = element_text(hjust = 1, size = 8)) +
theme(title = element_text(hjust = 1, size = 8))
# Superfoods
gg3 <- Results[,c(1,2,ncol(Results))] %>%
filter(Levels %in% levels(mydatc9_case_design$Superfoods)) %>%
ggplot(., aes(x = Levels, y = Average, group = 1)) +
geom_point() +
geom_line() +
ggtitle("Superfoods") +
theme(axis.text.x = element_text(angle = 10, hjust = 1, size = 8)) +
theme(axis.text.y = element_text(hjust = 1, size = 8)) +
theme(title = element_text(hjust = 1, size = 8))
# Filling
gg4 <- Results[,c(1,2,ncol(Results))] %>%
filter(Levels %in% levels(mydatc9_case_design$Filling)) %>%
ggplot(., aes(x = Levels, y = Average, group = 1)) +
geom_point() +
geom_line() +
ggtitle("Filling") +
theme(axis.text.x = element_text(angle = 10, hjust = 1, size = 8)) +
theme(axis.text.y = element_text(hjust = 1, size = 8)) +
theme(title = element_text(hjust = 1, size = 8))
# Packaging
gg5 <- Results[,c(1,2,ncol(Results))] %>%
filter(Levels %in% levels(mydatc9_case_design$Packaging)) %>%
ggplot(., aes(x = Levels, y = Average, group = 1)) +
geom_point() +
geom_line() +
ggtitle("Packaging") +
theme(axis.text.x = element_text(angle = 10, hjust = 1, size = 8)) +
theme(axis.text.y = element_text(hjust = 1, size = 8)) +
theme(title = element_text(hjust = 1, size = 8))
# Price
gg6 <- Results[,c(1,2,ncol(Results))] %>%
filter(Levels == "Price") %>%
ggplot(., aes(x = Levels, y = Average,)) +
geom_point() +
# geom_line() +
ggtitle("Price") +
theme(axis.text.x = element_text(angle = 10, hjust = 1, size = 8)) +
theme(axis.text.y = element_text(hjust = 1, size = 8)) +
theme(title = element_text(hjust = 1, size = 8))
# Plot
cowplot::plot_grid(gg1, gg2, gg3, gg4, gg5, gg6, nrow = 3, ncol = 2)