Results

Demographics

# demographics 

# one participant indicated 3 for age. Needs to be excluded for the age analysis.
tdata_age <- subset(tdata, Age > 3) # one participant erronously reported 3 

min(tdata_age$Age)
## [1] 18
max(tdata_age$Age)
## [1] 75
mean(tdata_age$Age)
## [1] 34.94363
sd(tdata_age$Age)
## [1] 13.34492
# 1 = male, 2 = female, 3 = other
table(tdata$Sex)
## 
##   1   2   3   4 
## 221 255   2   2

Graphs

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 
process.labs <- c("Process: Generative", "Process: Preventive")
names(process.labs) <- c("generative", "preventive")

valence.labs <- c("Effect valence: Positive", "Effect Valence: Negative")
names(valence.labs) <- c("positive", "negative")


g <- ggplot(tdata_sub, aes(x=variable, y=valueJitter, group = sID)) +
  guides(fill=FALSE)+
  facet_grid(Valence ~ Process, labeller = labeller(Process = process.labs, Valence = valence.labs))+
  #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", "common \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 = "Target Cause", 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_lines.pdf",width=15.5,height=9)

Descriptive Stats

## : single
## : generative
## : positive
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.91500000   0.82816667   0.01978703   0.03918029   0.04698317   0.21675600 
##     coef.var 
##   0.26172993 
## ------------------------------------------------------------ 
## : multiple
## : generative
## : positive
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.45500000   0.51300000   0.02077578   0.04113812   0.05179597   0.22758727 
##     coef.var 
##   0.44363991 
## ------------------------------------------------------------ 
## : single
## : preventive
## : positive
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.91000000   0.82900000   0.01924354   0.03810413   0.04443765   0.21080239 
##     coef.var 
##   0.25428515 
## ------------------------------------------------------------ 
## : multiple
## : preventive
## : positive
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.70500000   0.67325000   0.02490687   0.04931810   0.07444229   0.27284114 
##     coef.var 
##   0.40525978 
## ------------------------------------------------------------ 
## : single
## : generative
## : negative
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.88000000   0.79250000   0.02124693   0.04207105   0.05417185   0.23274847 
##     coef.var 
##   0.29368892 
## ------------------------------------------------------------ 
## : multiple
## : generative
## : negative
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.35000000   0.43866667   0.01893929   0.03750168   0.04304359   0.20746948 
##     coef.var 
##   0.47295474 
## ------------------------------------------------------------ 
## : single
## : preventive
## : negative
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.76500000   0.73891667   0.02200134   0.04356484   0.05808705   0.24101256 
##     coef.var 
##   0.32617014 
## ------------------------------------------------------------ 
## : multiple
## : preventive
## : negative
##       median         mean      SE.mean CI.mean.0.95          var      std.dev 
##   0.49000000   0.55691667   0.02384145   0.04720844   0.06820974   0.26116995 
##     coef.var 
##   0.46895696
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 ~ Order*Process*Valence*Multiple_Effects*Target*variable + Error(sID/(variable)), tdata_sub)
## Contrasts set to contr.sum for the following variables: Order, Process, Valence, Multiple_Effects, Target
a1
## Anova Table (Type 3 tests)
## 
## Response: value
##                                                    Effect     df  MSE
## 1                                                   Order 1, 432 0.06
## 2                                                 Process 1, 432 0.06
## 3                                                 Valence 1, 432 0.06
## 4                                        Multiple_Effects 1, 432 0.06
## 5                                                  Target 2, 432 0.06
## 6                                           Order:Process 1, 432 0.06
## 7                                           Order:Valence 1, 432 0.06
## 8                                         Process:Valence 1, 432 0.06
## 9                                  Order:Multiple_Effects 1, 432 0.06
## 10                               Process:Multiple_Effects 1, 432 0.06
## 11                               Valence:Multiple_Effects 1, 432 0.06
## 12                                           Order:Target 2, 432 0.06
## 13                                         Process:Target 2, 432 0.06
## 14                                         Valence:Target 2, 432 0.06
## 15                                Multiple_Effects:Target 2, 432 0.06
## 16                                  Order:Process:Valence 1, 432 0.06
## 17                         Order:Process:Multiple_Effects 1, 432 0.06
## 18                         Order:Valence:Multiple_Effects 1, 432 0.06
## 19                       Process:Valence:Multiple_Effects 1, 432 0.06
## 20                                   Order:Process:Target 2, 432 0.06
## 21                                   Order:Valence:Target 2, 432 0.06
## 22                                 Process:Valence:Target 2, 432 0.06
## 23                          Order:Multiple_Effects:Target 2, 432 0.06
## 24                        Process:Multiple_Effects:Target 2, 432 0.06
## 25                        Valence:Multiple_Effects:Target 2, 432 0.06
## 26                 Order:Process:Valence:Multiple_Effects 1, 432 0.06
## 27                           Order:Process:Valence:Target 2, 432 0.06
## 28                  Order:Process:Multiple_Effects:Target 2, 432 0.06
## 29                  Order:Valence:Multiple_Effects:Target 2, 432 0.06
## 30                Process:Valence:Multiple_Effects:Target 2, 432 0.06
## 31          Order:Process:Valence:Multiple_Effects:Target 2, 432 0.06
## 32                                               variable 1, 432 0.05
## 33                                         Order:variable 1, 432 0.05
## 34                                       Process:variable 1, 432 0.05
## 35                                       Valence:variable 1, 432 0.05
## 36                              Multiple_Effects:variable 1, 432 0.05
## 37                                        Target:variable 2, 432 0.05
## 38                                 Order:Process:variable 1, 432 0.05
## 39                                 Order:Valence:variable 1, 432 0.05
## 40                               Process:Valence:variable 1, 432 0.05
## 41                        Order:Multiple_Effects:variable 1, 432 0.05
## 42                      Process:Multiple_Effects:variable 1, 432 0.05
## 43                      Valence:Multiple_Effects:variable 1, 432 0.05
## 44                                  Order:Target:variable 2, 432 0.05
## 45                                Process:Target:variable 2, 432 0.05
## 46                                Valence:Target:variable 2, 432 0.05
## 47                       Multiple_Effects:Target:variable 2, 432 0.05
## 48                         Order:Process:Valence:variable 1, 432 0.05
## 49                Order:Process:Multiple_Effects:variable 1, 432 0.05
## 50                Order:Valence:Multiple_Effects:variable 1, 432 0.05
## 51              Process:Valence:Multiple_Effects:variable 1, 432 0.05
## 52                          Order:Process:Target:variable 2, 432 0.05
## 53                          Order:Valence:Target:variable 2, 432 0.05
## 54                        Process:Valence:Target:variable 2, 432 0.05
## 55                 Order:Multiple_Effects:Target:variable 2, 432 0.05
## 56               Process:Multiple_Effects:Target:variable 2, 432 0.05
## 57               Valence:Multiple_Effects:Target:variable 2, 432 0.05
## 58        Order:Process:Valence:Multiple_Effects:variable 1, 432 0.05
## 59                  Order:Process:Valence:Target:variable 2, 432 0.05
## 60         Order:Process:Multiple_Effects:Target:variable 2, 432 0.05
## 61         Order:Valence:Multiple_Effects:Target:variable 2, 432 0.05
## 62       Process:Valence:Multiple_Effects:Target:variable 2, 432 0.05
## 63 Order:Process:Valence:Multiple_Effects:Target:variable 2, 432 0.05
##             F   ges p.value
## 1      3.31 +  .004    .070
## 2   12.90 ***  .016   <.001
## 3   25.35 ***  .030   <.001
## 4        0.34 <.001    .559
## 5        0.56  .001    .574
## 6        0.02 <.001    .896
## 7      3.30 +  .004    .070
## 8        2.35  .003    .126
## 9        0.67 <.001    .415
## 10       0.08 <.001    .776
## 11     4.42 *  .005    .036
## 12       0.49  .001    .613
## 13       0.07 <.001    .933
## 14       0.36 <.001    .699
## 15     3.86 *  .009    .022
## 16       0.00 <.001    .990
## 17       0.16 <.001    .686
## 18       0.00 <.001    .969
## 19       2.44  .003    .119
## 20       0.72  .002    .487
## 21       0.73  .002    .481
## 22       0.60  .001    .551
## 23       0.34 <.001    .710
## 24       1.43  .003    .241
## 25       0.51  .001    .602
## 26       0.05 <.001    .829
## 27     2.69 +  .007    .069
## 28       0.57  .001    .564
## 29       0.97  .002    .380
## 30       0.12 <.001    .889
## 31       0.03 <.001    .967
## 32 290.57 ***  .240   <.001
## 33       1.67  .002    .197
## 34  31.46 ***  .033   <.001
## 35       1.21  .001    .272
## 36     4.44 *  .005    .036
## 37       0.17 <.001    .842
## 38       0.04 <.001    .834
## 39       2.03  .002    .154
## 40       0.04 <.001    .834
## 41       0.00 <.001    .972
## 42       0.67 <.001    .413
## 43       0.16 <.001    .686
## 44       0.02 <.001    .976
## 45       0.83  .002    .439
## 46       1.17  .003    .310
## 47       0.63  .001    .531
## 48       0.03 <.001    .860
## 49       0.06 <.001    .803
## 50       0.06 <.001    .803
## 51       0.02 <.001    .885
## 52       0.15 <.001    .859
## 53       0.23 <.001    .791
## 54       0.49  .001    .611
## 55       0.09 <.001    .913
## 56       0.91  .002    .405
## 57       0.15 <.001    .863
## 58       1.23  .001    .269
## 59       1.03  .002    .359
## 60       1.24  .003    .290
## 61       0.98  .002    .377
## 62     2.44 +  .005    .089
## 63       1.13  .002    .325
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
# same ANOVA as before
lmeModel <- lmer(value ~ Process*variable + (1|sID), data=tdata_sub)

