Browse Source

complete repetition analyses for all effects reported in main text

Lennart Wittkuhn 3 years ago
parent
commit
1e29cbff82
1 changed files with 34 additions and 34 deletions
  1. 34 34
      code/highspeed-analysis-repetition.Rmd

+ 34 - 34
code/highspeed-analysis-repetition.Rmd

@@ -691,10 +691,10 @@ df3_test = df3 %>%
   )] %>% verify(all(num_comp == 2))
 ```
 
-# Sequence transitions
+### Transitions
 
-**Question: Are there more within sequence transitions than transitions to
-out-of-sequence elements?**
+We analyzed if  there more within sequence transitions than transitions to
+out-of-sequence elements:
 
 ```{r}
 transition_type <- function(head, tail){
@@ -867,23 +867,18 @@ ggsave(filename = "highspeed_plot_decoding_repetition_transition_matrix.pdf",
 
 
 ```{r, echo = FALSE, dev = "cairo_pdf"}
-plot_rep_trans <- function(dt){ggplot(
-  data = dt, aes(x = as.factor(step_type), y = as.numeric(mean_proportion),
-                 fill = as.factor(step_type))) +
-    # geom_flat_violin(scale = "width", trim = FALSE, color = NA,
-    #                   position = position_nudge(x = 0.15, y = 0)) +
-    #geom_point(stat = "summary", fun.y = "mean", color = "black",
-    #             position = position_nudge(x = 0.25, y = 0), pch = 23) +
-    # geom_errorbar(stat = "summary", fun.data = "mean_se", width = 0,
-    #                position = position_nudge(x = 0.25, y = 0), color = "black") +
-    # geom_boxplot(outlier.colour = "black", outlier.shape = NA, outlier.size = 50,
-    #               notch = FALSE, outlier.alpha = 1, width = 0.1, color = "black",
-    #               alpha = 1, position = position_nudge(x = -0.2, y = 0)) +
-    geom_bar(aes(fill = as.factor(step_type)),
-             stat = "identity", color = "black", position = position_dodge()) +
-    geom_errorbar(aes(ymin = sem_lower, ymax = sem_upper), width = 0, position = position_dodge(.9)) +
-    #geom_point(position = position_jitter(width = .05, height = 0, seed = 4),
-    #             pch = 21, alpha = 1, color = "black") +
+plot_rep_trans <- function(dt){
+  ggplot(
+    data = dt, aes(x = as.factor(step_type), y = as.numeric(mean_proportion),
+                   fill = as.factor(step_type))) +
+    geom_bar(stat = "summary", fun = "mean",
+      aes(fill = as.factor(step_type)),
+      color = "black",
+      position = position_dodge()) +
+    geom_point(position = position_jitter(width = .2, height = 0, seed = 4),
+                 pch = 21, alpha = 0.5, color = "black") +
+    geom_errorbar(stat = "summary", fun.data = "mean_se", width = 0,
+                  position = position_dodge(.9), color = "black") +
     facet_wrap(~ as.factor(change), labeller = as_labeller(facet_labels_new)) +
     xlab("Serial event") +
     #xlab(expression(paste("Time-point of change to ", 2^nd, " serial event"))) +
@@ -894,25 +889,25 @@ plot_rep_trans <- function(dt){ggplot(
     #scale_x_discrete(labels = as_labeller(facet_labels_new)) +
     #theme(legend.position = "right", legend.direction = "vertical", legend.justification = "center") +
     theme(legend.position = "bottom", legend.direction = "horizontal",
-        legend.justification = "center", legend.margin = margin(t = 0, r = 0, b = 0, l = 0),
-        legend.box.margin = margin(t = -10, r = 0, b = 10, l = 0)) +
+          legend.justification = "center", legend.margin = margin(t = 0, r = 0, b = 0, l = 0),
+          legend.box.margin = margin(t = -10, r = 0, b = 10, l = 0)) +
     guides(fill = guide_legend(nrow = 2, title.position = "top", title.hjust = 0.5)) +
     theme(panel.background = element_blank()) +
     #theme(plot.margin = unit(c(t = 1, r = 1, b = 1, l = 1), "pt")) +
     theme(axis.line.y = element_line(colour = "black"),
-        axis.line.x = element_line(colour = "white"),
-        panel.grid.major = element_blank(),
-        panel.grid.minor = element_blank(),
-        panel.border = element_blank(),
-        panel.background = element_blank(),
-        axis.text.x = element_blank(),
-        axis.title.x = element_blank(),
-        axis.ticks.x = element_line(colour = "white"))
+          axis.line.x = element_line(colour = "white"),
+          panel.grid.major = element_blank(),
+          panel.grid.minor = element_blank(),
+          panel.border = element_blank(),
+          panel.background = element_blank(),
+          axis.text.x = element_blank(),
+          axis.title.x = element_blank(),
+          axis.ticks.x = element_line(colour = "white"))
 }
 
 # & change %in% c(2,9)
 fig_trans_prop = plot_rep_trans(dt = subset(
-  dt_pred_rep_step_mean, classification == "ovr" & change %in% c(2,9) &
+  dt_pred_rep_step_version1, classification == "ovr" & change %in% c(2,9) &
   step_type != "repetition 1" & step_type != "repetition 2" & step_type != "repetition out"
 ))
 fig_trans_prop
@@ -942,10 +937,10 @@ dt_pred_rep_trans_test = dt_pred_rep_step_version1 %>%
          df = ttest_outwards$parameter,
          ttest_outwards_pvalue = p.adjust(ttest_outwards$p.value,
                                           method = "bonferroni", n = 4),
-         ttest_outwards_tvalue = ttest_outwards$statistic,
+         ttest_outwards_tvalue = round(ttest_outwards$statistic, 2),
          ttest_outside_pvalue = p.adjust(ttest_outside$p.value,
                                           method = "bonferroni", n = 4),
-         ttest_outside_tvalue = ttest_outside$statistic,
+         ttest_outside_tvalue = round(ttest_outside$statistic, 2),
          num_subs = .N)
   }] %>%
   verify(all(num_subs == 36)) %>%
@@ -959,10 +954,15 @@ plot_grid(plot_grid(fig_a, fig_b, labels = c("a", "b")),
           plot_grid(fig_c, fig_trans_prop, labels = c("c", "d")),
           plot_grid(fig_trans_mat, labels = c("e")),
           ncol = 1, label_fontface = "bold")
+```
+
+```{r}
 ggsave(filename = "highspeed_plot_decoding_repetition.pdf",
        plot = last_plot(), device = cairo_pdf, path = path_figures, scale = 1,
        dpi = "retina", width = 10, height = 10)
+ggsave(filename = "wittkuhn_schuck_figure_4.pdf",
+       plot = last_plot(), device = cairo_pdf, path = path_figures, scale = 1,
+       dpi = "retina", width = 10, height = 10)
 ```
 
 
-