# read data 
library(readr)
tdata <- read_csv("tdata_final.csv")

1 Demographics

table(tdata$gender) #%>% sum()
## 
##              1: male            2: female        3: non-binary 
##                  211                  203                    5 
## 4: prefer not to say 
##                    1
#tdata$age <- as.numeric(tdata$age)

mean(tdata$age)
## [1] 38.34762
sd(tdata$age)
## [1] 12.61238
min(tdata$age)
## [1] 18
max(tdata$age)
## [1] 73

2 Data handling

# add a column that represents the transformations as a factor
tdata$Transformation <- factor(tdata$test_stimulus, 
                               levels = c("img/Left_Y_Symmetry_Big.svg",
                                          "img/Left_Y_Symmetry_Angle.svg",
                                          "img/Left_Y_Symmetry_X_Rotation.svg",
                                          "img/Left_Y_Symmetry_X_Rotation_180.svg",
                                          "img/Left_Y_Symmetry_X_Symmetry.svg",
                                          "img/Left_Y_Symmetry_Y_Translation.svg",
                                          "img/Left_Y_Symmetry_X_Translation.svg",
                                          "img/Right_Y_Symmetry_Big.svg",
                                          "img/Right_Y_Symmetry_Angle.svg",
                                          "img/Right_Y_Symmetry_X_Rotation.svg",
                                          "img/Right_Y_Symmetry_X_Rotation_180.svg",
                                          "img/Right_Y_Symmetry_X_Symmetry.svg",
                                          "img/Right_Y_Symmetry_Y_Translation.svg",
                                          "img/Right_Y_Symmetry_X_Translation.svg"), 
                               labels = c("Size", 
                                          "Shape", 
                                          "90-Rot.", 
                                          "180-Rot.", 
                                          "X-Refl.", 
                                          "Y-Tran.",
                                          "X-Tran.",
                                          "Size", 
                                          "Shape", 
                                          "90-Rot.", 
                                          "180-Rot.", 
                                          "X-Refl.", 
                                          "Y-Tran.",
                                          "X-Tran."))


# add another column that codes the side of the y-symm transformation as a factor
tdata$Side <- factor(tdata$Ysym_side, levels = c("left", "right"), labels = c("left", "right"))



tdata$selection_rec <- factor(tdata$dv_selection_rec, levels = c("Ysym", "None", "not-Ysym"), labels = c("Y-Refl.", "None", "Not-Y-Refl."))
table(tdata$condition)
## 
##  1  2  3  4  5  6  7  8  9 10 11 12 13 14 
## 30 30 30 30 30 30 30 30 30 30 30 30 30 30
table(tdata$Transformation)
## 
##     Size    Shape  90-Rot. 180-Rot.  X-Refl.  Y-Tran.  X-Tran. 
##       60       60       60       60       60       60       60

3 Graphs

# create a summary dataset that also contains the percentages

plotdata_between <- tdata %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))



plotdata_sub <- subset(plotdata_between, selection_rec == "Y-Refl.")

Get the CI values that will be plotted as error bars:

see: https://rcompanion.org/handbook/H_02.html

# create a summary dataset that also contains the percentages
plotdata_between <- tdata %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))


library(PropCIs)
library(DescTools)
library(purrr)

plotdata_between %>% 
  filter(Transformation == "Size") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> size_ci)
##            est    lwr.ci    upr.ci
## [1,] 0.1333333 0.0500000 0.2271559
## [2,] 0.0500000 0.0000000 0.1438226
## [3,] 0.8166667 0.7333333 0.9104893
plotdata_between %>% 
  filter(Transformation == "Shape") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> shape_ci)
