–//– Load R Packages –//–


Install and/or load all required R Packages

knitr::opts_chunk$set(echo = TRUE)

if(!require("tidyverse")) {install.packages("tidyverse"); library("tidyverse")}
if(!require("klaR")) {install.packages("klaR"); library("klaR")}
if(!require("caret")) {install.packages("caret"); library("caret")}
if(!require("cowplot")) {install.packages("cowplot"); library("cowplot")}
if(!require("scales")) {install.packages("scales"); library("scales")}
if(!require("Hmisc")) {install.packages("Hmisc"); library("Hmisc")}
if(!require("sjlabelled")) {install.packages("sjlabelled"); library("sjlabelled")}

–//– Clean-Up Working Emvironment –//–


Removes all objects from the current working environment

# clean up working environment
rm(list = ls())

–//– Chapter 04 - Discriminant Analysis –//–


[=> Case Study] | 4.3 | Case Study

(-) Create exemplary dataset (N = 127) | incl. Table 4.11 - Chocolate flavors and perceived attributes examined in the case study

mydatc4_case.1 <- data.frame(
"ID"    = c(    1,  2,  3,  4,  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, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100,    101,    102,    103,    104,    105,    106,    107,    108,    109,    110,    111,    112,    113,    114,    115,    116,    117,    118,    119,    120,    121,    122,    123,    124,    125,    126,    127 ),
"Price" = c(    3,  6,  2,  4,  7,  5,  6,  3,  7,  3,  7,  7,  6,  3,  4,  4,  3,  6,  7,  5,  3,  6,  4,  6,  6,  6,  5,  6,  3,  7,  2,  6,  5,  5,  4,  7,  5,  4,  2,  3,  3,  7,  3,  6,  4,  2,  3,  4,  6,  1,  2,  2,  3,  2,  5,  1,  3,  3,  5,  7,  3,  2,  3,  2,  6,  2,  3,  7,  5,  3,  6,  5,  6,  6,  4,  5,  5,  5,  6,  7,  5,  7,  5,  7,  6,  6,  6,  6,  7,  6,  5,  5,  4,  7,  7,  7,  5,  5,  6,  5,  2,  6,  5,  5,  4,  4,  6,  5,  5,  5,  6,  6,  5,  4,  5,  4,  7,  4,  5,  5,  3,  5,  6,  4,  5,  3,  5   ),
"Refreshing"    = c(    3,  6,  3,  3,  5,  4,  5,  3,  6,  4,  1,  7,  5,  3,  6,  3,  4,  3,  7,  2,  4,  2,  3,  2,  5,  2,  2,  5,  4,  7,  2,  5,  3,  4,  6,  4,  5,  5,  2,  6,  7,  7,  5,  2,  5,  7,  7,  6,  7,  7,  2,  4,  6,  4,  4,  3,  6,  7,  4,  5,  5,  7,  1,  2,  4,  1,  4,  4,  3,  4,  2,  3,  3,  4,  2,  3,  3,  5,  4,  5,  4,  6,  2,  5,  2,  4,  6,  2,  6,  6,  4,  4,  5,  6,  4,  7,  2,  4,  4,  2,  2,  4,  6,  4,  3,  7,  5,  5,  1,  4,  NA, 5,  3,  1,  3,  4,  5,  4,  3,  3,  3,  5,  7,  3,  4,  4,  4   ),
"Delicious" = c(    5,  5,  3,  3,  5,  5,  6,  3,  6,  4,  4,  3,  4,  4,  2,  4,  4,  5,  3,  3,  4,  5,  4,  4,  7,  6,  4,  6,  6,  4,  5,  4,  4,  4,  4,  6,  4,  4,  2,  3,  3,  7,  3,  3,  4,  5,  5,  6,  5,  1,  2,  4,  2,  3,  5,  3,  4,  3,  4,  6,  5,  3,  3,  2,  4,  2,  6,  6,  6,  3,  6,  4,  5,  5,  4,  4,  4,  5,  5,  4,  4,  6,  5,  4,  6,  5,  6,  6,  2,  6,  4,  4,  4,  7,  2,  7,  5,  4,  4,  6,  5,  6,  5,  4,  4,  4,  4,  4,  4,  4,  3,  4,  3,  4,  5,  4,  4,  4,  4,  5,  3,  5,  5,  4,  4,  4,  4   ),
"Healthy"   = c(    4,  2,  3,  4,  7,  2,  5,  4,  2,  4,  5,  7,  3,  3,  4,  4,  4,  4,  2,  4,  4,  2,  3,  5,  3,  4,  4,  4,  2,  NA, 4,  1,  4,  4,  4,  4,  3,  3,  2,  3,  1,  3,  2,  2,  5,  6,  6,  4,  4,  NA, 6,  4,  2,  5,  3,  3,  4,  1,  4,  3,  4,  2,  6,  6,  4,  2,  4,  4,  5,  4,  4,  4,  5,  1,  2,  3,  5,  4,  5,  5,  4,  3,  2,  4,  4,  6,  4,  4,  4,  6,  3,  5,  4,  1,  6,  4,  2,  5,  6,  3,  4,  3,  4,  4,  3,  4,  4,  5,  3,  4,  4,  4,  4,  3,  6,  4,  4,  3,  4,  4,  4,  5,  5,  3,  6,  4,  1   ),
"Bitter"    = c(    1,  2,  2,  4,  3,  5,  6,  3,  3,  2,  1,  1,  1,  1,  1,  4,  3,  4,  1,  4,  3,  3,  4,  6,  3,  6,  6,  6,  6,  4,  3,  1,  4,  4,  4,  5,  4,  4,  3,  7,  4,  7,  3,  4,  5,  5,  1,  6,  2,  7,  6,  4,  2,  2,  3,  1,  6,  4,  4,  6,  3,  6,  5,  6,  4,  2,  6,  5,  7,  2,  6,  5,  3,  5,  5,  4,  2,  5,  5,  3,  4,  2,  3,  3,  5,  6,  6,  6,  3,  3,  3,  3,  3,  7,  1,  5,  3,  3,  7,  5,  3,  5,  5,  4,  3,  4,  5,  4,  6,  5,  2,  4,  3,  1,  7,  4,  4,  2,  3,  4,  4,  4,  5,  3,  4,  4,  4   ),
"Light" = c(    2,  5,  3,  3,  6,  4,  5,  2,  7,  5,  4,  3,  2,  4,  3,  4,  3,  4,  2,  4,  4,  4,  5,  6,  2,  6,  5,  6,  4,  6,  5,  3,  3,  5,  4,  5,  3,  5,  2,  5,  6,  7,  3,  3,  5,  6,  7,  7,  6,  7,  5,  6,  4,  5,  4,  7,  6,  6,  4,  6,  5,  7,  5,  5,  4,  4,  6,  6,  6,  4,  6,  5,  6,  6,  3,  3,  1,  4,  4,  5,  4,  6,  5,  4,  6,  5,  6,  6,  4,  6,  5,  4,  3,  7,  2,  7,  2,  4,  5,  4,  5,  4,  5,  4,  5,  4,  4,  4,  4,  5,  6,  3,  4,  2,  5,  4,  4,  2,  3,  3,  5,  5,  5,  3,  5,  4,  4   ),
"Crunchy"   = c(    3,  2,  5,  5,  5,  3,  6,  3,  5,  5,  1,  1,  NA, 2,  1,  4,  3,  4,  5,  5,  3,  2,  4,  3,  3,  4,  4,  4,  6,  7,  3,  4,  4,  4,  3,  5,  1,  5,  6,  4,  3,  7,  5,  5,  5,  5,  6,  4,  6,  7,  5,  4,  5,  7,  5,  5,  7,  3,  3,  4,  6,  7,  6,  5,  4,  5,  7,  4,  2,  5,  4,  3,  3,  6,  5,  6,  4,  6,  6,  6,  3,  1,  2,  4,  2,  5,  3,  4,  3,  2,  4,  3,  3,  2,  3,  7,  2,  4,  6,  6,  3,  3,  NA, 4,  3,  1,  5,  5,  5,  4,  5,  5,  3,  3,  7,  4,  4,  3,  3,  5,  3,  3,  5,  4,  5,  4,  1   ),
"Exotic"    = c(    1,  1,  1,  2,  1,  7,  5,  1,  1,  1,  1,  1,  1,  3,  2,  4,  7,  3,  1,  3,  1,  1,  7,  1,  1,  6,  6,  5,  7,  1,  1,  1,  1,  4,  1,  1,  1,  1,  6,  7,  7,  1,  7,  1,  1,  7,  7,  5,  7,  7,  7,  2,  7,  2,  2,  7,  7,  7,  5,  1,  7,  7,  NA, 7,  NA, 7,  7,  1,  7,  2,  5,  1,  6,  7,  1,  1,  7,  5,  1,  1,  1,  1,  1,  1,  7,  1,  1,  NA, 1,  NA, 1,  1,  NA, 7,  1,  1,  1,  1,  1,  7,  1,  1,  1,  NA, 1,  1,  1,  7,  1,  1,  1,  1,  1,  1,  1,  1,  3,  1,  1,  1,  5,  5,  5,  1,  1,  1,  1   ),
"Sweet" = c(    3,  6,  3,  4,  5,  7,  6,  3,  6,  4,  3,  4,  3,  4,  4,  4,  5,  4,  1,  3,  1,  3,  4,  5,  3,  5,  5,  4,  2,  5,  4,  3,  2,  4,  4,  3,  3,  3,  3,  4,  4,  6,  2,  5,  3,  5,  5,  5,  6,  1,  4,  4,  3,  4,  4,  7,  6,  4,  3,  5,  5,  7,  5,  4,  4,  2,  6,  5,  6,  4,  5,  4,  4,  3,  5,  5,  4,  4,  5,  5,  3,  2,  4,  5,  6,  6,  4,  5,  4,  4,  6,  4,  4,  7,  5,  6,  3,  4,  5,  3,  4,  3,  2,  4,  3,  3,  4,  3,  4,  4,  3,  4,  3,  3,  6,  4,  5,  2,  3,  5,  4,  4,  5,  3,  4,  4,  1   ),
"Fruity"    = c(    4,  7,  2,  4,  5,  3,  5,  3,  3,  4,  5,  5,  1,  2,  4,  4,  5,  4,  1,  3,  3,  4,  4,  4,  1,  5,  4,  4,  4,  1,  5,  3,  2,  4,  4,  5,  3,  6,  2,  4,  5,  6,  4,  5,  6,  6,  6,  5,  5,  7,  6,  4,  6,  4,  4,  7,  7,  5,  3,  5,  5,  7,  4,  6,  4,  5,  7,  5,  3,  3,  5,  4,  4,  3,  4,  4,  1,  3,  6,  3,  2,  3,  5,  4,  3,  3,  2,  5,  4,  4,  5,  3,  3,  7,  2,  6,  4,  3,  6,  3,  5,  7,  4,  4,  3,  3,  4,  3,  4,  4,  4,  1,  4,  3,  6,  4,  5,  2,  3,  4,  3,  4,  5,  4,  4,  4,  4   ),
"Respondent"    = c(    1,  3,  4,  7,  11, 12, 16, 18, 2,  4,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 1,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17, 18, 2,  8,  10, 11, 13, 1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13, 14, 15, 16, 17, 18, 4,  7,  8,  10, 12, 13, 14, 16, 2,  6,  7,  8,  9,  12, 13, 14, 15, 16, 17, 18, 1,  2,  3,  4,  6,  8,  10, 11, 12, 13, 14, 15, 16, 17, 1,  2,  3,  4,  5,  6,  8,  9,  11, 13, 17, 18, 4,  5,  7,  9,  12, 13, 14, 15, 16, 17, 18, 1,  2,  3,  4,  6,  8,  9,  13, 17, 18  ),
"Flavor"    = c(    1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  6,  6,  6,  6,  6,  6,  6,  6,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  7,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  8,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11  ),
"Segment"   = c(    1,  1,  1,  1,  1,  1,  1,  1,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  2,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1   )
)