# follow-up analysis 

ls1 <- lsmeans(a1, c("variable", "Process", "Valence")) # joint evaluation (basically gives the same table)
## NOTE: Results may be misleading due to involvement in interactions
ls1
##  variable Process    Valence  lsmean     SE  df lower.CL upper.CL
##  single   generative positive  0.828 0.0216 861    0.786    0.870
##  multiple generative positive  0.513 0.0216 861    0.471    0.555
##  single   preventive positive  0.829 0.0216 861    0.787    0.871
##  multiple preventive positive  0.673 0.0216 861    0.631    0.716
##  single   generative negative  0.792 0.0216 861    0.750    0.835
##  multiple generative negative  0.439 0.0216 861    0.396    0.481
##  single   preventive negative  0.739 0.0216 861    0.697    0.781
##  multiple preventive negative  0.557 0.0216 861    0.515    0.599
## 
## Results are averaged over the levels of: Order, Multiple_Effects, Target 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95
############### 
# a conditional analysis 

ls2 <- lsmeans(a1, c("Valence")) # group means by between-condition
## NOTE: Results may be misleading due to involvement in interactions
ls2
##  Valence  lsmean     SE  df lower.CL upper.CL
##  positive  0.711 0.0111 432    0.689    0.733
##  negative  0.632 0.0111 432    0.610    0.654
## 
## Results are averaged over the levels of: Order, Process, Multiple_Effects, Target, variable 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95
# simple main effects 
pairs(ls2) # compares rep-measure differences separately for each between-factor level
##  contrast            estimate     SE  df t.ratio p.value
##  positive - negative   0.0791 0.0157 432 5.035   <.0001 
## 
## Results are averaged over the levels of: Order, Process, Multiple_Effects, Target, variable
ls3 <- lsmeans(a1, c("Process")) # group means by between-condition
## NOTE: Results may be misleading due to involvement in interactions
ls3
##  Process    lsmean     SE  df lower.CL upper.CL
##  generative  0.643 0.0111 432    0.621    0.665
##  preventive  0.700 0.0111 432    0.678    0.721
## 
## Results are averaged over the levels of: Order, Valence, Multiple_Effects, Target, variable 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95
# simple main effects 
pairs(ls3) # compares rep-measure differences separately for each between-factor level
##  contrast                estimate     SE  df t.ratio p.value
##  generative - preventive  -0.0564 0.0157 432 -3.592  0.0004 
## 
## Results are averaged over the levels of: Order, Valence, Multiple_Effects, Target, variable
############### 
# a conditional analysis 

