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 ...
#exclude five participants for not meeting the learning criterion:
data <- droplevels( data[!(data$sbj %in% c("77623", "77337", "48888", "43423", "63018")), ])
str(data)
## 'data.frame': 8784 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/ 122 levels "2025-02-25_13h08.44.108",..: 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/ 122 levels "2025-02-25 13h09.40.421447 +0200",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ sbj : Factor w/ 61 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 5 first sbjs (instructions: we will delete your data)
data$excl_instr<-"no"
#For the first 5 participants, we need to register that the instructions were different.
#These 5 participants are: "17202" "40242" "57393" "89443" "94372"
data[data$sbj=="17202" | data$sbj=="40242" | data$sbj=="57393" | data$sbj=="89443" | data$sbj=="94372",]$excl_instr<-"yes"
data$excl_instr<-as.factor(data$excl_instr)
str(data)
## 'data.frame': 8784 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/ 122 levels "2025-02-25_13h08.44.108",..: 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/ 122 levels "2025-02-25 13h09.40.421447 +0200",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ sbj : Factor w/ 61 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")
table_sim<-table(data$resp, data$excl_instr)
chi_sim<-chisq.test(table_sim)
## Warning in chisq.test(table_sim): Chi-squared approximation may be incorrect
print(chi_sim)
##
## Pearson's Chi-squared test
##
## data: table_sim
## X-squared = 18.417, df = 8, p-value = 0.01831
#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_sim)
## [1] 94.44444
# it should be >80%
#plot distribution
plot_sim <- data %>%
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_sim, 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()