mydatc4_case.1$Flavor <- factor(mydatc4_case.1$Flavor, 
                                   levels = c(1:11),
                                   labels = c("Milk", 
                                      "Espresso",
                                      "Biscuit",
                                      "Orange",
                                      "Strawberry",
                                      "Mango",
                                      "Cappuccino",
                                      "Mousse",
                                      "Caramel",
                                      "Nougat",
                                      "Nut"))

mydatc4_case.1$Segment <- factor(mydatc4_case.1$Segment, 
                                   levels = c(1:3),
                                   labels = c("Seg_1 Classic", 
                                              "Seg_2 Fruit",
                                              "Seg_3 Coffee"))
                                      

print(mydatc4_case.1)
##      ID Price Refreshing Delicious Healthy Bitter Light Crunchy Exotic Sweet
## 1     1     3          3         5       4      1     2       3      1     3
## 2     2     6          6         5       2      2     5       2      1     6
## 3     3     2          3         3       3      2     3       5      1     3
## 4     4     4          3         3       4      4     3       5      2     4
## 5     5     7          5         5       7      3     6       5      1     5
## 6     6     5          4         5       2      5     4       3      7     7
## 7     7     6          5         6       5      6     5       6      5     6
## 8     8     3          3         3       4      3     2       3      1     3
## 9     9     7          6         6       2      3     7       5      1     6
## 10   10     3          4         4       4      2     5       5      1     4
## 11   11     7          1         4       5      1     4       1      1     3
## 12   12     7          7         3       7      1     3       1      1     4
## 13   13     6          5         4       3      1     2      NA      1     3
## 14   14     3          3         4       3      1     4       2      3     4
## 15   15     4          6         2       4      1     3       1      2     4
## 16   16     4          3         4       4      4     4       4      4     4
## 17   17     3          4         4       4      3     3       3      7     5
## 18   18     6          3         5       4      4     4       4      3     4
## 19   19     7          7         3       2      1     2       5      1     1
## 20   20     5          2         3       4      4     4       5      3     3
## 21   21     3          4         4       4      3     4       3      1     1
## 22   22     6          2         5       2      3     4       2      1     3
## 23   23     4          3         4       3      4     5       4      7     4
## 24   24     6          2         4       5      6     6       3      1     5
## 25   25     6          5         7       3      3     2       3      1     3
## 26   26     6          2         6       4      6     6       4      6     5
## 27   27     5          2         4       4      6     5       4      6     5
## 28   28     6          5         6       4      6     6       4      5     4
## 29   29     3          4         6       2      6     4       6      7     2
## 30   30     7          7         4      NA      4     6       7      1     5
## 31   31     2          2         5       4      3     5       3      1     4
## 32   32     6          5         4       1      1     3       4      1     3
## 33   33     5          3         4       4      4     3       4      1     2
## 34   34     5          4         4       4      4     5       4      4     4
## 35   35     4          6         4       4      4     4       3      1     4
## 36   36     7          4         6       4      5     5       5      1     3
## 37   37     5          5         4       3      4     3       1      1     3
## 38   38     4          5         4       3      4     5       5      1     3
## 39   39     2          2         2       2      3     2       6      6     3
## 40   40     3          6         3       3      7     5       4      7     4
## 41   41     3          7         3       1      4     6       3      7     4
## 42   42     7          7         7       3      7     7       7      1     6
## 43   43     3          5         3       2      3     3       5      7     2
## 44   44     6          2         3       2      4     3       5      1     5
## 45   45     4          5         4       5      5     5       5      1     3
## 46   46     2          7         5       6      5     6       5      7     5
## 47   47     3          7         5       6      1     7       6      7     5
## 48   48     4          6         6       4      6     7       4      5     5
## 49   49     6          7         5       4      2     6       6      7     6
## 50   50     1          7         1      NA      7     7       7      7     1
## 51   51     2          2         2       6      6     5       5      7     4
## 52   52     2          4         4       4      4     6       4      2     4
## 53   53     3          6         2       2      2     4       5      7     3
## 54   54     2          4         3       5      2     5       7      2     4
## 55   55     5          4         5       3      3     4       5      2     4
## 56   56     1          3         3       3      1     7       5      7     7
## 57   57     3          6         4       4      6     6       7      7     6
## 58   58     3          7         3       1      4     6       3      7     4
## 59   59     5          4         4       4      4     4       3      5     3
## 60   60     7          5         6       3      6     6       4      1     5
## 61   61     3          5         5       4      3     5       6      7     5
## 62   62     2          7         3       2      6     7       7      7     7
## 63   63     3          1         3       6      5     5       6     NA     5
## 64   64     2          2         2       6      6     5       5      7     4
## 65   65     6          4         4       4      4     4       4     NA     4
## 66   66     2          1         2       2      2     4       5      7     2
## 67   67     3          4         6       4      6     6       7      7     6
## 68   68     7          4         6       4      5     6       4      1     5
## 69   69     5          3         6       5      7     6       2      7     6
## 70   70     3          4         3       4      2     4       5      2     4
## 71   71     6          2         6       4      6     6       4      5     5
## 72   72     5          3         4       4      5     5       3      1     4
## 73   73     6          3         5       5      3     6       3      6     4
## 74   74     6          4         5       1      5     6       6      7     3
## 75   75     4          2         4       2      5     3       5      1     5
## 76   76     5          3         4       3      4     3       6      1     5
## 77   77     5          3         4       5      2     1       4      7     4
## 78   78     5          5         5       4      5     4       6      5     4
## 79   79     6          4         5       5      5     4       6      1     5
## 80   80     7          5         4       5      3     5       6      1     5
## 81   81     5          4         4       4      4     4       3      1     3
## 82   82     7          6         6       3      2     6       1      1     2
## 83   83     5          2         5       2      3     5       2      1     4
## 84   84     7          5         4       4      3     4       4      1     5
## 85   85     6          2         6       4      5     6       2      7     6
## 86   86     6          4         5       6      6     5       5      1     6
## 87   87     6          6         6       4      6     6       3      1     4
## 88   88     6          2         6       4      6     6       4     NA     5
## 89   89     7          6         2       4      3     4       3      1     4
## 90   90     6          6         6       6      3     6       2     NA     4
## 91   91     5          4         4       3      3     5       4      1     6
## 92   92     5          4         4       5      3     4       3      1     4
## 93   93     4          5         4       4      3     3       3     NA     4
## 94   94     7          6         7       1      7     7       2      7     7
## 95   95     7          4         2       6      1     2       3      1     5
## 96   96     7          7         7       4      5     7       7      1     6
## 97   97     5          2         5       2      3     2       2      1     3
## 98   98     5          4         4       5      3     4       4      1     4
## 99   99     6          4         4       6      7     5       6      1     5
## 100 100     5          2         6       3      5     4       6      7     3
## 101 101     2          2         5       4      3     5       3      1     4
## 102 102     6          4         6       3      5     4       3      1     3
## 103 103     5          6         5       4      5     5      NA      1     2
## 104 104     5          4         4       4      4     4       4     NA     4
## 105 105     4          3         4       3      3     5       3      1     3
## 106 106     4          7         4       4      4     4       1      1     3
## 107 107     6          5         4       4      5     4       5      1     4
## 108 108     5          5         4       5      4     4       5      7     3
## 109 109     5          1         4       3      6     4       5      1     4
## 110 110     5          4         4       4      5     5       4      1     4
## 111 111     6         NA         3       4      2     6       5      1     3
## 112 112     6          5         4       4      4     3       5      1     4
## 113 113     5          3         3       4      3     4       3      1     3
## 114 114     4          1         4       3      1     2       3      1     3
## 115 115     5          3         5       6      7     5       7      1     6
## 116 116     4          4         4       4      4     4       4      1     4
## 117 117     7          5         4       4      4     4       4      3     5
## 118 118     4          4         4       3      2     2       3      1     2
## 119 119     5          3         4       4      3     3       3      1     3
## 120 120     5          3         5       4      4     3       5      1     5
## 121 121     3          3         3       4      4     5       3      5     4
## 122 122     5          5         5       5      4     5       3      5     4
## 123 123     6          7         5       5      5     5       5      5     5
## 124 124     4          3         4       3      3     3       4      1     3
## 125 125     5          4         4       6      4     5       5      1     4
## 126 126     3          4         4       4      4     4       4      1     4
## 127 127     5          4         4       1      4     4       1      1     1
##     Fruity Respondent     Flavor       Segment
## 1        4          1       Milk Seg_1 Classic
## 2        7          3       Milk Seg_1 Classic
## 3        2          4       Milk Seg_1 Classic
## 4        4          7       Milk Seg_1 Classic
## 5        5         11       Milk Seg_1 Classic
## 6        3         12       Milk Seg_1 Classic
## 7        5         16       Milk Seg_1 Classic
## 8        3         18       Milk Seg_1 Classic
## 9        3          2   Espresso  Seg_3 Coffee
## 10       4          4   Espresso  Seg_3 Coffee
## 11       5          7   Espresso  Seg_3 Coffee
## 12       5          8   Espresso  Seg_3 Coffee
## 13       1          9   Espresso  Seg_3 Coffee
## 14       2         10   Espresso  Seg_3 Coffee
## 15       4         11   Espresso  Seg_3 Coffee
## 16       4         12   Espresso  Seg_3 Coffee
## 17       5         13   Espresso  Seg_3 Coffee
## 18       4         14   Espresso  Seg_3 Coffee
## 19       1         15   Espresso  Seg_3 Coffee
## 20       3         16   Espresso  Seg_3 Coffee
## 21       3          1    Biscuit Seg_1 Classic
## 22       4          3    Biscuit Seg_1 Classic
## 23       4          4    Biscuit Seg_1 Classic
## 24       4          5    Biscuit Seg_1 Classic
## 25       1          6    Biscuit Seg_1 Classic
## 26       5          7    Biscuit Seg_1 Classic
## 27       4          8    Biscuit Seg_1 Classic
## 28       4          9    Biscuit Seg_1 Classic
## 29       4         10    Biscuit Seg_1 Classic
## 30       1         11    Biscuit Seg_1 Classic
## 31       5         12    Biscuit Seg_1 Classic
## 32       3         13    Biscuit Seg_1 Classic
## 33       2         14    Biscuit Seg_1 Classic
## 34       4         15    Biscuit Seg_1 Classic
## 35       4         16    Biscuit Seg_1 Classic
## 36       5         17    Biscuit Seg_1 Classic
## 37       3         18    Biscuit Seg_1 Classic
## 38       6          2     Orange   Seg_2 Fruit
## 39       2          8     Orange   Seg_2 Fruit
## 40       4         10     Orange   Seg_2 Fruit
## 41       5         11     Orange   Seg_2 Fruit
## 42       6         13     Orange   Seg_2 Fruit
## 43       4          1 Strawberry   Seg_2 Fruit
## 44       5          2 Strawberry   Seg_2 Fruit
## 45       6          3 Strawberry   Seg_2 Fruit
## 46       6          4 Strawberry   Seg_2 Fruit
## 47       6          5 Strawberry   Seg_2 Fruit
## 48       5          6 Strawberry   Seg_2 Fruit
## 49       5          7 Strawberry   Seg_2 Fruit
## 50       7          8 Strawberry   Seg_2 Fruit
## 51       6          9 Strawberry   Seg_2 Fruit
## 52       4         10 Strawberry   Seg_2 Fruit
## 53       6         11 Strawberry   Seg_2 Fruit
## 54       4         12 Strawberry   Seg_2 Fruit
## 55       4         13 Strawberry   Seg_2 Fruit
## 56       7         14 Strawberry   Seg_2 Fruit
## 57       7         15 Strawberry   Seg_2 Fruit
## 58       5         16 Strawberry   Seg_2 Fruit
## 59       3         17 Strawberry   Seg_2 Fruit
## 60       5         18 Strawberry   Seg_2 Fruit
## 61       5          4      Mango   Seg_2 Fruit
## 62       7          7      Mango   Seg_2 Fruit
## 63       4          8      Mango   Seg_2 Fruit
## 64       6         10      Mango   Seg_2 Fruit
## 65       4         12      Mango   Seg_2 Fruit
## 66       5         13      Mango   Seg_2 Fruit
## 67       7         14      Mango   Seg_2 Fruit
## 68       5         16      Mango   Seg_2 Fruit
## 69       3          2 Cappuccino  Seg_3 Coffee
## 70       3          6 Cappuccino  Seg_3 Coffee
## 71       5          7 Cappuccino  Seg_3 Coffee
## 72       4          8 Cappuccino  Seg_3 Coffee
## 73       4          9 Cappuccino  Seg_3 Coffee
## 74       3         12 Cappuccino  Seg_3 Coffee
## 75       4         13 Cappuccino  Seg_3 Coffee
## 76       4         14 Cappuccino  Seg_3 Coffee
## 77       1         15 Cappuccino  Seg_3 Coffee
## 78       3         16 Cappuccino  Seg_3 Coffee
## 79       6         17 Cappuccino  Seg_3 Coffee
## 80       3         18 Cappuccino  Seg_3 Coffee
## 81       2          1     Mousse Seg_1 Classic
## 82       3          2     Mousse Seg_1 Classic
## 83       5          3     Mousse Seg_1 Classic
## 84       4          4     Mousse Seg_1 Classic
## 85       3          6     Mousse Seg_1 Classic
## 86       3          8     Mousse Seg_1 Classic
## 87       2         10     Mousse Seg_1 Classic
## 88       5         11     Mousse Seg_1 Classic
## 89       4         12     Mousse Seg_1 Classic
## 90       4         13     Mousse Seg_1 Classic
## 91       5         14     Mousse Seg_1 Classic
## 92       3         15     Mousse Seg_1 Classic
## 93       3         16     Mousse Seg_1 Classic
## 94       7         17     Mousse Seg_1 Classic
## 95       2          1    Caramel Seg_1 Classic
## 96       6          2    Caramel Seg_1 Classic
## 97       4          3    Caramel Seg_1 Classic
## 98       3          4    Caramel Seg_1 Classic
## 99       6          5    Caramel Seg_1 Classic
## 100      3          6    Caramel Seg_1 Classic
## 101      5          8    Caramel Seg_1 Classic
## 102      7          9    Caramel Seg_1 Classic
## 103      4         11    Caramel Seg_1 Classic
## 104      4         13    Caramel Seg_1 Classic
## 105      3         17    Caramel Seg_1 Classic
## 106      3         18    Caramel Seg_1 Classic
## 107      4          4     Nougat Seg_1 Classic
## 108      3          5     Nougat Seg_1 Classic
## 109      4          7     Nougat Seg_1 Classic
## 110      4          9     Nougat Seg_1 Classic
## 111      4         12     Nougat Seg_1 Classic
## 112      1         13     Nougat Seg_1 Classic
## 113      4         14     Nougat Seg_1 Classic
## 114      3         15     Nougat Seg_1 Classic
## 115      6         16     Nougat Seg_1 Classic
## 116      4         17     Nougat Seg_1 Classic
## 117      5         18     Nougat Seg_1 Classic
## 118      2          1        Nut Seg_1 Classic
## 119      3          2        Nut Seg_1 Classic
## 120      4          3        Nut Seg_1 Classic
## 121      3          4        Nut Seg_1 Classic
## 122      4          6        Nut Seg_1 Classic
## 123      5          8        Nut Seg_1 Classic
## 124      4          9        Nut Seg_1 Classic
## 125      4         13        Nut Seg_1 Classic
## 126      4         17        Nut Seg_1 Classic
## 127      4         18        Nut Seg_1 Classic