##            est    lwr.ci    upr.ci
## [1,] 0.1833333 0.1000000 0.2977632
## [2,] 0.0500000 0.0000000 0.1644298
## [3,] 0.7666667 0.6833333 0.8810965
plotdata_between %>% 
  filter(Transformation == "90-Rot.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> ninerot_ci)
##             est     lwr.ci    upr.ci
## [1,] 0.11666667 0.03333333 0.2094774
## [2,] 0.06666667 0.00000000 0.1594774
## [3,] 0.81666667 0.73333333 0.9094774
plotdata_between %>% 
  filter(Transformation == "180-Rot.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> huneightyrot_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.1500000 0.03333333 0.2682955
## [2,] 0.2166667 0.10000000 0.3349622
## [3,] 0.6333333 0.51666667 0.7516289
plotdata_between %>% 
  filter(Transformation == "X-Refl.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> xrefl_ci)
##             est    lwr.ci    upr.ci
## [1,] 0.26666667 0.1666667 0.3962393
## [2,] 0.06666667 0.0000000 0.1962393
## [3,] 0.66666667 0.5666667 0.7962393
plotdata_between %>% 
  filter(Transformation == "Y-Tran.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> ytran_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.1833333 0.08333333 0.3030758
## [2,] 0.1166667 0.01666667 0.2364091
## [3,] 0.7000000 0.60000000 0.8197424
plotdata_between %>% 
  filter(Transformation == "X-Tran.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> xtran_ci)
##       est     lwr.ci    upr.ci
## [1,] 0.55 0.43333333 0.6857161
## [2,] 0.30 0.18333333 0.4357161
## [3,] 0.15 0.03333333 0.2857161
ci_low <- c(size_ci[,2], shape_ci[,2], ninerot_ci[,2], huneightyrot_ci[,2], xrefl_ci[,2], ytran_ci[,2], xtran_ci[,2])

ci_up <- c(size_ci[,3], shape_ci[,3], ninerot_ci[,3], huneightyrot_ci[,3], xrefl_ci[,3], ytran_ci[,3], xtran_ci[,3])
plotdata$ci_low <- ci_low
plotdata$ci_up <- ci_up
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

pvalues_x <- c(1:7)
pvalues <- c(rep("p < .001",6), "p = .057")

g<- ggplot(plotdata, 
       aes(x = Transformation,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "dodge") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  coord_cartesian(xlim =c(1, 7), ylim = c(0, 1.1))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 3.5,
            position = position_dodge(width = 1),
            vjust = -7) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selected Object",
       x = "Type of Transformation")+
  geom_pointrange(ymin = ci_low, ymax = ci_up, position = position_dodge(width = 0.89), shape = 22, size = 0.3)+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  #annotate("pointrange", x = plotdata$Transformation, y = plotdata$pct, 
   #        ymin = plotdata$ci_low, 
    #       ymax = plotdata$ci_up, 
     #      colour = "black", size = 0.8, shape = 22, fill = Transformation, fatten = 1)+
  #annotate("text", x = pvalues_x, y = Inf, label = pvalues, size = 4, vjust = 1.8)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13),legend.title = element_text(size = 13))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

g

#ggsave("selections_between.pdf",width=6,height=5)
ggsave("selections_dodged.svg",width=12,height=5)
ggsave("selections_dodged.pdf",width=12,height=5)

The method “sisongalz” is the default method. It is also the most recently developed method, and we’ll go with it. We nonetheless may want to check whether other methods lead immensely different results.

4 Data from pilot study

The pilot study was mostly identical with the main study but tested fewer subjects. One difference from the main study was that the pilot study contained an additional “explanation” screen where subjects were asked to write short explanations of their choice.

tdata_p <- read_csv("tdata_pilot.csv")
table(tdata_p$gender) #%>% sum()
## 
##              1: male            2: female        3: non-binary 
##                   95                  110                    4 
## 4: prefer not to say 
##                    1
#tdata_p$age <- as.numeric(tdata_p$age)

mean(tdata_p$age)
## [1] NA
sd(tdata_p$age)
## [1] NA
min(tdata_p$age)
## [1] "18"
max(tdata_p$age)
## [1] "78"
# add a column that represents the transformations as a factor
tdata_p$Transformation <- factor(tdata_p$test_stimulus, 
                               levels = c("img/Left_Y_Symmetry_Big.svg",
                                          "img/Left_Y_Symmetry_Angle.svg",
                                          "img/Left_Y_Symmetry_X_Rotation.svg",
                                          "img/Left_Y_Symmetry_X_Rotation_180.svg",
                                          "img/Left_Y_Symmetry_X_Symmetry.svg",
                                          "img/Left_Y_Symmetry_Y_Translation.svg",
                                          "img/Left_Y_Symmetry_X_Translation.svg",
                                          "img/Right_Y_Symmetry_Big.svg",
                                          "img/Right_Y_Symmetry_Angle.svg",
                                          "img/Right_Y_Symmetry_X_Rotation.svg",
                                          "img/Right_Y_Symmetry_X_Rotation_180.svg",
                                          "img/Right_Y_Symmetry_X_Symmetry.svg",
                                          "img/Right_Y_Symmetry_Y_Translation.svg",
                                          "img/Right_Y_Symmetry_X_Translation.svg"), 
                               labels = c("Size", 
                                          "Shape", 
                                          "90-Rot.", 
                                          "180-Rot.", 
                                          "X-Refl.", 
                                          "Y-Tran.",
                                          "X-Tran.",
                                          "Size", 
                                          "Shape", 
                                          "90-Rot.", 
                                          "180-Rot.", 
                                          "X-Refl.", 
                                          "Y-Tran.",
                                          "X-Tran."))


# add another column that codes the side of the y-symm transformation as a factor
tdata_p$Side <- factor(tdata_p$Ysym_side, levels = c("left", "right"), labels = c("left", "right"))



tdata_p$selection_rec <- factor(tdata_p$dv_selection_rec, levels = c("Ysym", "None", "not-Ysym"), labels = c("Y-Refl.", "None", "Not-Y-Refl."))
table(tdata_p$condition)
## 
##  1  2  3  4  5  6  7  8  9 10 11 12 13 14 
## 15 15 15 15 15 15 15 15 15 15 15 15 15 15
table(tdata_p$Transformation)
## 
##     Size    Shape  90-Rot. 180-Rot.  X-Refl.  Y-Tran.  X-Tran. 
##       30       30       30       30       30       30       30
# create a summary dataset that also contains the percentages

plotdata_between <- tdata_p %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))



plotdata_sub <- subset(plotdata_between, selection_rec == "Y-Refl.")

Get the CI values that will be plotted as error bars:

see: https://rcompanion.org/handbook/H_02.html

# create a summary dataset that also contains the percentages
plotdata_between <- tdata_p %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))


