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

Chapter 2 - A Napping based methodology to quickly obtain a model of emotions

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) # for colors
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"
#**************************************************************************
# Chapter 2: Emotions of Vietnamese consumers
# Updated: 17.08.2015
#************************************************************************** 

# Remind 1: 
# Data: Emotion of 121 Vietnamese subjects as consumers
# Here is apart of the source file 
# source("C:/Users/LE Minh-Tam/Dropbox/00. Thesis/Script/emotionVN_v2.R")
# This script is devoted to the article of Behavior Research Method

# Remind 2: For this chapter, I create some functions. They are: 
#
# permutate: permutate the eigenvalues of napping data
# barplot with error.bar: Plot real eigen values vs. permuted eigen values + error
# dianaplot: plot diana diagram for each subject
# cpdata: Obtain the matrix of cluster from Divisive analysis
# cpMFA: running MFA with supplementary variables as steps in individual cognitive process
# indcog: plot each individual cognitive process in the group representation obtained from MFA

# Call functions for Chapter 2
# source("C:/Users/LE Minh-Tam/Dropbox/00. Thesis/Script/emotionFunction_v2.R")


# load data: emotion_vn ---------------------------------------------------
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("emotion_vn.rda")
  # summary(emotion_vn) 

# Fig 2.1 to 2.4, and Tab 1: illustrations

# Fig 2.5: structure of emotions provided by MFA ----------------------------
res_vn <- MFA(emotion_vn, group= rep(2,121), type=rep("c",121), 
              ncp=Inf, name.group=c(paste("J",1:121, sep="")), 
              axes=c(1,2), graph=F)

plot(res_vn, choix="ind", habillage="ind", xlim=c(-8,8), ylim=c(-10,10),
     palette=palette(c("black","black")), cex=0.8, las=1)

  # names(res_vn)
  # res_vn$group$coord[,1:2]

# Fig 2.6: Hierarchy at panel level using DIANA ---------------------------
# Here, the matrix of observation will be changed to the matrix distance 
#       automatically by the arguments of the function diana
# diss=FALSE --> X is the matrix of observation, will be changed
# stand = FALSE --> do not standardised X befor calculating the dissimilarity

res.diana_vn <- diana(res_vn$ind$coord, diss=FALSE, metric="euclidean", stand=FALSE) 
plot(res.diana_vn, which.plots = 2, main="Hierarchy obtained by divisive alogrithm")

  ## Use this code if you want to verify: 
  ## - Change X to matrix distance
  ## - Note: we have the same results
  # res.diana_vn1 <- diana(dist(res_vn$ind$coord, method="euclidean"), 
  #                       diss=TRUE, metric="euclidean", stand=FALSE)

  # X11(); plot(res.diana_vn1, which.plots = 2, main="matrix distance")


# Tab 2.2: Typology of 5 clusters -------------------------------------------
  # print(res.diana_vn)
k <- cutree(as.hclust(res.diana_vn), k = 5) # k: number of clusters
table(k) # view elements and their group names
## k
##  1  2  3  4  5 
## 18 16 12  4  3
sort(k) 
## affectionate         calm         fair         free     friendly 
##            1            1            1            1            1 
##        happy      hopeful       joyful      beloved   optimistic 
##            1            1            1            1            1 
##     peaceful      pleased        proud     relieved    satisfied 
##            1            1            1            1            1 
##      secured  trustworthy     youthful        angry      annoyed 
##            1            1            1            2            2 
##        bored disappointed      furious     doubtful         hurt 
##            2            2            2            2            2 
##  indifferent      jealous         lazy       lonely         lost 
##            2            2            2            2            2 
##      enraged     rejected          sad      selfish     confused 
##            2            2            2            2            3 
##  embarrassed      fearful       guilty   humiliated     panicked 
##            3            3            3            3            3 
##    nostalgic      pitiful    regretful      ashamed          shy 
##            3            3            3            3            3 
##      worried   courageous        eager enthusiastic   passionate 
##            3            4            4            4            4 
##      curious    surprised      stunned 
##            5            5            5
# Fig 2.7: Hierarchies of s1, s11, s73, s59 ---------------------------------
## Recall: function dianaplot 
## source("C:/Users/LE Minh-Tam/Dropbox/00. Thesis/Script/emotionFunction_v2.R")
dianaplot(X=emotion_vn, subject=1)

dianaplot(X=emotion_vn, subject=11)

dianaplot(X=emotion_vn, subject=73)

dianaplot(X=emotion_vn, subject=59)

# Fig 2.7: Trajectories of s1, s11, s73, s59 ------------------------------
# The cognitive process of individual subject obtained by divisive model
# Call functions: cpdm and plot.cpdm

# Calculate the data  
res.cpdm <- cpdm(emotion_vn, nb.step=4) 
  # names(res.cpdm)
plotcpdm(res.cpdm, subject=1, axes=c(1,2))  # it takes 2 minutes for each fig.

# plotcpdm(res.cpdm, subject=11, axes=c(1,2))
# plotcpdm(res.cpdm, subject=59, axes=c(1,2))
# plotcpdm(res.cpdm, subject=73, axes=c(1,2))