(-) Remove NAs (11 Cases)

mydatc4_case.2 <- na.omit(mydatc4_case.1)

dim(mydatc4_case.2); print(mydatc4_case.2)
## [1] 116  14
##      ID Price Refreshing Delicious Healthy Bitter Light Crunchy Exotic Sweet
## 1     1     3          3         5       4      1     2       3      1     3
## 2     2     6          6         5       2      2     5       2      1     6
## 3     3     2          3         3       3      2     3       5      1     3
## 4     4     4          3         3       4      4     3       5      2     4
## 5     5     7          5         5       7      3     6       5      1     5
## 6     6     5          4         5       2      5     4       3      7     7
## 7     7     6          5         6       5      6     5       6      5     6
## 8     8     3          3         3       4      3     2       3      1     3
## 9     9     7          6         6       2      3     7       5      1     6
## 10   10     3          4         4       4      2     5       5      1     4
## 11   11     7          1         4       5      1     4       1      1     3
## 12   12     7          7         3       7      1     3       1      1     4
## 14   14     3          3         4       3      1     4       2      3     4
## 15   15     4          6         2       4      1     3       1      2     4
## 16   16     4          3         4       4      4     4       4      4     4
## 17   17     3          4         4       4      3     3       3      7     5
## 18   18     6          3         5       4      4     4       4      3     4
## 19   19     7          7         3       2      1     2       5      1     1
## 20   20     5          2         3       4      4     4       5      3     3
## 21   21     3          4         4       4      3     4       3      1     1
## 22   22     6          2         5       2      3     4       2      1     3
## 23   23     4          3         4       3      4     5       4      7     4
## 24   24     6          2         4       5      6     6       3      1     5
## 25   25     6          5         7       3      3     2       3      1     3
## 26   26     6          2         6       4      6     6       4      6     5
## 27   27     5          2         4       4      6     5       4      6     5
## 28   28     6          5         6       4      6     6       4      5     4
## 29   29     3          4         6       2      6     4       6      7     2
## 31   31     2          2         5       4      3     5       3      1     4
## 32   32     6          5         4       1      1     3       4      1     3
## 33   33     5          3         4       4      4     3       4      1     2
## 34   34     5          4         4       4      4     5       4      4     4
## 35   35     4          6         4       4      4     4       3      1     4
## 36   36     7          4         6       4      5     5       5      1     3
## 37   37     5          5         4       3      4     3       1      1     3
## 38   38     4          5         4       3      4     5       5      1     3
## 39   39     2          2         2       2      3     2       6      6     3
## 40   40     3          6         3       3      7     5       4      7     4
## 41   41     3          7         3       1      4     6       3      7     4
## 42   42     7          7         7       3      7     7       7      1     6
## 43   43     3          5         3       2      3     3       5      7     2
## 44   44     6          2         3       2      4     3       5      1     5
## 45   45     4          5         4       5      5     5       5      1     3
## 46   46     2          7         5       6      5     6       5      7     5
## 47   47     3          7         5       6      1     7       6      7     5
## 48   48     4          6         6       4      6     7       4      5     5
## 49   49     6          7         5       4      2     6       6      7     6
## 51   51     2          2         2       6      6     5       5      7     4
## 52   52     2          4         4       4      4     6       4      2     4
## 53   53     3          6         2       2      2     4       5      7     3
## 54   54     2          4         3       5      2     5       7      2     4
## 55   55     5          4         5       3      3     4       5      2     4
## 56   56     1          3         3       3      1     7       5      7     7
## 57   57     3          6         4       4      6     6       7      7     6
## 58   58     3          7         3       1      4     6       3      7     4
## 59   59     5          4         4       4      4     4       3      5     3
## 60   60     7          5         6       3      6     6       4      1     5
## 61   61     3          5         5       4      3     5       6      7     5
## 62   62     2          7         3       2      6     7       7      7     7
## 64   64     2          2         2       6      6     5       5      7     4
## 66   66     2          1         2       2      2     4       5      7     2
## 67   67     3          4         6       4      6     6       7      7     6
## 68   68     7          4         6       4      5     6       4      1     5
## 69   69     5          3         6       5      7     6       2      7     6
## 70   70     3          4         3       4      2     4       5      2     4
## 71   71     6          2         6       4      6     6       4      5     5
## 72   72     5          3         4       4      5     5       3      1     4
## 73   73     6          3         5       5      3     6       3      6     4
## 74   74     6          4         5       1      5     6       6      7     3
## 75   75     4          2         4       2      5     3       5      1     5
## 76   76     5          3         4       3      4     3       6      1     5
## 77   77     5          3         4       5      2     1       4      7     4
## 78   78     5          5         5       4      5     4       6      5     4
## 79   79     6          4         5       5      5     4       6      1     5
## 80   80     7          5         4       5      3     5       6      1     5
## 81   81     5          4         4       4      4     4       3      1     3
## 82   82     7          6         6       3      2     6       1      1     2
## 83   83     5          2         5       2      3     5       2      1     4
## 84   84     7          5         4       4      3     4       4      1     5
## 85   85     6          2         6       4      5     6       2      7     6
## 86   86     6          4         5       6      6     5       5      1     6
## 87   87     6          6         6       4      6     6       3      1     4
## 89   89     7          6         2       4      3     4       3      1     4
## 91   91     5          4         4       3      3     5       4      1     6
## 92   92     5          4         4       5      3     4       3      1     4
## 94   94     7          6         7       1      7     7       2      7     7
## 95   95     7          4         2       6      1     2       3      1     5
## 96   96     7          7         7       4      5     7       7      1     6
## 97   97     5          2         5       2      3     2       2      1     3
## 98   98     5          4         4       5      3     4       4      1     4
## 99   99     6          4         4       6      7     5       6      1     5
## 100 100     5          2         6       3      5     4       6      7     3
## 101 101     2          2         5       4      3     5       3      1     4
## 102 102     6          4         6       3      5     4       3      1     3
## 105 105     4          3         4       3      3     5       3      1     3
## 106 106     4          7         4       4      4     4       1      1     3
## 107 107     6          5         4       4      5     4       5      1     4
## 108 108     5          5         4       5      4     4       5      7     3
## 109 109     5          1         4       3      6     4       5      1     4
## 110 110     5          4         4       4      5     5       4      1     4
## 112 112     6          5         4       4      4     3       5      1     4
## 113 113     5          3         3       4      3     4       3      1     3
## 114 114     4          1         4       3      1     2       3      1     3
## 115 115     5          3         5       6      7     5       7      1     6
## 116 116     4          4         4       4      4     4       4      1     4
## 117 117     7          5         4       4      4     4       4      3     5
## 118 118     4          4         4       3      2     2       3      1     2
## 119 119     5          3         4       4      3     3       3      1     3
## 120 120     5          3         5       4      4     3       5      1     5
## 121 121     3          3         3       4      4     5       3      5     4
## 122 122     5          5         5       5      4     5       3      5     4
## 123 123     6          7         5       5      5     5       5      5     5
## 124 124     4          3         4       3      3     3       4      1     3
## 125 125     5          4         4       6      4     5       5      1     4
## 126 126     3          4         4       4      4     4       4      1     4
## 127 127     5          4         4       1      4     4       1      1     1
##     Fruity Respondent     Flavor       Segment
## 1        4          1       Milk Seg_1 Classic
## 2        7          3       Milk Seg_1 Classic
## 3        2          4       Milk Seg_1 Classic
## 4        4          7       Milk Seg_1 Classic
## 5        5         11       Milk Seg_1 Classic
## 6        3         12       Milk Seg_1 Classic
## 7        5         16       Milk Seg_1 Classic
## 8        3         18       Milk Seg_1 Classic
## 9        3          2   Espresso  Seg_3 Coffee
## 10       4          4   Espresso  Seg_3 Coffee
## 11       5          7   Espresso  Seg_3 Coffee
## 12       5          8   Espresso  Seg_3 Coffee
## 14       2         10   Espresso  Seg_3 Coffee
## 15       4         11   Espresso  Seg_3 Coffee
## 16       4         12   Espresso  Seg_3 Coffee
## 17       5         13   Espresso  Seg_3 Coffee
## 18       4         14   Espresso  Seg_3 Coffee
## 19       1         15   Espresso  Seg_3 Coffee
## 20       3         16   Espresso  Seg_3 Coffee
## 21       3          1    Biscuit Seg_1 Classic
## 22       4          3    Biscuit Seg_1 Classic
## 23       4          4    Biscuit Seg_1 Classic
## 24       4          5    Biscuit Seg_1 Classic
## 25       1          6    Biscuit Seg_1 Classic
## 26       5          7    Biscuit Seg_1 Classic
## 27       4          8    Biscuit Seg_1 Classic
## 28       4          9    Biscuit Seg_1 Classic
## 29       4         10    Biscuit Seg_1 Classic
## 31       5         12    Biscuit Seg_1 Classic
## 32       3         13    Biscuit Seg_1 Classic
## 33       2         14    Biscuit Seg_1 Classic
## 34       4         15    Biscuit Seg_1 Classic
## 35       4         16    Biscuit Seg_1 Classic
## 36       5         17    Biscuit Seg_1 Classic
## 37       3         18    Biscuit Seg_1 Classic
## 38       6          2     Orange   Seg_2 Fruit
## 39       2          8     Orange   Seg_2 Fruit
## 40       4         10     Orange   Seg_2 Fruit
## 41       5         11     Orange   Seg_2 Fruit
## 42       6         13     Orange   Seg_2 Fruit
## 43       4          1 Strawberry   Seg_2 Fruit
## 44       5          2 Strawberry   Seg_2 Fruit
## 45       6          3 Strawberry   Seg_2 Fruit
## 46       6          4 Strawberry   Seg_2 Fruit
## 47       6          5 Strawberry   Seg_2 Fruit
## 48       5          6 Strawberry   Seg_2 Fruit
## 49       5          7 Strawberry   Seg_2 Fruit
## 51       6          9 Strawberry   Seg_2 Fruit
## 52       4         10 Strawberry   Seg_2 Fruit
## 53       6         11 Strawberry   Seg_2 Fruit
## 54       4         12 Strawberry   Seg_2 Fruit
## 55       4         13 Strawberry   Seg_2 Fruit
## 56       7         14 Strawberry   Seg_2 Fruit
## 57       7         15 Strawberry   Seg_2 Fruit
## 58       5         16 Strawberry   Seg_2 Fruit
## 59       3         17 Strawberry   Seg_2 Fruit
## 60       5         18 Strawberry   Seg_2 Fruit
## 61       5          4      Mango   Seg_2 Fruit
## 62       7          7      Mango   Seg_2 Fruit
## 64       6         10      Mango   Seg_2 Fruit
## 66       5         13      Mango   Seg_2 Fruit
## 67       7         14      Mango   Seg_2 Fruit
## 68       5         16      Mango   Seg_2 Fruit
## 69       3          2 Cappuccino  Seg_3 Coffee
## 70       3          6 Cappuccino  Seg_3 Coffee
## 71       5          7 Cappuccino  Seg_3 Coffee
## 72       4          8 Cappuccino  Seg_3 Coffee
## 73       4          9 Cappuccino  Seg_3 Coffee
## 74       3         12 Cappuccino  Seg_3 Coffee
## 75       4         13 Cappuccino  Seg_3 Coffee
## 76       4         14 Cappuccino  Seg_3 Coffee
## 77       1         15 Cappuccino  Seg_3 Coffee
## 78       3         16 Cappuccino  Seg_3 Coffee
## 79       6         17 Cappuccino  Seg_3 Coffee
## 80       3         18 Cappuccino  Seg_3 Coffee
## 81       2          1     Mousse Seg_1 Classic
## 82       3          2     Mousse Seg_1 Classic
## 83       5          3     Mousse Seg_1 Classic
## 84       4          4     Mousse Seg_1 Classic
## 85       3          6     Mousse Seg_1 Classic
## 86       3          8     Mousse Seg_1 Classic
## 87       2         10     Mousse Seg_1 Classic
## 89       4         12     Mousse Seg_1 Classic
## 91       5         14     Mousse Seg_1 Classic
## 92       3         15     Mousse Seg_1 Classic
## 94       7         17     Mousse Seg_1 Classic
## 95       2          1    Caramel Seg_1 Classic
## 96       6          2    Caramel Seg_1 Classic
## 97       4          3    Caramel Seg_1 Classic
## 98       3          4    Caramel Seg_1 Classic
## 99       6          5    Caramel Seg_1 Classic
## 100      3          6    Caramel Seg_1 Classic
## 101      5          8    Caramel Seg_1 Classic
## 102      7          9    Caramel Seg_1 Classic
## 105      3         17    Caramel Seg_1 Classic
## 106      3         18    Caramel Seg_1 Classic
## 107      4          4     Nougat Seg_1 Classic
## 108      3          5     Nougat Seg_1 Classic
## 109      4          7     Nougat Seg_1 Classic
## 110      4          9     Nougat Seg_1 Classic
## 112      1         13     Nougat Seg_1 Classic
## 113      4         14     Nougat Seg_1 Classic
## 114      3         15     Nougat Seg_1 Classic
## 115      6         16     Nougat Seg_1 Classic
## 116      4         17     Nougat Seg_1 Classic
## 117      5         18     Nougat Seg_1 Classic
## 118      2          1        Nut Seg_1 Classic
## 119      3          2        Nut Seg_1 Classic
## 120      4          3        Nut Seg_1 Classic
## 121      3          4        Nut Seg_1 Classic
## 122      4          6        Nut Seg_1 Classic
## 123      5          8        Nut Seg_1 Classic
## 124      4          9        Nut Seg_1 Classic
## 125      4         13        Nut Seg_1 Classic
## 126      4         17        Nut Seg_1 Classic
## 127      4         18        Nut Seg_1 Classic

