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)
## 'data.frame': 9648 obs. of 38 variables:
## $ trl : int 20 12 17 14 21 3 10 13 6 23 ...
## $ cnd : Factor w/ 2 levels "between","within": 2 2 2 2 1 2 2 2 2 1 ...
## $ dim : Factor w/ 2 levels "irrel","rel": 2 1 2 2 2 1 1 2 1 2 ...
## $ size1 : num 3.4 2.6 2.2 2.6 2.2 2.2 2.6 2.2 3 3 ...
## $ hue1 : num 0.1 0.3 0.1 -0.3 -0.1 0.1 -0.1 -0.3 -0.1 -0.1 ...
## $ size2 : num 3.4 3 2.2 2.6 2.2 2.6 3 2.2 3.4 3 ...
## $ hue2 : num 0.3 0.3 0.3 -0.1 0.1 0.1 -0.1 -0.1 -0.1 0.1 ...
## $ practice_trials.thisRepN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisTrialN: logi NA NA NA NA NA NA ...
## $ practice_trials.thisN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisIndex : logi NA NA NA NA NA NA ...
## $ blocks.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisTrialN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisIndex : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisTrialN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisIndex : int 19 11 16 13 20 2 9 12 5 22 ...
## $ break_loop.thisRepN : logi NA NA NA NA NA NA ...
## $ break_loop.thisTrialN : logi NA NA NA NA NA NA ...
## $ break_loop.thisN : logi NA NA NA NA NA NA ...
## $ break_loop.thisIndex : logi NA NA NA NA NA NA ...
## $ thisRow.t : num 68.9 73.1 75.9 79.7 82.8 ...
## $ notes : logi NA NA NA NA NA NA ...
## $ slider_exp.response : int 5 7 5 4 3 4 3 2 7 5 ...
## $ slider_exp.rt : num 3.89 2.6 3.45 2.87 4.87 ...
## $ participant : int 17202 17202 17202 17202 17202 17202 17202 17202 17202 17202 ...
## $ session : Factor w/ 2 levels "Post","Pre": 1 1 1 1 1 1 1 1 1 1 ...
## $ group : Factor w/ 4 levels "1100","1600",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ date : Factor w/ 134 levels "2025-02-25_11h40.18.454",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ expName : Factor w/ 1 level "SimilarityRatings": 1 1 1 1 1 1 1 1 1 1 ...
## $ psychopyVersion : Factor w/ 1 level "2023.2.3": 1 1 1 1 1 1 1 1 1 1 ...
## $ frameRate : num 60 60 60 60 60 ...
## $ expStart : Factor w/ 134 levels "2025-02-25 11h48.02.736634 +0200",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ sbj : Factor w/ 67 levels "341","1003","1206",..: 10 10 10 10 10 10 10 10 10 10 ...
## $ resp : int 5 7 5 4 3 4 3 2 7 5 ...
## $ block : num 1 1 1 1 1 1 1 1 1 1 ...
#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)
## 'data.frame': 9504 obs. of 38 variables:
## $ trl : int 20 12 17 14 21 3 10 13 6 23 ...
## $ cnd : Factor w/ 2 levels "between","within": 2 2 2 2 1 2 2 2 2 1 ...
## $ dim : Factor w/ 2 levels "irrel","rel": 2 1 2 2 2 1 1 2 1 2 ...
## $ size1 : num 3.4 2.6 2.2 2.6 2.2 2.2 2.6 2.2 3 3 ...
## $ hue1 : num 0.1 0.3 0.1 -0.3 -0.1 0.1 -0.1 -0.3 -0.1 -0.1 ...
## $ size2 : num 3.4 3 2.2 2.6 2.2 2.6 3 2.2 3.4 3 ...
## $ hue2 : num 0.3 0.3 0.3 -0.1 0.1 0.1 -0.1 -0.1 -0.1 0.1 ...
## $ practice_trials.thisRepN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisTrialN: logi NA NA NA NA NA NA ...
## $ practice_trials.thisN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisIndex : logi NA NA NA NA NA NA ...
## $ blocks.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisTrialN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisIndex : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisTrialN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisIndex : int 19 11 16 13 20 2 9 12 5 22 ...
## $ break_loop.thisRepN : logi NA NA NA NA NA NA ...
## $ break_loop.thisTrialN : logi NA NA NA NA NA NA ...
## $ break_loop.thisN : logi NA NA NA NA NA NA ...
## $ break_loop.thisIndex : logi NA NA NA NA NA NA ...
## $ thisRow.t : num 68.9 73.1 75.9 79.7 82.8 ...
## $ notes : logi NA NA NA NA NA NA ...
## $ slider_exp.response : int 5 7 5 4 3 4 3 2 7 5 ...
## $ slider_exp.rt : num 3.89 2.6 3.45 2.87 4.87 ...
## $ participant : int 17202 17202 17202 17202 17202 17202 17202 17202 17202 17202 ...
## $ session : Factor w/ 2 levels "Pre","Post": 2 2 2 2 2 2 2 2 2 2 ...
## $ group : Factor w/ 4 levels "1100","1600",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ date : Factor w/ 132 levels "2025-02-25_11h40.18.454",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ expName : Factor w/ 1 level "SimilarityRatings": 1 1 1 1 1 1 1 1 1 1 ...
## $ psychopyVersion : Factor w/ 1 level "2023.2.3": 1 1 1 1 1 1 1 1 1 1 ...
## $ frameRate : num 60 60 60 60 60 ...
## $ expStart : Factor w/ 132 levels "2025-02-25 11h48.02.736634 +0200",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ sbj : Factor w/ 66 levels "341","1003","1206",..: 10 10 10 10 10 10 10 10 10 10 ...
## $ resp : int 5 7 5 4 3 4 3 2 7 5 ...
## $ block : num 1 1 1 1 1 1 1 1 1 1 ...
Comparison of Responses from “Exclusion-Instructions”
Participants
#check if we can keep data from 7 first sbjs (instructions: we will delete your data)
data$excl_instr<-"no"
#For the first 7 participants, we need to register that the instructions were different.
#These 7 participants are: "17202" "40242" "57393" "77337" "77623" "89443" "94372"
data[data$sbj=="17202" | data$sbj=="40242" | data$sbj=="57393" | data$sbj=="77337" | data$sbj=="77623" | data$sbj=="89443" | data$sbj=="94372",]$excl_instr<-"yes"
data$excl_instr<-as.factor(data$excl_instr)
str(data)
## 'data.frame': 9504 obs. of 39 variables:
## $ trl : int 20 12 17 14 21 3 10 13 6 23 ...
## $ cnd : Factor w/ 2 levels "between","within": 2 2 2 2 1 2 2 2 2 1 ...
## $ dim : Factor w/ 2 levels "irrel","rel": 2 1 2 2 2 1 1 2 1 2 ...
## $ size1 : num 3.4 2.6 2.2 2.6 2.2 2.2 2.6 2.2 3 3 ...
## $ hue1 : num 0.1 0.3 0.1 -0.3 -0.1 0.1 -0.1 -0.3 -0.1 -0.1 ...
## $ size2 : num 3.4 3 2.2 2.6 2.2 2.6 3 2.2 3.4 3 ...
## $ hue2 : num 0.3 0.3 0.3 -0.1 0.1 0.1 -0.1 -0.1 -0.1 0.1 ...
## $ practice_trials.thisRepN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisTrialN: logi NA NA NA NA NA NA ...
## $ practice_trials.thisN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisIndex : logi NA NA NA NA NA NA ...
## $ blocks.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisTrialN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisIndex : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisTrialN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisIndex : int 19 11 16 13 20 2 9 12 5 22 ...
## $ break_loop.thisRepN : logi NA NA NA NA NA NA ...
## $ break_loop.thisTrialN : logi NA NA NA NA NA NA ...
## $ break_loop.thisN : logi NA NA NA NA NA NA ...
## $ break_loop.thisIndex : logi NA NA NA NA NA NA ...
## $ thisRow.t : num 68.9 73.1 75.9 79.7 82.8 ...
## $ notes : logi NA NA NA NA NA NA ...
## $ slider_exp.response : int 5 7 5 4 3 4 3 2 7 5 ...
## $ slider_exp.rt : num 3.89 2.6 3.45 2.87 4.87 ...
## $ participant : int 17202 17202 17202 17202 17202 17202 17202 17202 17202 17202 ...
## $ session : Factor w/ 2 levels "Pre","Post": 2 2 2 2 2 2 2 2 2 2 ...
## $ group : Factor w/ 4 levels "1100","1600",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ date : Factor w/ 132 levels "2025-02-25_11h40.18.454",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ expName : Factor w/ 1 level "SimilarityRatings": 1 1 1 1 1 1 1 1 1 1 ...
## $ psychopyVersion : Factor w/ 1 level "2023.2.3": 1 1 1 1 1 1 1 1 1 1 ...
## $ frameRate : num 60 60 60 60 60 ...
## $ expStart : Factor w/ 132 levels "2025-02-25 11h48.02.736634 +0200",..: 4 4 4 4 4 4 4 4 4 4 ...
## $ sbj : Factor w/ 66 levels "341","1003","1206",..: 10 10 10 10 10 10 10 10 10 10 ...
## $ resp : int 5 7 5 4 3 4 3 2 7 5 ...
## $ block : num 1 1 1 1 1 1 1 1 1 1 ...
## $ excl_instr : Factor w/ 2 levels "no","yes": 2 2 2 2 2 2 2 2 2 2 ...
#test if there's a difference in response distribution among participants (excl_instr= "yes" vs. "no")
#Pre Session
data_pre <- subset(data, session == "Pre")
table_pre <- table(data_pre$resp, data_pre$excl_instr)
chi_pre <- chisq.test(table_pre)
## Warning in chisq.test(table_pre): Chi-squared approximation may be incorrect
print(table_pre)
##
## no yes
## 1 24 3
## 2 66 10
## 3 150 30
## 4 280 41
## 5 427 41
## 6 658 86
## 7 900 112
## 8 1092 119
## 9 651 62
print(chi_pre)
##
## Pearson's Chi-squared test
##
## data: table_pre
## X-squared = 15.233, df = 8, p-value = 0.05477
#function to calculate the percentage of expected counts >=5)
check_expected_frequencies <- function(chisq_test_result) {
expected <- chisq_test_result$expected
total_cells <- length(expected)
cells_over_5 <- sum(expected >= 5)
percent_over_5 <- (cells_over_5 / total_cells) * 100
return(percent_over_5)
}
check_expected_frequencies(chi_pre)
## [1] 94.44444
# it should be >80%
#plot distribution
plot_pre <- data_pre %>%
group_by(resp, excl_instr) %>%
summarise(n = n()) %>%
group_by(excl_instr) %>%
mutate(freq = n / sum(n))
## `summarise()` has grouped output by 'resp'. You can override using the
## `.groups` argument.
ggplot(plot_pre, aes(x = as.factor(resp), y = freq, fill = excl_instr)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Response Distribution - Pre Session", x = "Response (1–9)", y = "Relative Frequency", fill = "Exclude\nInstructions") +
theme_minimal()

#Post Session
data_post <- subset(data, session == "Post")
table_post <- table(data_post$resp, data_post$excl_instr)
chi_post <- chisq.test(table_post)
## Warning in chisq.test(table_post): Chi-squared approximation may be incorrect
print(table_post)
##
## no yes
## 1 34 3
## 2 91 18
## 3 195 31
## 4 396 59
## 5 497 72
## 6 663 98
## 7 837 103
## 8 950 84
## 9 585 36
print(chi_post)
##
## Pearson's Chi-squared test
##
## data: table_post
## X-squared = 37.886, df = 8, p-value = 7.903e-06
check_expected_frequencies(chi_post)
## [1] 94.44444
# it should be >80%
plot_post <- data_post %>%
group_by(resp, excl_instr) %>%
summarise(n = n()) %>%
group_by(excl_instr) %>%
mutate(freq = n / sum(n))
## `summarise()` has grouped output by 'resp'. You can override using the
## `.groups` argument.
ggplot(plot_post, aes(x = as.factor(resp), y = freq, fill = excl_instr)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Response Distribution - Post Session", x = "Response (1–9)", y = "Relative Frequency", fill = "Exclude\nInstructions") +
theme_minimal()

#exclude data from participants not meeting the learning criterion, and from "exclusion instruction" participants
exclude_list= readRDS("exclude_list.rds")
exclude_list
## [1] "43423" "48888" "63018" "77337" "77623" "17202" "57393" "94372" "40242"
## [10] "89443"
data<-droplevels(data[!(data$sbj %in% exclude_list), ])
str(data)
## 'data.frame': 8064 obs. of 39 variables:
## $ trl : int 7 5 9 11 19 3 2 13 12 8 ...
## $ cnd : Factor w/ 2 levels "between","within": 2 2 2 2 2 2 2 2 2 2 ...
## $ dim : Factor w/ 2 levels "irrel","rel": 1 1 1 1 2 1 1 2 1 1 ...
## $ size1 : num 3 3 2.6 2.6 3 2.2 2.2 2.2 2.6 3 ...
## $ hue1 : num 0.1 -0.3 -0.3 0.1 0.1 0.1 -0.1 -0.3 0.3 0.3 ...
## $ size2 : num 3.4 3.4 3 3 3 2.6 2.6 2.2 3 3.4 ...
## $ hue2 : num 0.1 -0.3 -0.3 0.1 0.3 0.1 -0.1 -0.1 0.3 0.3 ...
## $ practice_trials.thisRepN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisTrialN: logi NA NA NA NA NA NA ...
## $ practice_trials.thisN : logi NA NA NA NA NA NA ...
## $ practice_trials.thisIndex : logi NA NA NA NA NA NA ...
## $ blocks.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisTrialN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ blocks.thisIndex : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisRepN : int 0 0 0 0 0 0 0 0 0 0 ...
## $ trials.thisTrialN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisN : int 0 1 2 3 4 5 6 7 8 9 ...
## $ trials.thisIndex : int 6 4 8 10 18 2 1 12 11 7 ...
## $ break_loop.thisRepN : logi NA NA NA NA NA NA ...
## $ break_loop.thisTrialN : logi NA NA NA NA NA NA ...
## $ break_loop.thisN : logi NA NA NA NA NA NA ...
## $ break_loop.thisIndex : logi NA NA NA NA NA NA ...
## $ thisRow.t : num 52.6 56.5 61 66.1 67.6 ...
## $ notes : logi NA NA NA NA NA NA ...
## $ slider_exp.response : int 9 8 6 7 8 4 3 4 2 3 ...
## $ slider_exp.rt : num 3.6 4.28 4.81 1.19 1.56 ...
## $ participant : int 81139 81139 81139 81139 81139 81139 81139 81139 81139 81139 ...
## $ session : Factor w/ 2 levels "Pre","Post": 2 2 2 2 2 2 2 2 2 2 ...
## $ group : Factor w/ 4 levels "1100","1600",..: 3 3 3 3 3 3 3 3 3 3 ...
## $ date : Factor w/ 112 levels "2025-03-18_11h13.00.672",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ expName : Factor w/ 1 level "SimilarityRatings": 1 1 1 1 1 1 1 1 1 1 ...
## $ psychopyVersion : Factor w/ 1 level "2023.2.3": 1 1 1 1 1 1 1 1 1 1 ...
## $ frameRate : num 60 60 60 60 60 ...
## $ expStart : Factor w/ 112 levels "2025-03-18 11h13.54.820981 +0200",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ sbj : Factor w/ 56 levels "341","1003","1206",..: 42 42 42 42 42 42 42 42 42 42 ...
## $ resp : int 9 8 6 7 8 4 3 4 2 3 ...
## $ block : num 1 1 1 1 1 1 1 1 1 1 ...
## $ excl_instr : Factor w/ 1 level "no": 1 1 1 1 1 1 1 1 1 1 ...
#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: 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 52 2.9523989 4.100911e-02 * 0.011222329
## 3 session 1 52 9.9460422 2.677392e-03 * 0.042344834
## 5 condition 2 104 43.2631437 2.128524e-14 * 0.317342741
## 4 group:session 3 52 0.6109458 6.109372e-01 0.008082404
## 6 group:condition 6 104 2.3650973 3.503680e-02 * 0.070838486
## 7 session:condition 2 104 5.5365083 5.189335e-03 * 0.015043348
## 8 group:session:condition 6 104 1.2724567 2.764522e-01 0.010420923
##
## $`Mauchly's Test for Sphericity`
## Effect W p p<.05
## 5 condition 0.1440179 3.464331e-22 *
## 6 group:condition 0.1440179 3.464331e-22 *
## 7 session:condition 0.5545809 2.958732e-07 *
## 8 group:session:condition 0.5545809 2.958732e-07 *
##
## $`Sphericity Corrections`
## Effect GGe p[GG] p[GG]<.05 HFe
## 5 condition 0.5387983 7.893205e-09 * 0.5411431
## 6 group:condition 0.5387983 7.629619e-02 0.5411431
## 7 session:condition 0.6918409 1.278300e-02 * 0.7046654
## 8 group:session:condition 0.6918409 2.883520e-01 0.7046654
## p[HF] p[HF]<.05
## 5 7.392858e-09 *
## 6 7.598765e-02
## 7 1.231053e-02 *
## 8 2.879117e-01
#report GG corrections
#2*0.5387983
#104*0.5387983
#2*0.6918409
#104*0.6918409
#6*0.5387983
#104*0.5387983
#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) 4.621 1 6.066 52 39.6142 6.591e-08 ***
## group 1.033 3 6.066 52 2.9524 0.041009 *
## session 4.025 1 21.046 52 9.9460 0.002677 **
## group:session 0.742 3 21.046 52 0.6109 0.610937
## condition 42.320 2 50.866 104 43.2631 2.129e-14 ***
## group:condition 6.941 6 50.866 104 2.3651 0.035037 *
## session:condition 1.390 2 13.059 104 5.5365 0.005189 **
## group:session:condition 0.959 6 13.059 104 1.2725 0.276452
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Mauchly Tests for Sphericity
##
## Test statistic p-value
## condition 0.14402 0.0000e+00
## group:condition 0.14402 0.0000e+00
## session:condition 0.55458 2.9587e-07
## group:session:condition 0.55458 2.9587e-07
##
##
## Greenhouse-Geisser and Huynh-Feldt Corrections
## for Departure from Sphericity
##
## GG eps Pr(>F[GG])
## condition 0.53880 7.893e-09 ***
## group:condition 0.53880 0.07630 .
## session:condition 0.69184 0.01278 *
## group:session:condition 0.69184 0.28835
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## HF eps Pr(>F[HF])
## condition 0.5411431 7.392858e-09
## group:condition 0.5411431 7.598765e-02
## session:condition 0.7046654 1.231053e-02
## group:session:condition 0.7046654 2.879117e-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.3334 0.188 52 1.769 0.0827
##
## condition = within_irrel, group = 1100:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.0924 0.165 52 0.561 0.5775
##
## condition = within_rel, group = 1100:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1196 0.176 52 0.679 0.5002
##
## condition = between, group = 1600:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.2548 0.188 52 1.352 0.1822
##
## condition = within_irrel, group = 1600:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.2383 0.165 52 -1.446 0.1543
##
## condition = within_rel, group = 1600:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.2332 0.176 52 1.324 0.1911
##
## condition = between, group = 600:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3594 0.188 52 1.907 0.0621
##
## condition = within_irrel, group = 600:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3455 0.165 52 2.096 0.0410
##
## condition = within_rel, group = 600:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.2638 0.176 52 1.498 0.1401
##
## condition = between, group = RD:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.4692 0.188 52 2.490 0.0160
##
## condition = within_irrel, group = RD:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.0160 0.165 52 -0.097 0.9232
##
## condition = within_rel, group = RD:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.4099 0.176 52 2.327 0.0239
Similarity Ratings Plot by Group, Block, Session, and Pair Type
temp<-aggregate(z_resp~block+session+group+condition, data=data, FUN=mean)
temp2<-aggregate(z_resp~block+session+group+condition, data=data, FUN=se)
temp$se<-1.96*temp2$z_resp
par(mfrow=c(3,1), oma = c(0, 0, 1.5, 0))
###Between Relevant
cond="between"
main="Between-Category Relevant Dimension"
xlab="Block"
ylab="Standardized Similarity Ratings"
cex=1.5
offset=.03
col=c("grey70","grey60","grey50", "grey40" )
axis=c(1.1,2.1,3.1)
ylim=c(-1, 1)
#600 Pre
pch=c(0,15)
plotCI(x=1:3, y=temp[temp$session=="Pre" & temp$group=="600" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="600" & temp$condition==cond,]$se, bty="n", las=1, xaxt="n", xlab=xlab, ylab=ylab, col=col[1], lty=2, cex=cex, pch=pch[1], xlim=c(1,3.3), gap=0, main=main, ylim=ylim)
axis(side=1, at=axis, labels=c(1,2,3))
#600 Post
plotCI(x=1:3+offset, y=temp[temp$session=="Post" & temp$group=="600" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="600" & temp$condition==cond,]$se, pch=pch[2], col=col[1], add=T, cex=cex, gap=0)
mtext("Similarity Ratings by Pair Type, Group, Session, and Block", outer = TRUE, cex = 1, font = 2)
#1100 Pre
pch=c(21,16)
plotCI(x=1:3+2*offset, y=temp[temp$session=="Pre" & temp$group=="1100" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="1100" & temp$condition==cond,]$se, pch=pch[1], col=col[2], add=T, cex=cex, lty=2, gap=0)
#1100 Post
plotCI(x=1:3+3*offset, y=temp[temp$session=="Post" & temp$group=="1100" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="1100" & temp$condition==cond,]$se, pch=pch[2], col=col[2], add=T, cex=cex, gap=0)
#1600 Pre
pch=c(2,17)
plotCI(x=1:3+4*offset, y=temp[temp$session=="Pre" & temp$group=="1600"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="1600"& temp$condition==cond,]$se, pch=pch[1], col=col[3], add=T, cex=cex, lty=2, gap=0)
#1600 Post
plotCI(x=1:3+5*offset, y=temp[temp$session=="Post" & temp$group=="1600"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="1600"& temp$condition==cond,]$se, pch=pch[2], col=col[3], add=T, cex=cex, gap=0)
#RD Pre
pch=c(23,18)
plotCI(x=1:3+6*offset, y=temp[temp$session=="Pre" & temp$group=="RD"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="RD" & temp$condition==cond,]$se, pch=pch[1], col=col[4], add=T, cex=cex, lty=2, gap=0)
#RD Post
plotCI(x=1:3+7*offset, y=temp[temp$session=="Post" & temp$group=="RD" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="RD" & temp$condition==cond,]$se, pch=pch[2], col=col[4], add=T, cex=cex, gap=0)
legend(x=2.3, y=1, legend=c("600 ms - Pre", "600 ms - Post", "1100 ms - Pre", "1100 ms - Post", "1600 ms - Pre", "1600 ms - Post","RD - Pre", "RD - Post"), col=c("grey70", "grey70", "grey60", "grey60", "grey50", "grey50", "grey40", "grey40"), lty=c(2,1,2,1,2,1,2,1), pch=c(0,15, 21,16, 2,17, 23,18 ), bty="n", seg.len=2, lwd=1, pt.cex=1.5)
###Within Relevant
cond="within_rel"
main="Within-Category Relevant Dimension"
ylim=c(-1, 1)
#600 Pre
pch=c(0,15)
plotCI(x=1:3, y=temp[temp$session=="Pre" & temp$group=="600" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="600" & temp$condition==cond,]$se, bty="n", las=1, xaxt="n", xlab=xlab, ylab=ylab, col=col[1], lty=2, cex=cex, pch=pch[1], xlim=c(1,3.3), gap=0, main=main, ylim=ylim)
axis(side=1, at=axis, labels=c(1,2,3))
#600 Post
plotCI(x=1:3+offset, y=temp[temp$session=="Post" & temp$group=="600" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="600" & temp$condition==cond,]$se, pch=pch[2], col=col[1], add=T, cex=cex, gap=0)
#1100 Pre
pch=c(21,16)
plotCI(x=1:3+2*offset, y=temp[temp$session=="Pre" & temp$group=="1100" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="1100" & temp$condition==cond,]$se, pch=pch[1], col=col[2], add=T, cex=cex, lty=2, gap=0)
#1100 Post
plotCI(x=1:3+3*offset, y=temp[temp$session=="Post" & temp$group=="1100" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="1100" & temp$condition==cond,]$se, pch=pch[2], col=col[2], add=T, cex=cex, gap=0)
#1600 Pre
pch=c(2,17)
plotCI(x=1:3+4*offset, y=temp[temp$session=="Pre" & temp$group=="1600"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="1600"& temp$condition==cond,]$se, pch=pch[1], col=col[3], add=T, cex=cex, lty=2, gap=0)
#1600 Post
plotCI(x=1:3+5*offset, y=temp[temp$session=="Post" & temp$group=="1600"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="1600"& temp$condition==cond,]$se, pch=pch[2], col=col[3], add=T, cex=cex, gap=0)
#RD Pre
pch=c(23,18)
plotCI(x=1:3+6*offset, y=temp[temp$session=="Pre" & temp$group=="RD"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="RD" & temp$condition==cond,]$se, pch=pch[1], col=col[4], add=T, cex=cex, lty=2, gap=0)
#RD Post
plotCI(x=1:3+7*offset, y=temp[temp$session=="Post" & temp$group=="RD" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="RD" & temp$condition==cond,]$se, pch=pch[2], col=col[4], add=T, cex=cex, gap=0)
legend(x=2.3, y=1, legend=c("600 ms - Pre", "600 ms - Post", "1100 ms - Pre", "1100 ms - Post", "1600 ms - Pre", "1600 ms - Post","RD - Pre", "RD - Post"), col=c("grey70", "grey70", "grey60", "grey60", "grey50", "grey50", "grey40", "grey40"), lty=c(2,1,2,1,2,1,2,1), pch=c(0,15, 21,16, 2,17, 23,18 ), bty="n", seg.len=2, lwd=1, pt.cex=1.5)
###Within Irrelevant
cond="within_irrel"
main="Within-Category Irrelevant Dimension"
ylim=c(-1, 1)
#600 Pre
pch=c(0,15)
plotCI(x=1:3, y=temp[temp$session=="Pre" & temp$group=="600" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="600" & temp$condition==cond,]$se, bty="n", las=1, xaxt="n", xlab=xlab, ylab=ylab, col=col[1], lty=2, cex=cex, pch=pch[1], xlim=c(1,3.3), gap=0, main=main, ylim=ylim)
axis(side=1, at=axis, labels=c(1,2,3))
#600 Post
plotCI(x=1:3+offset, y=temp[temp$session=="Post" & temp$group=="600" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="600" & temp$condition==cond,]$se, pch=pch[2], col=col[1], add=T, cex=cex, gap=0)
#1100 Pre
pch=c(21,16)
plotCI(x=1:3+2*offset, y=temp[temp$session=="Pre" & temp$group=="1100" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="1100" & temp$condition==cond,]$se, pch=pch[1], col=col[2], add=T, cex=cex, lty=2, gap=0)
#1100 Post
plotCI(x=1:3+3*offset, y=temp[temp$session=="Post" & temp$group=="1100" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="1100" & temp$condition==cond,]$se, pch=pch[2], col=col[2], add=T, cex=cex, gap=0)
#1600 Pre
pch=c(2,17)
plotCI(x=1:3+4*offset, y=temp[temp$session=="Pre" & temp$group=="1600"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="1600"& temp$condition==cond,]$se, pch=pch[1], col=col[3], add=T, cex=cex, lty=2, gap=0)
#1600 Post
plotCI(x=1:3+5*offset, y=temp[temp$session=="Post" & temp$group=="1600"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="1600"& temp$condition==cond,]$se, pch=pch[2], col=col[3], add=T, cex=cex, gap=0)
#RD Pre
pch=c(23,18)
plotCI(x=1:3+6*offset, y=temp[temp$session=="Pre" & temp$group=="RD"& temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Pre" & temp$group=="RD" & temp$condition==cond,]$se, pch=pch[1], col=col[4], add=T, cex=cex, lty=2, gap=0)
#RD Post
plotCI(x=1:3+7*offset, y=temp[temp$session=="Post" & temp$group=="RD" & temp$condition==cond,]$z_resp, uiw=temp[temp$session=="Post" & temp$group=="RD" & temp$condition==cond,]$se, pch=pch[2], col=col[4], add=T, cex=cex, gap=0)
legend(x=2.3, y=1, legend=c("600 ms - Pre", "600 ms - Post", "1100 ms - Pre", "1100 ms - Post", "1600 ms - Pre", "1600 ms - Post","RD - Pre", "RD - Post"), col=c("grey70", "grey70", "grey60", "grey60", "grey50", "grey50", "grey40", "grey40"), lty=c(2,1,2,1,2,1,2,1), pch=c(0,15, 21,16, 2,17, 23,18 ), bty="n", seg.len=2, lwd=1, pt.cex=1.5)

par(mfrow=c(1,1), oma=c(0,0,0,0))
Exploratory Analysis, Similarity Ratings by Group, Block, Session,
and Pair Type
data$block <- as.factor(data$block)
ezANOVA(data=data, dv=z_resp,wid=sbj, within=.(session,condition, block), between=group, type=3)
## 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
## 2 group 3 52 2.9523989 4.100911e-02 *
## 3 session 1 52 9.9460422 2.677392e-03 *
## 5 condition 2 104 43.2631437 2.128524e-14 *
## 7 block 2 104 0.6129252 5.437090e-01
## 4 group:session 3 52 0.6109458 6.109372e-01
## 6 group:condition 6 104 2.3650973 3.503680e-02 *
## 8 group:block 6 104 0.2428507 9.611632e-01
## 9 session:condition 2 104 5.5365083 5.189335e-03 *
## 11 session:block 2 104 3.5714495 3.161434e-02 *
## 13 condition:block 4 208 0.9025758 4.633621e-01
## 10 group:session:condition 6 104 1.2724567 2.764522e-01
## 12 group:session:block 6 104 0.7441410 6.153614e-01
## 14 group:condition:block 12 208 1.4465721 1.470440e-01
## 15 session:condition:block 4 208 1.9715923 1.000753e-01
## 16 group:session:condition:block 12 208 0.7801827 6.705470e-01
## ges
## 2 0.008011061
## 3 0.030502595
## 5 0.248554744
## 7 0.001015389
## 4 0.005764387
## 6 0.051455817
## 8 0.001206708
## 9 0.010750584
## 11 0.005693405
## 13 0.001193324
## 10 0.007437252
## 12 0.003566417
## 14 0.005711719
## 15 0.001893136
## 16 0.002246614
##
## $`Mauchly's Test for Sphericity`
## Effect W p p<.05
## 5 condition 0.1440179 3.464331e-22 *
## 6 group:condition 0.1440179 3.464331e-22 *
## 7 block 0.8092639 4.532098e-03 *
## 8 group:block 0.8092639 4.532098e-03 *
## 9 session:condition 0.5545809 2.958732e-07 *
## 10 group:session:condition 0.5545809 2.958732e-07 *
## 11 session:block 0.5208363 5.968735e-08 *
## 12 group:session:block 0.5208363 5.968735e-08 *
## 13 condition:block 0.4678159 1.560376e-05 *
## 14 group:condition:block 0.4678159 1.560376e-05 *
## 15 session:condition:block 0.6275370 5.208049e-03 *
## 16 group:session:condition:block 0.6275370 5.208049e-03 *
##
## $`Sphericity Corrections`
## Effect GGe p[GG] p[GG]<.05 HFe
## 5 condition 0.5387983 7.893205e-09 * 0.5411431
## 6 group:condition 0.5387983 7.629619e-02 0.5411431
## 7 block 0.8398166 5.165903e-01 0.8646654
## 8 group:block 0.8398166 9.432015e-01 0.8646654
## 9 session:condition 0.6918409 1.278300e-02 * 0.7046654
## 10 group:session:condition 0.6918409 2.883520e-01 0.7046654
## 11 session:block 0.6760577 5.031385e-02 0.6877100
## 12 group:session:block 0.6760577 5.669082e-01 0.6877100
## 13 condition:block 0.7368102 4.400228e-01 0.7859077
## 14 group:condition:block 0.7368102 1.742531e-01 0.7859077
## 15 session:condition:block 0.7887693 1.170840e-01 0.8456309
## 16 group:session:condition:block 0.7887693 6.410691e-01 0.8456309
## p[HF] p[HF]<.05
## 5 7.392858e-09 *
## 6 7.598765e-02
## 7 5.211054e-01
## 8 9.464942e-01
## 9 1.231053e-02 *
## 10 2.879117e-01
## 11 4.948625e-02 *
## 12 5.689851e-01
## 13 4.450372e-01
## 14 1.687368e-01
## 15 1.122401e-01
## 16 6.496021e-01
#report GG corrections
#0.5387983*2
#0.5387983*104
#0.6918409*2
#0.6918409*104
#0.5387983*6
#0.5387983*104
#0.6760577*2
#0.6760577*104
#0.8398166*2
#0.8398166*104
levels(data$group)
## [1] "1100" "1600" "600" "RD"
levels(data$condition)
## [1] "between" "within_irrel" "within_rel"
#to facilitate post-hoc comparisons
data$group <- factor(data$group, levels = c("600", "1100", "1600", "RD"))
data$condition <- factor(data$condition, levels = c("between", "within_rel", "within_irrel"))
# post-hoc comparisons
aov_model <- aov_ez(id = "sbj", dv = "z_resp", data = data, within = c("session", "condition", "block"), 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) 13.864 1 18.198 52 39.6142 6.591e-08
## group 3.100 3 18.198 52 2.9524 0.041009
## session 12.076 1 63.137 52 9.9460 0.002677
## group:session 2.225 3 63.137 52 0.6109 0.610937
## condition 126.959 2 152.598 104 43.2631 2.129e-14
## group:condition 20.822 6 152.598 104 2.3651 0.035037
## block 0.390 2 33.099 104 0.6129 0.543709
## group:block 0.464 6 33.099 104 0.2429 0.961163
## session:condition 4.171 2 39.177 104 5.5365 0.005189
## group:session:condition 2.876 6 39.177 104 1.2725 0.276452
## session:block 2.198 2 32.000 104 3.5714 0.031614
## group:session:block 1.374 6 32.000 104 0.7441 0.615361
## condition:block 0.459 4 26.420 208 0.9026 0.463362
## group:condition:block 2.205 12 26.420 208 1.4466 0.147044
## session:condition:block 0.728 4 19.201 208 1.9716 0.100075
## group:session:condition:block 0.864 12 19.201 208 0.7802 0.670547
##
## (Intercept) ***
## group *
## session **
## group:session
## condition ***
## group:condition *
## block
## group:block
## session:condition **
## group:session:condition
## session:block *
## group:session:block
## condition:block
## group:condition:block
## session:condition:block
## group:session:condition:block
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
##
## Mauchly Tests for Sphericity
##
## Test statistic p-value
## condition 0.14402 0.0000000
## group:condition 0.14402 0.0000000
## block 0.80926 0.0045321
## group:block 0.80926 0.0045321
## session:condition 0.55458 0.0000003
## group:session:condition 0.55458 0.0000003
## session:block 0.52084 0.0000001
## group:session:block 0.52084 0.0000001
## condition:block 0.46782 0.0000156
## group:condition:block 0.46782 0.0000156
## session:condition:block 0.62754 0.0052080
## group:session:condition:block 0.62754 0.0052080
##
##
## Greenhouse-Geisser and Huynh-Feldt Corrections
## for Departure from Sphericity
##
## GG eps Pr(>F[GG])
## condition 0.53880 7.893e-09 ***
## group:condition 0.53880 0.07630 .
## block 0.83982 0.51659
## group:block 0.83982 0.94320
## session:condition 0.69184 0.01278 *
## group:session:condition 0.69184 0.28835
## session:block 0.67606 0.05031 .
## group:session:block 0.67606 0.56691
## condition:block 0.73681 0.44002
## group:condition:block 0.73681 0.17425
## session:condition:block 0.78877 0.11708
## group:session:condition:block 0.78877 0.64107
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## HF eps Pr(>F[HF])
## condition 0.5411431 7.392858e-09
## group:condition 0.5411431 7.598765e-02
## block 0.8646654 5.211054e-01
## group:block 0.8646654 9.464942e-01
## session:condition 0.7046654 1.231053e-02
## group:session:condition 0.7046654 2.879117e-01
## session:block 0.6877100 4.948625e-02
## group:session:block 0.6877100 5.689851e-01
## condition:block 0.7859077 4.450372e-01
## group:condition:block 0.7859077 1.687368e-01
## session:condition:block 0.8456309 1.122401e-01
## group:session:condition:block 0.8456309 6.496021e-01
emms <- emmeans(aov_model, ~ session |condition*group*block)
comparisons <- contrast(emms, method = "pairwise", adjust = "bonferroni")
summary(comparisons)
## condition = between, group = 600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.54965 0.269 52 2.047 0.0457
##
## condition = within_rel, group = 600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.54646 0.247 52 2.211 0.0315
##
## condition = within_irrel, group = 600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.42292 0.235 52 1.797 0.0781
##
## condition = between, group = 1100, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.37505 0.269 52 1.397 0.1684
##
## condition = within_rel, group = 1100, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.05402 0.247 52 -0.219 0.8279
##
## condition = within_irrel, group = 1100, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.08303 0.235 52 0.353 0.7256
##
## condition = between, group = 1600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.36251 0.269 52 1.350 0.1829
##
## condition = within_rel, group = 1600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.42490 0.247 52 1.719 0.0916
##
## condition = within_irrel, group = 1600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.34575 0.235 52 -1.469 0.1477
##
## condition = between, group = RD, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.72529 0.269 52 2.701 0.0093
##
## condition = within_rel, group = RD, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.60146 0.247 52 2.433 0.0184
##
## condition = within_irrel, group = RD, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.05618 0.235 52 0.239 0.8122
##
## condition = between, group = 600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.44392 0.221 52 2.010 0.0496
##
## condition = within_rel, group = 600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.24933 0.206 52 1.210 0.2316
##
## condition = within_irrel, group = 600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.43657 0.176 52 2.477 0.0165
##
## condition = between, group = 1100, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.36494 0.221 52 1.653 0.1044
##
## condition = within_rel, group = 1100, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.30781 0.206 52 1.494 0.1412
##
## condition = within_irrel, group = 1100, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.12440 0.176 52 0.706 0.4834
##
## condition = between, group = 1600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.27786 0.221 52 1.258 0.2139
##
## condition = within_rel, group = 1600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.19137 0.206 52 0.929 0.3572
##
## condition = within_irrel, group = 1600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.19975 0.176 52 -1.133 0.2622
##
## condition = between, group = RD, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.50743 0.221 52 2.298 0.0256
##
## condition = within_rel, group = RD, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.41872 0.206 52 2.033 0.0472
##
## condition = within_irrel, group = RD, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.08561 0.176 52 -0.486 0.6292
##
## condition = between, group = 600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.08455 0.200 52 0.423 0.6740
##
## condition = within_rel, group = 600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.00434 0.172 52 -0.025 0.9799
##
## condition = within_irrel, group = 600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.17692 0.204 52 0.869 0.3890
##
## condition = between, group = 1100, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.26032 0.200 52 1.302 0.1986
##
## condition = within_rel, group = 1100, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.10487 0.172 52 0.611 0.5440
##
## condition = within_irrel, group = 1100, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.06980 0.204 52 0.343 0.7332
##
## condition = between, group = 1600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.12409 0.200 52 0.621 0.5374
##
## condition = within_rel, group = 1600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.08341 0.172 52 0.486 0.6292
##
## condition = within_irrel, group = 1600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.16937 0.204 52 -0.832 0.4094
##
## condition = between, group = RD, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.17490 0.200 52 0.875 0.3856
##
## condition = within_rel, group = RD, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.20938 0.172 52 1.219 0.2282
##
## condition = within_irrel, group = RD, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.01844 0.204 52 -0.091 0.9282
Correlation Analyses, Accuracy ~ Perceptual Change
# we average all ratings for specific pairs
dat<- aggregate(z_resp~sbj+ session + size1+hue1+size2+hue2+ group, data=data, FUN=mean)
#we tranform data
wide_dat <- reshape(dat, timevar = "session", idvar = c("sbj", "size1","hue1", "size2", "hue2", "group"), direction = "wide")
# calculate diff between Post and Pre for each pair
wide_dat$diff <- wide_dat$z_resp.Post - wide_dat$z_resp.Pre
#average across pairs
d_sim<-aggregate(diff~sbj+group, data=wide_dat, FUN=mean)
#load average accuracy
d_cat<-read.csv("d_cat.csv", header=T)
d_cat$sbj<-as.factor(d_cat$sbj)
#merge the two data-sets
d_cor<-left_join(d_cat, d_sim, by = "sbj")
cor.test(d_cor$acc, d_cor$diff)
##
## Pearson's product-moment correlation
##
## data: d_cor$acc and d_cor$diff
## t = -0.96544, df = 54, p-value = 0.3386
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.3801426 0.1373437
## sample estimates:
## cor
## -0.1302603
#by group
#600
cor.test(d_cor[d_cor$group.x=="600",]$acc, d_cor[d_cor$group.x=="600",]$diff)
##
## Pearson's product-moment correlation
##
## data: d_cor[d_cor$group.x == "600", ]$acc and d_cor[d_cor$group.x == "600", ]$diff
## t = -1.4543, df = 12, p-value = 0.1715
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.7613092 0.1805787
## sample estimates:
## cor
## -0.3870882
#ns
#1100
cor.test(d_cor[d_cor$group.x=="1100",]$acc, d_cor[d_cor$group.x=="1100",]$diff)
##
## Pearson's product-moment correlation
##
## data: d_cor[d_cor$group.x == "1100", ]$acc and d_cor[d_cor$group.x == "1100", ]$diff
## t = 0.18303, df = 12, p-value = 0.8578
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.4915794 0.5674556
## sample estimates:
## cor
## 0.05276149
#ns
#1600
cor.test(d_cor[d_cor$group.x=="1600",]$acc, d_cor[d_cor$group.x=="1600",]$diff)
##
## Pearson's product-moment correlation
##
## data: d_cor[d_cor$group.x == "1600", ]$acc and d_cor[d_cor$group.x == "1600", ]$diff
## t = -2.0833, df = 12, p-value = 0.05928
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.82135318 0.02093757
## sample estimates:
## cor
## -0.5153672
# p = 0.059
#RD
cor.test(d_cor[d_cor$group.x=="RD",]$acc, d_cor[d_cor$group.x=="RD",]$diff)
##
## Pearson's product-moment correlation
##
## data: d_cor[d_cor$group.x == "RD", ]$acc and d_cor[d_cor$group.x == "RD", ]$diff
## t = -0.50917, df = 12, p-value = 0.6199
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.6275794 0.4173593
## sample estimates:
## cor
## -0.145423
#ns
#Correlation analysis only for those groups (600 and RD) that exhibited perceptual change
cor.test(d_cor[d_cor$group.x=="RD" | d_cor$group.x=="600",]$acc, d_cor[d_cor$group.x=="RD" | d_cor$group.x=="600",]$diff)
##
## Pearson's product-moment correlation
##
## data: d_cor[d_cor$group.x == "RD" | d_cor$group.x == "600", ]$acc and d_cor[d_cor$group.x == "RD" | d_cor$group.x == "600", ]$diff
## t = -1.0761, df = 26, p-value = 0.2917
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.5381210 0.1804798
## sample estimates:
## cor
## -0.2065014
#ns
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 farver_2.1.1
## [19] compiler_4.3.1 stringr_1.5.0 munsell_0.5.0
## [22] codetools_0.2-19 lmerTest_3.1-3 htmltools_0.5.6
## [25] sass_0.4.7 yaml_2.3.7 pillar_1.9.0
## [28] nloptr_2.0.3 jquerylib_0.1.4 tidyr_1.3.0
## [31] MASS_7.3-60 cachem_1.0.8 multcomp_1.4-25
## [34] boot_1.3-28.1 abind_1.4-5 nlme_3.1-162
## [37] gtools_3.9.4 tidyselect_1.2.0 digest_0.6.33
## [40] mvtnorm_1.2-3 stringi_1.7.12 reshape2_1.4.4
## [43] purrr_1.0.2 labeling_0.4.3 splines_4.3.1
## [46] fastmap_1.1.1 grid_4.3.1 colorspace_2.1-0
## [49] cli_3.6.1 magrittr_2.0.3 survival_3.5-5
## [52] utf8_1.2.3 TH.data_1.1-2 broom_1.0.5
## [55] withr_2.5.0 scales_1.2.1 backports_1.4.1
## [58] estimability_1.4.1 rmarkdown_2.24 zoo_1.8-12
## [61] evaluate_0.21 knitr_1.44 mgcv_1.8-42
## [64] rlang_1.1.1 Rcpp_1.0.11 xtable_1.8-4
## [67] glue_1.6.2 rstudioapi_0.15.0 minqa_1.2.5
## [70] jsonlite_1.8.7 R6_2.5.1 plyr_1.8.8