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)


#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: Converting "sbj" to factor for ANOVA.
## 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  62  3.7559012 1.520923e-02     * 0.011874357
## 3                 session   1  62 16.0662403 1.666830e-04     * 0.054446854
## 5               condition   2 124 50.0838474 1.139244e-16     * 0.306755089
## 4           group:session   3  62  0.7917551 5.031027e-01       0.008441181
## 6         group:condition   6 124  3.0500102 8.111371e-03     * 0.074794261
## 7       session:condition   2 124 10.7750489 4.845843e-05     * 0.027694708
## 8 group:session:condition   6 124  0.9414590 4.680054e-01       0.007410834
## 
## $`Mauchly's Test for Sphericity`
##                    Effect         W            p p<.05
## 5               condition 0.1532633 1.431743e-25     *
## 6         group:condition 0.1532633 1.431743e-25     *
## 7       session:condition 0.4754269 1.415969e-10     *
## 8 group:session:condition 0.4754269 1.415969e-10     *
## 
## $`Sphericity Corrections`
##                    Effect       GGe        p[GG] p[GG]<.05       HFe
## 5               condition 0.5414957 4.018405e-10         * 0.5435958
## 6         group:condition 0.5414957 3.096786e-02         * 0.5435958
## 7       session:condition 0.6559213 5.552497e-04         * 0.6644302
## 8 group:session:condition 0.6559213 4.432638e-01           0.6644302
##          p[HF] p[HF]<.05
## 5 3.749292e-10         *
## 6 3.077382e-02         *
## 7 5.225694e-04         *
## 8 4.440504e-01
#Post-hoc comparisons:
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)              5.110      1    7.029     62 45.0764 6.708e-09 ***
## group                    1.277      3    7.029     62  3.7559 0.0152092 *  
## session                  6.121      1   23.620     62 16.0662 0.0001667 ***
## group:session            0.905      3   23.620     62  0.7918 0.5031027    
## condition               47.035      2   58.226    124 50.0838 < 2.2e-16 ***
## group:condition          8.593      6   58.226    124  3.0500 0.0081114 ** 
## session:condition        3.028      2   17.421    124 10.7750 4.846e-05 ***
## group:session:condition  0.794      6   17.421    124  0.9415 0.4680054    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Mauchly Tests for Sphericity
## 
##                         Test statistic   p-value
## condition                      0.15326 0.000e+00
## group:condition                0.15326 0.000e+00
## session:condition              0.47543 1.416e-10
## group:session:condition        0.47543 1.416e-10
## 
## 
## Greenhouse-Geisser and Huynh-Feldt Corrections
##  for Departure from Sphericity
## 
##                          GG eps Pr(>F[GG])    
## condition               0.54150  4.018e-10 ***
## group:condition         0.54150  0.0309679 *  
## session:condition       0.65592  0.0005552 ***
## group:session:condition 0.65592  0.4432638    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
##                            HF eps   Pr(>F[HF])
## condition               0.5435958 3.749292e-10
## group:condition         0.5435958 3.077382e-02
## session:condition       0.6644302 5.225694e-04
## group:session:condition 0.6644302 4.440504e-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.181 62   2.350  0.0220
## 
## condition = within_irrel, group = 1100:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.0378 0.158 62   0.240  0.8113
## 
## condition = within_rel, group = 1100:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.1993 0.175 62   1.142  0.2579
## 
## condition = between, group = 1600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.2905 0.170 62   1.705  0.0932
## 
## condition = within_irrel, group = 1600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post  -0.2067 0.148 62  -1.395  0.1680
## 
## condition = within_rel, group = 1600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.2454 0.164 62   1.497  0.1396
## 
## condition = between, group = 600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.4262 0.166 62   2.574  0.0125
## 
## condition = within_irrel, group = 600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.2660 0.144 62   1.847  0.0695
## 
## condition = within_rel, group = 600:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.3698 0.159 62   2.320  0.0236
## 
## condition = between, group = RD:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.5037 0.176 62   2.868  0.0056
## 
## condition = within_irrel, group = RD:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post  -0.0738 0.153 62  -0.483  0.6307
## 
## condition = within_rel, group = RD:
##  contrast   estimate    SE df t.ratio p.value
##  Pre - Post   0.5062 0.169 62   2.995  0.0039

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