(-) Table 4.12 - Definition of groups for discriminant analysis and number of observations

mydatc4_case.2 %>% 
  group_by(Segment, Flavor) %>% 
  tally()
## # A tibble: 11 x 3
## # Groups:   Segment [3]
##    Segment       Flavor         n
##    <fct>         <fct>      <int>
##  1 Seg_1 Classic Milk           8
##  2 Seg_1 Classic Biscuit       16
##  3 Seg_1 Classic Mousse        11
##  4 Seg_1 Classic Caramel       10
##  5 Seg_1 Classic Nougat        10
##  6 Seg_1 Classic Nut           10
##  7 Seg_2 Fruit   Orange         5
##  8 Seg_2 Fruit   Strawberry    17
##  9 Seg_2 Fruit   Mango          6
## 10 Seg_3 Coffee  Espresso      11
## 11 Seg_3 Coffee  Cappuccino    12
mydatc4_case.2 %>% 
  group_by(Segment) %>% 
  tally()
## # A tibble: 3 x 2
##   Segment           n
##   <fct>         <int>
## 1 Seg_1 Classic    65
## 2 Seg_2 Fruit      28
## 3 Seg_3 Coffee     23

(-) 4.3.3.1 Results of the Blockwise Estimation Procedure

(-) Figure 4.14 - Group statistics