# Fig 2.9: typology of 5 clusters ------------------------------------------
# define groups as illustrative variables
k <- as.data.frame(k)
don <- cbind(res_vn$ind$coord,k)
don$k <- paste("cluster",don$k, sep="")
don$k <- as.factor(don$k)
  # summary(don, max=5)

## obtenir la representation consensuelle
res <- PCA(don, scale.unit=FALSE, ncp=5, quali.sup=c(53:53), graph = FALSE)
plot.PCA(res, axes=c(1, 2), choix="ind", habillage=53, col.ind="black", 
         col.ind.sup="blue", col.quali="magenta", 
         label=c("ind", "ind.sup", "quali", new.plot=TRUE), 
         title="Typology of 5 clusters obtained by Vietnamese consumers")

# Conf.ellipses of clusters on Dim1&2 factorial plan
aa = cbind.data.frame(don[,53],res$ind$coord)
bb = coord.ellipse(aa, bary=TRUE, axes=c(1,2))
plot.PCA(res, axes=c(1,2), ellipse=bb, cex=0.9, choix="ind", habillage=53, col.ind="black", 
         col.ind.sup="blue", col.quali="magenta")

# Conf.ellipses of clusters on Dim1&3 factorial plan 
bb = coord.ellipse(aa, bary=TRUE, axes=c(1,3))
plot.PCA(res, axes=c(1,3), ellipse=bb, cex=0.9, choix="ind", habillage=53, col.ind="black", 
         col.ind.sup="blue", col.quali="magenta")    

# Fig 2.10: illustration

# Fig 2.11: Classifcation of cognitive process into 4 different types 

don.pron <- res.cpdm$CPDM.data # dim(don.pron): 53 730
namesgroup = c(paste("G",1:121,sep=""), colnames(don.pron[,243:ncol(don.pron)]))
projn <- MFA(don.pron,group= c(rep(2,121), rep(1,488)), type=c(rep("c",121), rep("n",488)),
             ncp=Inf, num.group.sup=c(122:(122+488-1)), name.group = namesgroup, graph=F)

## Extracting the coordinates to obtain the data table as follows
#     ------------------------------------------
#     |   Coord. Dim1     ||   Coord. Dim2     |
#     ------------------------------------------
#     | k2 | k3 | k4 | k5 || k2 | k3 | k4 | k5 |
#| J1 |    |    |    |    ||    |    |    |    |
#| J2 |    |    |    |    ||    |    |    |    |
#|J121|    |    |    |    ||    |    |    |    |

Run function cpMFA (for more info, see chapter02_functions.R)

# Running MFA with supplementary variables as steps in individual cognitive process
#
# First step for plotting Cognitive process in Theoretical model

@param don.pron Dataframe

@param nb.subject Number of subjects

@param nb.step Number of steps in cognitive process

@return Results of Multiple Factor Analysis

@export

cpMFA <- function(don.pron, nb.subject, nb.step){ 
  namesgroup = c(paste("G", 1:nb.subject, sep=""), colnames(don.pron[,(nb.subject*2+1):ncol(don.pron)]))
  # length(var.sub) = (nb.subject + 1)*nb.step = number of var. supplement
  var.sub = c((nb.subject+1) : ((nb.subject+1)+((nb.subject+1)*nb.step)-1))
  projn <- MFA(don.pron, group= c(rep(2, nb.subject), rep(1, (nb.subject+1)*nb.step)), 
               type=c(rep("c", nb.subject), rep("n",(nb.subject+1)*nb.step)), ncp=Inf, 
               num.group.sup=var.sub, name.group=namesgroup, graph=FALSE)
  coord.P <- projn$group$coord.sup
  results <- list("Coordinate " = coord.P, "Number of subject" = nb.subject, "Number of steps" = nb.step, "Results of MFA" = projn)
  return(results)
}

End of the function cpMFA

coord.P <- cpMFA(don.pron, nb.subject=121, nb.step=4)
names(coord.P)
## [1] "Coordinate "       "Number of subject" "Number of steps"  
## [4] "Results of MFA"
coordn <-  coord.P[[1]] # coord of 4 steps per subject

tab <- matrix(NA,122,8)   # creer une matrice vide

for (j in 1:122){
  tab [j,1:4] = coordn[((j-1)*4+1):(j*4),1]
  tab [j,5:8] = coordn[((j-1)*4+1):(j*4),2]
}