ls4 <- lsmeans(a1, c("variable"), by = c("Process", "Valence")) # group means by between-condition
## NOTE: Results may be misleading due to involvement in interactions
ls4
## Process = generative, Valence = positive:
##  variable lsmean     SE  df lower.CL upper.CL
##  single    0.828 0.0216 861    0.786    0.870
##  multiple  0.513 0.0216 861    0.471    0.555
## 
## Process = preventive, Valence = positive:
##  variable lsmean     SE  df lower.CL upper.CL
##  single    0.829 0.0216 861    0.787    0.871
##  multiple  0.673 0.0216 861    0.631    0.716
## 
## Process = generative, Valence = negative:
##  variable lsmean     SE  df lower.CL upper.CL
##  single    0.792 0.0216 861    0.750    0.835
##  multiple  0.439 0.0216 861    0.396    0.481
## 
## Process = preventive, Valence = negative:
##  variable lsmean     SE  df lower.CL upper.CL
##  single    0.739 0.0216 861    0.697    0.781
##  multiple  0.557 0.0216 861    0.515    0.599
## 
## Results are averaged over the levels of: Order, Multiple_Effects, Target 
## Warning: EMMs are biased unless design is perfectly balanced 
## Confidence level used: 0.95
# simple main effects 
pairs(ls4) # compares rep-measure differences separately for each between-factor level
## Process = generative, Valence = positive:
##  contrast          estimate     SE  df t.ratio p.value
##  single - multiple    0.315 0.0295 432 10.673  <.0001 
## 
## Process = preventive, Valence = positive:
##  contrast          estimate     SE  df t.ratio p.value
##  single - multiple    0.156 0.0295 432  5.274  <.0001 
## 
## Process = generative, Valence = negative:
##  contrast          estimate     SE  df t.ratio p.value
##  single - multiple    0.354 0.0295 432 11.982  <.0001 
## 
## Process = preventive, Valence = negative:
##  contrast          estimate     SE  df t.ratio p.value
##  single - multiple    0.182 0.0295 432  6.163  <.0001 
## 
## Results are averaged over the levels of: Order, Multiple_Effects, Target
# interaction contrast 
pairs(pairs(ls4), by = NULL)
##  contrast                                                                         
##  (single - multiple generative positive) - (single - multiple preventive positive)
##  (single - multiple generative positive) - (single - multiple generative negative)
##  (single - multiple generative positive) - (single - multiple preventive negative)
##  (single - multiple preventive positive) - (single - multiple generative negative)
##  (single - multiple preventive positive) - (single - multiple preventive negative)
##  (single - multiple generative negative) - (single - multiple preventive negative)
##  estimate     SE  df t.ratio p.value
##    0.1594 0.0418 432  3.817  0.0009 
##   -0.0387 0.0418 432 -0.926  0.7910 
##    0.1332 0.0418 432  3.189  0.0083 
##   -0.1981 0.0418 432 -4.743  <.0001 
##   -0.0262 0.0418 432 -0.629  0.9228 
##    0.1718 0.0418 432  4.115  0.0003 
## 
## Results are averaged over the levels of: Order, Multiple_Effects, Target 
## P value adjustment: tukey method for comparing a family of 4 estimates
test(pairs(pairs(ls4), by = NULL), joint = TRUE) # This reproduces the F-Value of the ANOVA interaction
##  df1 df2 F.ratio p.value note
##    3 432  10.903 <.0001   d  
## 
## d: df1 reduced due to linear dependence
#lsmip(a1, High_Strength_Component ~ variable) # lsemans can also produce graphs
# 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
gen_pos <- subset(tdata_sub, Process == "generative" & Valence == "positive")
gen_neg <- subset(tdata_sub, Process == "generative" & Valence == "negative")