# Group statistics
mydatc4_case.2 %>% 
  group_by(Segment) %>% 
  summarise_at(., .vars = vars(2:11), .funs = c(mean, sd)) %>%
  cbind(Meaning = paste0("in the following fn1 = mean, fn2 = sd"),.) %>% 
  t()
##                [,1]                                   
## Meaning        "in the following fn1 = mean, fn2 = sd"
## Segment        "Seg_1 Classic"                        
## Price_fn1      "5.061538"                             
## Refreshing_fn1 "3.907692"                             
## Delicious_fn1  "4.523077"                             
## Healthy_fn1    "3.784615"                             
## Bitter_fn1     "3.969231"                             
## Light_fn1      "4.246154"                             
## Crunchy_fn1    "3.692308"                             
## Exotic_fn1     "2.200000"                             
## Sweet_fn1      "3.953846"                             
## Fruity_fn1     "3.846154"                             
## Price_fn2      "1.321421"                             
## Refreshing_fn2 "1.443986"                             
## Delicious_fn2  "1.091268"                             
## Healthy_fn2    "1.231010"                             
## Bitter_fn2     "1.489224"                             
## Light_fn2      "1.237825"                             
## Crunchy_fn2    "1.379799"                             
## Exotic_fn2     "2.173707"                             
## Sweet_fn2      "1.304209"                             
## Fruity_fn2     "1.289753"                             
##                [,2]                                   
## Meaning        "in the following fn1 = mean, fn2 = sd"
## Segment        "Seg_2 Fruit"                          
## Price_fn1      "3.535714"                             
## Refreshing_fn1 "4.785714"                             
## Delicious_fn1  "3.928571"                             
## Healthy_fn1    "3.500000"                             
## Bitter_fn1     "4.178571"                             
## Light_fn1      "5.285714"                             
## Crunchy_fn1    "5.107143"                             
## Exotic_fn1     "5.000000"                             
## Sweet_fn1      "4.428571"                             
## Fruity_fn1     "5.214286"                             
## Price_fn2      "1.731669"                             
## Refreshing_fn2 "1.853068"                             
## Delicious_fn2  "1.463850"                             
## Healthy_fn2    "1.478237"                             
## Bitter_fn2     "1.785820"                             
## Light_fn2      "1.329359"                             
## Crunchy_fn2    "1.227442"                             
## Exotic_fn2     "2.638743"                             
## Sweet_fn2      "1.345185"                             
## Fruity_fn2     "1.227981"                             
##                [,3]                                   
## Meaning        "in the following fn1 = mean, fn2 = sd"
## Segment        "Seg_3 Coffee"                         
## Price_fn1      "5.173913"                             
## Refreshing_fn1 "3.782609"                             
## Delicious_fn1  "4.217391"                             
## Healthy_fn1    "3.913043"                             
## Bitter_fn1     "3.347826"                             
## Light_fn1      "4.173913"                             
## Crunchy_fn1    "4.000000"                             
## Exotic_fn1     "3.086957"                             
## Sweet_fn1      "4.173913"                             
## Fruity_fn1     "3.608696"                             
## Price_fn2      "1.402989"                             
## Refreshing_fn2 "1.594209"                             
## Delicious_fn2  "1.042572"                             
## Healthy_fn2    "1.311247"                             
## Bitter_fn2     "1.773766"                             
## Light_fn2      "1.435022"                             
## Crunchy_fn2    "1.705606"                             
## Exotic_fn2     "2.372437"                             
## Sweet_fn2      "1.072473"                             
## Fruity_fn2     "1.233588"
# lda(Attributes, Group)
lda(mydatc4_case.2[,2:11], mydatc4_case.2[,14])
## Call:
## lda(mydatc4_case.2[, 2:11], mydatc4_case.2[, 14])
## 
## Prior probabilities of groups:
## Seg_1 Classic   Seg_2 Fruit  Seg_3 Coffee 
##     0.5603448     0.2413793     0.1982759 
## 
## Group means:
##                  Price Refreshing Delicious  Healthy   Bitter    Light  Crunchy
## Seg_1 Classic 5.061538   3.907692  4.523077 3.784615 3.969231 4.246154 3.692308
## Seg_2 Fruit   3.535714   4.785714  3.928571 3.500000 4.178571 5.285714 5.107143
## Seg_3 Coffee  5.173913   3.782609  4.217391 3.913043 3.347826 4.173913 4.000000
##                 Exotic    Sweet   Fruity
## Seg_1 Classic 2.200000 3.953846 3.846154
## Seg_2 Fruit   5.000000 4.428571 5.214286
## Seg_3 Coffee  3.086957 4.173913 3.608696
## 
## Coefficients of linear discriminants:
##                    LD1        LD2
## Price      -0.25708626  0.4142271
## Refreshing  0.20810366 -0.2121803
## Delicious  -0.32772535 -0.2862550
## Healthy    -0.15785482  0.0708641
## Bitter     -0.06348995 -0.4903264
## Light       0.29777066  0.1381961
## Crunchy     0.31538550  0.2353022
## Exotic      0.14700067  0.2570126
## Sweet      -0.16433475  0.2644106
## Fruity      0.36487237 -0.2657973
## 
## Proportion of trace:
##   LD1   LD2 
## 0.898 0.102