library(PropCIs)
library(DescTools)
library(purrr)

plotdata_between %>% 
  filter(Transformation == "Size") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> size_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.1666667 0.06666667 0.3026767
## [2,] 0.8333333 0.73333333 0.9693433
plotdata_between %>% 
  filter(Transformation == "Shape") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> shape_ci)
##             est     lwr.ci    upr.ci
## [1,] 0.20000000 0.06666667 0.3552812
## [2,] 0.06666667 0.00000000 0.2219479
## [3,] 0.73333333 0.60000000 0.8886145
plotdata_between %>% 
  filter(Transformation == "90-Rot.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> ninerot_ci)
##             est     lwr.ci    upr.ci
## [1,] 0.06666667 0.00000000 0.2179374
## [2,] 0.13333333 0.03333333 0.2846041
## [3,] 0.80000000 0.70000000 0.9512708
plotdata_between %>% 
  filter(Transformation == "180-Rot.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> huneightyrot_ci)
##             est    lwr.ci    upr.ci
## [1,] 0.23333333 0.1000000 0.4047986
## [2,] 0.06666667 0.0000000 0.2381319
## [3,] 0.70000000 0.5666667 0.8714653
plotdata_between %>% 
  filter(Transformation == "X-Refl.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> xrefl_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.2333333 0.10000000 0.4308808
## [2,] 0.1666667 0.03333333 0.3642141
## [3,] 0.6000000 0.46666667 0.7975475
plotdata_between %>% 
  filter(Transformation == "Y-Tran.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> ytran_ci)
##            est lwr.ci    upr.ci
## [1,] 0.1333333    0.0 0.2851916
## [2,] 0.1333333    0.0 0.2851916
## [3,] 0.7333333    0.6 0.8851916
plotdata_between %>% 
  filter(Transformation == "X-Tran.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> xtran_ci)
##      est    lwr.ci    upr.ci
## [1,] 0.3 0.1333333 0.5017336
## [2,] 0.3 0.1333333 0.5017336
## [3,] 0.4 0.2333333 0.6017336
ci_low <- c(size_ci[,2], shape_ci[,2], ninerot_ci[,2], huneightyrot_ci[,2], xrefl_ci[,2], ytran_ci[,2], xtran_ci[,2])

ci_up <- c(size_ci[,3], shape_ci[,3], ninerot_ci[,3], huneightyrot_ci[,3], xrefl_ci[,3], ytran_ci[,3], xtran_ci[,3])
plotdata$ci_low <- ci_low
plotdata$ci_up <- ci_up
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

pvalues_x <- c(1:7)
pvalues <- c(rep("p < .001",6), "p = .057")

g<- ggplot(plotdata, 
       aes(x = Transformation,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "dodge") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  coord_cartesian(xlim =c(1, 7), ylim = c(0, 1.1))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 3.5,
            position = position_dodge(width = 1),
            vjust = -7) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selected Object",
       x = "Type of Transformation")+
  geom_pointrange(ymin = ci_low, ymax = ci_up, position = position_dodge(width = 0.89), shape = 22, size = 0.3)+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  #annotate("pointrange", x = plotdata$Transformation, y = plotdata$pct, 
   #        ymin = plotdata$ci_low, 
    #       ymax = plotdata$ci_up, 
     #      colour = "black", size = 0.8, shape = 22, fill = Transformation, fatten = 1)+
  #annotate("text", x = pvalues_x, y = Inf, label = pvalues, size = 4, vjust = 1.8)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13),legend.title = element_text(size = 13))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

g

#ggsave("selections_between.pdf",width=6,height=5)
ggsave("pilot_selections_dodged.svg",width=12,height=5)
ggsave("pilot_selections_dodged.pdf",width=12,height=5)

5 Aggregate Pilot and Main

tdata_p <- subset(tdata_p, select = -c(explanation) )
tdata_t <- rbind(tdata, tdata_p)


table(tdata_t$condition)
## 
##  1  2  3  4  5  6  7  8  9 10 11 12 13 14 
## 45 45 45 45 45 45 45 45 45 45 45 45 45 45
table(tdata_t$Transformation)
## 
##     Size    Shape  90-Rot. 180-Rot.  X-Refl.  Y-Tran.  X-Tran. 
##       90       90       90       90       90       90       90
# create a summary dataset that also contains the percentages

plotdata_between <- tdata_t %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))



plotdata_sub <- subset(plotdata_between, selection_rec == "Y-Refl.")

Get the CI values that will be plotted as error bars:

see: https://rcompanion.org/handbook/H_02.html

# create a summary dataset that also contains the percentages
plotdata_between <- tdata_t %>%
  group_by(Transformation, selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))


library(PropCIs)
library(DescTools)
library(purrr)

plotdata_between %>% 
  filter(Transformation == "Size") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> size_ci)