prev_pos <- subset(tdata_sub, Process == "preventive" & Valence == "positive")
prev_neg <- subset(tdata_sub, Process == "preventive" & Valence == "negative")


gen_pos %>% cohens_d(value ~ variable, paired = TRUE)
## # A tibble: 1 x 7
##   .y.   group1 group2   effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>      <dbl> <int> <int> <ord>    
## 1 value single multiple   0.916   120   120 large
gen_neg %>% cohens_d(value ~ variable, paired = TRUE)
## # A tibble: 1 x 7
##   .y.   group1 group2   effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>      <dbl> <int> <int> <ord>    
## 1 value single multiple    1.14   120   120 large
prev_pos %>% cohens_d(value ~ variable, paired = TRUE)
## # A tibble: 1 x 7
##   .y.   group1 group2   effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>      <dbl> <int> <int> <ord>    
## 1 value single multiple   0.593   120   120 moderate
prev_neg %>% cohens_d(value ~ variable, paired = TRUE)
## # A tibble: 1 x 7
##   .y.   group1 group2   effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>      <dbl> <int> <int> <ord>    
## 1 value single multiple   0.513   120   120 moderate
d_gen_pos <- 0.9161883
d_gen_neg <- 1.138706

d_prev_pos <- 0.5932288
d_prev_neg <- 0.5132523
# get confidence intervals for d 