rownames(tab) = 1:122
tab <- as.data.frame(tab)
head(tab)
##           V1         V2        V3        V4           V5          V6
## 1 0.83825921 0.83877104 0.8870690 0.9048850 0.0017069319 0.364042509
## 2 0.81117062 0.81563485 0.8387480 0.8432996 0.0066845331 0.075814360
## 3 0.02472019 0.07417009 0.4255190 0.4478459 0.0286455907 0.029776917
## 4 0.02891887 0.12411979 0.5451421 0.5460304 0.3310649034 0.331089714
## 5 0.73323176 0.94394443 0.9440088 0.9543856 0.0400304717 0.114424713
## 6 0.10310423 0.10310423 0.1798193 0.2026381 0.0003689335 0.009604875
##           V7         V8
## 1 0.36720117 0.45533951
## 2 0.10459774 0.47196618
## 3 0.04291996 0.05912456
## 4 0.36029915 0.40274609
## 5 0.12223641 0.12497773
## 6 0.27921712 0.28620777
# classify the consumer model
res.tab <- HCPC(tab[-122,], consol=FALSE, nb.clust=4, graph=F) # "Consol": made in France, but other country
which(res.tab$data.clust$clust==1)
##  [1]   6   8   9  10  16  25  27  38  39  40  41  47  50  56  59  72  74
## [18]  79  89  94  97  98 100 102 104 108 114 115 116 118 119
rownames(res.tab$data.clust)[which(res.tab$data.clust$clust==1)]
##  [1] "6"   "8"   "9"   "10"  "16"  "25"  "27"  "38"  "39"  "40"  "41" 
## [12] "47"  "50"  "56"  "59"  "72"  "74"  "79"  "89"  "94"  "97"  "98" 
## [23] "100" "102" "104" "108" "114" "115" "116" "118" "119"
# Plot background & Group 1
p = 1 # p: provisional var.
plot.MFA(projn, choix = "group", habillage="group", title = "Trajectories of the four groups",
         palette = palette(c(rep("transparent",(122+(p-1)*4)),rep("transparent",4), rep("transparent",484-p*4))))

liste=as.numeric(rownames(res.tab$data.clust)[which(res.tab$data.clust$clust==1)])

for (p in liste){
  jp <- coordn[((4*p-4)+1):((4*p-4)+4), 1:2]; print(jp)
  points(jp[,1], jp[,2], pch=20, col="black")
  lines(jp[,1], jp[,2], type = "l", col="black")
}

