Similarity Ratings Analyses

Libraries and Data Files

#load libraries
library(dplyr)
library(ggplot2)
library(rstatix)
## Warning: package 'rstatix' was built under R version 4.3.2
library(ez)
library(sciplot)
library(gplots)
library(car)
library(afex)
## Warning: package 'afex' was built under R version 4.3.3
library(emmeans)

#load data
data<-read.csv("AllData_SimilarityRatings.csv", header = T)

Data Pre-processing

#rename useful variables
data$sbj<-data$participant
data$resp<-data$slider_exp.response
data$block<-data$blocks.thisN +1

data <- mutate_if(data, is.character, as.factor)
data$sbj<-as.factor(data$sbj)
#str(data)
#re-order the levels of the session factor
data$session <- factor(data$session, levels = c("Pre", "Post"))

#exclude one participant (20335) for not following instructions
data<-droplevels(data[data$sbj!="20335",])
#str(data)

#exclude data from participants not meeting the learning criterion
exclude_list= readRDS("exclude_list_learnersonly.rds")
exclude_list
## [1] "43423" "48888" "63018" "77337" "77623"
data<-droplevels(data[!(data$sbj %in% exclude_list), ])
#str(data)

#Calculate standardized score for the resp variable.
data <- data %>%
  group_by(sbj) %>%
  mutate(z_resp = (resp - mean(resp, na.rm = TRUE)) / sd(resp, na.rm = TRUE))

Similarity Change Plots, by Group and Pair Type

# 600 ms
###########

#Between-category differences
################################
data_btw600<-droplevels(data[data$cnd=="between" & data$group=="600",])
data_btw_av600<-aggregate(data_btw600$z_resp, list(data_btw600$sbj, data_btw600$session), mean)
colnames(data_btw_av600)<-c("sbj", "session", "z_resp")

#Within-category differences, Relevant Dimension 
#################################################
data_w_r600<-droplevels(data[data$cnd=="within" & data$dim=="rel" & data$group=="600",])
data_w_r_av600<-aggregate(data_w_r600$z_resp, list(data_w_r600$sbj, data_w_r600$session), mean)
colnames(data_w_r_av600)<-c("sbj", "session", "z_resp")

#Within-category differences, Irrelevant Dimension
#################################################
data_w_i600<-droplevels(data[data$cnd=="within" & data$dim=="irrel" & data$group=="600",])
data_w_i_av600<-aggregate(data_w_i600$z_resp, list(data_w_i600$sbj, data_w_i600$session), mean)
colnames(data_w_i_av600)<-c("sbj", "session", "z_resp")