# 1) compute correlations for the ratings

gen_pos_mult <- subset(gen_pos, variable == "multiple")
gen_pos_sing <- subset(gen_pos, variable == "single")

cor.test(gen_pos_sing$value, gen_pos_mult$value)
## 
##  Pearson's product-moment correlation
## 
## data:  gen_pos_sing$value and gen_pos_mult$value
## t = -2.1966, df = 118, p-value = 0.03
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.3644973 -0.0196625
## sample estimates:
##        cor 
## -0.1982053
cor_pos_gen <- -0.1982053


prev_pos_mult <- subset(prev_pos, variable == "multiple")
prev_pos_sing <- subset(prev_pos, variable == "single")

cor.test(prev_pos_sing$value, prev_pos_mult$value)
## 
##  Pearson's product-moment correlation
## 
## data:  prev_pos_sing$value and prev_pos_mult$value
## t = 5.2363, df = 118, p-value = 7.234e-07
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.2765045 0.5691676
## sample estimates:
##       cor 
## 0.4342252
cor_pos_prev <- 0.4342252


gen_neg_mult <- subset(gen_neg, variable == "multiple")
gen_neg_sing <- subset(gen_neg, variable == "single")

cor.test(gen_neg_sing$value, gen_neg_mult$value)
## 
##  Pearson's product-moment correlation
## 
## data:  gen_neg_sing$value and gen_neg_mult$value
## t = 0.074294, df = 118, p-value = 0.9409
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1726138  0.1858527
## sample estimates:
##         cor 
## 0.006839188
cor_neg_gen <- 0.006839188


prev_neg_mult <- subset(prev_neg, variable == "multiple")
prev_neg_sing <- subset(prev_neg, variable == "single")

cor.test(prev_neg_sing$value, prev_neg_mult$value)
## 
##  Pearson's product-moment correlation
## 
## data:  prev_neg_sing$value and prev_neg_mult$value
## t = 0.047856, df = 118, p-value = 0.9619
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.1749740  0.1835019
## sample estimates:
##         cor 
## 0.004405479
cor_neg_prev <-0.004405479



# 2) Now compute SE for d

n <- 120


# formula: Sqrt((1/n + d^2/n)*2*(1-r))

SEd_pos_gen <- sqrt((1/n + d_gen_pos^2/n)*2*(1-cor_pos_gen))
SEd_pos_gen
## [1] 0.1916586
SEd_neg_gen <- sqrt((1/n + d_gen_neg^2/n)*2*(1-cor_neg_gen))
SEd_neg_gen
## [1] 0.1949762
SEd_pos_prev <- sqrt((1/n + d_prev_pos^2/n)*2*(1-cor_pos_prev))
SEd_pos_prev
## [1] 0.1129072
SEd_neg_prev <- sqrt((1/n + d_prev_neg^2/n)*2*(1-cor_neg_prev))
SEd_neg_prev
## [1] 0.1447908
# Confidence intervalls for d


("d gen pos")
## [1] "d gen pos"
round(d_gen_pos,2)
## [1] 0.92
round((d_gen_pos - 1.96*SEd_pos_gen),2)
## [1] 0.54
round((d_gen_pos + 1.96*SEd_pos_gen),2)
## [1] 1.29
("d prev pos")
## [1] "d prev pos"
round(d_prev_pos,2)
## [1] 0.59
round((d_prev_pos - 1.96*SEd_pos_prev),2)
## [1] 0.37
round((d_prev_pos + 1.96*SEd_pos_prev),2)
## [1] 0.81
("d gen neg")
## [1] "d gen neg"
round(d_gen_neg,2)
## [1] 1.14
round((d_gen_neg - 1.96*SEd_neg_gen),2)
## [1] 0.76
round((d_gen_neg + 1.96*SEd_neg_gen),2)
## [1] 1.52
("d prev neg")
## [1] "d prev neg"
round(d_prev_neg,2)
## [1] 0.51
round((d_prev_neg - 1.96*SEd_neg_prev),2)
## [1] 0.23
round((d_prev_neg + 1.96*SEd_neg_prev),2)
## [1] 0.8
# compute the confidence interval for the singular causation differences in each between-subject condition