##          Dim.1        Dim.2
## k2j6 0.1031042 0.0003689335
## k3j6 0.1031042 0.0096048747
## k4j6 0.1798193 0.2792171206
## k5j6 0.2026381 0.2862077689
##             Dim.1     Dim.2
## k2j8 3.224651e-05 0.1667856
## k3j8 2.847475e-02 0.2152654
## k4j8 1.031791e-01 0.3005053
## k5j8 1.125846e-01 0.3299617
##            Dim.1      Dim.2
## k2j9 0.001250773 0.02112562
## k3j9 0.176184430 0.08751901
## k4j9 0.176382820 0.12981395
## k5j9 0.215701465 0.13284651
##            Dim.1        Dim.2
## k2j10 0.08228077 0.0003317971
## k3j10 0.08513923 0.0195916227
## k4j10 0.10691885 0.1011741182
## k5j10 0.13115366 0.1025105390
##            Dim.1       Dim.2
## k2j16 0.01318512 0.002261988
## k3j16 0.09642187 0.002264728
## k4j16 0.17354533 0.123176946
## k5j16 0.35975839 0.134032031
##           Dim.1       Dim.2
## k2j25 0.1139086 0.006312138
## k3j25 0.1163600 0.036329107
## k4j25 0.1166722 0.040794257
## k5j25 0.2983066 0.113852256
##             Dim.1      Dim.2
## k2j27 0.004895766 0.01658408
## k3j27 0.014416534 0.01747533
## k4j27 0.025222068 0.03756580
## k5j27 0.025230704 0.13834931
##           Dim.1      Dim.2
## k2j38 0.2776564 0.06690596
## k3j38 0.2781263 0.06710625
## k4j38 0.2802842 0.30038722
## k5j38 0.3078815 0.49291247
##             Dim.1      Dim.2
## k2j39 0.002805930 0.07271609
## k3j39 0.003151188 0.08725694
## k4j39 0.013444661 0.08953880
## k5j39 0.013743800 0.09059171
##           Dim.1       Dim.2
## k2j40 0.1019598 0.006349571
## k3j40 0.1020800 0.129237491
## k4j40 0.1414068 0.148867920
## k5j40 0.2328301 0.148903639
##             Dim.1      Dim.2
## k2j41 0.001147786 0.00187824
## k3j41 0.032579728 0.03808564
## k4j41 0.197024047 0.13869225
## k5j41 0.197517518 0.52571781
##             Dim.1      Dim.2
## k2j47 0.001663498 0.08594877
## k3j47 0.041975279 0.36035754
## k4j47 0.314329142 0.39200176
## k5j47 0.333957574 0.39339735
##              Dim.1      Dim.2
## k2j50 0.0004838223 0.08754428
## k3j50 0.0064820800 0.20955984
## k4j50 0.0071683168 0.21446979
## k5j50 0.0216708310 0.21450787
##              Dim.1     Dim.2
## k2j56 0.0007750098 0.2818111
## k3j56 0.0242371385 0.2919955
## k4j56 0.0912761634 0.3572825
## k5j56 0.2344514742 0.4191139
##            Dim.1      Dim.2
## k2j59 0.02409029 0.00366493
## k3j59 0.02451933 0.06050787
## k4j59 0.04280268 0.10321770
## k5j59 0.04309629 0.10939179
##            Dim.1      Dim.2
## k2j72 0.04410073 0.04322089
## k3j72 0.17230914 0.07252600
## k4j72 0.17380388 0.21838469
## k5j72 0.19689121 0.25996929
##            Dim.1        Dim.2
## k2j74 0.01515905 3.391909e-06
## k3j74 0.01563434 7.923164e-06
## k4j74 0.15747797 6.153728e-05
## k5j74 0.31121296 9.882881e-03
##            Dim.1      Dim.2
## k2j79 0.07449956 0.01675032
## k3j79 0.08585381 0.10577366
## k4j79 0.08714908 0.10804991
## k5j79 0.09276044 0.14687588
##             Dim.1      Dim.2
## k2j89 0.004580103 0.02601996
## k3j89 0.006008478 0.07540719
## k4j89 0.006008558 0.09353484
## k5j89 0.009367880 0.09578188
##             Dim.1     Dim.2
## k2j94 0.009342227 0.1730989
## k3j94 0.009606094 0.2696640
## k4j94 0.010226123 0.2742237
## k5j94 0.016739072 0.2804920
##            Dim.1     Dim.2
## k2j97 0.01226503 0.1363393
## k3j97 0.02570148 0.1900158
## k4j97 0.03079919 0.1950826
## k5j97 0.04670202 0.3237001
##            Dim.1       Dim.2
## k2j98 0.01096281 0.001102932
## k3j98 0.06719433 0.025585615
## k4j98 0.06845702 0.035949502
## k5j98 0.13204109 0.037457094
##             Dim.1     Dim.2
## k2j100 0.07497517 0.1342438
## k3j100 0.07628483 0.1554956
## k4j100 0.10241793 0.1585291
## k5j100 0.37618335 0.1671961
##             Dim.1       Dim.2
## k2j102 0.03237056 0.007000435
## k3j102 0.08290600 0.207141578
## k4j102 0.08322152 0.253426958
## k5j102 0.08346135 0.295018902
##             Dim.1      Dim.2
## k2j104 0.02582069 0.05773374
## k3j104 0.03344769 0.24060950
## k4j104 0.10660358 0.47596211
## k5j104 0.10664937 0.53546844
##             Dim.1       Dim.2
## k2j108 0.02898101 0.002015617
## k3j108 0.03141713 0.002067224
## k4j108 0.04530290 0.036832347
## k5j108 0.06486320 0.064562881
##             Dim.1     Dim.2
## k2j114 0.06436027 0.1614691
## k3j114 0.06931615 0.2640776
## k4j114 0.12536320 0.2654116
## k5j114 0.17788000 0.2654344
##               Dim.1      Dim.2
## k2j115 0.0006499916 0.01516949
## k3j115 0.0964091613 0.01542901
## k4j115 0.1020045000 0.02004796
## k5j115 0.1731127178 0.02082108
##             Dim.1       Dim.2
## k2j116 0.01804985 0.001052819
## k3j116 0.02914361 0.193791295
## k4j116 0.09280248 0.247643825
## k5j116 0.38066492 0.247691786
##             Dim.1       Dim.2
## k2j118 0.04706756 0.009051907
## k3j118 0.05379581 0.032406348
## k4j118 0.13861606 0.036919836
## k5j118 0.13865052 0.053498099
##             Dim.1     Dim.2
## k2j119 0.06162990 0.3544922
## k3j119 0.07900015 0.3560686
## k4j119 0.08913853 0.3601768
## k5j119 0.25709604 0.3904771
# Plot background & Groupe 2
p = 1 # p: provisional var.
plot.MFA(projn, choix = "group", habillage="group", title = "Trajectories of the four groups",
         palette = palette(c(rep("transparent",(122+(p-1)*4)),rep("transparent",4), rep("transparent",484-p*4))))

liste=as.numeric(rownames(res.tab$data.clust)[which(res.tab$data.clust$clust==2)])

for (p in liste){
  jp <- coordn[((4*p-4)+1):((4*p-4)+4), 1:2]; print(jp)
  points(jp[,1], jp[,2], pch=18, col="red")
  lines(jp[,1], jp[,2], type = "l", col="red")
}