##             est     lwr.ci    upr.ci
## [1,] 0.14444444 0.07777778 0.2237677
## [2,] 0.03333333 0.00000000 0.1126566
## [3,] 0.82222222 0.75555556 0.9015455
plotdata_between %>% 
  filter(Transformation == "Shape") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> shape_ci)
##             est    lwr.ci    upr.ci
## [1,] 0.18888889 0.1111111 0.2793715
## [2,] 0.05555556 0.0000000 0.1460382
## [3,] 0.75555556 0.6777778 0.8460382
plotdata_between %>% 
  filter(Transformation == "90-Rot.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> ninerot_ci)
##             est     lwr.ci    upr.ci
## [1,] 0.10000000 0.03333333 0.1812248
## [2,] 0.08888889 0.02222222 0.1701137
## [3,] 0.81111111 0.74444444 0.8923359
plotdata_between %>% 
  filter(Transformation == "180-Rot.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> huneightyrot_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.1777778 0.08888889 0.2801202
## [2,] 0.1666667 0.07777778 0.2690091
## [3,] 0.6555556 0.56666667 0.7578980
plotdata_between %>% 
  filter(Transformation == "X-Refl.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> xrefl_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.2555556 0.16666667 0.3607485
## [2,] 0.1000000 0.01111111 0.2051929
## [3,] 0.6444444 0.55555556 0.7496373
plotdata_between %>% 
  filter(Transformation == "Y-Tran.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> ytran_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.1666667 0.08888889 0.2663921
## [2,] 0.1222222 0.04444444 0.2219476
## [3,] 0.7111111 0.63333333 0.8108365
plotdata_between %>% 
  filter(Transformation == "X-Tran.") -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> xtran_ci)
##            est    lwr.ci    upr.ci
## [1,] 0.4666667 0.3666667 0.5830584
## [2,] 0.3000000 0.2000000 0.4163917
## [3,] 0.2333333 0.1333333 0.3497251
ci_low <- c(size_ci[,2], shape_ci[,2], ninerot_ci[,2], huneightyrot_ci[,2], xrefl_ci[,2], ytran_ci[,2], xtran_ci[,2])

ci_up <- c(size_ci[,3], shape_ci[,3], ninerot_ci[,3], huneightyrot_ci[,3], xrefl_ci[,3], ytran_ci[,3], xtran_ci[,3])
plotdata$ci_low <- ci_low
plotdata$ci_up <- ci_up
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

pvalues_x <- c(1:7)
pvalues <- c(rep("p < .001",6), "p = .057")

g<- ggplot(plotdata, 
       aes(x = Transformation,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "dodge") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  coord_cartesian(xlim =c(1, 7), ylim = c(0, 1.1))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 3.5,
            position = position_dodge(width = 1),
            vjust = -7) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selected Object",
       x = "Type of Transformation")+
  geom_pointrange(ymin = ci_low, ymax = ci_up, position = position_dodge(width = 0.89), shape = 22, size = 0.3)+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  #annotate("pointrange", x = plotdata$Transformation, y = plotdata$pct, 
   #        ymin = plotdata$ci_low, 
    #       ymax = plotdata$ci_up, 
     #      colour = "black", size = 0.8, shape = 22, fill = Transformation, fatten = 1)+
  #annotate("text", x = pvalues_x, y = Inf, label = pvalues, size = 4, vjust = 1.8)+
  theme(legend.position = "top", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13),legend.title = element_text(size = 13))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())