#Process = generative, Valence = positive:
# contrast          estimate     SE  df t.ratio p.value
# single - multiple    0.315 0.0295 432 10.673  <.0001 

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

effect <- "Mdiff"
Mdiff <- 0.315
SE <- 0.0295
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.315
CI_low
## [1] 0.2570186
CI_up
## [1] 0.3729814
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_blank(),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 40, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(size = 22),
        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 change") +
  #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 = 2, 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 = "white",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("delta_posGen.svg",width=2.5,height=4)
#ggsave("delta_posGen.pdf",width=2.5,height=4)
# Process = preventive, Valence = positive:
# contrast          estimate     SE  df t.ratio p.value
# single - multiple    0.156 0.0295 432  5.274  <.0001 

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

effect <- "Mdiff"
Mdiff <- 0.156
SE <- 0.0295
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.156
CI_low
## [1] 0.09801862
CI_up
## [1] 0.2139814
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_blank(),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 40, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(size = 22),
        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 change") +
  #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 = 2, 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 = "white",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("delta_PosPrev.svg",width=2.5,height=4)
#ggsave("delta_PosPrev.pdf",width=2.5,height=4)
#Process = generative, Valence = negative:
# contrast          estimate     SE  df t.ratio p.value
# single - multiple    0.354 0.0295 432 11.982  <.0001 

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

effect <- "Mdiff"
Mdiff <- 0.354
SE <- 0.0295
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.354
CI_low
## [1] 0.2960186
CI_up
## [1] 0.4119814
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_blank(),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 40, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(size = 22),
        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 change") +
  #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 = 2, 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 = "white",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("delta_NegGen.svg",width=2.5,height=4)
#ggsave("delta_NegGen.pdf",width=2.5,height=4)
#Process = preventive, Valence = negative:
# contrast          estimate     SE  df t.ratio p.value
# single - multiple    0.182 0.0295 432  6.163  <.0001

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

effect <- "Mdiff"
Mdiff <- 0.182
SE <- 0.0295
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.182
CI_low
## [1] 0.1240186
CI_up
## [1] 0.2399814
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_blank(),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 40, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(size = 22),
        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 change") +
  #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 = 2, 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 = "white",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("delta_NegPrev.svg",width=2.5,height=4)
#ggsave("delta_NegPrev.pdf",width=2.5,height=4)
# contrast                                                                          estimate     SE  df t.ratio p.value
# (single - multiple generative positive) - (single - multiple preventive positive)   0.1594 0.0418 432  3.817  0.0009 

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

effect <- "Mdiff"
Mdiff <- 0.1594 
SE <- 0.0418
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.1594
CI_low
## [1] 0.07724333
CI_up
## [1] 0.2415567
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_blank(),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 40, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(size = 22),
        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 = 2, 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 = "white",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("interaction_positive.svg",width=2.5,height=4)
#ggsave("interaction_positive.pdf",width=2.5,height=4)
# contrast                                                                          estimate     SE  df t.ratio p.value
#(single - multiple generative negative) - (single - multiple preventive negative)   0.1718 0.0418 432  4.115  0.0003

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

effect <- "Mdiff"
Mdiff <- 0.1718
SE <- 0.0418
CI <- SE*t
CI_low <- Mdiff - CI
CI_up <- Mdiff + CI

Mdiff
## [1] 0.1718
CI_low
## [1] 0.08964333
CI_up
## [1] 0.2539567
# Plot 

myTheme <- theme(plot.title = element_text(face="bold", size = 22),
        axis.title.x = element_text(face = "bold", size = 20),
        axis.title.y = element_blank(),
        axis.text.x = element_text(size = 18, angle = 0), 
        axis.text.y = element_text(size = 40, angle = 0),
        legend.text = element_text(size = 18),
        legend.title = element_text(size = 22),
        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 = 2, 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 = "white",
    size = 1
  ))
## Warning: Ignoring unknown aesthetics: y
barchart

#ggsave("interaction_negative.svg",width=2.5,height=4)
#ggsave("interaction_negative.pdf",width=2.5,height=4)

Cluster Analysis

