#--------------- WORKSPACE SETTING --------------------------------
suppressPackageStartupMessages(c(
library(dplyr),
library(magrittr),
library(psych),
library(mice),
library(psychTools),
library(careless),
library(eulerr),
library(ggplot2),
library(patchwork),
library(ComplexUpset),
library(fmsb)
))
## Warning: il pacchetto 'psychTools' è stato creato con R versione 4.4.3
## Warning: il pacchetto 'careless' è stato creato con R versione 4.4.2
## Warning: il pacchetto 'eulerr' è stato creato con R versione 4.4.3
## Warning: il pacchetto 'ggplot2' è stato creato con R versione 4.4.3
## Warning: il pacchetto 'patchwork' è stato creato con R versione 4.4.3
## Warning: il pacchetto 'ComplexUpset' è stato creato con R versione 4.4.3
## Warning: il pacchetto 'fmsb' è stato creato con R versione 4.4.3
## [1] "dplyr" "stats" "graphics" "grDevices" "utils"
## [6] "datasets" "methods" "base" "magrittr" "dplyr"
## [11] "stats" "graphics" "grDevices" "utils" "datasets"
## [16] "methods" "base" "psych" "magrittr" "dplyr"
## [21] "stats" "graphics" "grDevices" "utils" "datasets"
## [26] "methods" "base" "mice" "psych" "magrittr"
## [31] "dplyr" "stats" "graphics" "grDevices" "utils"
## [36] "datasets" "methods" "base" "psychTools" "mice"
## [41] "psych" "magrittr" "dplyr" "stats" "graphics"
## [46] "grDevices" "utils" "datasets" "methods" "base"
## [51] "careless" "psychTools" "mice" "psych" "magrittr"
## [56] "dplyr" "stats" "graphics" "grDevices" "utils"
## [61] "datasets" "methods" "base" "eulerr" "careless"
## [66] "psychTools" "mice" "psych" "magrittr" "dplyr"
## [71] "stats" "graphics" "grDevices" "utils" "datasets"
## [76] "methods" "base" "ggplot2" "eulerr" "careless"
## [81] "psychTools" "mice" "psych" "magrittr" "dplyr"
## [86] "stats" "graphics" "grDevices" "utils" "datasets"
## [91] "methods" "base" "patchwork" "ggplot2" "eulerr"
## [96] "careless" "psychTools" "mice" "psych" "magrittr"
## [101] "dplyr" "stats" "graphics" "grDevices" "utils"
## [106] "datasets" "methods" "base" "ComplexUpset" "patchwork"
## [111] "ggplot2" "eulerr" "careless" "psychTools" "mice"
## [116] "psych" "magrittr" "dplyr" "stats" "graphics"
## [121] "grDevices" "utils" "datasets" "methods" "base"
## [126] "fmsb" "ComplexUpset" "patchwork" "ggplot2" "eulerr"
## [131] "careless" "psychTools" "mice" "psych" "magrittr"
## [136] "dplyr" "stats" "graphics" "grDevices" "utils"
## [141] "datasets" "methods" "base"
Setting wd in the same directory where the R file is stored (dynamic for reproducilibiliy, it only works in R studio)
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
#-------- DATA INPUT -------------------------------------------
dat <- read.csv("data/data.csv")
#----------- DATA CLEANING -------------------------------------
remove useless columns
lucca <- dat %>%
select(
matches(c("^AS","^ID","^IO","^PA","^SD","gen","QUESTNNR"))
)
renaming useful columns
source("Columns Renaming.R")
lucca <- rename_luccaChef(lucca)
selecting only finished questionnaires and during administration period
lucca <- lucca %>%
filter(
as.logical(dat$FINISHED) &
(dat$STARTED %>% as.Date() %>% {.> as.Date("2025-10-28")})
)
dividing pre and post
lucca_pre <- lucca[lucca$QUESTNNR=="start",]
lucca_post <- lucca[lucca$QUESTNNR=="Robot",]
creating single-string codes for both
pre_codes <- paste(lucca_pre$ID_01,
lucca_pre$ID_02,
lucca_pre$ID_03,
lucca_pre$ID_04,
sep = "."
)
post_codes <- paste(lucca_post$ID_01,
lucca_post$ID_02,
lucca_post$ID_03,
lucca_post$ID_04,
sep = "."
)
finding the ones that match perfectly
pairings <- adist(pre_codes,post_codes) %>%
{.<=1} %>%
which(arr.ind=T)
ordering the two datasets
lucca_pre <- lucca_pre[pairings[,1],]
lucca_post <- lucca_post[pairings[,2],]
which codes are missing?
pre_codes[
!(1:length(pre_codes)) %in% pairings[,1]
]
## [1] "17.Se.6.2" "17.Se.6.2"
post_codes[
!(1:length(post_codes)) %in% pairings[,2]
]
## [1] "39.Gu.12.1"
cbind(
pre=lucca_pre$IOS,
post=lucca_post$IOS) %>%
error.bars(eyes=F,xlab=c("administrations"),ylab=("ios score"),main="IOS")
t.test(
lucca_pre$IOS,
lucca_post$IOS,
alternative="less"
)
##
## Welch Two Sample t-test
##
## data: lucca_pre$IOS and lucca_post$IOS
## t = -2.0273, df = 26.601, p-value = 0.02638
## alternative hypothesis: true difference in means is less than 0
## 95 percent confidence interval:
## -Inf -0.08500855
## sample estimates:
## mean of x mean of y
## 1.400000 1.933333
pa_pre <- lucca_pre %>%
select(
matches("^pa")
) %>%
apply(1,mean)
pa_post <- lucca_post %>%
select(
matches("^pa")
) %>%
apply(1,mean)
cbind(pre = pa_pre,
post = pa_post) %>%
error.bars(eyes=F,
ylab="positive affect scores",
xlab="pre-post",
main="Positive Affect")
na_pre <- lucca_pre %>%
select(
matches("^na")
) %>%
apply(1,mean)
na_post <- lucca_post %>%
select(
matches("^na")
) %>%
apply(1,mean)
cbind(pre = na_pre,
post = na_post) %>%
error.bars(eyes=F,
ylab="negative affect scores",
xlab="pre-post",
main="Negative Affect")
hlb <- lucca_post %>%
select(
matches("^ASAQ_HLB_")
) %>%
apply(1,mean)
ae <- lucca_post %>%
select(
matches("^ASAQ_AE_")
) %>%
mutate(
ASAQ_AE_01 = 8 - ASAQ_AE_01,
ASAQ_AE_04 = 8 - ASAQ_AE_04
) %>%
apply(1,mean)
ue <- lucca_post %>%
select(
matches("^ASAQ_UE_")
) %>%
apply(1,mean)
aa <- lucca_post %>%
select(
matches("^ASAQ_AQ_")
) %>%
apply(1,mean)
ac <- lucca_post %>%
select(
matches("^ASAQ_AC_")
) %>%
apply(1,mean)
ai <- lucca_post %>%
select(
matches("^ASAQ_AI_")
) %>%
mutate(ASAQ_AI_03 = 8 - ASAQ_AI_03) %>%
apply(1,mean)
aeip <- lucca_post %>%
select(
matches("^ASAQ_AEIP_")
) %>%
mutate(ASAQ_AEIP_03 = 8 - ASAQ_AEIP_03,
ASAQ_AEIP_05 = 8 - ASAQ_AEIP_05) %>%
apply(1,mean)
uep <- lucca_post %>%
select(
matches("^ASAQ_UEP_")
) %>%
apply(1,mean)
cor.test(hlb,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: hlb and lucca_post$IOS
## t = -1.0254, df = 13, p-value = 0.3239
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.6892359 0.2776066
## sample estimates:
## cor
## -0.2735583
cor.test(ae,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: ae and lucca_post$IOS
## t = 0.44951, df = 13, p-value = 0.6605
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.4148400 0.5980736
## sample estimates:
## cor
## 0.1237127
cor.test(ue,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: ue and lucca_post$IOS
## t = 0.82969, df = 13, p-value = 0.4217
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.3253883 0.6606262
## sample estimates:
## cor
## 0.2242542
cor.test(aa,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: aa and lucca_post$IOS
## t = 0.4883, df = 13, p-value = 0.6335
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.4059668 0.6048836
## sample estimates:
## cor
## 0.1342057
cor.test(ac,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: ac and lucca_post$IOS
## t = -0.70902, df = 13, p-value = 0.4908
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.6417797 0.3543343
## sample estimates:
## cor
## -0.1929516
cor.test(ai,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: ai and lucca_post$IOS
## t = 0.78184, df = 13, p-value = 0.4483
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.3369190 0.6532647
## sample estimates:
## cor
## 0.2119192
cor.test(aeip,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: aeip and lucca_post$IOS
## t = -1.1884, df = 13, p-value = 0.2559
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.7112418 0.2372832
## sample estimates:
## cor
## -0.3130287
cor.test(uep,lucca_post$IOS)
##
## Pearson's product-moment correlation
##
## data: uep and lucca_post$IOS
## t = 1.7443, df = 13, p-value = 0.1047
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.09880416 0.77489235
## sample estimates:
## cor
## 0.435501
In the barplot the following are the labels: - hlb: human-like behaviour - ae: agent’s enjoyability - ue: User’s engagement - aa: Agent’s attentiveness - ac: Agent’s coherence - ai: Agent’s intentionality - aeip: Agent’s Emotional Intelligence Presence - uep: User’s emotional presence
We explore the correlation between asaq values and IOS
barplot(
cbind(
hlb = cor(hlb,lucca_post$IOS),
ae = cor(ae,lucca_post$IOS),
ue = cor(ue,lucca_post$IOS),
aa = cor(aa,lucca_post$IOS),
ac = cor(ac,lucca_post$IOS),
ai = cor(ai,lucca_post$IOS),
aeip = cor(aeip,lucca_post$IOS),
uep = cor(uep,lucca_post$IOS)
),
main = "cor ASAQ - IOS_post"
)
In rosso i punteggi di iCub,
alexa = c(-0.34, 1.3, 1.54, 1.8, 1.89, 0.61, -1.71, -0.38)+4
furhat = c(-0.29, 1.23, 2.01, 2.13, 2.04, 0.76, -1.48, 0.81)+4
nao = c(0.74, 1.91, 2.11, 1.59, 1.61, 0.82, 0.07, 0.99)+4
par(xpd=T)
radarchart(
cbind.data.frame(
human_like_behaviour = c(7,0,mean(hlb)),
enjoyability = c(7,0,mean(ae)),
user_engagement = c(7,0,mean(ue)),
attentiveness = c(7,0,mean(aa)),
agent_coherence = c(7,0,mean(ac)),
imtentionality = c(7,0,mean(ai)),
emotional_intelligence = c(7,0,mean(aeip)),
user_emotional_presence = c(7,0,mean(uep))
) %>% rbind.data.frame(
alexa,
furhat,
nao
),
pcol=c("red","blue","darkgrey","darkgreen"),
cglcol = "lightgrey"
)
legend(
"topleft",
legend = c("alexa", "icub", "furhat", "nao"),
col = c("blue", "red","darkgrey", "darkgreen"),
lty = 1,
lwd = 2,
bty = "n"
)
#' <h2> Single items PANAS </h2>
panas_pre <- lucca_pre %>%
select(matches("^PA_|^NA_"))
panas_post <- lucca_post %>%
select(matches("^PA_|^NA_"))
panas <- (panas_post - panas_pre) %>%
apply(2,mean)
names(panas) <- c("Determinato",
"Attivo",
"Interessato",
"Attento",
"Entusiasta",
"Concentrato",
"Forte",
"Ispirato",
"Eccitato",
"Orgoglioso",
"Impaurito",
"Turbato",
"Nervoso",
"Agitato",
"Spaventato",
"Angosciato",
"Colpevole",
"Vergogna",
"Irritabile",
"Ostile")
panas %>% barplot(las=2,
main = "Δ PANAS (post - pre)")