# demographics
# one participant indicated 3 for age. Needs to be excluded for the age analysis.
tdata_age <- tdata
min(tdata_age$Age)
## [1] 18
max(tdata_age$Age)
## [1] 63
mean(tdata_age$Age)
## [1] 30.01235
sd(tdata_age$Age)
## [1] 9.479575
# 1 = male, 2 = female, 3 = other
table(tdata$Sex)
##
## 1 2 3
## 31 49 1
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 = 14, 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"))
library(see)
## first, turn sID into a factor
tdata_sub$sID <- factor(tdata_sub$sID)
pd <- position_dodge(width = 0.3)
tdata_sub$valueJitter <- jitter(tdata_sub$value, factor = 1, amount = 0.04)
theme_set(theme_light(base_size = 20, base_family = "Poppins"))
# new labes for the facets
g <- ggplot(tdata_sub, aes(x=variable, y=valueJitter, group = sID)) +
guides(fill=FALSE)+
#facet_grid( ~ Side + Q_order)+
#ggtitle("Subjects' causal srength ratings") +
scale_y_continuous(limits = c(-0.05, 1.05), breaks=seq(0, 1, 0.1), expand = c(0,0)) +
#scale_x_discrete(labels=c("Single-effect \n cause", "Multiple-effects \n cause")) +
#stat_summary(fun.y = mean, geom = "bar", position = "dodge", colour = "black", alpha =0.5) +
geom_violinhalf(aes(y = value, group = variable, fill = variable), color = NA, position=position_dodge(1), alpha = 0.2)+
geom_line(position = pd, color = "black", size = 1, alpha=0.04) +
geom_point(aes(color = variable), position = pd, alpha = 0.2) +
stat_summary(aes(y = value,group=1), fun.data = mean_cl_boot, geom = "errorbar", width = 0, size = 1) +
stat_summary(aes(y = value,group=1), fun.y=mean, colour="black", geom="line",group=1, size = 1.5, linetype = "solid", alpha = 1)+
stat_summary(aes(y = value,group=1, fill = variable), fun.y=mean, geom="point", color = "black", shape = 22, size = 5, group=1, alpha = 1)+
stat_summary(aes(y = value,group=1), fun.y=median, geom="point", color = "black", shape = 3, size = 4, group=1, alpha = 1, position = position_dodge(width = 0.5))+
labs(x = "Number of Cause's Effects", y = "Causal Strength Rating") +
scale_color_manual(name = "Entity",values=c("#fc9272", "#3182bd"))+
scale_fill_manual(name = "Entity",values=c("#fc9272", "#3182bd"))+
theme(legend.position = "none")+
myTheme
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
g
ggsave("results_lines_main.svg",width=15.5,height=9)
#ggsave("results_lines.pdf",width=15.5,height=9)
Overall, a very strong dilution effect.
What about the different counterbalancing conditions?
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 = 14, 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"))
library(see)
## first, turn sID into a factor
tdata_sub$sID <- factor(tdata_sub$sID)
pd <- position_dodge(width = 0.3)
tdata_sub$valueJitter <- jitter(tdata_sub$value, factor = 1, amount = 0.04)
theme_set(theme_light(base_size = 20, base_family = "Poppins"))
# new labes for the facets
g <- ggplot(tdata_sub, aes(x=variable, y=valueJitter, group = sID)) +
guides(fill=FALSE)+
facet_grid( ~ Side + Q_order)+
#ggtitle("Subjects' causal srength ratings") +
scale_y_continuous(limits = c(-0.05, 1.05), breaks=seq(0, 1, 0.1), expand = c(0,0)) +
#scale_x_discrete(labels=c("Single-effect \n cause", "Multiple-effects \n cause")) +
#stat_summary(fun.y = mean, geom = "bar", position = "dodge", colour = "black", alpha =0.5) +
geom_violinhalf(aes(y = value, group = variable, fill = variable), color = NA, position=position_dodge(1), alpha = 0.2)+
geom_line(position = pd, color = "black", size = 1, alpha=0.04) +
geom_point(aes(color = variable), position = pd, alpha = 0.2) +
stat_summary(aes(y = value,group=1), fun.data = mean_cl_boot, geom = "errorbar", width = 0, size = 1) +
stat_summary(aes(y = value,group=1), fun.y=mean, colour="black", geom="line",group=1, size = 1.5, linetype = "solid", alpha = 1)+
stat_summary(aes(y = value,group=1, fill = variable), fun.y=mean, geom="point", color = "black", shape = 22, size = 5, group=1, alpha = 1)+
stat_summary(aes(y = value,group=1), fun.y=median, geom="point", color = "black", shape = 3, size = 4, group=1, alpha = 1, position = position_dodge(width = 0.5))+
labs(x = "Number of Cause's Effects", y = "Causal Strength Rating") +
scale_color_manual(name = "Entity",values=c("#fc9272", "#3182bd"))+
scale_fill_manual(name = "Entity",values=c("#fc9272", "#3182bd"))+
theme(legend.position = "none")+
myTheme
## Warning: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> =
## "none")` instead.
## Warning: `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
## `fun.y` is deprecated. Use `fun` instead.
g
ggsave("results_lines.svg",width=15.5,height=9)
#ggsave("results_lines.pdf",width=15.5,height=9)
A quite pronounced dilution effect in all conditions.
## : one
## median mean SE.mean CI.mean.0.95 var std.dev
## 0.99000000 0.87975309 0.02128436 0.04235722 0.03669494 0.19155923
## coef.var
## 0.21774204
## ------------------------------------------------------------
## : three
## median mean SE.mean CI.mean.0.95 var std.dev
## 0.45000000 0.51913580 0.02875943 0.05723309 0.06699549 0.25883488
## coef.var
## 0.49858799
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(): 'S', 'KR', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - NEWS: emmeans() for ANOVA models now uses model = 'multivariate' as default.
## - 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")
## ************
##
## Attache Paket: 'afex'
## Das folgende Objekt ist maskiert 'package:lme4':
##
## lmer
library(emmeans)
a1 <- aov_car(value ~ Side*Q_order*Target_effect + Error(sID/(variable)), tdata_sub)
## Contrasts set to contr.sum for the following variables: Side, Q_order, Target_effect
a1
## Anova Table (Type 3 tests)
##
## Response: value
## Effect df MSE F ges p.value
## 1 Side 1, 69 0.05 1.89 .012 .173
## 2 Q_order 1, 69 0.05 2.43 .016 .124
## 3 Target_effect 2, 69 0.05 0.25 .003 .779
## 4 Side:Q_order 1, 69 0.05 0.05 <.001 .831
## 5 Side:Target_effect 2, 69 0.05 0.43 .006 .654
## 6 Q_order:Target_effect 2, 69 0.05 0.56 .007 .575
## 7 Side:Q_order:Target_effect 2, 69 0.05 0.43 .006 .651
## 8 variable 1, 69 0.06 89.49 *** .413 <.001
## 9 Side:variable 1, 69 0.06 0.53 .004 .471
## 10 Q_order:variable 1, 69 0.06 0.01 <.001 .926
## 11 Target_effect:variable 2, 69 0.06 0.45 .007 .639
## 12 Side:Q_order:variable 1, 69 0.06 3.23 + .025 .077
## 13 Side:Target_effect:variable 2, 69 0.06 0.43 .007 .654
## 14 Q_order:Target_effect:variable 2, 69 0.06 1.47 .023 .237
## 15 Side:Q_order:Target_effect:variable 2, 69 0.06 0.55 .009 .581
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
###############
# a conditional analysis
ls2 <- lsmeans(a1, c("variable")) # group means by between-condition
ls2
## variable lsmean SE df lower.CL upper.CL
## one 0.878 0.0217 69 0.834 0.921
## three 0.519 0.0293 69 0.460 0.577
##
## Results are averaged over the levels of: Side, Q_order, Target_effect
## Confidence level used: 0.95
# simple main effects
t <- pairs(ls2) # compares rep-measure differences separately for each between-factor level
t
## contrast estimate SE df t.ratio p.value
## one - three 0.359 0.038 69 9.460 <.0001
##
## Results are averaged over the levels of: Side, Q_order, Target_effect
confint(t, level = 0.95)
## contrast estimate SE df lower.CL upper.CL
## one - three 0.359 0.038 69 0.283 0.435
##
## Results are averaged over the levels of: Side, Q_order, Target_effect
## Confidence level used: 0.95
A clear dilution effect.
Compute effect sizes (Cohen’s d)
# subsets for the different between groups (conditions)
# condition: generative cause and positive effects
dat <- tdata_sub
# since we have a repeated-meausres design, we now need the correlations of the ratings
library(dplyr) # for pipe operator
tdata -> t
r <- cor(t$single, t$multiple)
r
## [1] -0.09893097
# now compute ES and SE and CI of it
# using the esc package because it gives SE of the ES directly
library(esc)
# get means and sds
m1 <- dat %>%
filter(variable == "one")%>%
summarize(Mean1 = mean(value))
sd1 <- dat %>%
filter(variable == "one")%>%
summarize(SD1 = sd(value))
m2 <- dat %>%
filter(variable == "three")%>%
summarize(Mean2 = mean(value))
sd2 <- dat %>%
filter(variable == "three")%>%
summarize(SD2 = sd(value))
esc_mean_sd(
grp1m = m1[,1], grp1sd = sd1[,1], grp1n = length(dat$sID)/2,
grp2m = m2[,1], grp2sd = sd2[,1], grp2n = length(dat$sID)/2,
r = r,
es.type = "d"
)
##
## Effect Size Calculation for Meta Analysis
##
## Conversion: mean and sd (within-subject) to effect size d
## Effect Size: 1.0704
## Standard Error: 0.1680
## Variance: 0.0282
## Lower CI: 0.7411
## Upper CI: 1.3997
## Weight: 35.4262