Goal: Identify and mark subjects who perceived dilution, who perceived strengthening, and who didn’t discriminate between the cases.

data_cluster <- tdata[-c(9:15)]

# append absolut deviations as new columns
data_cluster$Delta_Rating <- data_cluster$single_strength_rating - data_cluster$multiple_strength_rating



crit = 3 # Threshold criterion (needs to be exceeded to leave the invariance cluster)

data_cluster$Change[data_cluster$Delta_Rating > crit] <- "Dilution"
data_cluster$Change[data_cluster$Delta_Rating >= -crit & data_cluster$Delta_Rating <= crit] <- "Invariance"
data_cluster$Change[data_cluster$Delta_Rating < -crit] <- "Strengthening"



data_cluster %>% count(Change)
##          Change   n
## 1      Dilution 313
## 2    Invariance 124
## 3 Strengthening  43
# now append the clustering results to the main data frame 
data_cluster <- subset(data_cluster, select = c(1,10))
tdata_sub <- merge(tdata_sub, data_cluster, by = c("sID"))
Dilution <- prop.test(313,480,correct=FALSE)
Dilution
## 
##  1-sample proportions test without continuity correction
## 
## data:  313 out of 480, null probability 0.5
## X-squared = 44.408, df = 1, p-value = 2.666e-11
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.6084177 0.6933341
## sample estimates:
##         p 
## 0.6520833
Invariance <- prop.test(124,480,correct=FALSE)
Invariance
## 
##  1-sample proportions test without continuity correction
## 
## data:  124 out of 480, null probability 0.5
## X-squared = 112.13, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.2212025 0.2993016
## sample estimates:
##         p 
## 0.2583333
Strengthening <- prop.test(43,480,correct=FALSE)
Strengthening
## 
##  1-sample proportions test without continuity correction
## 
## data:  43 out of 480, null probability 0.5
## X-squared = 323.41, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.06718743 0.11849625
## sample estimates:
##          p 
## 0.08958333
## Warning: `fun.y` is deprecated. Use `fun` instead.

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

# Generative vs. Preventive 
gen <- subset(tdata_sub, Process == "generative" | Process == "preventive")
gen %>% count(Change, by = Process)
##          Change         by   n
## 1      Dilution generative 368
## 2      Dilution preventive 258
## 3    Invariance generative  84
## 4    Invariance preventive 164
## 5 Strengthening generative  28
## 6 Strengthening preventive  58
# keep in mind that data are in long format i.e. each subject has to rows
# More dilution if process is generative?
prop.test(c(368/2,257/2), c(240,240), p = NULL, alternative = "two.sided",
          correct = TRUE)
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  c(368/2, 257/2) out of c(240, 240)
## X-squared = 27.238, df = 1, p-value = 1.799e-07
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  0.1443503 0.3181497
## sample estimates:
##    prop 1    prop 2 
## 0.7666667 0.5354167
# models in each of the four conditions 

# generative cause leading to positive effects
posgen <- subset(tdata_sub, Process == "generative" & Valence == "positive")
posgen %>% count(Change)
##          Change   n
## 1      Dilution 186
## 2    Invariance  40
## 3 Strengthening  14
Dilution <- prop.test(186/2,120,correct=FALSE)
Dilution
## 
##  1-sample proportions test without continuity correction
## 
## data:  186/2 out of 120, null probability 0.5
## X-squared = 36.3, df = 1, p-value = 1.692e-09
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.6924310 0.8405085
## sample estimates:
##     p 
## 0.775
Invariance <- prop.test(40/2,120,correct=FALSE)
Invariance
## 
##  1-sample proportions test without continuity correction
## 
## data:  40/2 out of 120, null probability 0.5
## X-squared = 53.333, df = 1, p-value = 2.815e-13
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.1105600 0.2434528
## sample estimates:
##         p 
## 0.1666667
Strengthening <- prop.test(14/2,120,correct=FALSE)
Strengthening
## 
##  1-sample proportions test without continuity correction
## 
## data:  14/2 out of 120, null probability 0.5
## X-squared = 93.633, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.02854101 0.11552592
## sample estimates:
##          p 
## 0.05833333
# models in each of the four conditions 