(-) Figure 4.15 - Univariate discriminatory power of the describing variables

# Run all single ANOVAs at once and print output all at once
formulae <- lapply(colnames(mydatc4_case.2)[2:11], function(x) as.formula(paste0(x, " ~ Segment")))

Segment_aovres <- lapply(formulae, function(x) summary(aov(x, data = mydatc4_case.2)))
names(Segment_aovres) <- format(formulae)
print(Segment_aovres)
## $`Price ~ Segment`
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Segment       2  51.59  25.795   12.35 1.41e-05 ***
## Residuals   113 236.02   2.089                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Refreshing ~ Segment`
##              Df Sum Sq Mean Sq F value Pr(>F)  
## Segment       2  17.88   8.942   3.582  0.031 *
## Residuals   113 282.07   2.496                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Delicious ~ Segment`
##              Df Sum Sq Mean Sq F value Pr(>F)  
## Segment       2   7.21   3.606   2.579 0.0803 .
## Residuals   113 157.99   1.398                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Healthy ~ Segment`
##              Df Sum Sq Mean Sq F value Pr(>F)
## Segment       2   2.43   1.215   0.709  0.495
## Residuals   113 193.81   1.715               
## 
## $`Bitter ~ Segment`
##              Df Sum Sq Mean Sq F value Pr(>F)
## Segment       2    9.5   4.748   1.805  0.169
## Residuals   113  297.3   2.631               
## 
## $`Light ~ Segment`
##              Df Sum Sq Mean Sq F value  Pr(>F)   
## Segment       2  23.89  11.943   7.063 0.00129 **
## Residuals   113 191.08   1.691                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Crunchy ~ Segment`
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Segment       2  39.43  19.716   9.835 0.000115 ***
## Residuals   113 226.52   2.005                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Exotic ~ Segment`
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Segment       2  153.5   76.73   14.12 3.37e-06 ***
## Residuals   113  614.2    5.44                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## $`Sweet ~ Segment`
##              Df Sum Sq Mean Sq F value Pr(>F)
## Segment       2   4.52    2.26   1.395  0.252
## Residuals   113 183.02    1.62               
## 
## $`Fruity ~ Segment`
##              Df Sum Sq Mean Sq F value   Pr(>F)    
## Segment       2  44.41  22.203   13.89 4.05e-06 ***
## Residuals   113 180.65   1.599                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Note: Function greedy.wilks uses stepwise forward variable selection. Therefore the differences compared to the SPSS results (Fig. 4.15)

(-) This corresponds to Figure 4.30 - Describing variables included in the discriminant functions (stepwise procedure)

# Wilks' Lambda
klaR::greedy.wilks(Segment ~ 
               Price +
               Refreshing +
               Delicious +
               Healthy +
               Bitter +
               Light +
               Crunchy +
               Exotic +
               Sweet +
               Fruity,
               data =  mydatc4_case.2, 
               niveau = 0.1) 
## Formula containing included variables: 
## 
## Segment ~ Exotic + Fruity + Price + Refreshing + Crunchy + Bitter
## <environment: 0x000000002229db88>
## 
## 
## Values calculated in each step of the selection procedure: 
## 
##         vars Wilks.lambda F.statistics.overall p.value.overall
## 1     Exotic    0.8000969            14.116450    3.369420e-06
## 2     Fruity    0.6751653            12.152687    5.869362e-09
## 3      Price    0.5992997            10.794695    1.565787e-10
## 4 Refreshing    0.5510574             9.545398    2.527499e-11
## 5    Crunchy    0.5161339             8.544172    9.860912e-12
## 6     Bitter    0.4873151             7.785025    5.444350e-12
##   F.statistics.diff p.value.diff
## 1         14.116450 3.369420e-06
## 2         10.362160 7.379799e-05
## 3          7.025763 1.335104e-03
## 4          4.814970 9.877945e-03
## 5          3.687668 2.817547e-02
## 6          3.193450 4.489672e-02

(-) Linear discriminant analysis (lda command for discriminant analysis)

(-) Figure 4.19 - Discriminant function coefficients and discriminant values at the group centroids

# lda(Attributes, Group)
lda_res <- lda(mydatc4_case.2[,2:11], mydatc4_case.2[,14])

print(lda_res)
## Call:
## lda(mydatc4_case.2[, 2:11], mydatc4_case.2[, 14])
## 
## Prior probabilities of groups:
## Seg_1 Classic   Seg_2 Fruit  Seg_3 Coffee 
##     0.5603448     0.2413793     0.1982759 
## 
## Group means:
##                  Price Refreshing Delicious  Healthy   Bitter    Light  Crunchy
## Seg_1 Classic 5.061538   3.907692  4.523077 3.784615 3.969231 4.246154 3.692308
## Seg_2 Fruit   3.535714   4.785714  3.928571 3.500000 4.178571 5.285714 5.107143
## Seg_3 Coffee  5.173913   3.782609  4.217391 3.913043 3.347826 4.173913 4.000000
##                 Exotic    Sweet   Fruity
## Seg_1 Classic 2.200000 3.953846 3.846154
## Seg_2 Fruit   5.000000 4.428571 5.214286
## Seg_3 Coffee  3.086957 4.173913 3.608696
## 
## Coefficients of linear discriminants:
##                    LD1        LD2
## Price      -0.25708626  0.4142271
## Refreshing  0.20810366 -0.2121803
## Delicious  -0.32772535 -0.2862550
## Healthy    -0.15785482  0.0708641
## Bitter     -0.06348995 -0.4903264
## Light       0.29777066  0.1381961
## Crunchy     0.31538550  0.2353022
## Exotic      0.14700067  0.2570126
## Sweet      -0.16433475  0.2644106
## Fruity      0.36487237 -0.2657973
## 
## Proportion of trace:
##   LD1   LD2 
## 0.898 0.102
print(lda_res$counts)
## Seg_1 Classic   Seg_2 Fruit  Seg_3 Coffee 
##            65            28            23
print(lda_res$prior)
## Seg_1 Classic   Seg_2 Fruit  Seg_3 Coffee 
##     0.5603448     0.2413793     0.1982759
print(lda_res$scaling)
##                    LD1        LD2
## Price      -0.25708626  0.4142271
## Refreshing  0.20810366 -0.2121803
## Delicious  -0.32772535 -0.2862550
## Healthy    -0.15785482  0.0708641
## Bitter     -0.06348995 -0.4903264
## Light       0.29777066  0.1381961
## Crunchy     0.31538550  0.2353022
## Exotic      0.14700067  0.2570126
## Sweet      -0.16433475  0.2644106
## Fruity      0.36487237 -0.2657973
t(as.data.frame(lda_res$scaling))
##          Price Refreshing  Delicious    Healthy      Bitter     Light   Crunchy
## LD1 -0.2570863  0.2081037 -0.3277254 -0.1578548 -0.06348995 0.2977707 0.3153855
## LD2  0.4142271 -0.2121803 -0.2862550  0.0708641 -0.49032642 0.1381961 0.2353022
##        Exotic      Sweet     Fruity
## LD1 0.1470007 -0.1643348  0.3648724
## LD2 0.2570126  0.2644106 -0.2657973