#One graph 600 ms
###############################
par(mfrow=c(1,3),  oma = c(0, 0, 3, 0))
ylb="Standardized Similarity Ratings"
xlb="Session"
clrs=c("grey25", "grey75")
#between 
mn="Between Category Pairs\nRelevant Dimension"
boxplot(data=data_btw_av600, z_resp~session, frame.plot=F, xlab=xlb, ylim=c(-1.5,1.5), ylab=ylb, boxwex=0.5, col=clrs, main =mn, las=1, range=0)
#within, rel
mn="Within Category Pairs\n Relevant Dimension"
boxplot(data=data_w_r_av600, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
#within, irrel
mn="Within Category Pairs\n Irrelevant Dimension"
boxplot(data=data_w_i_av600, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
mtext("Group: 600 ms", outer = TRUE, cex = 1.5, font = 1.5)

par(mfrow=c(1,1), oma = c(0, 0, 0, 0))

# 1100 ms
###########

#Between-category differences 
################################
data_btw1100<-droplevels(data[data$cnd=="between" & data$group=="1100",])
data_btw_av1100<-aggregate(data_btw1100$z_resp, list(data_btw1100$sbj, data_btw1100$session), mean)
colnames(data_btw_av1100)<-c("sbj", "session", "z_resp")

#Within-category differences, Relevant Dimension 
#################################################
data_w_r1100<-droplevels(data[data$cnd=="within" & data$dim=="rel" & data$group=="1100",])
data_w_r_av1100<-aggregate(data_w_r1100$z_resp, list(data_w_r1100$sbj, data_w_r1100$session), mean)
colnames(data_w_r_av1100)<-c("sbj", "session", "z_resp")

#Within-category differences, Irrelevant Dimension 
#################################################
data_w_i1100<-droplevels(data[data$cnd=="within" & data$dim=="irrel" & data$group=="1100",])
data_w_i_av1100<-aggregate(data_w_i1100$z_resp, list(data_w_i1100$sbj, data_w_i1100$session), mean)
colnames(data_w_i_av1100)<-c("sbj", "session", "z_resp")

#One graph 1100 ms
###############################
par(mfrow=c(1,3),  oma = c(0, 0, 3, 0))
ylb="Standardized Similarity Ratings"
xlb="Session"
clrs=c("grey25", "grey75")
#between 
mn="Between Category Pairs\nRelevant Dimension"
boxplot(range=0, data=data_btw_av1100, z_resp~session, frame.plot=F, xlab=xlb, ylim=c(-1.5,1.5), ylab=ylb, boxwex=0.5, col=clrs, main =mn, las=1)
#within, rel
mn="Within Category Pairs\nRelevant Dimension"
boxplot(data=data_w_r_av1100, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
#within, irrel
mn="Within Category Pairs\nIrrelevant Dimension"
boxplot(data=data_w_i_av1100, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
mtext("Group: 1100ms", outer = TRUE, cex = 1.5, font = 1.5)

par(mfrow=c(1,1), oma = c(0, 0, 0, 0))

# 1600 ms
###########

#Between-category differences 
################################
data_btw1600<-droplevels(data[data$cnd=="between" & data$group=="1600",])
data_btw_av1600<-aggregate(data_btw1600$z_resp, list(data_btw1600$sbj, data_btw1600$session), mean)
colnames(data_btw_av1600)<-c("sbj", "session", "z_resp")

#Within-category differences, Relevant Dimension 
#################################################
data_w_r1600<-droplevels(data[data$cnd=="within" & data$dim=="rel" & data$group=="1600",])
data_w_r_av1600<-aggregate(data_w_r1600$z_resp, list(data_w_r1600$sbj, data_w_r1600$session), mean)
colnames(data_w_r_av1600)<-c("sbj", "session", "z_resp")

#Within-category differences, Irrelevant Dimension
#################################################
data_w_i1600<-droplevels(data[data$cnd=="within" & data$dim=="irrel" & data$group=="1600",])
data_w_i_av1600<-aggregate(data_w_i1600$z_resp, list(data_w_i1600$sbj, data_w_i1600$session), mean)
colnames(data_w_i_av1600)<-c("sbj", "session", "z_resp")

#One graph 1600 ms
###############################
par(mfrow=c(1,3),  oma = c(0, 0, 3, 0))
ylb="Standardized Similarity Ratings"
xlb="Session"
clrs=c("grey25", "grey75")
#between 
mn="Between Category Pairs\nRelevant Dimension"
boxplot(range=0, data=data_btw_av1600, z_resp~session, frame.plot=F, xlab=xlb, ylim=c(-1.5,1.5), ylab=ylb, boxwex=0.5, col=clrs, main =mn, las=1)
#within, rel
mn="Within Category Pairs\nRelevant Dimension"
boxplot(data=data_w_r_av1600, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
#within, irrel
mn="Within Category Pairs\nIrrelevant Dimension"
boxplot(data=data_w_i_av1600, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
mtext("Group: 1600ms", outer = TRUE, cex = 1.5, font = 1.5)

par(mfrow=c(1,1), oma = c(0, 0, 0, 0))

# RD
###########

#Between-category differences
################################
data_btwRD<-droplevels(data[data$cnd=="between" & data$group=="RD",])
data_btw_avRD<-aggregate(data_btwRD$z_resp, list(data_btwRD$sbj, data_btwRD$session), mean)
colnames(data_btw_avRD)<-c("sbj", "session", "z_resp")

#Within-category differences, Relevant Dimension 
#################################################
data_w_rRD<-droplevels(data[data$cnd=="within" & data$dim=="rel" & data$group=="RD",])
data_w_r_avRD<-aggregate(data_w_rRD$z_resp, list(data_w_rRD$sbj, data_w_rRD$session), mean)
colnames(data_w_r_avRD)<-c("sbj", "session", "z_resp")

#Within-category differences, Irrelevant Dimension 
#################################################
data_w_iRD<-droplevels(data[data$cnd=="within" & data$dim=="irrel" & data$group=="RD",])
data_w_i_avRD<-aggregate(data_w_iRD$z_resp, list(data_w_iRD$sbj, data_w_iRD$session), mean)
colnames(data_w_i_avRD)<-c("sbj", "session", "z_resp")

#One graph RD
###############################
par(mfrow=c(1,3),  oma = c(0, 0, 3, 0))
ylb="Standardized Similarity Ratings"
xlb="Session"
clrs=c("grey25", "grey75")
#between 
mn="Between Category Pairs\nRelevant Dimension"
boxplot(range=0, data=data_btw_avRD, z_resp~session, frame.plot=F, xlab=xlb, ylim=c(-1.5,1.5), ylab=ylb, boxwex=0.5, col=clrs, main =mn, las=1)
#within, rel
mn="Within Category Pairs\nRelevant Dimension"
boxplot(data=data_w_r_avRD, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
#within, irrel
mn="Within Category Pairs\nIrrelevant Dimension"
boxplot(data=data_w_i_avRD, z_resp~session, frame.plot=F, ylim=c(-1.5,1.5), xlab=xlb, ylab="", boxwex=0.5, col=clrs, main =mn, las=1, range=0)
mtext("Group: RD", outer = TRUE, cex = 1.5, font = 1.5)

par(mfrow=c(1,1), oma = c(0, 0, 0, 0))

Inferential Statistics - ANOVA

#create new factor, condition (pair type) with three levels
data$condition<-as.factor(ifelse(data$cnd=="between", "between", ifelse(data$dim=="rel","within_rel","within_irrel" )))

ezANOVA(data=data, dv=z_resp,wid=sbj, within=.(session,condition), between=group, type=3)
## Warning: Data is unbalanced (unequal N per group). Make sure you specified a
## well-considered value for the type argument to ezANOVA().
## Warning: Collapsing data to cell means. *IF* the requested effects are a subset
## of the full design, you must use the "within_full" argument, else results may
## be inaccurate.
## $ANOVA
##                    Effect DFn DFd          F            p p<.05         ges
## 2                   group   3  57  2.9180733 4.179359e-02     * 0.009906707
## 3                 session   1  57 13.1225571 6.220974e-04     * 0.048932436
## 5               condition   2 114 42.3330979 1.780369e-14     * 0.288107750
## 4           group:session   3  57  0.8059441 4.957776e-01       0.009390649
## 6         group:condition   6 114  2.3418151 3.602935e-02     * 0.062936624
## 7       session:condition   2 114 10.0766925 9.338633e-05     * 0.028583838
## 8 group:session:condition   6 114  0.8783103 5.132696e-01       0.007635503
## 
## $`Mauchly's Test for Sphericity`
##                    Effect         W            p p<.05
## 5               condition 0.1464522 4.360026e-24     *
## 6         group:condition 0.1464522 4.360026e-24     *
## 7       session:condition 0.4552354 2.695317e-10     *
## 8 group:session:condition 0.4552354 2.695317e-10     *
## 
## $`Sphericity Corrections`
##                    Effect       GGe        p[GG] p[GG]<.05       HFe
## 5               condition 0.5395059 6.936719e-09         * 0.5416811
## 6         group:condition 0.5395059 7.736925e-02           0.5416811
## 7       session:condition 0.6473478 9.223859e-04         * 0.6560627
## 8 group:session:condition 0.6473478 4.786980e-01           0.6560627
##          p[HF] p[HF]<.05
## 5 6.525744e-09         *
## 6 7.708394e-02          
## 7 8.713289e-04         *
## 8 4.797683e-01
aov_model <- aov_ez(id = "sbj", dv = "z_resp", data = data, within = c("session", "condition"), between = "group", type = 3)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Contrasts set to contr.sum for the following variables: group
summary(aov_model)
## 
## Univariate Type III Repeated-Measures ANOVA Assuming Sphericity
## 
##                         Sum Sq num Df Error SS den Df F value    Pr(>F)    
## (Intercept)              4.511      1    6.661     57 38.5996 6.430e-08 ***
## group                    1.023      3    6.661     57  2.9181 0.0417936 *  
## session                  5.260      1   22.848     57 13.1226 0.0006221 ***
## group:session            0.969      3   22.848     57  0.8059 0.4957776    
## condition               41.376      2   55.712    114 42.3331 1.780e-14 ***
## group:condition          6.867      6   55.712    114  2.3418 0.0360293 *  
## session:condition        3.008      2   17.017    114 10.0767 9.339e-05 ***
## group:session:condition  0.787      6   17.017    114  0.8783 0.5132696    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                         Test statistic    p-value
## condition                      0.14645 0.0000e+00
## group:condition                0.14645 0.0000e+00
## session:condition              0.45524 2.6953e-10
## group:session:condition        0.45524 2.6953e-10
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                          GG eps Pr(>F[GG])    
## condition               0.53951  6.937e-09 ***
## group:condition         0.53951  0.0773693 .  
## session:condition       0.64735  0.0009224 ***
## group:session:condition 0.64735  0.4786980    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                            HF eps   Pr(>F[HF])
## condition               0.5416811 6.525744e-09
## group:condition         0.5416811 7.708394e-02
## session:condition       0.6560627 8.713289e-04
## group:session:condition 0.6560627 4.797683e-01
emms <- emmeans(aov_model, ~ session |condition*group)

comparisons <- contrast(emms, method = "pairwise", adjust = "bonferroni")
summary(comparisons)
## condition = between, group = 1100:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.4262 0.188 57   2.271  0.0269
## 
## condition = within_irrel, group = 1100:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.0378 0.161 57   0.235  0.8149
## 
## condition = within_rel, group = 1100:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.1993 0.179 57   1.112  0.2709
## 
## condition = between, group = 1600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.2748 0.188 57   1.465  0.1485
## 
## condition = within_irrel, group = 1600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post  -0.2779 0.161 57  -1.728  0.0895
## 
## condition = within_rel, group = 1600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.2501 0.179 57   1.395  0.1686
## 
## condition = between, group = 600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.4273 0.182 57   2.352  0.0222
## 
## condition = within_irrel, group = 600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.2695 0.156 57   1.730  0.0891
## 
## condition = within_rel, group = 600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.3693 0.174 57   2.127  0.0377
## 
## condition = between, group = RD:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.5111 0.188 57   2.723  0.0086
## 
## condition = within_irrel, group = RD:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post  -0.0754 0.161 57  -0.469  0.6409
## 
## condition = within_rel, group = RD:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.4663 0.179 57   2.600  0.0118

Session Information

sessionInfo()
## R version 4.3.1 (2023-06-16 ucrt)
## Platform: x86_64-w64-mingw32/x64 (64-bit)
## Running under: Windows 10 x64 (build 19045)
## 
## Matrix products: default
## 
## 
## locale:
## [1] LC_COLLATE=English_United States.utf8 
## [2] LC_CTYPE=English_United States.utf8   
## [3] LC_MONETARY=English_United States.utf8
## [4] LC_NUMERIC=C                          
## [5] LC_TIME=English_United States.utf8    
## 
## time zone: Europe/Athens
## tzcode source: internal
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] emmeans_1.8.8 afex_1.4-1    lme4_1.1-34   Matrix_1.6-1  car_3.1-2    
##  [6] carData_3.0-5 gplots_3.1.3  sciplot_1.2-0 ez_4.4-0      rstatix_0.7.2
## [11] ggplot2_3.4.3 dplyr_1.1.3  
## 
## loaded via a namespace (and not attached):
##  [1] gtable_0.3.4        xfun_0.40           bslib_0.5.1        
##  [4] caTools_1.18.2      lattice_0.21-8      numDeriv_2016.8-1.1
##  [7] vctrs_0.6.3         tools_4.3.1         bitops_1.0-7       
## [10] generics_0.1.3      sandwich_3.0-2      parallel_4.3.1     
## [13] tibble_3.2.1        fansi_1.0.4         pkgconfig_2.0.3    
## [16] KernSmooth_2.23-21  lifecycle_1.0.3     compiler_4.3.1     
## [19] stringr_1.5.0       munsell_0.5.0       codetools_0.2-19   
## [22] lmerTest_3.1-3      htmltools_0.5.6     sass_0.4.7         
## [25] yaml_2.3.7          pillar_1.9.0        nloptr_2.0.3       
## [28] jquerylib_0.1.4     tidyr_1.3.0         MASS_7.3-60        
## [31] cachem_1.0.8        multcomp_1.4-25     boot_1.3-28.1      
## [34] abind_1.4-5         nlme_3.1-162        gtools_3.9.4       
## [37] tidyselect_1.2.0    digest_0.6.33       mvtnorm_1.2-3      
## [40] stringi_1.7.12      reshape2_1.4.4      purrr_1.0.2        
## [43] splines_4.3.1       fastmap_1.1.1       grid_4.3.1         
## [46] colorspace_2.1-0    cli_3.6.1           magrittr_2.0.3     
## [49] survival_3.5-5      utf8_1.2.3          TH.data_1.1-2      
## [52] broom_1.0.5         withr_2.5.0         scales_1.2.1       
## [55] backports_1.4.1     estimability_1.4.1  rmarkdown_2.24     
## [58] zoo_1.8-12          evaluate_0.21       knitr_1.44         
## [61] mgcv_1.8-42         rlang_1.1.1         Rcpp_1.0.11        
## [64] xtable_1.8-4        glue_1.6.2          rstudioapi_0.15.0  
## [67] minqa_1.2.5         jsonlite_1.8.7      R6_2.5.1           
## [70] plyr_1.8.8