Thesis: “Reflexions methodologies autour du Napping: vers une integration du comportement du sujet dans l’analyse des donnees de Napping”

Chapter 1 - Napping and sorted Napping as a sensory profiling technique

Author: Tam Minh LE

Supervisor : Francois Husson & Sebastien Le

R version: 3.2.1 - Updated: 17.08.2015

rm(list=ls())
options(max.print=5.5E5)   # max print

# Require package ---------------------------------------------------------
library(FactoMineR)
library(SensoMineR)
library(ggplot2)
library(reshape2)
library(stringr)
library(holos)
library(car)
library(cluster)
library(grDevices) 
library(knitr)

# Set working directory ---------------------------------------------------
wd <- "C:/Users/LE Minh-Tam/Dropbox/00. Thesis/Data"
setwd(wd)
list.files(pattern=".rda")
## [1] "ba.qual.rda"     "ba.sort.rda"     "cards.fico.rda"  "cards.rda"      
## [5] "cards.tempo.rda" "emotion_fr.rda"  "emotion_vn.rda"  "videotablet.rda"
# Load data: (1) emotion data of French consumers & (2) Smoothies
load("emotion_fr.rda") # in the script of chapter 9, emotions = emotion_fr
emotions <- emotion_fr 

# Figure 1.1: Tablecloth of s31
nappeplot(emotions[, c("X31","Y31")], numr=1, numc=1, lim=c(60,40), color = "black")

# Figure 1.2: Tablecloth of s96 -------------------------------------------
nappeplot(emotions[, c("X96","Y96")], numr=1, numc=1, lim=c(60,40), color = "black")

# Figure 1.3: representation provided by MFA 
## MFA
njuge <- ncol(emotions)/2
namegroup <- c(paste("s", 1:100, sep=""))
res <- MFA(emotions, group = rep(2, njuge), ncp=Inf, 
           type = rep("c", njuge), graph=FALSE, name.group=namegroup)
round(res$ind$cos2["surprised",1:5],2)    # cos2
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 
##  0.00  0.00  0.00  0.01  0.00
round(res$ind$contrib["surprised",1:5],2) # contribution
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5 
##  0.04  0.03  0.20  6.15  1.04
## Plot
plot(res, axes = c(1, 2), choix = "ind", habillage = "ind", 
     palette=palette(c("black","black")), 
     xlim=c(-8,8), ylim=c(-10,10), cex=0.8, 
     title="Emotional space of French consumer", las=1)

# Figure 1.4: separate analysis of the group -----------------------------
palette.j = palette(c(rep("transparent",31), "blue", 
                      rep("transparent",64), "blue", 
                      rep("transparent", 5)))

plot(res, axes = c(1, 2), choix="axes", habillage="group", 
     palette=palette.j, lab.grpe=FALSE)

# Figure 1.5: representation of groups of variables ----------------------
plot(res, axes = c(1, 2), choix="group", col="black")

# Table 1.1: Decomposition of the total variance -------------------------
round(res$eig[1:10,],2)
##         eigenvalue percentage of variance
## comp 1       49.43                  37.36
## comp 2        8.85                   6.69
## comp 3        5.58                   4.22
## comp 4        4.85                   3.67
## comp 5        4.03                   3.05
## comp 6        3.79                   2.86
## comp 7        3.66                   2.76
## comp 8        3.36                   2.54
## comp 9        3.23                   2.44
## comp 10       2.71                   2.05
##         cumulative percentage of variance
## comp 1                              37.36
## comp 2                              44.05
## comp 3                              48.27
## comp 4                              51.94
## comp 5                              54.98
## comp 6                              57.85
## comp 7                              60.61
## comp 8                              63.15
## comp 9                              65.59
## comp 10                             67.64
# Part 2 - sorted Napping -------------------------------------------------
# load data smoothies
data(smoothies)   # 24 subjects, 8 products
ncol(smoothies)/3 # number of subjects
## [1] 24
# Figure 1.6: an example of sorted napping --------------------------------
nappeplot(smoothies[, c("X5","Y5")], numr=1, numc=1, 
          lim=c(60,40), color = "black")

# Figure 1.7, 1.8, 1.9 ----------------------------------------------------
res.fasnt <- fasnt(smoothies, first = "nappe", sep.word = ";")
## Number of different words :  90
H.list <- list(rep(c(2,1),24), rep(2,24))
X11(); HMFA(smoothies, H = H.list, type = rep(c("c","n"), 24))
## **Results of the Hierarchical Multiple Factor Analysis (HMFA)**
## 
## There are 8 individuals
## 
## *Results are available in the following objects :
## 
##   name          description                              
## 1 "$eig"        "eigenvalues"                            
## 2 "$group"      "results for all the groups"             
## 3 "$ind"        "results for the individuals"            
## 4 "$partial"    "partial coordinates for the individuals"
## 5 "$quanti.var" "results for the quantitative variables" 
## 6 "$quali.var"  "results for the categorical variables"
# Tab 1.2: sorted napping data of subject 5 -------------------------------
smoothies[,c("X5", "Y5", "C5")]

##                X5 Y5                  C5
## Immedia_MP   47.5 28  exotic fruits;acid
## Carrefour_MP 53.0 33  exotic fruits;acid
## Immedia_SRB  41.0 34  exotic fruits;acid
## Casino_SRB   40.5 25  exotic fruits;acid
## Innocent_PBC 45.0  8 banana flavor;heavy
## Casino_PBC   40.0  8 banana flavor;heavy
## Innocent_SB  14.0 22 unknown taste;heavy
## Carrefour_SB 19.0 16 unknown taste;heavy
# Table 1.3: An automatic description of fasnt() function -----------------
res.fasnt$textual
## $Carrefour_MP
##      Intern %   glob % Intern freq Glob freq      p.value   v.test
## acid 42.10526 15.66265           8         26 0.005900086 2.753283
## 
## $Carrefour_SB
## NULL
## 
## $Casino_PBC
##      Intern %   glob % Intern freq Glob freq     p.value   v.test
## acid        0 15.66265           0         26 0.01582659 -2.41289
## 
## $Casino_SRB
## NULL
## 
## $Immedia_MP
## NULL
## 
## $Immedia_SRB
##      Intern %   glob % Intern freq Glob freq     p.value   v.test
## acid 34.78261 15.66265           8         26 0.02439432 2.250861
## 
## $Innocent_PBC
##      Intern %   glob % Intern freq Glob freq     p.value   v.test
## acid        0 15.66265           0         26 0.01582659 -2.41289
## 
## $Innocent_SB
##            Intern %   glob % Intern freq Glob freq     p.value   v.test
## strawberry 22.22222 6.626506           4         11 0.03997686 2.053988
## 
## attr(,"class")
## [1] "descfreq" "list "

End of Chapter 1