(-) Figure 4.22 - Individual classification results

# Predictions based on lda coefficients (LD1, LD2)
lda_pred <- predict(lda_res, data = mydatc4_case.2)

print(lda_pred)
## $class
##   [1] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##   [6] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [11] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [16] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [21] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [26] Seg_1 Classic Seg_1 Classic Seg_2 Fruit   Seg_1 Classic Seg_1 Classic
##  [31] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [36] Seg_2 Fruit   Seg_2 Fruit   Seg_2 Fruit   Seg_2 Fruit   Seg_1 Classic
##  [41] Seg_2 Fruit   Seg_1 Classic Seg_2 Fruit   Seg_2 Fruit   Seg_2 Fruit  
##  [46] Seg_1 Classic Seg_2 Fruit   Seg_2 Fruit   Seg_1 Classic Seg_2 Fruit  
##  [51] Seg_2 Fruit   Seg_1 Classic Seg_2 Fruit   Seg_2 Fruit   Seg_2 Fruit  
##  [56] Seg_1 Classic Seg_1 Classic Seg_2 Fruit   Seg_2 Fruit   Seg_2 Fruit  
##  [61] Seg_2 Fruit   Seg_2 Fruit   Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [66] Seg_1 Classic Seg_1 Classic Seg_3 Coffee  Seg_2 Fruit   Seg_1 Classic
##  [71] Seg_1 Classic Seg_3 Coffee  Seg_1 Classic Seg_1 Classic Seg_3 Coffee 
##  [76] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [81] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [86] Seg_1 Classic Seg_3 Coffee  Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [91] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
##  [96] Seg_1 Classic Seg_1 Classic Seg_3 Coffee  Seg_1 Classic Seg_1 Classic
## [101] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
## [106] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
## [111] Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic Seg_1 Classic
## [116] Seg_1 Classic
## Levels: Seg_1 Classic Seg_2 Fruit Seg_3 Coffee
## 
## $posterior
##     Seg_1 Classic  Seg_2 Fruit Seg_3 Coffee
## 1    0.8619031871 5.731822e-03 1.323650e-01
## 2    0.7356805754 1.084532e-01 1.558663e-01
## 3    0.6716406044 9.149125e-02 2.368681e-01
## 4    0.6993253841 7.613796e-02 2.245367e-01
## 5    0.5434439183 2.345054e-02 4.331055e-01
## 6    0.5876488507 8.820301e-03 4.035308e-01
## 7    0.6679950992 7.932773e-02 2.526772e-01
## 8    0.8708858845 8.337538e-03 1.207766e-01
## 9    0.5213401134 2.721862e-02 4.514413e-01
## 10   0.5015929618 3.050909e-01 1.933161e-01
## 11   0.5643269470 5.678271e-04 4.351052e-01
## 12   0.6827325002 4.049182e-03 3.132183e-01
## 14   0.6083348263 8.057977e-03 3.836072e-01
## 15   0.6874824181 5.823899e-02 2.542786e-01
## 16   0.6866002293 6.775731e-02 2.456425e-01
## 17   0.5315308751 2.085111e-01 2.599580e-01
## 18   0.7102883050 6.956922e-03 2.827548e-01
## 19   0.4954358045 2.202567e-02 4.825385e-01
## 20   0.5413937204 4.209430e-02 4.165120e-01
## 21   0.8793556228 5.004498e-02 7.059939e-02
## 22   0.8330405212 1.753879e-03 1.652056e-01
## 23   0.3518039713 3.462209e-01 3.019751e-01
## 24   0.8181098634 3.140428e-03 1.787497e-01
## 25   0.8990379873 4.196981e-05 1.009200e-01
## 26   0.6809468294 2.627036e-02 2.927828e-01
## 27   0.6065472253 4.485715e-02 3.485956e-01
## 28   0.7896236403 4.995200e-02 1.604244e-01
## 29   0.3150774881 6.516033e-01 3.331921e-02
## 31   0.8654335209 5.648818e-02 7.807830e-02
## 32   0.5856912198 2.727930e-02 3.870295e-01
## 33   0.8393386334 2.680496e-03 1.579809e-01
## 34   0.5908987049 1.126287e-01 2.964726e-01
## 35   0.8812450903 4.663908e-02 7.211583e-02
## 36   0.8614450344 1.772864e-02 1.208263e-01
## 37   0.9390348372 1.589159e-03 5.937600e-02
## 38   0.2114426573 7.669779e-01 2.157944e-02
## 39   0.2459249437 4.320873e-01 3.219878e-01
## 40   0.1172492285 8.666143e-01 1.613645e-02
## 41   0.0091808047 9.879364e-01 2.882802e-03
## 42   0.6104875623 3.326742e-01 5.683828e-02
## 43   0.0511583255 9.204243e-01 2.841737e-02
## 44   0.6287760456 3.319211e-02 3.380318e-01
## 45   0.4091918552 5.618126e-01 2.899549e-02
## 46   0.0277178389 9.676975e-01 4.584653e-03
## 47   0.0039368874 9.879226e-01 8.140549e-03
## 48   0.4768991564 4.710189e-01 5.208191e-02
## 49   0.0579591488 7.031500e-01 2.388909e-01
## 51   0.0409226434 9.428847e-01 1.619266e-02
## 52   0.4922173198 4.417943e-01 6.598838e-02
## 53   0.0015493854 9.968799e-01 1.570708e-03
## 54   0.0708749588 8.700195e-01 5.910552e-02
## 55   0.6938721962 5.024116e-02 2.558866e-01
## 56   0.0010318512 9.956557e-01 3.312450e-03
## 57   0.0025855978 9.964588e-01 9.555948e-04
## 58   0.0091808047 9.879364e-01 2.882802e-03
## 59   0.6903456642 2.617236e-02 2.834820e-01
## 60   0.8925842597 1.551862e-02 9.189712e-02
## 61   0.0676645117 8.696657e-01 6.266977e-02
## 62   0.0001352823 9.998087e-01 5.598071e-05
## 64   0.0409226434 9.428847e-01 1.619266e-02
## 66   0.0139448406 9.643441e-01 2.171101e-02
## 67   0.0330932679 9.577493e-01 9.157391e-03
## 68   0.8297864235 8.092170e-03 1.621214e-01
## 69   0.8041313114 1.892155e-03 1.939765e-01
## 70   0.4718429333 2.076544e-01 3.205026e-01
## 71   0.7347936904 1.901299e-02 2.461933e-01
## 72   0.8688226222 1.116021e-02 1.200172e-01
## 73   0.3950959236 2.238092e-02 5.825232e-01
## 74   0.2186731582 5.217622e-01 2.595647e-01
## 75   0.8464596507 1.950799e-02 1.340324e-01
## 76   0.6966939554 2.919873e-02 2.741073e-01
## 77   0.2643975143 5.306802e-04 7.350718e-01
## 78   0.6252678608 9.880649e-02 2.759256e-01
## 79   0.7900957175 5.429764e-02 1.556066e-01
## 80   0.3834982228 1.622909e-02 6.002727e-01
## 81   0.8439147432 2.844964e-03 1.532403e-01
## 82   0.8413144116 3.023254e-03 1.556623e-01
## 83   0.8434958159 1.025528e-02 1.462489e-01
## 84   0.6055667704 8.140254e-03 3.862930e-01
## 85   0.5212982322 1.062554e-03 4.776392e-01
## 86   0.7948593630 1.686224e-03 2.034544e-01
## 87   0.9318857354 1.639275e-03 6.647499e-02
## 89   0.5888638922 4.233700e-02 3.687991e-01
## 91   0.6359673682 7.690504e-02 2.871276e-01
## 92   0.7646875551 3.689422e-03 2.316230e-01
## 94   0.7332564500 1.719701e-01 9.477348e-02
## 95   0.2584229399 1.831778e-04 7.413939e-01
## 96   0.5400923947 3.328235e-01 1.270841e-01
## 97   0.9065095316 7.469259e-04 9.274354e-02
## 98   0.7134681541 7.644175e-03 2.788877e-01
## 99   0.7834675019 1.109883e-01 1.055442e-01
## 100  0.5716635338 4.469458e-02 3.836419e-01
## 101  0.8654335209 5.648818e-02 7.807830e-02
## 102  0.9436192009 2.401603e-02 3.236477e-02
## 105  0.7952168835 2.534873e-02 1.794344e-01
## 106  0.9511874644 9.992614e-03 3.881992e-02
## 107  0.8052395747 3.561740e-02 1.591430e-01
## 108  0.4069254944 1.857220e-01 4.073525e-01
## 109  0.8487303562 1.161411e-02 1.396555e-01
## 110  0.8351432796 3.764838e-02 1.272083e-01
## 112  0.6886431287 1.576859e-03 3.097800e-01
## 113  0.7440102928 2.421165e-02 2.317781e-01
## 114  0.6858377645 1.558619e-03 3.126036e-01
## 115  0.8076434199 8.450121e-02 1.078554e-01
## 116  0.8391330541 3.948584e-02 1.213811e-01
## 117  0.6190733368 3.300148e-02 3.479252e-01
## 118  0.8462556327 3.685711e-03 1.500587e-01
## 119  0.8085155601 2.394805e-03 1.890896e-01
## 120  0.8063425650 4.579725e-03 1.890777e-01
## 121  0.5777471050 1.389227e-01 2.833302e-01
## 122  0.7200726556 4.382686e-02 2.361005e-01
## 123  0.5207658839 2.888029e-01 1.904312e-01
## 124  0.8258085020 3.043294e-02 1.437586e-01
## 125  0.7177553721 4.425997e-02 2.379847e-01
## 126  0.8441764665 6.795622e-02 8.786731e-02
## 127  0.9387819550 1.968223e-02 4.153581e-02
## 
## $x
##              LD1         LD2
## 1   -1.117537022 -0.62239399
## 2    0.167274201 -0.47318249
## 3    0.088161737  0.11509356
## 4    0.001565154  0.02358754
## 5   -0.472162586  1.12850589
## 6   -0.906522071  1.03275352
## 7    0.023720876  0.20488343
## 8   -0.953938586 -0.76473951
## 9   -0.398819020  1.20995141
## 10   0.714550279  0.11095757
## 11  -2.062576151  1.35598474
## 12  -1.264043900  0.63710027
## 14  -0.951879169  0.94411742
## 15  -0.117470663  0.20307194
## 16  -0.049773692  0.15425171
## 17   0.507289650  0.41432341
## 18  -1.038672241  0.43943832
## 19  -0.477483711  1.35575011
## 20  -0.219391050  1.04659052
## 21  -0.149349453 -1.51560371
## 22  -1.628013904 -0.24882330
## 23   0.846853804  0.99262158
## 24  -1.382065528 -0.18043969
## 25  -3.191781394 -0.63070826
## 26  -0.464400192  0.43075416
## 27  -0.214506257  0.71663824
## 28  -0.187627510 -0.46141272
## 29   1.349137767 -1.45422564
## 31  -0.101684706 -1.39189198
## 32  -0.423014895  0.90888498
## 33  -1.446707872 -0.33798160
## 34   0.199014368  0.49449459
## 35  -0.181850231 -1.48862938
## 36  -0.630508210 -0.80583113
## 37  -1.618264616 -1.54049977
## 38   1.590522081 -1.53451785
## 39   1.054766491  1.43450753
## 40   1.865506541 -1.24287084
## 41   2.927047221 -0.48870355
## 42   0.795132772 -1.50571311
## 43   2.117731174  0.28983990
## 44  -0.351464445  0.66409451
## 45   1.211322495 -1.88311606
## 46   2.507227356 -1.14222893
## 47   3.117257059  1.60680217
## 48   1.032956956 -1.36523793
## 49   1.771240171  2.60944064
## 51   2.252959263 -0.11549532
## 52   0.974042477 -1.12401583
## 53   3.580230790  0.72525296
## 54   1.919278747  0.78146656
## 55  -0.183752725  0.21078276
## 56   3.648847483  2.01470861
## 57   3.453291091 -0.39240349
## 58   2.927047221 -0.48870355
## 59  -0.467678744  0.37939566
## 60  -0.674324020 -1.14748695
## 61   1.929365779  0.89818692
## 62   4.695351914 -0.47167747
## 64   2.252959263 -0.11549532
## 66   2.596261144  1.37331438
## 67   2.381633069 -0.54055276
## 68  -0.976792545 -0.37411608
## 69  -1.598404857 -0.03270215
## 70   0.526633270  0.78182638
## 71  -0.611400863  0.17374155
## 72  -0.828966753 -0.78999152
## 73  -0.411879265  1.81275673
## 74   1.193283309  1.30077314
## 75  -0.593379594 -0.67514377
## 76  -0.421341567  0.32339570
## 77  -1.884661959  2.77383723
## 78   0.131031356  0.36095106
## 79  -0.149733707 -0.50280930
## 80  -0.540857502  1.90173343
## 81  -1.420553799 -0.38285746
## 82  -1.395157547 -0.36590523
## 83  -0.872619357 -0.52624106
## 84  -0.946671977  0.95627146
## 85  -1.778760058  1.50349404
## 86  -1.647645170  0.04242489
## 87  -1.612656776 -1.40535104
## 89  -0.234168361  0.81688833
## 91   0.015559992  0.40594285
## 92  -1.314381046  0.17694628
## 94   0.408352902 -1.07108305
## 95  -2.328726228  2.88324305
## 96   0.764257855 -0.45419618
## 97  -1.966468970 -0.93944266
## 98  -0.998995547  0.41224848
## 99   0.190927592 -0.98814691
## 100 -0.204814060  0.88998769
## 101 -0.101684706 -1.39189198
## 102 -0.414364052 -2.43131754
## 105 -0.487583392 -0.29304311
## 106 -0.805055191 -2.17002735
## 107 -0.336845367 -0.46771684
## 108  0.507342437  1.22270904
## 109 -0.817808868 -0.59441307
## 110 -0.305477597 -0.76686967
## 112 -1.665743190  0.68180547
## 113 -0.507697413  0.07430962
## 114 -1.670122798  0.69738204
## 115  0.063235592 -0.97673590
## 116 -0.282672048 -0.82896648
## 117 -0.351288215  0.71417294
## 118 -1.309839396 -0.42809864
## 119 -1.498065800 -0.08434416
## 120 -1.222307237 -0.12729738
## 121  0.299551391  0.45198347
## 122 -0.246846973  0.08863377
## 123  0.680092747  0.05739138
## 124 -0.402866851 -0.59993050
## 125 -0.242311782  0.10048715
## 126 -0.025585785 -1.24319359
## 127 -0.519346104 -2.12646995