#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
#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.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
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: 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
## 2 group 3 57 2.9180733 4.179359e-02 *
## 3 session 1 57 13.1225571 6.220974e-04 *
## 5 condition 2 114 42.3330979 1.780369e-14 *
## 7 block 2 114 0.5310578 5.894301e-01
## 4 group:session 3 57 0.8059441 4.957776e-01
## 6 group:condition 6 114 2.3418151 3.602935e-02 *
## 8 group:block 6 114 0.4024683 8.760869e-01
## 9 session:condition 2 114 10.0766925 9.338633e-05 *
## 11 session:block 2 114 4.3105338 1.568073e-02 *
## 13 condition:block 4 228 0.7182833 5.802102e-01
## 10 group:session:condition 6 114 0.8783103 5.132696e-01
## 12 group:session:block 6 114 0.8749942 5.156894e-01
## 14 group:condition:block 12 228 1.3023070 2.180803e-01
## 15 session:condition:block 4 228 1.4450889 2.199765e-01
## 16 group:session:condition:block 12 228 0.7286911 7.226568e-01
## ges
## 2 0.0071402833
## 3 0.0356606858
## 5 0.2253351227
## 7 0.0007758908
## 4 0.0067673479
## 6 0.0460504858
## 8 0.0017623120
## 9 0.0207109704
## 11 0.0062710347
## 13 0.0008335078
## 10 0.0054997847
## 12 0.0038282549
## 14 0.0045169426
## 15 0.0012221587
## 16 0.0018476754
##
## $`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 block 0.8123173 2.967017e-03 *
## 8 group:block 0.8123173 2.967017e-03 *
## 9 session:condition 0.4552354 2.695317e-10 *
## 10 group:session:condition 0.4552354 2.695317e-10 *
## 11 session:block 0.5534166 6.389427e-08 *
## 12 group:session:block 0.5534166 6.389427e-08 *
## 13 condition:block 0.5024261 1.660983e-05 *
## 14 group:condition:block 0.5024261 1.660983e-05 *
## 15 session:condition:block 0.6767251 1.013030e-02 *
## 16 group:session:condition:block 0.6767251 1.013030e-02 *
##
## $`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 block 0.8419757 5.591576e-01 0.8647507
## 8 group:block 0.8419757 8.477849e-01 0.8647507
## 9 session:condition 0.6473478 9.223859e-04 * 0.6560627
## 10 group:session:condition 0.6473478 4.786980e-01 0.6560627
## 11 session:block 0.6912840 2.903417e-02 * 0.7029177
## 12 group:session:block 0.6912840 4.859481e-01 0.7029177
## 13 condition:block 0.7473196 5.418708e-01 0.7932598
## 14 group:condition:block 0.7473196 2.391275e-01 0.7932598
## 15 session:condition:block 0.8156627 2.285582e-01 0.8710596
## 16 group:session:condition:block 0.8156627 6.938578e-01 0.8710596
## p[HF] p[HF]<.05
## 5 6.525744e-09 *
## 6 7.708394e-02
## 7 5.638393e-01
## 8 8.523170e-01
## 9 8.713289e-04 *
## 10 4.797683e-01
## 11 2.836804e-02 *
## 12 4.872965e-01
## 13 5.496685e-01
## 14 2.351212e-01
## 15 2.260314e-01
## 16 7.030774e-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.532 1 19.982 57 38.5996 6.430e-08
## group 3.069 3 19.982 57 2.9181 0.0417936
## session 15.780 1 68.545 57 13.1226 0.0006221
## group:session 2.908 3 68.545 57 0.8059 0.4957776
## condition 124.129 2 167.135 114 42.3331 1.780e-14
## group:condition 20.600 6 167.135 114 2.3418 0.0360293
## block 0.331 2 35.565 114 0.5311 0.5894301
## group:block 0.753 6 35.565 114 0.4025 0.8760869
## session:condition 9.025 2 51.051 114 10.0767 9.339e-05
## group:session:condition 2.360 6 51.051 114 0.8783 0.5132696
## session:block 2.693 2 35.610 114 4.3105 0.0156807
## group:session:block 1.640 6 35.610 114 0.8750 0.5156894
## condition:block 0.356 4 28.249 228 0.7183 0.5802102
## group:condition:block 1.936 12 28.249 228 1.3023 0.2180803
## session:condition:block 0.522 4 20.597 228 1.4451 0.2199765
## group:session:condition:block 0.790 12 20.597 228 0.7287 0.7226568
##
## (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.14645 0.0000000
## group:condition 0.14645 0.0000000
## block 0.81232 0.0029670
## group:block 0.81232 0.0029670
## session:condition 0.45524 0.0000000
## group:session:condition 0.45524 0.0000000
## session:block 0.55342 0.0000001
## group:session:block 0.55342 0.0000001
## condition:block 0.50243 0.0000166
## group:condition:block 0.50243 0.0000166
## session:condition:block 0.67673 0.0101303
## group:session:condition:block 0.67673 0.0101303
##
##
## 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 .
## block 0.84198 0.5591576
## group:block 0.84198 0.8477849
## session:condition 0.64735 0.0009224 ***
## group:session:condition 0.64735 0.4786980
## session:block 0.69128 0.0290342 *
## group:session:block 0.69128 0.4859481
## condition:block 0.74732 0.5418708
## group:condition:block 0.74732 0.2391275
## session:condition:block 0.81566 0.2285582
## group:session:condition:block 0.81566 0.6938578
## ---
## 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
## block 0.8647507 5.638393e-01
## group:block 0.8647507 8.523170e-01
## session:condition 0.6560627 8.713289e-04
## group:session:condition 0.6560627 4.797683e-01
## session:block 0.7029177 2.836804e-02
## group:session:block 0.7029177 4.872965e-01
## condition:block 0.7932598 5.496685e-01
## group:condition:block 0.7932598 2.351212e-01
## session:condition:block 0.8710596 2.260314e-01
## group:session:condition:block 0.8710596 7.030774e-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.6512 0.254 57 2.564 0.0130
##
## condition = within_rel, group = 600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.6175 0.237 57 2.604 0.0117
##
## condition = within_irrel, group = 600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3717 0.217 57 1.711 0.0925
##
## condition = between, group = 1100, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.4590 0.262 57 1.750 0.0856
##
## condition = within_rel, group = 1100, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.0494 0.245 57 0.202 0.8407
##
## condition = within_irrel, group = 1100, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.0593 0.224 57 0.264 0.7924
##
## condition = between, group = 1600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3661 0.262 57 1.395 0.1683
##
## condition = within_rel, group = 1600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.4243 0.245 57 1.733 0.0886
##
## condition = within_irrel, group = 1600, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.3643 0.224 57 -1.624 0.1099
##
## condition = between, group = RD, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.7265 0.262 57 2.769 0.0076
##
## condition = within_rel, group = RD, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.6357 0.245 57 2.595 0.0120
##
## condition = within_irrel, group = RD, block = X1:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.0183 0.224 57 -0.082 0.9351
##
## condition = between, group = 600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.5246 0.216 57 2.425 0.0185
##
## condition = within_rel, group = 600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3992 0.202 57 1.979 0.0527
##
## condition = within_irrel, group = 600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3946 0.163 57 2.425 0.0185
##
## condition = between, group = 1100, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.5131 0.223 57 2.297 0.0253
##
## condition = within_rel, group = 1100, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3781 0.208 57 1.814 0.0749
##
## condition = within_irrel, group = 1100, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1131 0.168 57 0.673 0.5038
##
## condition = between, group = 1600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.2871 0.223 57 1.285 0.2039
##
## condition = within_rel, group = 1600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1717 0.208 57 0.824 0.4134
##
## condition = within_irrel, group = 1600, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.2420 0.168 57 -1.440 0.1554
##
## condition = between, group = RD, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.5514 0.223 57 2.469 0.0166
##
## condition = within_rel, group = RD, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.4899 0.208 57 2.351 0.0222
##
## condition = within_irrel, group = RD, block = X2:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.1507 0.168 57 -0.897 0.3737
##
## condition = between, group = 600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1061 0.186 57 0.569 0.5716
##
## condition = within_rel, group = 600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.0912 0.168 57 0.544 0.5889
##
## condition = within_irrel, group = 600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.0421 0.202 57 0.209 0.8353
##
## condition = between, group = 1100, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.3065 0.193 57 1.592 0.1170
##
## condition = within_rel, group = 1100, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1705 0.173 57 0.984 0.3295
##
## condition = within_irrel, group = 1100, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.0589 0.208 57 -0.283 0.7783
##
## condition = between, group = 1600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1713 0.193 57 0.890 0.3774
##
## condition = within_rel, group = 1600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.1542 0.173 57 0.889 0.3775
##
## condition = within_irrel, group = 1600, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.2275 0.208 57 -1.092 0.2795
##
## condition = between, group = RD, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.2552 0.193 57 1.325 0.1903
##
## condition = within_rel, group = RD, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post 0.2733 0.173 57 1.577 0.1204
##
## condition = within_irrel, group = RD, block = X3:
## contrast estimate SE df t.ratio p.value
## Pre - Post -0.0573 0.208 57 -0.275 0.7842
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