##           Dim.1     Dim.2
## k2j4 0.02891887 0.3310649
## k3j4 0.12411979 0.3310897
## k4j4 0.54514210 0.3602992
## k5j4 0.54603040 0.4027461
##             Dim.1     Dim.2
## k2j12 0.003932184 0.3266156
## k3j12 0.118204207 0.4050578
## k4j12 0.161645559 0.4107318
## k5j12 0.567038336 0.4932780
##            Dim.1      Dim.2
## k2j28 0.00885568 0.03911722
## k3j28 0.26316262 0.16650768
## k4j28 0.32416289 0.24719221
## k5j28 0.44798640 0.38664962
##            Dim.1      Dim.2
## k2j29 0.09742702 0.02232827
## k3j29 0.30853783 0.03753594
## k4j29 0.38837431 0.08080908
## k5j29 0.40049445 0.19398471
##            Dim.1      Dim.2
## k2j34 0.06391464 0.08233696
## k3j34 0.37089622 0.18255195
## k4j34 0.56471852 0.20404853
## k5j34 0.56632358 0.20448050
##            Dim.1     Dim.2
## k2j49 0.04790189 0.4600766
## k3j49 0.12314534 0.4865525
## k4j49 0.26688600 0.5404553
## k5j49 0.29820823 0.5404567
##           Dim.1     Dim.2
## k2j55 0.2348579 0.1673402
## k3j55 0.2877518 0.3128961
## k4j55 0.3350187 0.3477221
## k5j55 0.6752602 0.6052234
##           Dim.1     Dim.2
## k2j58 0.1726945 0.3561938
## k3j58 0.1744952 0.3945776
## k4j58 0.1892836 0.3950496
## k5j58 0.3844295 0.5464635
##            Dim.1     Dim.2
## k2j73 0.01386904 0.4735993
## k3j73 0.08083641 0.5106885
## k4j73 0.46465773 0.5254575
## k5j73 0.48185688 0.5412284
##           Dim.1     Dim.2
## k2j78 0.2939022 0.1994197
## k3j78 0.2945243 0.2896270
## k4j78 0.4089055 0.3930495
## k5j78 0.4158971 0.3931571
##            Dim.1      Dim.2
## k2j81 0.04141491 0.08516622
## k3j81 0.39762198 0.13908408
## k4j81 0.41712570 0.21147799
## k5j81 0.42802642 0.21882438
##            Dim.1     Dim.2
## k2j82 0.07358313 0.1140317
## k3j82 0.26801359 0.3580418
## k4j82 0.65462685 0.4060885
## k5j82 0.65507025 0.4224855
##            Dim.1     Dim.2
## k2j83 0.03088753 0.4606132
## k3j83 0.24507379 0.4879414
## k4j83 0.25137840 0.4943199
## k5j83 0.47275832 0.4961532
##             Dim.1     Dim.2
## k2j84 0.000567892 0.0894948
## k3j84 0.474783435 0.1826037
## k4j84 0.557650117 0.2592440
## k5j84 0.560125893 0.2743298
##            Dim.1     Dim.2
## k2j86 0.09935509 0.1335479
## k3j86 0.43987442 0.1882754
## k4j86 0.53775183 0.2848224
## k5j86 0.57121623 0.2851023
##              Dim.1       Dim.2
## k2j87 0.0000290199 0.002598441
## k3j87 0.4142745393 0.024252821
## k4j87 0.5562038157 0.280367828
## k5j87 0.5936864556 0.296716430
##            Dim.1     Dim.2
## k2j90 0.00976079 0.2266405
## k3j90 0.61202912 0.3447567
## k4j90 0.61205032 0.3667345
## k5j90 0.61240236 0.3956737
##            Dim.1     Dim.2
## k2j91 0.01960546 0.3021480
## k3j91 0.19236589 0.4337983
## k4j91 0.29682622 0.4391796
## k5j91 0.30181963 0.4514865
##             Dim.1     Dim.2
## k2j92 0.001301858 0.1093086
## k3j92 0.005829247 0.2323616
## k4j92 0.520525360 0.2671479
## k5j92 0.521037562 0.3481201
##            Dim.1     Dim.2
## k2j101 0.2956921 0.2782369
## k3j101 0.6322758 0.4131321
## k4j101 0.6408985 0.4728135
## k5j101 0.6435993 0.4929982
##            Dim.1     Dim.2
## k2j107 0.3124829 0.2538435
## k3j107 0.4373029 0.2798282
## k4j107 0.4527585 0.3227508
## k5j107 0.6126948 0.3771371
# Plot background & Groupe 3
p = 1 # p: provisional var.
plot.MFA(projn, choix = "group", habillage="group", title = "Trajectories of the four groups",
         palette = palette(c(rep("transparent",(122+(p-1)*4)),rep("transparent",4), rep("transparent",484-p*4))))

liste=as.numeric(rownames(res.tab$data.clust)[which(res.tab$data.clust$clust==3)])

for (p in liste){
  jp <- coordn[((4*p-4)+1):((4*p-4)+4), 1:2]; print(jp)
  points(jp[,1], jp[,2], pch=15, col="green")
  lines(jp[,1], jp[,2], type = "l", col="green")
}