(-) Figure 4.23 - Classification matrix

# Classification matrix

print("rows = Actual_Group; colums = Predicted_Group"); caret::confusionMatrix(table(mydatc4_case.2$Segment, lda_pred$class));
## [1] "rows = Actual_Group; colums = Predicted_Group"
## Confusion Matrix and Statistics
## 
##                
##                 Seg_1 Classic Seg_2 Fruit Seg_3 Coffee
##   Seg_1 Classic            62           1            2
##   Seg_2 Fruit               8          20            0
##   Seg_3 Coffee             19           1            3
## 
## Overall Statistics
##                                           
##                Accuracy : 0.7328          
##                  95% CI : (0.6426, 0.8107)
##     No Information Rate : 0.7672          
##     P-Value [Acc > NIR] : 0.8388353       
##                                           
##                   Kappa : 0.4818          
##                                           
##  Mcnemar's Test P-Value : 0.0001538       
## 
## Statistics by Class:
## 
##                      Class: Seg_1 Classic Class: Seg_2 Fruit
## Sensitivity                        0.6966             0.9091
## Specificity                        0.8889             0.9149
## Pos Pred Value                     0.9538             0.7143
## Neg Pred Value                     0.4706             0.9773
## Prevalence                         0.7672             0.1897
## Detection Rate                     0.5345             0.1724
## Detection Prevalence               0.5603             0.2414
## Balanced Accuracy                  0.7928             0.9120
##                      Class: Seg_3 Coffee
## Sensitivity                      0.60000
## Specificity                      0.81982
## Pos Pred Value                   0.13043
## Neg Pred Value                   0.97849
## Prevalence                       0.04310
## Detection Rate                   0.02586
## Detection Prevalence             0.19828
## Balanced Accuracy                0.70991
prop.table(table(mydatc4_case.2$Segment, lda_pred$class), margin = 1);
##                
##                 Seg_1 Classic Seg_2 Fruit Seg_3 Coffee
##   Seg_1 Classic    0.95384615  0.01538462   0.03076923
##   Seg_2 Fruit      0.28571429  0.71428571   0.00000000
##   Seg_3 Coffee     0.82608696  0.04347826   0.13043478
table(mydatc4_case.2$Segment, lda_pred$class)
##                
##                 Seg_1 Classic Seg_2 Fruit Seg_3 Coffee
##   Seg_1 Classic            62           1            2
##   Seg_2 Fruit               8          20            0
##   Seg_3 Coffee             19           1            3

(-) Figure 4.24 - Territorial map

plot(lda_res, col = as.integer(mydatc4_case.2$Segment),
     cex.main = 1,
     cex.lab = 1, 
     cex.axis = 1)

plot(lda_res, dimen = 1, type = "b",
     cex.main = 1,
     cex.lab = 1, 
     cex.axis = 1)

klaR::partimat(Segment ~ 
               Price +
               Refreshing +
               Delicious +
               Healthy +
               Bitter +
               Light +
               Crunchy +
               Exotic +
               Sweet +
               Fruity,
               data = mydatc4_case.2,
               method = "lda",
               nplots.hor = 3,
               nplots.ver = 3,
               cex.main = 1,
               cex.lab = 1, 
               cex.axis = 1)