# 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] 75
mean(tdata_age$Age)
## [1] 31.16667
sd(tdata_age$Age)
## [1] 10.34374
# 1 = male, 2 = female, 3 = other
table(tdata$Sex)
##
## 1 2 3
## 62 81 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)
## Warning: package 'see' was built under R version 4.0.4
## 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
capacity.labs <- c("Capacity: no info", "Capacity: same", "Capacity: different")
names(capacity.labs) <- c("none", "same", "different")
g <- ggplot(tdata_sub, aes(x=variable, y=valueJitter, group = sID)) +
guides(fill=FALSE)+
#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 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: `fun.y` is deprecated. Use `fun` instead.
## Warning: `fun.y` is deprecated. Use `fun` instead.
## Warning: `fun.y` is deprecated. Use `fun` instead.
g
#ggsave("results_lines.svg",width=15.5,height=9)
ggsave("results_graph_lines.pdf",width=15.5,height=9)
## : one
## median mean SE.mean CI.mean.0.95 var std.dev
## 0.99000000 0.88437500 0.01711850 0.03383801 0.04219821 0.20542202
## coef.var
## 0.23227932
## ------------------------------------------------------------
## : three
## median mean SE.mean CI.mean.0.95 var std.dev
## 0.52000000 0.56256944 0.01939718 0.03834225 0.05418007 0.23276612
## coef.var
## 0.41375535
## ------------------------------------------------------------
## : seven
## median mean SE.mean CI.mean.0.95 var std.dev
## 0.32500000 0.40527778 0.02563054 0.05066368 0.09459713 0.30756646
## coef.var
## 0.75890284
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(value ~ Crystal_Order*Q_Order + Error(sID/(variable)), tdata_sub)
## Converting to factor: Crystal_Order, Q_Order
## Contrasts set to contr.sum for the following variables: Crystal_Order, Q_Order
a1
## Anova Table (Type 3 tests)
##
## Response: value
## Effect df MSE F ges p.value
## 1 Crystal_Order 5, 108 0.10 1.09 .025 .373
## 2 Q_Order 5, 108 0.10 0.98 .023 .434
## 3 Crystal_Order:Q_Order 25, 108 0.10 0.74 .080 .806
## 4 variable 1.22, 132.27 0.08 175.14 *** .442 <.001
## 5 Crystal_Order:variable 6.12, 132.27 0.08 0.68 .015 .666
## 6 Q_Order:variable 6.12, 132.27 0.08 1.73 .038 .117
## 7 Crystal_Order:Q_Order:variable 30.62, 132.27 0.08 0.62 .065 .941
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
# same ANOVA as before
lmeModel <- lmer(value ~ Crystal_Order*Q_Order*variable + (1|sID), data=tdata_sub)
# follow-up analysis
ls1 <- lsmeans(a1, c("variable")) # joint evaluation (basically gives the same table)
## NOTE: Results may be misleading due to involvement in interactions
ls1
## variable lsmean SE df lower.CL upper.CL
## one 0.884 0.0215 284 0.842 0.927
## three 0.563 0.0215 284 0.520 0.605
## seven 0.405 0.0215 284 0.363 0.448
##
## Results are averaged over the levels of: Crystal_Order, Q_Order
## Warning: EMMs are biased unless design is perfectly balanced
## Confidence level used: 0.95
Compute Cohen’s d for the two dilution effects (1 vs 3 and 1 vs 7 effects)
# one vs. three
tdata_13 <- subset(tdata_sub, variable != "seven")
tdata_13 <- subset(tdata_13, select = c(1:3,5:6))
# one vs. seven
tdata_17 <- subset(tdata_sub, variable != "three")
tdata_17 <- subset(tdata_17, select = c(1:3,5:6))
dat <- tdata_13
# since we have a repeated-meausres design, we now need the correlations of the ratings
library(dplyr) # for pipe operator
dat_wide <- spread(tdata_13, variable, value)
dat_wide -> t
r <- cor(t$one, t$three)
r
## [1] 0.1734942
# 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.1393
## Standard Error: 0.1271
## Variance: 0.0161
## Lower CI: 0.8903
## Upper CI: 1.3883
## Weight: 61.9492
dat <- tdata_17
# since we have a repeated-meausres design, we now need the correlations of the ratings
library(dplyr) # for pipe operator
dat_wide <- spread(tdata_17, variable, value)
dat_wide -> t
r <- cor(t$one, t$seven)
r
## [1] -0.1925013
# 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 == "seven")%>%
summarize(Mean2 = mean(value))
sd2 <- dat %>%
filter(variable == "seven")%>%
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.1936
## Standard Error: 0.1279
## Variance: 0.0164
## Lower CI: 0.9429
## Upper CI: 1.4443
## Weight: 61.1166