##           Dim.1      Dim.2
## k2j3 0.02472019 0.02864559
## k3j3 0.07417009 0.02977692
## k4j3 0.42551903 0.04291996
## k5j3 0.44784590 0.05912456
##          Dim.1     Dim.2
## k2j7 0.4212585 0.1020070
## k3j7 0.5800945 0.2123411
## k4j7 0.5989294 0.2129304
## k5j7 0.7034065 0.3105577
##           Dim.1      Dim.2
## k2j11 0.4595043 0.01127333
## k3j11 0.4756357 0.02546661
## k4j11 0.5101829 0.12391009
## k5j11 0.5442836 0.13348800
##            Dim.1        Dim.2
## k2j17 0.01153908 0.0001021943
## k3j17 0.51410930 0.0145960670
## k4j17 0.88462513 0.0342632678
## k5j17 0.88466971 0.0454247915
##            Dim.1      Dim.2
## k2j26 0.09201843 0.03327009
## k3j26 0.15810862 0.03702749
## k4j26 0.31703850 0.03930974
## k5j26 0.31908774 0.04002346
##           Dim.1     Dim.2
## k2j30 0.2458358 0.0537026
## k3j30 0.4013261 0.2313570
## k4j30 0.6033766 0.2377800
## k5j30 0.6064253 0.2408027
##           Dim.1        Dim.2
## k2j32 0.4052346 3.021278e-07
## k3j32 0.4229146 6.398891e-04
## k4j32 0.5081051 8.142865e-03
## k5j32 0.5085950 1.464328e-01
##            Dim.1       Dim.2
## k2j35 0.09125144 0.002822977
## k3j35 0.15232780 0.054592870
## k4j35 0.40445103 0.054933649
## k5j35 0.41868187 0.061309764
##           Dim.1      Dim.2
## k2j36 0.2626495 0.03880861
## k3j36 0.3860641 0.08168563
## k4j36 0.3985949 0.19816704
## k5j36 0.5258493 0.19919599
##           Dim.1      Dim.2
## k2j37 0.2983905 0.06100298
## k3j37 0.4074041 0.07306724
## k4j37 0.4132485 0.09851702
## k5j37 0.5093973 0.10359057
##           Dim.1      Dim.2
## k2j42 0.4334883 0.02788077
## k3j42 0.4777580 0.02933497
## k4j42 0.8211841 0.11264569
## k5j42 0.8251407 0.13567112
##           Dim.1        Dim.2
## k2j43 0.1286230 0.0000702725
## k3j43 0.5236936 0.0135418584
## k4j43 0.9147868 0.0145749694
## k5j43 0.9153520 0.2790891615
##            Dim.1     Dim.2
## k2j44 0.02178217 0.1078972
## k3j44 0.49786643 0.1083144
## k4j44 0.89904110 0.1158123
## k5j44 0.89914484 0.1205620
##           Dim.1        Dim.2
## k2j52 0.2474502 2.011331e-08
## k3j52 0.4948555 1.418060e-02
## k4j52 0.4958759 1.432804e-01
## k5j52 0.4993464 1.458215e-01
##           Dim.1        Dim.2
## k2j53 0.2360749 0.0003813992
## k3j53 0.6169768 0.0118929966
## k4j53 0.6196458 0.0119953756
## k5j53 0.8640166 0.1116596085
##           Dim.1      Dim.2
## k2j57 0.1146210 0.06318020
## k3j57 0.4159482 0.06362641
## k4j57 0.7915369 0.13147110
## k5j57 0.7932088 0.25267869
##           Dim.1      Dim.2
## k2j61 0.2246379 0.01599544
## k3j61 0.2270929 0.02472921
## k4j61 0.2956447 0.09233460
## k5j61 0.5734720 0.14601365
##           Dim.1       Dim.2
## k2j63 0.5303992 0.008933298
## k3j63 0.5311493 0.014557440
## k4j63 0.5511407 0.014671741
## k5j63 0.6954229 0.035440334
##              Dim.1       Dim.2
## k2j68 3.157810e-06 0.002638415
## k3j68 6.238790e-02 0.003684711
## k4j68 4.580131e-01 0.009450195
## k5j68 7.340327e-01 0.017433667
##           Dim.1       Dim.2
## k2j69 0.2726176 0.001248043
## k3j69 0.4217297 0.021625883
## k4j69 0.5227892 0.038371428
## k5j69 0.6881556 0.135738666
##              Dim.1       Dim.2
## k2j70 0.0002929026 0.006901111
## k3j70 0.3036564703 0.011261202
## k4j70 0.4926091233 0.016310246
## k5j70 0.6460080593 0.034587539
##           Dim.1       Dim.2
## k2j85 0.2662417 0.006679658
## k3j85 0.4664734 0.008190254
## k4j85 0.9067853 0.014118464
## k5j85 0.9098337 0.022291980
##             Dim.1       Dim.2
## k2j93 0.003042587 0.005366414
## k3j93 0.117871109 0.005458878
## k4j93 0.268921309 0.080803739
## k5j93 0.558569206 0.094968980
##           Dim.1       Dim.2
## k2j96 0.4827815 0.008817519
## k3j96 0.4855668 0.127657763
## k4j96 0.4932394 0.143498834
## k5j96 0.5322413 0.213170731
##           Dim.1        Dim.2
## k2j99 0.2786768 0.0000717737
## k3j99 0.4747558 0.0442703733
## k4j99 0.5369071 0.0657315406
## k5j99 0.5378640 0.0688326459
##             Dim.1      Dim.2
## k2j103 0.02654896 0.04348404
## k3j103 0.18347756 0.05803351
## k4j103 0.74026979 0.06067610
## k5j103 0.74190981 0.06288199
##            Dim.1       Dim.2
## k2j105 0.2871645 0.009713572
## k3j105 0.6109124 0.012560094
## k4j105 0.7819336 0.013756973
## k5j105 0.7825393 0.016193173
##            Dim.1      Dim.2
## k2j109 0.4366756 0.01779058
## k3j109 0.4788827 0.07045108
## k4j109 0.4809712 0.12417522
## k5j109 0.5009823 0.12422180
##            Dim.1       Dim.2
## k2j117 0.4363207 0.002881116
## k3j117 0.5230810 0.053686285
## k4j117 0.5388187 0.055417491
## k5j117 0.7103723 0.077260603
# # Plot Groupe 4
p = 1 # p: provisional var.
plot.MFA(projn, choix = "group", habillage="group", title = "Trajectories of the four groups",
         palette = palette(c(rep("transparent",(122+(p-1)*4)),rep("transparent",4), rep("transparent",484-p*4))))

