# demographics 
min(tdata$Age)
## [1] 18
max(tdata$Age)
## [1] 79
mean(tdata$Age)
## [1] 35.60556
sd(tdata$Age)
## [1] 12.41158
# 1 = male, 2 = female, 3 = other
count(tdata$Sex)
##   x freq
## 1 1  299
## 2 2  416
## 3 3    4
## 4 4    1

Graphs

Interaction between number of effects and similarity of effects

The bars represent means and the error bars depict 95% bootstrapped CIs.

## Warning: package 'see' was built under R version 4.0.4
## Warning: `fun.y` is deprecated. Use `fun` instead.

## Warning: `fun.y` is deprecated. Use `fun` instead.

## Warning: `fun.y` is deprecated. Use `fun` instead.

Descriptive Stats

## : single-effect cause
## : joint presentation
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.80000000   0.77277778   0.01569476   0.03097056   0.04433861   0.21056735 
##     coef.var 
##   0.27248112 
## ------------------------------------------------------------ 
## : multiple-effects cause
## : joint presentation
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.60000000   0.60277778   0.01998495   0.03943641   0.07189168   0.26812624 
##     coef.var 
##   0.44481773 
## ------------------------------------------------------------ 
## : single-effect cause
## : separate presentation
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.70000000   0.66777778   0.01625479   0.03207567   0.04755928   0.21808090 
##     coef.var 
##   0.32657706 
## ------------------------------------------------------------ 
## : multiple-effects cause
## : separate presentation
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.60000000   0.60166667   0.01649775   0.03255509   0.04899162   0.22134051 
##     coef.var 
##   0.36787896

Test

library(afex)
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'KR', 'S', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: library('emmeans') now needs to be called explicitly!
## - Get and set global package options with: afex_options()
## - Set orthogonal sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
## 
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
## 
##     lmer
library(emmeans)

a1 <- aov_car(strength_rating ~ learning_format*target_cause + Error(sID), tdata_sub)
## Contrasts set to contr.sum for the following variables: learning_format, target_cause
a1
## Anova Table (Type 3 tests)
## 
## Response: strength_rating
##                         Effect     df  MSE         F  ges p.value
## 1              learning_format 1, 716 0.05   9.52 ** .013    .002
## 2                 target_cause 1, 716 0.05 47.16 *** .062   <.001
## 3 learning_format:target_cause 1, 716 0.05   9.13 ** .013    .003
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
############### 
# a conditional analysis 

# Means for the different conditions

ls2 <- lsmeans(a1, c("target_cause"), by = "learning_format") # group means by between-condition
ls2
## learning_format = joint presentation:
##  target_cause           lsmean     SE  df lower.CL upper.CL
##  single-effect cause     0.773 0.0172 716    0.739    0.807
##  multiple-effects cause  0.603 0.0172 716    0.569    0.637
## 
## learning_format = separate presentation:
##  target_cause           lsmean     SE  df lower.CL upper.CL
##  single-effect cause     0.668 0.0172 716    0.634    0.702
##  multiple-effects cause  0.602 0.0172 716    0.568    0.635
## 
## Confidence level used: 0.95
# Tets

# simple main effects 
pairs(ls2) # compares rep-measure differences separately for each between-factor level
## learning_format = joint presentation:
##  contrast                                         estimate     SE  df t.ratio
##  (single-effect cause) - (multiple-effects cause)   0.1700 0.0243 716 6.993  
##  p.value
##  <.0001 
## 
## learning_format = separate presentation:
##  contrast                                         estimate     SE  df t.ratio
##  (single-effect cause) - (multiple-effects cause)   0.0661 0.0243 716 2.719  
##  p.value
##  0.0067
# interaction contrast 
pairs(pairs(ls2), by = NULL)
##  contrast                                                                                                                                        
##  ((single-effect cause) - (multiple-effects cause) joint presentation) - ((single-effect cause) - (multiple-effects cause) separate presentation)
##  estimate     SE  df t.ratio p.value
##     0.104 0.0344 716 3.022   0.0026
#test(pairs(pairs(ls2), by = NULL), joint = TRUE) # This reproduces the F-Value of the ANOVA interaction


#lsmip(a1, High_Strength_Component ~ variable) # lsemans can also produce graphs
# compute the confidence interval for the singular causation differences in each between-subject condition