g

#ggsave("selections_between.pdf",width=6,height=5)
ggsave("pilot_and_main_selections_dodged.svg",width=12,height=5)
ggsave("pilot_and_main_selections_dodged.pdf",width=12,height=5)

6 Graph averaging over transformations

6.1 Main study

# create a summary dataset that also contains the percentages

plotdata_between <- tdata %>%
  group_by(selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
library(PropCIs)
library(DescTools)
library(purrr)

plotdata_between -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> selection_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.2261905 0.18095238 0.2726978
## [2,] 0.1238095 0.07857143 0.1703169
## [3,] 0.6500000 0.60476190 0.6965074
ci_low <- c(selection_ci[,2])

ci_up <- c(selection_ci[,3])
plotdata <- plotdata_between

plotdata$ci_low <- ci_low
plotdata$ci_up <- ci_up
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

pvalues_x <- c(1:7)
pvalues <- c(rep("p < .001",6), "p = .057")

g<- ggplot(plotdata, 
       aes(x = selection_rec,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "dodge") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  #coord_cartesian(xlim =c(1, 7), ylim = c(0, 1.1))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 3.5,
            position = position_dodge(width = 1),
            vjust = -7) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selected Object",
       x = "Selected Object ")+
  geom_pointrange(ymin = ci_low, ymax = ci_up, position = position_dodge(width = 0.89), shape = 22, size = 0.3)+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  #annotate("pointrange", x = plotdata$Transformation, y = plotdata$pct, 
   #        ymin = plotdata$ci_low, 
    #       ymax = plotdata$ci_up, 
     #      colour = "black", size = 0.8, shape = 22, fill = Transformation, fatten = 1)+
  #annotate("text", x = pvalues_x, y = Inf, label = pvalues, size = 4, vjust = 1.8)+
  theme(legend.position = "none", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13),legend.title = element_text(size = 13))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  ggtitle("Main Study (N = 420)")

g

#ggsave("selections_between.pdf",width=6,height=5)
ggsave("main_averaged_over_transformations.svg",width=5,height=5)
ggsave("main_averaged_over_transformations.pdf",width=5,height=5)

6.2 Pilot study

# create a summary dataset that also contains the percentages