# preventive cause leading to positive effects
posprev <- subset(tdata_sub, Process == "preventive" & Valence == "positive")
posprev %>% count(Change)
##          Change   n
## 1      Dilution 120
## 2    Invariance 100
## 3 Strengthening  20
Dilution <- prop.test(120,240,correct=FALSE)
Dilution
## 
##  1-sample proportions test without continuity correction
## 
## data:  120 out of 240, null probability 0.5
## X-squared = 0, df = 1, p-value = 1
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.4372427 0.5627573
## sample estimates:
##   p 
## 0.5
Invariance <- prop.test(100,240,correct=FALSE)
Invariance
## 
##  1-sample proportions test without continuity correction
## 
## data:  100 out of 240, null probability 0.5
## X-squared = 6.6667, df = 1, p-value = 0.009823
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.356086 0.479873
## sample estimates:
##         p 
## 0.4166667
Strengthening <- prop.test(20,240,correct=FALSE)
Strengthening
## 
##  1-sample proportions test without continuity correction
## 
## data:  20 out of 240, null probability 0.5
## X-squared = 166.67, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.05459149 0.12520345
## sample estimates:
##          p 
## 0.08333333
# models in each of the four conditions 

# generative cause leading to negative effects
posprev <- subset(tdata_sub, Process == "generative" & Valence == "negative")
posprev %>% count(Change)
##          Change   n
## 1      Dilution 182
## 2    Invariance  44
## 3 Strengthening  14
Dilution <- prop.test(182,240,correct=FALSE)
Dilution
## 
##  1-sample proportions test without continuity correction
## 
## data:  182 out of 240, null probability 0.5
## X-squared = 64.067, df = 1, p-value = 1.203e-15
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.7003777 0.8081494
## sample estimates:
##         p 
## 0.7583333
Invariance <- prop.test(44,240,correct=FALSE)
Invariance
## 
##  1-sample proportions test without continuity correction
## 
## data:  44 out of 240, null probability 0.5
## X-squared = 96.267, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.1395000 0.2371442
## sample estimates:
##         p 
## 0.1833333
Strengthening <- prop.test(14,240,correct=FALSE)
Strengthening
## 
##  1-sample proportions test without continuity correction
## 
## data:  14 out of 240, null probability 0.5
## X-squared = 187.27, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.03506244 0.09552019
## sample estimates:
##          p 
## 0.05833333
# models in each of the four conditions 

# preventive cause leading to negative effects
posprev <- subset(tdata_sub, Process == "preventive" & Valence == "negative")
posprev %>% count(Change)
##          Change   n
## 1      Dilution 138
## 2    Invariance  64
## 3 Strengthening  38
Dilution <- prop.test(138,240,correct=FALSE)
Dilution
## 
##  1-sample proportions test without continuity correction
## 
## data:  138 out of 240, null probability 0.5
## X-squared = 5.4, df = 1, p-value = 0.02014
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.5117599 0.6358770
## sample estimates:
##     p 
## 0.575
Invariance <- prop.test(64,240,correct=FALSE)
Invariance
## 
##  1-sample proportions test without continuity correction
## 
## data:  64 out of 240, null probability 0.5
## X-squared = 52.267, df = 1, p-value = 4.845e-13
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.2147163 0.3259688
## sample estimates:
##         p 
## 0.2666667
Strengthening <- prop.test(38,240,correct=FALSE)
Strengthening
## 
##  1-sample proportions test without continuity correction
## 
## data:  38 out of 240, null probability 0.5
## X-squared = 112.07, df = 1, p-value < 2.2e-16
## alternative hypothesis: true p is not equal to 0.5
## 95 percent confidence interval:
##  0.1175813 0.2098505
## sample estimates:
##         p 
## 0.1583333
# check if the proportion of strengtheners is higher in the prev_neg condition compared to all the others 

strengthening_prev_neg <- 27
strengthening_rest <- 45
n_prev_neg <- 120
n_rest <- 120*3

x <- c(strengthening_prev_neg,strengthening_rest)
n <- c(n_prev_neg,n_rest <- 120*3)

prop.test(x, n, p = NULL, alternative = "two.sided",
          correct = TRUE)
## 
##  2-sample test for equality of proportions with continuity correction
## 
## data:  x out of n
## X-squared = 6.2963, df = 1, p-value = 0.0121
## alternative hypothesis: two.sided
## 95 percent confidence interval:
##  0.01229075 0.18770925
## sample estimates:
## prop 1 prop 2 
##  0.225  0.125