liste=as.numeric(rownames(res.tab$data.clust)[which(res.tab$data.clust$clust==4)])

for (p in liste){
  jp <- coordn[((4*p-4)+1):((4*p-4)+4), 1:2]; print(jp)
  points(jp[,1], jp[,2], pch=17, col="blue")
  lines(jp[,1], jp[,2], type = "l", col="blue")
}

##          Dim.1       Dim.2
## k2j1 0.8382592 0.001706932
## k3j1 0.8387710 0.364042509
## k4j1 0.8870690 0.367201170
## k5j1 0.9048850 0.455339514
##          Dim.1       Dim.2
## k2j2 0.8111706 0.006684533
## k3j2 0.8156348 0.075814360
## k4j2 0.8387480 0.104597735
## k5j2 0.8432996 0.471966178
##          Dim.1      Dim.2
## k2j5 0.7332318 0.04003047
## k3j5 0.9439444 0.11442471
## k4j5 0.9440088 0.12223641
## k5j5 0.9543856 0.12497773
##           Dim.1       Dim.2
## k2j13 0.9421001 0.001064004
## k3j13 0.9428762 0.005194537
## k4j13 0.9428943 0.160718145
## k5j13 0.9503986 0.161113371
##           Dim.1       Dim.2
## k2j14 0.8899955 0.003818284
## k3j14 0.8984064 0.022165372
## k4j14 0.9026761 0.046413920
## k5j14 0.9193897 0.149857104
##           Dim.1       Dim.2
## k2j15 0.9421001 0.001064004
## k3j15 0.9555528 0.004534529
## k4j15 0.9599364 0.025632774
## k5j15 0.9604462 0.028853906
##           Dim.1        Dim.2
## k2j18 0.8813320 0.0005559574
## k3j18 0.8858303 0.0090635405
## k4j18 0.8862408 0.1812034658
## k5j18 0.9096899 0.2023446251
##           Dim.1       Dim.2
## k2j19 0.9421001 0.001064004
## k3j19 0.9421907 0.006640884
## k4j19 0.9462144 0.014785756
## k5j19 0.9465266 0.078549319
##           Dim.1        Dim.2
## k2j20 0.9148899 0.0008085302
## k3j20 0.9265445 0.0049760543
## k4j20 0.9305108 0.0512724993
## k5j20 0.9390396 0.1250274821
##           Dim.1       Dim.2
## k2j21 0.7805460 0.005256531
## k3j21 0.7846687 0.036142980
## k4j21 0.7936295 0.039518327
## k5j21 0.7940033 0.410500338
##           Dim.1       Dim.2
## k2j22 0.9421001 0.001064004
## k3j22 0.9445488 0.009082134
## k4j22 0.9446890 0.039866613
## k5j22 0.9474681 0.040028372
##           Dim.1      Dim.2
## k2j23 0.4130497 0.04987785
## k3j23 0.6444393 0.31821782
## k4j23 0.8391225 0.31888337
## k5j23 0.8402682 0.47349276
##           Dim.1      Dim.2
## k2j24 0.5237284 0.05564307
## k3j24 0.6131521 0.08781281
## k4j24 0.7091527 0.09215173
## k5j24 0.7132479 0.48260289
##           Dim.1        Dim.2
## k2j31 0.5260063 0.0005854785
## k3j31 0.5309822 0.0048247983
## k4j31 0.5313445 0.3474029455
## k5j31 0.8949952 0.3637043108
##           Dim.1       Dim.2
## k2j33 0.8083874 0.002265147
## k3j33 0.8168229 0.219166608
## k4j33 0.8182027 0.247938815
## k5j33 0.8314497 0.247941466
##           Dim.1     Dim.2
## k2j45 0.6378601 0.1091845
## k3j45 0.7446733 0.2140461
## k4j45 0.7454125 0.2503118
## k5j45 0.7500424 0.2902717
##           Dim.1       Dim.2
## k2j46 0.9421001 0.001064004
## k3j46 0.9448006 0.010361929
## k4j46 0.9453085 0.125149954
## k5j46 0.9457317 0.171053199
##           Dim.1      Dim.2
## k2j48 0.6406900 0.01958630
## k3j48 0.7207932 0.05879936
## k4j48 0.7242145 0.06280879
## k5j48 0.7532781 0.07678375
##           Dim.1       Dim.2
## k2j51 0.6067637 0.005484655
## k3j51 0.6869407 0.138686232
## k4j51 0.7022985 0.156229826
## k5j51 0.7037838 0.158528684
##           Dim.1        Dim.2
## k2j54 0.6637068 0.0001384462
## k3j54 0.6724525 0.3060020545
## k4j54 0.7005273 0.3107139253
## k5j54 0.7060360 0.3159606884
##           Dim.1       Dim.2
## k2j60 0.8899955 0.003818284
## k3j60 0.9025162 0.015767250
## k4j60 0.9044270 0.020744224
## k5j60 0.9049800 0.028465692
##           Dim.1       Dim.2
## k2j62 0.4996336 0.001223975
## k3j62 0.9135682 0.003326394
## k4j62 0.9186726 0.152306478
## k5j62 0.9188098 0.155231211
##           Dim.1      Dim.2
## k2j64 0.6659707 0.01930382
## k3j64 0.7853134 0.02120541
## k4j64 0.7879684 0.02629328
## k5j64 0.7892357 0.03345354
##           Dim.1       Dim.2
## k2j65 0.7525341 0.003447235
## k3j65 0.7625080 0.005541627
## k4j65 0.7632075 0.005578491
## k5j65 0.7633245 0.008673144
##           Dim.1      Dim.2
## k2j66 0.5148476 0.03348518
## k3j66 0.8726665 0.07126505
## k4j66 0.8730894 0.08167717
## k5j66 0.8755628 0.08167949
##           Dim.1        Dim.2
## k2j67 0.7608988 5.120358e-06
## k3j67 0.8084040 3.758200e-03
## k4j67 0.8304791 2.141668e-01
## k5j67 0.8304828 2.184211e-01
##           Dim.1      Dim.2
## k2j71 0.8659185 0.00184988
## k3j71 0.9300809 0.01356512
## k4j71 0.9313020 0.03427584
## k5j71 0.9314706 0.57373986
##           Dim.1       Dim.2
## k2j75 0.9118129 0.003264574
## k3j75 0.9121759 0.006059910
## k4j75 0.9150031 0.008702041
## k5j75 0.9188311 0.024305904
##           Dim.1        Dim.2
## k2j76 0.9263695 8.616026e-05
## k3j76 0.9281725 1.352628e-04
## k4j76 0.9282146 2.229894e-02
## k5j76 0.9293865 1.554529e-01
##           Dim.1       Dim.2
## k2j77 0.6411933 0.002703138
## k3j77 0.8348610 0.027596258
## k4j77 0.8900345 0.047842001
## k5j77 0.8901204 0.346188486
##           Dim.1       Dim.2
## k2j80 0.8899955 0.003818284
## k3j80 0.8903288 0.133022040
## k4j80 0.8904879 0.140483436
## k5j80 0.8938407 0.430884737
##           Dim.1       Dim.2
## k2j88 0.9118129 0.003264574
## k3j88 0.9151320 0.004350286
## k4j88 0.9241378 0.153283166
## k5j88 0.9251934 0.201498604
##           Dim.1        Dim.2
## k2j95 0.8429995 8.454230e-06
## k3j95 0.8435065 5.029718e-03
## k4j95 0.8445775 1.892127e-02
## k5j95 0.8456642 5.212654e-02
##            Dim.1       Dim.2
## k2j106 0.5898217 0.009605163
## k3j106 0.8082095 0.028884771
## k4j106 0.8088085 0.319828273
## k5j106 0.8107083 0.489457297
##            Dim.1      Dim.2
## k2j110 0.5793182 0.02421976
## k3j110 0.6705367 0.03343554
## k4j110 0.6722368 0.06626234
## k5j110 0.6951630 0.06973741
##            Dim.1      Dim.2
## k2j111 0.6152024 0.06748413
## k3j111 0.6175781 0.09384061
## k4j111 0.7595798 0.12080458
## k5j111 0.7620485 0.12884844
##            Dim.1       Dim.2
## k2j112 0.6606176 0.006775540
## k3j112 0.7997276 0.007030620
## k4j112 0.8004205 0.007165103
## k5j112 0.8004698 0.182368197
##            Dim.1      Dim.2
## k2j113 0.7232738 0.01555211
## k3j113 0.7345779 0.01574961
## k4j113 0.8548914 0.04731747
## k5j113 0.8549521 0.15073181
##            Dim.1       Dim.2
## k2j120 0.7970565 0.002420318
## k3j120 0.8005085 0.005553721
## k4j120 0.8010349 0.021248396
## k5j120 0.8119093 0.055183259
##            Dim.1       Dim.2
## k2j121 0.6870181 0.004225469
## k3j121 0.7356438 0.032635738
## k4j121 0.7500982 0.049964071
## k5j121 0.7501031 0.078780214

End of Chapter 2

#******************************************************************
# Chapter 2 - Appendix 1: Typology of emotion obtained by ---------
#                         100 French consumers
#******************************************************************
# This script file is for the article of Behavior Research Method
# source("emotionFR.R")

#******************************************************************
# Chapter 2 - Appendix 2: Cross-cultural study between FR & VN ----
#                         100 French consumers
#******************************************************************
# Poster presented at Pangborn 2013
# source("CrossCulture.R")