# joint presentation

t <- qt(0.975, 716, lower.tail = TRUE, log.p = FALSE)
#t

effect <- "Mdiff"
Mdiff <- 0.1700
SE <- 0.0243
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.17
CI_low
## [1] 0.1222922
CI_up
## [1] 0.2177078
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_text(face = "bold", size = 20),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 25, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(face = "bold", size = 18),
        strip.text.x = element_text(size = 18),
        #panel.grid.major = element_blank(), 
        #panel.grid.minor = element_blank(), 
        #panel.background = element_blank(), 
        axis.line.x = element_line(colour = "black"), 
        axis.line.y = element_line(colour = "black"),
        axis.text = element_text(colour ="black"), 
        axis.ticks = element_line(colour ="black"))

theme_set(theme_light(base_size = 30, base_family = "Poppins"))



barchart <- ggplot()+
  myTheme+
  #guides(fill=FALSE)+
  #facet_wrap(~Latency + SampleSize, ncol=2)+
  #ggtitle("Mean difference (95% CI)") +
  #coord_cartesian(ylim=c(-0.1,2)) + 
  scale_y_continuous(limits = c(-0.1, 0.5), breaks=seq(-0.1, 0.5, 0.1), expand = c(0,0)) +
  scale_x_discrete(labels=c("r")) +
  #annotate("rect", xmin=1.7, xmax=2.3, ymin=0.95, ymax=1.05, color="#31a354", fill = "white", size = 1) +
  #stat_summary(fun.y=mean, colour="grey20", geom="point", shape = 21, size = 3)+
  #stat_summary(fun.y = mean, geom = "bar", position = "dodge", colour = "black")+
  #stat_summary(fun.data = mean_cl_boot, geom = "errorbar", position = position_dodge(width = 0.90), width = 0.2) +
  #geom_jitter(width = 0.3, height = 0.02, alpha = 0.6, colour = "red") +
  #ggtitle("Means (95% bootstr. CIs)") +
  #theme(axis.text.x = element_text(size = 10, angle = 0, hjust = 0.5))+
  labs(x= "", y = "Mean difference") +
  #scale_color_manual(values=c("#005083",  "#f0b64d"))# +
  #scale_fill_manual(values=c("#969696",  "#969696"))
  #annotate("point", x = 1, y = 100, colour = "firebrick", size = 2)+
  #annotate(xmin = -Inf, xmax = Inf, ymin = 4.77-1.96*0.297, ymax = 4.77+1.96*0.297, geom = "rect", alpha = 0.2, fill = "firebrick")+
  #annotate(xmin = -Inf, xmax = Inf, ymin = 5.02-1.96*0.372, ymax = 5.02+1.96*0.372, geom = "rect", alpha = 0.2, fill = "blue")+
  #annotate(geom = "hline",yintercept = 100, y = 100, color = "red")+
  annotate("pointrange", x = 1, y = Mdiff, ymin = CI_low, ymax = CI_up, colour = "black", size = 1.5, shape = 24, fill = "darkgrey")+
  #annotate("pointrange", x = 2, y = 5.02, ymin = 5.02-1.96*0.372, ymax = 5.02+1.96*0.372, colour = "blue", size = 0.8, shape = 15)+
  #annotate("text", x = 0.5, y = 2.6, family = "Poppins", size = 6, color = "gray20", label = "Impfeffekt")+
  #geom_curve(aes(x = 0.5, y = 3, xend = 0.9, yend = 4),arrow = arrow(length = unit(0.03, "npc")),color = "gray20", curvature = +0.2)+
  #annotate("text", x = 1.8, y = 2.6, family = "Poppins", size = 6, color = "gray20", label = "Dosierungseffekt")+
  #geom_curve(aes(x = 1.8, y = 3, xend = 2, yend = 4),arrow = arrow(length = unit(0.03, "npc")),color = "gray20", curvature = +0.2)+
  annotate(geom = "hline",yintercept = 0, y = 0, color = "red", size = 1.2)+
  theme(plot.background = element_rect(
    fill = "white",
    colour = "black",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("delta_joint.svg",width=2.5,height=4)
#ggsave("delta_joint.pdf",width=2.5,height=4)
# compute the confidence interval for the singular causation differences in each between-subject condition

# separate presentation
t <- qt(0.975, 716, lower.tail = TRUE, log.p = FALSE)
#t

effect <- "Mdiff"
Mdiff <- 0.0661 
SE <- 0.0243
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.0661
CI_low
## [1] 0.01839223
CI_up
## [1] 0.1138078
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_text(face = "bold", size = 20),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 25, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(face = "bold", size = 18),
        strip.text.x = element_text(size = 18),
        #panel.grid.major = element_blank(), 
        #panel.grid.minor = element_blank(), 
        #panel.background = element_blank(), 
        axis.line.x = element_line(colour = "black"), 
        axis.line.y = element_line(colour = "black"),
        axis.text = element_text(colour ="black"), 
        axis.ticks = element_line(colour ="black"))

theme_set(theme_light(base_size = 30, base_family = "Poppins"))



barchart <- ggplot()+
  myTheme+
  #guides(fill=FALSE)+
  #facet_wrap(~Latency + SampleSize, ncol=2)+
  #ggtitle("Mean difference (95% CI)") +
  #coord_cartesian(ylim=c(-0.1,2)) + 
  scale_y_continuous(limits = c(-0.1, 0.5), breaks=seq(-0.1, 0.5, 0.1), expand = c(0,0)) +
  scale_x_discrete(labels=c("r")) +
  #annotate("rect", xmin=1.7, xmax=2.3, ymin=0.95, ymax=1.05, color="#31a354", fill = "white", size = 1) +
  #stat_summary(fun.y=mean, colour="grey20", geom="point", shape = 21, size = 3)+
  #stat_summary(fun.y = mean, geom = "bar", position = "dodge", colour = "black")+
  #stat_summary(fun.data = mean_cl_boot, geom = "errorbar", position = position_dodge(width = 0.90), width = 0.2) +
  #geom_jitter(width = 0.3, height = 0.02, alpha = 0.6, colour = "red") +
  #ggtitle("Means (95% bootstr. CIs)") +
  #theme(axis.text.x = element_text(size = 10, angle = 0, hjust = 0.5))+
  labs(x= "", y = "Mean difference") +
  #scale_color_manual(values=c("#005083",  "#f0b64d"))# +
  #scale_fill_manual(values=c("#969696",  "#969696"))
  #annotate("point", x = 1, y = 100, colour = "firebrick", size = 2)+
  #annotate(xmin = -Inf, xmax = Inf, ymin = 4.77-1.96*0.297, ymax = 4.77+1.96*0.297, geom = "rect", alpha = 0.2, fill = "firebrick")+
  #annotate(xmin = -Inf, xmax = Inf, ymin = 5.02-1.96*0.372, ymax = 5.02+1.96*0.372, geom = "rect", alpha = 0.2, fill = "blue")+
  #annotate(geom = "hline",yintercept = 100, y = 100, color = "red")+
  annotate("pointrange", x = 1, y = Mdiff, ymin = CI_low, ymax = CI_up, colour = "black", size = 1.5, shape = 24, fill = "darkgrey")+
  #annotate("pointrange", x = 2, y = 5.02, ymin = 5.02-1.96*0.372, ymax = 5.02+1.96*0.372, colour = "blue", size = 0.8, shape = 15)+
  #annotate("text", x = 0.5, y = 2.6, family = "Poppins", size = 6, color = "gray20", label = "Impfeffekt")+
  #geom_curve(aes(x = 0.5, y = 3, xend = 0.9, yend = 4),arrow = arrow(length = unit(0.03, "npc")),color = "gray20", curvature = +0.2)+
  #annotate("text", x = 1.8, y = 2.6, family = "Poppins", size = 6, color = "gray20", label = "Dosierungseffekt")+
  #geom_curve(aes(x = 1.8, y = 3, xend = 2, yend = 4),arrow = arrow(length = unit(0.03, "npc")),color = "gray20", curvature = +0.2)+
  annotate(geom = "hline",yintercept = 0, y = 0, color = "red", size = 1.2)+
  theme(plot.background = element_rect(
    fill = "white",
    colour = "black",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("delta_sep.svg",width=2.5,height=4)
#ggsave("delta_sep.pdf",width=2.5,height=4)
# compute the confidence interval for the singular causation differences in each between-subject condition

# interaction

t <- qt(0.975, 716, lower.tail = TRUE, log.p = FALSE)
#t

effect <- "Mdiff"
Mdiff <- 0.104 
SE <- 0.0344
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.104
CI_low
## [1] 0.03646307
CI_up
## [1] 0.1715369
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_text(face = "bold", size = 20),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 25, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(face = "bold", size = 18),
        strip.text.x = element_text(size = 18),
        #panel.grid.major = element_blank(), 
        #panel.grid.minor = element_blank(), 
        #panel.background = element_blank(), 
        axis.line.x = element_line(colour = "black"), 
        axis.line.y = element_line(colour = "black"),
        axis.text = element_text(colour ="black"), 
        axis.ticks = element_line(colour ="black"))

theme_set(theme_light(base_size = 30, base_family = "Poppins"))



barchart <- ggplot()+
  myTheme+
  #guides(fill=FALSE)+
  #facet_wrap(~Latency + SampleSize, ncol=2)+
  #ggtitle("Mean difference (95% CI)") +
  #coord_cartesian(ylim=c(-0.1,2)) + 
  scale_y_continuous(limits = c(-0.1, 0.5), breaks=seq(-0.1, 0.5, 0.1), expand = c(0,0)) +
  scale_x_discrete(labels=c("r")) +
  #annotate("rect", xmin=1.7, xmax=2.3, ymin=0.95, ymax=1.05, color="#31a354", fill = "white", size = 1) +
  #stat_summary(fun.y=mean, colour="grey20", geom="point", shape = 21, size = 3)+
  #stat_summary(fun.y = mean, geom = "bar", position = "dodge", colour = "black")+
  #stat_summary(fun.data = mean_cl_boot, geom = "errorbar", position = position_dodge(width = 0.90), width = 0.2) +
  #geom_jitter(width = 0.3, height = 0.02, alpha = 0.6, colour = "red") +
  #ggtitle("Means (95% bootstr. CIs)") +
  #theme(axis.text.x = element_text(size = 10, angle = 0, hjust = 0.5))+
  labs(x= "", y = "Delta Mean difference") +
  #scale_color_manual(values=c("#005083",  "#f0b64d"))# +
  #scale_fill_manual(values=c("#969696",  "#969696"))
  #annotate("point", x = 1, y = 100, colour = "firebrick", size = 2)+
  #annotate(xmin = -Inf, xmax = Inf, ymin = 4.77-1.96*0.297, ymax = 4.77+1.96*0.297, geom = "rect", alpha = 0.2, fill = "firebrick")+
  #annotate(xmin = -Inf, xmax = Inf, ymin = 5.02-1.96*0.372, ymax = 5.02+1.96*0.372, geom = "rect", alpha = 0.2, fill = "blue")+
  #annotate(geom = "hline",yintercept = 100, y = 100, color = "red")+
  annotate("pointrange", x = 1, y = Mdiff, ymin = CI_low, ymax = CI_up, colour = "black", size = 1.5, shape = 23, fill = "darkgrey")+
  #annotate("pointrange", x = 2, y = 5.02, ymin = 5.02-1.96*0.372, ymax = 5.02+1.96*0.372, colour = "blue", size = 0.8, shape = 15)+
  #annotate("text", x = 0.5, y = 2.6, family = "Poppins", size = 6, color = "gray20", label = "Impfeffekt")+
  #geom_curve(aes(x = 0.5, y = 3, xend = 0.9, yend = 4),arrow = arrow(length = unit(0.03, "npc")),color = "gray20", curvature = +0.2)+
  #annotate("text", x = 1.8, y = 2.6, family = "Poppins", size = 6, color = "gray20", label = "Dosierungseffekt")+
  #geom_curve(aes(x = 1.8, y = 3, xend = 2, yend = 4),arrow = arrow(length = unit(0.03, "npc")),color = "gray20", curvature = +0.2)+
  annotate(geom = "hline",yintercept = 0, y = 0, color = "red", size = 1.2)+
  theme(plot.background = element_rect(
    fill = "white",
    colour = "black",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("interaction.svg",width=2.5,height=4)
#ggsave("interaction.pdf",width=2.5,height=4)
# compute Cohen's d

library(rstatix)
## 
## Attaching package: 'rstatix'
## The following objects are masked from 'package:plyr':
## 
##     desc, mutate
## The following object is masked from 'package:stats':
## 
##     filter
# subset for the four panels shown in the figure
joint_pres <- subset(tdata_sub, learning_format == "joint presentation")
sep_pres <- subset(tdata_sub, learning_format == "separate presentation")



joint_pres %>% cohens_d(strength_rating ~ target_cause, paired = FALSE)
## # A tibble: 1 x 7
##   .y.           group1           group2            effsize    n1    n2 magnitude
## * <chr>         <chr>            <chr>               <dbl> <int> <int> <ord>    
## 1 strength_rat~ single-effect c~ multiple-effects~   0.705   180   180 moderate
sep_pres %>% cohens_d(strength_rating ~ target_cause, paired = FALSE)
## # A tibble: 1 x 7
##   .y.           group1           group2            effsize    n1    n2 magnitude
## * <chr>         <chr>            <chr>               <dbl> <int> <int> <ord>    
## 1 strength_rat~ single-effect c~ multiple-effects~   0.301   180   180 small
d_joint <- 0.7051869    
d_sep <- 0.3008925  

Compute Cohen’s ds and their SE, CI.

library(dplyr) # for pipe operator
## 
## Attaching package: 'dplyr'
## The following object is masked from 'package:nlme':
## 
##     collapse
## The following objects are masked from 'package:data.table':
## 
##     between, first, last
## The following objects are masked from 'package:pastecs':
## 
##     first, last
## The following objects are masked from 'package:plyr':
## 
##     arrange, count, desc, failwith, id, mutate, rename, summarise,
##     summarize
## The following object is masked from 'package:reshape':
## 
##     rename
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
# using the esc package because it gives SE of the ES directly
library(esc)
## 
## Attaching package: 'esc'
## The following objects are masked from 'package:rstatix':
## 
##     cohens_d, eta_squared
# condition: joint presentation of causes

joint <- subset(tdata_sub, learning_format == "joint presentation")



m1 <- joint %>%
          filter(target_cause == "single-effect cause")%>%
          summarize(Mean1 = mean(strength_rating))

sd1 <- joint %>%
          filter(target_cause == "single-effect cause")%>%
          summarize(SD1 = sd(strength_rating))


m2 <- joint %>%
          filter(target_cause == "multiple-effects cause")%>%
          summarize(Mean2 = mean(strength_rating))

sd2 <- joint %>%
          filter(target_cause == "multiple-effects cause")%>%
          summarize(SD2 = sd(strength_rating))



esc_mean_sd(
  grp1m = m1[,1], grp1sd = sd1[,1], grp1n = 360/2,
  grp2m = m2[,1], grp2sd = sd2[,1], grp2n = 360/2,
  es.type = "d"
)
## 
## Effect Size Calculation for Meta Analysis
## 
##      Conversion: mean and sd to effect size d
##     Effect Size:   0.7052
##  Standard Error:   0.1086
##        Variance:   0.0118
##        Lower CI:   0.4923
##        Upper CI:   0.9181
##          Weight:  84.7329
library(dplyr) # for pipe operator
# using the esc package because it gives SE of the ES directly
library(esc)



# condition: joint presentation of causes

sep <- subset(tdata_sub, learning_format == "separate presentation")



m1 <- sep %>%
          filter(target_cause == "single-effect cause")%>%
          summarize(Mean1 = mean(strength_rating))

sd1 <- sep %>%
          filter(target_cause == "single-effect cause")%>%
          summarize(SD1 = sd(strength_rating))


m2 <- sep %>%
          filter(target_cause == "multiple-effects cause")%>%
          summarize(Mean2 = mean(strength_rating))

sd2 <- sep %>%
          filter(target_cause == "multiple-effects cause")%>%
          summarize(SD2 = sd(strength_rating))



esc_mean_sd(
  grp1m = m1[,1], grp1sd = sd1[,1], grp1n = 360/2,
  grp2m = m2[,1], grp2sd = sd2[,1], grp2n = 360/2,
  es.type = "d"
)
## 
## Effect Size Calculation for Meta Analysis
## 
##      Conversion: mean and sd to effect size d
##     Effect Size:   0.3009
##  Standard Error:   0.1060
##        Variance:   0.0112
##        Lower CI:   0.0931
##        Upper CI:   0.5087
##          Weight:  88.9929