plotdata_between <- tdata_p %>%
  group_by(selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
library(PropCIs)
library(DescTools)
library(purrr)

plotdata_between -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> selection_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.1904762 0.13333333 0.2564584
## [2,] 0.1238095 0.06666667 0.1897917
## [3,] 0.6857143 0.62857143 0.7516965
ci_low <- c(selection_ci[,2])

ci_up <- c(selection_ci[,3])
plotdata <- plotdata_between

plotdata$ci_low <- ci_low
plotdata$ci_up <- ci_up
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

pvalues_x <- c(1:7)
pvalues <- c(rep("p < .001",6), "p = .057")

g<- ggplot(plotdata, 
       aes(x = selection_rec,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "dodge") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  #coord_cartesian(xlim =c(1, 7), ylim = c(0, 1.1))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 3.5,
            position = position_dodge(width = 1),
            vjust = -7) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selected Object",
       x = "Selected Object ")+
  geom_pointrange(ymin = ci_low, ymax = ci_up, position = position_dodge(width = 0.89), shape = 22, size = 0.3)+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  #annotate("pointrange", x = plotdata$Transformation, y = plotdata$pct, 
   #        ymin = plotdata$ci_low, 
    #       ymax = plotdata$ci_up, 
     #      colour = "black", size = 0.8, shape = 22, fill = Transformation, fatten = 1)+
  #annotate("text", x = pvalues_x, y = Inf, label = pvalues, size = 4, vjust = 1.8)+
  theme(legend.position = "none", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13),legend.title = element_text(size = 13))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  ggtitle("Pilot Study (N = 215)")

g

#ggsave("selections_between.pdf",width=6,height=5)
ggsave("pilot_averaged_over_transformations.svg",width=5,height=5)
ggsave("pilot_averaged_over_transformations.pdf",width=5,height=5)

6.3 Pilot and Main together

# create a summary dataset that also contains the percentages

plotdata_between <- tdata_t %>%
  group_by(selection_rec) %>%
  summarize(n = n()) %>% 
  mutate(pct = n/sum(n),
         lbl = scales::percent(pct))
library(PropCIs)
library(DescTools)
library(purrr)

plotdata_between -> transf
  
(MultinomCI(transf$n,
           conf.level=0.95,
           method="sisonglaz") -> selection_ci)
##            est     lwr.ci    upr.ci
## [1,] 0.2142857 0.17777778 0.2521209
## [2,] 0.1238095 0.08730159 0.1616447
## [3,] 0.6619048 0.62539683 0.6997399
ci_low <- c(selection_ci[,2])

ci_up <- c(selection_ci[,3])
plotdata <- plotdata_between

plotdata$ci_low <- ci_low
plotdata$ci_up <- ci_up
library(scales)
theme_set(theme_light(base_size = 12, base_family = "Poppins"))

pvalues_x <- c(1:7)
pvalues <- c(rep("p < .001",6), "p = .057")

g<- ggplot(plotdata, 
       aes(x = selection_rec,
           y = pct,
           fill = selection_rec)) +
  geom_bar(stat = "identity",
           position = "dodge") +
  scale_y_continuous(limits = seq(0, 2),
                     breaks = seq(0, 1, .25),
                     expand = c(0,0),
                     label = percent) +
  #coord_cartesian(xlim =c(1, 7), ylim = c(0, 1.1))+
  #coord_cartesian(clip = "off")+
  geom_text(aes(label = lbl), 
            size = 3.5,
            position = position_dodge(width = 1),
            vjust = -7) +
  scale_fill_brewer(palette = "Pastel1") +
  labs(y = "Percentage", 
       fill = "Selected Object",
       x = "Selected Object ")+
  geom_pointrange(ymin = ci_low, ymax = ci_up, position = position_dodge(width = 0.89), shape = 22, size = 0.3)+
  #annotate(geom = "hline",yintercept = 0.5, y = 0.5, color = "black", size = 1, linetype='dotted')+
  #annotate("pointrange", x = plotdata$Transformation, y = plotdata$pct, 
   #        ymin = plotdata$ci_low, 
    #       ymax = plotdata$ci_up, 
     #      colour = "black", size = 0.8, shape = 22, fill = Transformation, fatten = 1)+
  #annotate("text", x = pvalues_x, y = Inf, label = pvalues, size = 4, vjust = 1.8)+
  theme(legend.position = "none", axis.title = element_text(size = 15), axis.text = element_text(size = 13, color = "black"),
        legend.text = element_text(size = 13),legend.title = element_text(size = 13))+
  theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())+
  ggtitle("Pilot and Main Study together (N = 635)")

g

#ggsave("selections_between.pdf",width=6,height=5)
ggsave("pilot_and_main_averaged_over_transformations.svg",width=5,height=5)
ggsave("pilot_and_main_averaged_over_transformations.pdf",width=5,height=5)