set.seed(12345) # for reproducibility

if (!require("Rmisc", quietly = TRUE)) install.packages("Rmisc") # Never load it directly.
pacman::p_load(tidyverse, psych)
pacman::p_load(knitr, ggridges)
pacman::p_load(rstatix, TOSTER, pwr)
pacman::p_load(cowplot)
pacman::p_load_gh("thomasp85/patchwork")
pacman::p_load_gh("RLesur/klippy", "mitchelloharawild/icons")

options(knitr.kable.NA = '')
options(dplyr.summarise.inform=FALSE) # suppress warning in regards to regrouping 
xcut <- 2

klippy::klippy()
# Exp1: distractor = O's
E1 <- read.csv("data/data_vstmAS1.csv", header = T)
headTail(E1)
##       SN Trial vstmLoad Targ Flnk Congruency Resp   RT vstmCond vstmResp vstmRT
## 1      1     1        1    1    1          1    1 1.15        2        2   1.13
## 2      1     2        2    1    2          0    1 1.36        1        2   1.22
## 3      1     3        1    2    1          0    2 0.84        1        1    0.7
## 4      1     4        1    1    2          0    1 1.21        2        2   0.68
## ...  ...   ...      ...  ...  ...        ...  ...  ...      ...      ...    ...
## 3837  20   189        1    2    1          0    2 0.94        2        2   0.54
## 3838  20   190        1    2    1          0    2 0.75        1        1   0.48
## 3839  20   191        1    2    2          1    2 0.76        1        1   0.55
## 3840  20   192        1    2    1          0    2 0.75        2        2   0.61

length(unique(E1$SN))
## [1] 20
table(E1$vstmLoad, E1$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
##   2 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
table(E1$Congruency, E1$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   0 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
##   1 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
table(E1$Resp, E1$SN) # 7 = no resp
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1  96  96  97  98  94  96  97  97  96  96  97  94  95  90  96  93  95  96  95
##   2  89  94  93  89  98  93  94  95  96  96  95  98  95 102  92  97  96  96  95
##   7   7   2   2   5   0   3   1   0   0   0   0   0   2   0   4   2   1   0   2
##    
##      20
##   1  94
##   2  97
##   7   1
table(E1$vstmResp, E1$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 113  84  99 114  89 111 109 111 102  87  88 106  97  99  96 106  97  99 108
##   2  78 103  93  77 103  79  83  81  89 104 103  86  95  92  95  86  93  92  82
##   7   1   5   0   1   0   2   0   0   1   1   1   0   0   1   1   0   2   1   2
##    
##      20
##   1 100
##   2  90
##   7   2

E1$SN <- factor(E1$SN)
E1$vstmLoad <- factor(E1$vstmLoad, levels=c(1,2), labels=c("Low","High"))
E1$Congruency <- factor(E1$Congruency, levels=c(0,1), labels=c("Incongruent","Congruent"))
E1$Corr <- ifelse(E1$Targ==E1$Resp,1,0)
E1$vstmCorr <- ifelse(E1$vstmCond==E1$vstmResp,1,0)
glimpse(E1, width=70)
## Rows: 3,840
## Columns: 13
## $ SN         <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ Trial      <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15…
## $ vstmLoad   <fct> Low, High, Low, Low, Low, High, Low, Low, Low, Lo…
## $ Targ       <int> 1, 1, 2, 1, 1, 2, 1, 1, 1, 1, 2, 1, 2, 2, 2, 2, 2…
## $ Flnk       <int> 1, 2, 1, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 2, 1…
## $ Congruency <fct> Congruent, Incongruent, Incongruent, Incongruent,…
## $ Resp       <int> 1, 1, 2, 1, 1, 7, 1, 1, 1, 1, 7, 1, 2, 2, 2, 2, 2…
## $ RT         <dbl> 1.1466, 1.3619, 0.8450, 1.2057, 1.0779, 7.0000, 0…
## $ vstmCond   <int> 2, 1, 1, 2, 2, 2, 1, 1, 2, 2, 1, 2, 1, 2, 1, 1, 1…
## $ vstmResp   <int> 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1…
## $ vstmRT     <dbl> 1.1304, 1.2176, 0.7007, 0.6774, 0.6777, 1.2781, 0…
## $ Corr       <dbl> 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1…
## $ vstmCorr   <dbl> 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1…

table(E1$Corr, E1$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  15  14   5   7   2   7   7   5   0   6   5   6   8  10   8   8   4   0   6
##   1 177 178 187 185 190 185 185 187 192 186 187 186 184 182 184 184 188 192 186
##    
##      20
##   0   4
##   1 188
table(E1$vstmCorr, E1$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  31  59  27  41   7  33  29  37  11  32  17  18  25  25  13  36  26  18  40
##   1 161 133 165 151 185 159 163 155 181 160 175 174 167 167 179 156 166 174 152
##    
##      20
##   0  10
##   1 182


# Exp2: distractor = ., blocked, 1 vs. 4
E2 <- read.csv("data/data_vstmAS2.csv", header = T)
headTail(E2)
##       SN Trial Block vstmLoad Targ Flnk TargPos FlnkPos Congruency Resp   RT
## 1      1     1     1        1    2    1       3       2          0    2 0.64
## 2      1     2     1        1    1    2       6       2          0    1  0.7
## 3      1     3     1        1    1    1       5       1          1    1 0.55
## 4      1     4     1        1    2    1       2       2          0    2 0.62
## ...  ...   ...   ...      ...  ...  ...     ...     ...        ...  ...  ...
## 3837  20   189     4        2    1    2       6       2          0    7    7
## 3838  20   190     4        2    1    2       6       1          0    1 0.75
## 3839  20   191     4        2    2    1       3       1          0    2 0.74
## 3840  20   192     4        2    2    2       6       1          1    2 0.65
##      vstmCond vstmResp vstmRT
## 1           1        1   0.62
## 2           2        2   0.62
## 3           1        1    0.6
## 4           2        2    0.8
## ...       ...      ...    ...
## 3837        1        1   1.65
## 3838        2        2   0.73
## 3839        2        2   0.73
## 3840        1        2   0.95

length(unique(E2$SN))
## [1] 20

table(E2$Block, E2$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   2 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   3 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   4 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
table(E2$vstmLoad, E2$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
##   2 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
table(E2$Congruency, E2$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   0 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
##   1 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
table(E2$Resp, E2$SN) # 7 = no resp
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1  97 112  98  92  92  95  98  97  99  98  99  97  84  96  92  97  95  98  99
##   2  93  75  94 100  99  97  92  95  93  94  91  93  93  96 100  89  97  94  93
##   7   2   5   0   0   1   0   2   0   0   0   2   2  15   0   0   6   0   0   0
##    
##      20
##   1  85
##   2 101
##   7   6
table(E2$vstmResp, E2$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 109  84 104 101 103  95 105 108 101 109 102 103  95 109  98  90  87  89 101
##   2  79 105  88  89  88  96  86  83  91  83  90  87  91  82  93 102 102 103  91
##   7   4   3   0   2   1   1   1   1   0   0   0   2   6   1   1   0   3   0   0
##    
##      20
##   1  95
##   2  94
##   7   3

E2$SN <- factor(E2$SN)
E2$vstmLoad <- factor(E2$vstmLoad, levels=c(1,2), labels=c("Low","High"))
E2$Congruency <- factor(E2$Congruency, levels=c(0,1), labels=c("Incongruent","Congruent"))
E2$Corr <- ifelse(E2$Targ==E2$Resp,1,0)
E2$vstmCorr <- ifelse(E2$vstmCond==E2$vstmResp,1,0)
glimpse(E2, width=70)
## Rows: 3,840
## Columns: 16
## $ SN         <fct> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ Trial      <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15…
## $ Block      <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1…
## $ vstmLoad   <fct> Low, Low, Low, Low, Low, Low, Low, Low, Low, Low,…
## $ Targ       <int> 2, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 2…
## $ Flnk       <int> 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 2, 2…
## $ TargPos    <int> 3, 6, 5, 2, 1, 5, 6, 6, 5, 1, 2, 2, 6, 6, 2, 4, 1…
## $ FlnkPos    <int> 2, 2, 1, 2, 1, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2…
## $ Congruency <fct> Incongruent, Incongruent, Congruent, Incongruent,…
## $ Resp       <int> 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, 2, 2, 1, 7, 1, 2…
## $ RT         <dbl> 0.6373, 0.6963, 0.5516, 0.6224, 0.7491, 0.7324, 0…
## $ vstmCond   <int> 1, 2, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 1, 1, 2, 1, 2…
## $ vstmResp   <int> 1, 2, 1, 2, 2, 7, 2, 2, 1, 1, 2, 2, 1, 1, 7, 1, 2…
## $ vstmRT     <dbl> 0.6211, 0.6161, 0.5994, 0.7982, 0.6049, 7.0000, 0…
## $ Corr       <dbl> 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1…
## $ vstmCorr   <dbl> 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1…

table(E2$Corr, E2$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0   6  30   2   6  14   3  10   7   5   4   7   7  28   4   4  12   1   6   5
##   1 186 162 190 186 178 189 182 185 187 188 185 185 164 188 188 180 191 186 187
##    
##      20
##   0  19
##   1 173
table(E2$vstmCorr, E2$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  34  70  28  35  19  15  31  22  21  29  24  42  47  31  34  14  26  23  15
##   1 158 122 164 157 173 177 161 170 171 163 168 150 145 161 158 178 166 169 177
##    
##      20
##   0  33
##   1 159
table(E2$TargPos, E2$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   2 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   3 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   5 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32


# Exp3: distractor = ., blocked, 0 vs. 3
E3 <- read.csv("data/data_vstmAS3.csv", header = T)
headTail(E3)
##       SN Trial Block vstmLoad Targ Flnk TargPos FlnkPos Congruency Resp   RT
## 1      1     1     1        1    2    2       4       1          1    7    7
## 2      1     2     1        1    2    1       2       2          0    2 1.08
## 3      1     3     1        1    2    1       5       1          0    2 1.03
## 4      1     4     1        1    1    1       5       2          1    1 0.83
## ...  ...   ...   ...      ...  ...  ...     ...     ...        ...  ...  ...
## 3837  20   189     4        2    1    2       4       1          0    1 1.01
## 3838  20   190     4        2    1    1       1       2          1    1 0.57
## 3839  20   191     4        2    1    2       3       1          0    1 0.82
## 3840  20   192     4        2    1    1       5       2          1    1 0.57
##      vstmCond vstmResp vstmRT
## 1           1        7      7
## 2           1        7      7
## 3           1        7      7
## 4           1        7      7
## ...       ...      ...    ...
## 3837        1        1   0.55
## 3838        2        2   0.62
## 3839        2        2   0.62
## 3840        1        1   0.74

length(unique(E3$SN))
## [1] 20

table(E3$Block, E3$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   2 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   3 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   4 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
table(E3$vstmLoad, E3$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
##   2 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
table(E3$Congruency, E3$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   0 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
##   1 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96
table(E3$Resp, E3$SN) # 7 = no resp
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1  97  98  99  90 101  99  98  99  90  95 100  94  96  92  98  91  91 110  96
##   2  94  93  93  99  91  88  93  90 102  96  92  98  96  97  94 101 100  82  96
##   7   1   1   0   3   0   5   1   3   0   1   0   0   0   3   0   0   1   0   0
##    
##      20
##   1  97
##   2  95
##   7   0
table(E3$vstmResp[E3$vstmLoad==2], E3$SN[E3$vstmLoad==2])
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 51 49 55 57 57 41 50 45 47 55 49 52 53 44 49 35 55 57 46 46
##   2 45 47 41 39 39 51 46 50 48 38 47 44 43 52 46 60 41 39 50 50
##   7  0  0  0  0  0  4  0  1  1  3  0  0  0  0  1  1  0  0  0  0

E3$SN <- factor(E3$SN)
E3$vstmLoad <- factor(E3$vstmLoad, levels=c(1,2), labels=c("Low","High"))
E3$Congruency <- factor(E3$Congruency, levels=c(0,1), labels=c("Incongruent","Congruent"))
E3$Corr <- ifelse(E3$Targ==E3$Resp,1,0)
E3$vstmCorr <- ifelse(E3$vstmLoad=="Low",1,ifelse(E3$vstmCond==E3$vstmResp,1,0))

table(E3$Corr, E3$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  10  22   3  18   5  18   4   7   6   7  18   8  10  13   6   9  25  30   4
##   1 182 170 189 174 187 174 188 185 186 185 174 184 182 179 186 183 167 162 188
##    
##      20
##   0   1
##   1 191
table(E3$vstmCorr, E3$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  13  19  13  23  15  24  18  22  17  18  15  16  11  18  14  34  11  31   8
##   1 179 173 179 169 177 168 174 170 175 174 177 176 181 174 178 158 181 161 184
##    
##      20
##   0   4
##   1 188
table(E3$TargPos, E3$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   2 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   3 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   4 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   5 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32
##   6 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32 32


# Exp4: perceptual load
E4 <- read.csv("data/data_vstmAS4.csv", header = T)
headTail(E4)
##       SN Trial Block PercLoad Targ Flnk TargPos FlnkPos Congruency Resp   RT
## 1      1     1     1        1    2    2       2       2          1    7    7
## 2      1     2     1        1    2    2       4       2          1    2 0.64
## 3      1     3     1        1    2    1       6       1          0    1 0.47
## 4      1     4     1        1    2    1       3       2          0    2 0.78
## ...  ...   ...   ...      ...  ...  ...     ...     ...        ...  ...  ...
## 8061  21   381     8        2    1    1       2       1          1    1 0.84
## 8062  21   382     8        2    2    2       2       2          1    2 0.79
## 8063  21   383     8        2    2    1       4       1          0    2 0.82
## 8064  21   384     8        2    1    2       6       1          0    1 0.79

length(unique(E4$SN))
## [1] 21

table(E4$Block, E4$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21
##   1 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   2 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   3 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   4 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   5 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   6 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   7 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   8 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
table(E4$PercLoad, E4$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##   2 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##    
##      20  21
##   1 192 192
##   2 192 192
table(E4$Congruency, E4$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##   1 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##    
##      20  21
##   0 192 192
##   1 192 192
table(E4$Resp, E4$SN) # 7 = no resp
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 183 198 196 191 191 198 193 192 192 194 202 197 191 198 176 190 194 192 197
##   2 190 186 188 193 191 185 190 191 190 189 182 186 193 186 208 191 189 192 187
##   7  11   0   0   0   2   1   1   1   2   1   0   1   0   0   0   3   1   0   0
##    
##      20  21
##   1 199 196
##   2 185 188
##   7   0   0

E4$SN <- factor(E4$SN)
E4$PercLoad <- factor(E4$PercLoad, levels=c(1,2), labels=c("Low","High"))
E4$Congruency <- factor(E4$Congruency, levels=c(0,1), labels=c("Incongruent","Congruent"))
E4$Corr <- ifelse(E4$Targ==E4$Resp,1,0)

table(E4$Corr, E4$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  76  18   8  55  31  31  40  25  27  26  18  14   5  44  58  60  21  18  15
##   1 308 366 376 329 353 353 344 359 357 358 366 370 379 340 326 324 363 366 369
##    
##      20  21
##   0  21  14
##   1 363 370


# Exp5: overlap
E5 <- read.csv("data/data_vstmAS5.csv", header = T)
headTail(E5)
##       SN Trial Block vstmLoad Overlap Targ Flnk TargPos FlnkPos Congruency Resp
## 1      1     1     1        1       0    2    2       2       2          1    2
## 2      1     2     1        1       0    2    2       4       2          1    2
## 3      1     3     1        1       1    2    1       6       1          0    2
## 4      1     4     1        1       0    2    1       3       2          0    1
## ...  ...   ...   ...      ...     ...  ...  ...     ...     ...        ...  ...
## 7677  20   381     8        1       1    1    1       2       1          1    1
## 7678  20   382     8        1       1    2    1       5       2          0    2
## 7679  20   383     8        1       0    1    2       3       2          0    1
## 7680  20   384     8        1       0    1    1       4       2          1    1
##        RT vstmPos vstmCond vstmResp vstmRT
## 1    0.52       1        2        2   0.44
## 2    0.51       1        2        2   0.69
## 3     0.5       1        1        1   0.74
## 4    0.56       1        1        2   1.04
## ...   ...     ...      ...      ...    ...
## 7677 0.82       1        1        1   0.49
## 7678 0.75       2        2        2   0.48
## 7679 0.62       1        1        1   0.61
## 7680 0.63       1        1        1   0.49

table(E5$Block, E5$SN)
##    
##      1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20
##   1 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   2 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   3 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   4 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   5 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   6 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   7 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
##   8 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48 48
table(E5$vstmLoad, E5$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##   2 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##    
##      20
##   1 192
##   2 192
table(E5$Overlap, E5$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##   1 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##    
##      20
##   0 192
##   1 192
table(E5$Congruency, E5$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##   1 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##    
##      20
##   0 192
##   1 192
table(E5$vstmPos, E5$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##   2 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192 192
##    
##      20
##   1 192
##   2 192
table(E5$Resp, E5$SN) # 7 = no resp
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   1 188 196 189 191 199 194 185 189 189 192 197 189 193 189 188 196 190 183 178
##   2 195 186 193 193 185 189 197 195 193 192 183 195 188 193 193 181 191 200 206
##   7   1   2   2   0   0   1   2   0   2   0   4   0   3   2   3   7   3   1   0
##    
##      20
##   1 195
##   2 189
##   7   0

E5$SN <- factor(E5$SN)
E5$vstmLoad <- factor(E5$vstmLoad, levels=c(1,2), labels=c("Low","High"))
E5$Congruency <- factor(E5$Congruency, levels=c(0,1), labels=c("Incongruent","Congruent"))
E5$Overlap <- factor(E5$Overlap, levels=c(0,1), labels=c("NonOverlap","Overlap"))
E5$Corr <- ifelse(E5$Targ==E5$Resp,1,0)
E5$vstmCorr <- ifelse(E5$vstmCond==E5$vstmResp,1,0)

table(E5$Corr, E5$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  19   9   5   3  21   7  14   3   9   4  10   3  10   8  12  22  20  48  22
##   1 365 375 379 381 363 377 370 381 375 380 374 381 374 376 372 362 364 336 362
##    
##      20
##   0   9
##   1 375
table(E5$vstmCorr, E5$SN)
##    
##       1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
##   0  70  64  57  62  41  93  60  58  46  52  78  90  90  63  82  69  73  62  57
##   1 314 320 327 322 343 291 324 326 338 332 306 294 294 321 302 315 311 322 327
##    
##      20
##   0  52
##   1 332






1 Experiment 1

VSTM low loadhigh load 조건의 기억항목은 각각 한 개와 네 개. 두 조건은 무작위 순서(interleaved).

ggdraw() + draw_image("fig_proc/procExp1.png")

1.1 VSTM: Accuracy

E1 %>% group_by(SN, vstmLoad) %>% 
    summarise(acc = mean(vstmCorr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = "SN", names_from = "vstmLoad", values_from = "acc") %>% 
    mutate(Diff = Low - High) %>% 
    pivot_longer(cols = Low:Diff, names_to = "Load", values_to = "Accuracy") %>% 
    mutate(Load = factor(.$Load, levels = c("Low", "High", "Diff"), 
                                             labels = c("Low", "High", "Diff"))) %>% 
    group_by(Load) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-2) %>% 
    kable(digits = 2, caption = "VSTM: Descriptive Stats")
VSTM: Descriptive Stats
Load n mean sd median iqr ci
Low 20 92.71 5.22 94.27 6.51 2.44
High 20 79.43 9.62 81.25 13.28 4.50
Diff 20 13.28 8.05 12.50 11.72 3.77

v1 <- E1 %>% group_by(SN, vstmLoad) %>% summarise(acc = mean(vstmCorr)*100) %>% ungroup()
v1g <- v1 %>% Rmisc::summarySEwithin(measurevar = 'acc', withinvars = 'vstmLoad', idvar = 'SN')

v1 %>% ggplot(aes(x=vstmLoad, y=acc)) +
    geom_violin(width = 0.5, trim=TRUE) + 
    geom_point(color="gray80", size=1.8) +
    geom_line(aes(group = SN), color="gray80") +
    geom_errorbar(data=v1g, aes(x = vstmLoad, ymin = acc-ci, ymax = acc+ci),
                                position = position_dodge(0.8), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=v1g, aes(x = vstmLoad, y = acc),
                         position=position_dodge(0.8), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Change Detection Accuracy (%)") +
    coord_cartesian(ylim = c(50, 100), clip = "on") +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())



v1 %>% pairwise_t_test(acc ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
Low High 20 20 7.38 19 0 0 ****
v1 %>% cohens_d(acc ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
Low High 1.65 20 20 large

1.2 VSTM: K

Cowan’s K(Rouder et al., 2011, PBR).

k1 <- E1 %>% 
    group_by(SN, vstmLoad, vstmCond) %>% # vstmCond: change = 1 or not = 2
    summarise(acc = mean(vstmCorr)) %>%
    ungroup() %>% 
    mutate(vstmCond = ifelse(vstmCond==1, "different", "same")) %>% 
    pivot_wider(id_cols = c(SN, vstmLoad), names_from = vstmCond, values_from = acc) %>% 
    mutate(SS = ifelse(vstmLoad=="Low", 1, 4),
                 K = SS * (same - (1 - different))) %>% 
    select(SN, vstmLoad, K)

k1 %>% pivot_wider(id_cols = SN, names_from = vstmLoad, values_from = K) %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "K") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"))) %>% 
    group_by(vstmLoad) %>% 
    get_summary_stats(K, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-2) %>% 
    kable(digits = 2, caption = "K: Descriptive Stats")
K: Descriptive Stats
vstmLoad n mean sd median iqr ci
Low 20 0.85 0.10 0.88 0.13 0.05
High 20 2.35 0.77 2.50 1.06 0.36
Diff 20 1.50 0.72 1.71 0.88 0.34

k1 %>% mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    pairwise_t_test(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
High Low 20 20 9.35 19 0 0 ****
k1 %>% mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    cohens_d(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
High Low 2.09 20 20 large

1.3 Flanker task: Error

E1 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "err") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                             labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker % Error: Descriptive Stats")
Flanker % Error: Descriptive Stats
vstmLoad Congruency n mean sd median iqr ci
Low Congruent 20 3.02 2.48 2.08 2.60 1.16
Low Incongruent 20 3.65 3.09 2.08 2.60 1.45
Low Diff 20 0.62 4.39 0.00 4.69 2.05
High Congruent 20 3.75 3.42 4.17 3.12 1.60
High Incongruent 20 2.81 2.81 2.08 4.17 1.31
High Diff 20 -0.94 3.13 -1.04 2.08 1.47


E1 %>% group_by(SN, Congruency, vstmLoad) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "vstmLoad", values_from = "err") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                         labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, vstmLoad) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  vstmLoad variable     n   mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl>  <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      Error       20  3.02   2.48   2.08  2.60  1.16
## 2 Congruent   High     Error       20  3.75   3.42   4.17  3.12  1.60
## 3 Congruent   Diff     Error       20  0.729  3.84   0     6.25  1.80
## 4 Incongruent Low      Error       20  3.65   3.09   2.08  2.60  1.44
## 5 Incongruent High     Error       20  2.81   2.81   2.08  4.17  1.32
## 6 Incongruent Diff     Error       20 -0.833  2.74   0     2.08  1.28

e1 <- E1 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(err = 100 - mean(Corr)*100) %>% ungroup()
e1g <- e1 %>% Rmisc::summarySEwithin(measurevar = "err", withinvars = c("vstmLoad", "Congruency"), idvar = "SN")

e1 %>% ggplot(aes(x=vstmLoad, y=err, fill=Congruency)) +
    geom_violin(width = 0.7, trim=TRUE) +
    ggbeeswarm::geom_quasirandom(dodge.width = 0.7, color = "gray80", size = 3, alpha = 0.4, show.legend = FALSE) +
    geom_errorbar(data=e1g, aes(x = vstmLoad, ymin = err-ci, ymax = err+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=e1g, aes(x = vstmLoad, y = err),
                         position=position_dodge(0.7), size=5, color = "darkred", show.legend = FALSE) + 
    coord_cartesian(ylim = c(0, 50), clip = "on") +
    labs(x = "VSTM Load", y = "% Error", fill="Congruency") +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


e1 %>% anova_test(dv = err, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
vstmLoad 1 19 0.01 0.92 0.0
Congruency 1 19 0.06 0.81 0.0
vstmLoad:Congruency 1 19 2.06 0.17 0.1

# arcsine transformation
E1 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(acc = asin(sqrt(mean(Corr)))) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "acc") %>% 
    mutate(Diff = Congruent - Incongruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Accuracy") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   vstmLoad Congruency  variable     n   mean    sd median   iqr    ci
##   <fct>    <fct>       <fct>    <dbl>  <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Low      Congruent   Accuracy    20  1.42  0.097  1.43  0.097 0.046
## 2 Low      Incongruent Accuracy    20  1.40  0.096  1.43  0.073 0.045
## 3 Low      Diff        Accuracy    20  0.022 0.134  0     0.206 0.063
## 4 High     Congruent   Accuracy    20  1.41  0.111  1.36  0.109 0.052
## 5 High     Incongruent Accuracy    20  1.44  0.103  1.43  0.206 0.048
## 6 High     Diff        Accuracy    20 -0.027 0.109 -0.024 0.078 0.051

s1 <- E1 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(acc = asin(sqrt(mean(Corr)))) %>% ungroup()
s1 %>% anova_test(dv = acc, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                Effect DFn DFd     F     p p<.05      pes
## 1            vstmLoad   1  19 0.263 0.614       0.014000
## 2          Congruency   1  19 0.015 0.903       0.000808
## 3 vstmLoad:Congruency   1  19 1.919 0.182       0.092000

1.4 Flanker task: RT

# filtering out incorrect trials
cE1 <- E1 %>% filter(Corr==1 & vstmCorr==1) %>% mutate(RT = RT*1000)

# trimming
tE1 <- cE1 %>% filter(RT > 200) %>% 
    group_by(SN) %>% 
    nest() %>%
    mutate(lbound = map(data, ~mean(.$RT)-xcut*sd(.$RT)),
                 ubound = map(data, ~mean(.$RT)+xcut*sd(.$RT))) %>%
    unnest(c(lbound, ubound)) %>%
    unnest(data) %>%
    mutate(Outlier = (RT < lbound)|(RT > ubound)) %>%
    filter(Outlier == FALSE) %>%
    ungroup %>%
    select(SN, vstmLoad, Congruency, RT)

# percentage trimmed.
100*(nrow(cE1)-nrow(tE1))/nrow(E1)
## [1] 3.723958

tE1 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), 
                                                    labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker RT (ms): Descriptive Stats")
Flanker RT (ms): Descriptive Stats
vstmLoad Congruency n mean sd median iqr ci
Low Congruent 20 733.07 88.19 714.63 106.37 41.27
Low Incongruent 20 757.09 99.16 723.51 101.70 46.41
Low Diff 20 24.02 31.57 18.11 27.14 14.77
High Congruent 20 734.43 83.90 732.76 85.90 39.27
High Incongruent 20 753.01 91.11 738.34 85.08 42.64
High Diff 20 18.58 30.38 14.64 40.39 14.22

tE1 %>% group_by(SN, Congruency, vstmLoad) %>% 
    summarise(rt = mean(RT)) %>%
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "vstmLoad", values_from = "rt") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, vstmLoad) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  vstmLoad variable     n   mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl>  <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      RT          20 733.    88.2 715.   106.   41.3
## 2 Congruent   High     RT          20 734.    83.9 733.    85.9  39.3
## 3 Congruent   Diff     RT          20   1.36  26.3   2.13  25.8  12.3
## 4 Incongruent Low      RT          20 757.    99.2 724.   102.   46.4
## 5 Incongruent High     RT          20 753.    91.1 738.    85.1  42.6
## 6 Incongruent Diff     RT          20  -4.08  30.3  -7.48  45.3  14.2

r1 <- tE1 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(RT = mean(RT)) %>% ungroup()
r1w <- r1 %>%   unite("temp", c("vstmLoad", "Congruency")) %>% 
    pivot_wider(id_cols = SN, names_from = temp, values_from = RT)
r1g <- r1 %>% Rmisc::summarySEwithin(measurevar = "RT", withinvars = c("vstmLoad", "Congruency"), idvar = "SN")

F1 <- ggplot() + 
    geom_bar(data=r1g, aes(x=vstmLoad, y=RT, fill=Congruency),
        stat="identity", width=0.7, color="black", position=position_dodge(.8)) + 
    geom_linerange(data=r1g, aes(x=vstmLoad, ymin=RT-ci, ymax=RT+ci, group=Congruency),
                                 linewidth=1, position=position_dodge(0.8)) +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    geom_point(data=r1, aes(x=vstmLoad, y=RT, group=Congruency),
                         position=position_dodge(0.6), color="gray80", size=1.8) +
    geom_segment(data=r1w, aes(x=1-.15, y=Low_Incongruent, xend=1+.15, yend=Low_Congruent), color="gray80") +
    geom_segment(data=r1w, aes(x=2-.15, y=High_Incongruent, xend=2+.15, yend=High_Congruent), color="gray80") +
    labs(x = "VSTM Load", y = "Response Time (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(500, 1000), clip = "on") +
    theme_bw(base_size = 18) +
    theme(legend.position="top",
                legend.spacing.x = unit(0.5, 'lines'),
                legend.margin = margin(0, 0, 0, 0),
                legend.title = element_blank(),
                legend.background = element_blank(),
                panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

r1ce <- tE1 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    select(SN, vstmLoad, Diff)
r1cew <- r1ce %>% pivot_wider(id_cols = SN, names_from = vstmLoad, values_from = Diff)
r1ceg <- r1ce %>% Rmisc::summarySEwithin(measurevar = "Diff", withinvars = "vstmLoad", idvar = "SN")

G1 <- ggplot(r1ce, aes(x=vstmLoad, y=Diff)) +
    geom_hline(yintercept = 0) +
    geom_violin(width = 0.5, trim=TRUE) + 
    geom_point(color="gray80", size=1.8) +
    geom_segment(data=r1cew, color="gray80", aes(x=1, y=Low, xend=2, yend=High)) +
    geom_errorbar(data=r1ceg, aes(x = vstmLoad, ymin = Diff-ci, ymax = Diff+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=r1ceg, aes(x = vstmLoad, y = Diff), 
                         position=position_dodge(0.7), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Congruency Effect (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(-60, 120), clip = "on") +
    scale_y_continuous(breaks=seq(-60, 120, by = 30)) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

F1 + G1 + plot_layout(nrow = 1, widths = c(2, 1.2))



r1 %>% anova_test(dv = RT, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
vstmLoad 1 19 0.07 0.80 0.00
Congruency 1 19 13.03 0.00 * 0.41
vstmLoad:Congruency 1 19 0.56 0.46 0.03






2 Experiment 2

VSTM low loadhigh load 조건의 기억항목은 각각 한 개와 네 개. 두 조건은 구획으로 분리(blocked).

ggdraw() + draw_image("fig_proc/procExp2.png")

2.1 VSTM: Accuracy


E2 %>% group_by(SN, vstmLoad) %>% 
    summarise(acc = mean(vstmCorr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = "SN", names_from = "vstmLoad", values_from = "acc") %>% 
    mutate(Diff = Low - High) %>% 
    pivot_longer(cols = Low:Diff, names_to = "Load", values_to = "Accuracy") %>% 
    mutate(Load = factor(.$Load, levels = c("Low", "High", "Diff"), 
                                             labels = c("Low", "High", "Diff"))) %>% 
    group_by(Load) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-2) %>% 
    kable(digits = 2, caption = "VSTM: Descriptive Stats")
VSTM: Descriptive Stats
Load n mean sd median iqr ci
Low 20 93.33 7.78 95.31 4.43 3.64
High 20 75.78 8.32 75.52 7.81 3.89
Diff 20 17.55 8.84 17.19 9.63 4.14


v2 <- E2 %>% group_by(SN, vstmLoad) %>% summarise(acc = mean(vstmCorr)*100) %>% ungroup()
v2g <- v2 %>% Rmisc::summarySEwithin(measurevar = 'acc', withinvars = 'vstmLoad', idvar = 'SN')

v2 %>% ggplot(aes(x=vstmLoad, y=acc)) +
    geom_violin(width = 0.5, trim=TRUE) + 
    geom_point(color="gray80", size=1.8) +
    geom_line(aes(group = SN), color="gray80") +
    geom_errorbar(data=v2g, aes(x = vstmLoad, ymin = acc-ci, ymax = acc+ci),
                                position = position_dodge(0.8), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=v2g, aes(x = vstmLoad, y = acc),
                         position=position_dodge(0.8), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Change Detection Accuracy (%)") +
    coord_cartesian(ylim = c(50, 100), clip = "on") +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


v2 %>% pairwise_t_test(acc ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
Low High 20 20 8.88 19 0 0 ****
v2 %>% cohens_d(acc ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
Low High 1.99 20 20 large

2.2 VSTM: K

k2 <- E2 %>% 
    group_by(SN, vstmLoad, vstmCond) %>% # vstmCond: change = 1 or not = 2
    summarise(acc = mean(vstmCorr)) %>%
    ungroup() %>% 
    mutate(vstmCond = ifelse(vstmCond==1, "different", "same")) %>% 
    pivot_wider(id_cols = c(SN, vstmLoad), names_from = vstmCond, values_from = acc) %>% 
    mutate(SS = ifelse(vstmLoad=="Low", 1, 4),
                 K = SS * (same - (1 - different))) %>% 
    select(SN, vstmLoad, K)

k2 %>% pivot_wider(id_cols = SN, names_from = vstmLoad, values_from = K) %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "K") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"))) %>% 
    group_by(vstmLoad) %>% 
    get_summary_stats(K, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-2) %>% 
    kable(digits = 2, caption = "K: Descriptive Stats")
K: Descriptive Stats
vstmLoad n mean sd median iqr ci
Low 20 0.87 0.16 0.91 0.09 0.07
High 20 2.06 0.67 2.04 0.62 0.31
Diff 20 1.20 0.62 1.26 0.60 0.29

k2 %>% mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    pairwise_t_test(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
High Low 20 20 8.62 19 0 0 ****
k2 %>% mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    cohens_d(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
High Low 1.93 20 20 large

2.3 Flanker task: Error

E2 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "err") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker % Error: Descriptive Stats")
Flanker % Error: Descriptive Stats
vstmLoad Congruency n mean sd median iqr ci
Low Congruent 20 3.75 3.35 4.17 2.08 1.57
Low Incongruent 20 6.04 8.36 2.08 5.21 3.91
Low Diff 20 2.29 6.30 0.00 2.60 2.95
High Congruent 20 3.33 2.65 2.08 2.08 1.24
High Incongruent 20 5.62 5.82 5.21 4.69 2.72
High Diff 20 2.29 5.65 1.04 2.60 2.64

E2 %>% group_by(SN, Congruency, vstmLoad) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "vstmLoad", values_from = "err") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, vstmLoad) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  vstmLoad variable     n   mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl>  <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      Error       20  3.75   3.35   4.17  2.08  1.57
## 2 Congruent   High     Error       20  3.33   2.65   2.08  2.08  1.24
## 3 Congruent   Diff     Error       20 -0.417  2.75   0     2.60  1.29
## 4 Incongruent Low      Error       20  6.04   8.36   2.08  5.21  3.91
## 5 Incongruent High     Error       20  5.62   5.82   5.21  4.69  2.72
## 6 Incongruent Diff     Error       20 -0.417  6.22   1.04  4.69  2.91

e2 <- E2 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(err = 100 - mean(Corr)*100) %>% ungroup()
e2g <- e2 %>% Rmisc::summarySEwithin(measurevar = "err", withinvars = c("vstmLoad", "Congruency"), idvar = "SN")

e2 %>% ggplot(aes(x=vstmLoad, y=err, fill=Congruency)) +
    geom_violin(width = 0.7, trim=TRUE) +
    ggbeeswarm::geom_quasirandom(dodge.width = 0.7, color = "gray80", size = 3, alpha = 0.4, show.legend = FALSE) +
    geom_errorbar(data=e2g, aes(x = vstmLoad, ymin = err-ci, ymax = err+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=e2g, aes(x = vstmLoad, y = err),
                         position=position_dodge(0.7), size=5, color = "darkred", show.legend = FALSE) + 
    coord_cartesian(ylim = c(0, 50), clip = "on") +
    labs(x = "VSTM Load", y = "% Error", fill="Congruency") +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


e2 %>% anova_test(dv = err, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
vstmLoad 1 19 0.22 0.64 0.01
Congruency 1 19 3.68 0.07 0.16
vstmLoad:Congruency 1 19 0.00 1.00 0.00

# arcsine transformation
E2 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(acc = asin(sqrt(mean(Corr)))) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "acc") %>% 
    mutate(Diff = Congruent - Incongruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Accuracy") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   vstmLoad Congruency  variable     n  mean    sd median   iqr    ci
##   <fct>    <fct>       <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Low      Congruent   Accuracy    20 1.40  0.103   1.36 0.061 0.048
## 2 Low      Incongruent Accuracy    20 1.38  0.17    1.43 0.154 0.079
## 3 Low      Diff        Accuracy    20 0.024 0.13    0    0.14  0.061
## 4 High     Congruent   Accuracy    20 1.41  0.088   1.43 0.061 0.041
## 5 High     Incongruent Accuracy    20 1.36  0.126   1.34 0.118 0.059
## 6 High     Diff        Accuracy    20 0.046 0.136   0.02 0.117 0.064

s2 <- E2 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(acc = asin(sqrt(mean(Corr)))) %>% ungroup()
s2 %>% anova_test(dv = acc, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                Effect DFn DFd     F     p p<.05   pes
## 1            vstmLoad   1  19 0.067 0.798       0.004
## 2          Congruency   1  19 1.849 0.190       0.089
## 3 vstmLoad:Congruency   1  19 0.497 0.489       0.025

2.4 Flanker task: RT

# filtering out incorrect trials
cE2 <- E2 %>% filter(Corr==1 & vstmCorr==1) %>% mutate(RT = RT*1000)

# trimming
tE2 <- cE2 %>% filter(RT > 200) %>% 
    group_by(SN) %>% 
    nest() %>%
    mutate(lbound = map(data, ~mean(.$RT)-xcut*sd(.$RT)),
                 ubound = map(data, ~mean(.$RT)+xcut*sd(.$RT))) %>%
    unnest(c(lbound, ubound)) %>%
    unnest(data) %>%
    mutate(Outlier = (RT < lbound)|(RT > ubound)) %>%
    filter(Outlier == FALSE) %>%
    ungroup %>%
    select(SN, vstmLoad, Congruency, RT)

# percentage trimmed.
100*(nrow(cE2)-nrow(tE2))/nrow(E2)
## [1] 4.0625

tE2 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), 
                                                    labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker RT (ms): Descriptive Stats")
Flanker RT (ms): Descriptive Stats
vstmLoad Congruency n mean sd median iqr ci
Low Congruent 20 739.74 100.10 747.25 145.65 46.85
Low Incongruent 20 783.89 98.74 797.79 137.32 46.21
Low Diff 20 44.15 29.08 39.71 39.24 13.61
High Congruent 20 717.22 68.59 725.75 80.51 32.10
High Incongruent 20 769.28 76.11 767.23 108.04 35.62
High Diff 20 52.05 34.35 49.17 37.14 16.08

tE2 %>% group_by(SN, Congruency, vstmLoad) %>% 
    summarise(rt = mean(RT)) %>%
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "vstmLoad", values_from = "rt") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, vstmLoad) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  vstmLoad variable     n  mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      RT          20 740.  100.  747.   146.   46.8
## 2 Congruent   High     RT          20 717.   68.6 726.    80.5  32.1
## 3 Congruent   Diff     RT          20 -22.5  70.9 -19.5   57.8  33.2
## 4 Incongruent Low      RT          20 784.   98.7 798.   137.   46.2
## 5 Incongruent High     RT          20 769.   76.1 767.   108.   35.6
## 6 Incongruent Diff     RT          20 -14.6  59.9  -5.54  92.2  28.0

r2 <- tE2 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(RT = mean(RT)) %>% ungroup()
r2w <- r2 %>%   unite("temp", c("vstmLoad", "Congruency")) %>% 
    pivot_wider(id_cols = SN, names_from = temp, values_from = RT)
r2g <- r2 %>% Rmisc::summarySEwithin(measurevar = "RT", withinvars = c("vstmLoad", "Congruency"), idvar = "SN")

F2 <- ggplot() + 
    geom_bar(data=r2g, aes(x=vstmLoad, y=RT, fill=Congruency),
                     stat="identity", width=0.7, color="black", position=position_dodge(.8)) + 
    geom_linerange(data=r2g, aes(x=vstmLoad, ymin=RT-ci, ymax=RT+ci, group=Congruency),
                                 linewidth=1, position=position_dodge(0.8)) +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    geom_point(data=r2, aes(x=vstmLoad, y=RT, group=Congruency),
                         position=position_dodge(0.6), color="gray80", size=1.8) +
    geom_segment(data=r2w, aes(x=1-.15, y=Low_Incongruent, xend=1+.15, yend=Low_Congruent), color="gray80") +
    geom_segment(data=r2w, aes(x=2-.15, y=High_Incongruent, xend=2+.15, yend=High_Congruent), color="gray80") +
    labs(x = "VSTM Load", y = "Response Time (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(500, 1000), clip = "on") +
    theme_bw(base_size = 18) +
    theme(legend.position="top",
                legend.spacing.x = unit(0.5, 'lines'),
                legend.margin = margin(0, 0, 0, 0),
                legend.title = element_blank(),
                legend.background = element_blank(),
                panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

r2ce <- tE2 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    select(SN, vstmLoad, Diff)
r2cew <- r2ce %>% pivot_wider(id_cols = SN, names_from = vstmLoad, values_from = Diff)
r2ceg <- r2ce %>% Rmisc::summarySEwithin(measurevar = "Diff", withinvars = "vstmLoad", idvar = "SN")

G2 <- ggplot(r2ce, aes(x=vstmLoad, y=Diff)) +
    geom_hline(yintercept = 0) +
    geom_violin(width = 0.5, trim=TRUE) + 
    geom_point(color="gray80", size=1.8) +
    geom_segment(data=r2cew, color="gray80", aes(x=1, y=Low, xend=2, yend=High)) +
    geom_errorbar(data=r2ceg, aes(x = vstmLoad, ymin = Diff-ci, ymax = Diff+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=r2ceg, aes(x = vstmLoad, y = Diff), 
                         position=position_dodge(0.7), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Congruency Effect (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(-20, 160), clip = "on") +
    scale_y_continuous(breaks=c(-20, 0, 40, 80, 120, 160)) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

F2 + G2 + plot_layout(nrow = 1, widths = c(2, 1.2))



r2 %>% anova_test(dv = RT, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
vstmLoad 1 19 1.81 0.20 0.09
Congruency 1 19 88.58 0.00 * 0.82
vstmLoad:Congruency 1 19 0.64 0.44 0.03






3 Experiment 3

VSTM low load 조건은 기억항목 없이 플랭커 과제만 제시, high load 조건은 기억항목 세 개. 두 조건은 구획으로 분리됨(blocked).

ggdraw() + draw_image("fig_proc/procExp3.png")

3.1 VSTM: Accuracy

E3 %>% filter(vstmLoad == "High") %>% 
    group_by(SN) %>% 
    summarise(acc = mean(vstmCorr)*100) %>% 
    ungroup() %>% 
    get_summary_stats(acc, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-1) %>% 
    kable(digits = 2, caption = "VSTM: Descriptive Stats")
VSTM: Descriptive Stats
n mean sd median iqr ci
20 82.08 7.46 82.81 7.03 3.49

v3 <- E3 %>% filter(vstmLoad == "High") %>% group_by(SN) %>% summarise(acc = mean(vstmCorr)*100) %>% ungroup()

ggplot(data=v3, aes(x=1, y=acc)) +
    geom_violin(width = 1, trim = TRUE) +
    ggbeeswarm::geom_quasirandom(dodge.width = 0.7, color = "blue", size = 3, alpha = 0.2, show.legend = FALSE) +
    stat_summary(fun.data = "mean_cl_normal", color = "darkred", size = 1) +
    coord_flip(ylim = c(50, 100), clip = "on") +
    labs(y = "Change Detection Accuracy (%)") +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(),
                panel.grid.minor = element_blank(),
                axis.title.y = element_blank(),
                axis.ticks.y = element_blank(),
                axis.text.y = element_blank(),
                aspect.ratio = .3)

3.2 VSTM: K

k3 <- E3 %>% 
    filter(vstmLoad == "High") %>% 
    group_by(SN, vstmLoad, vstmCond) %>% # vstmCond: change = 1 or not = 2
    summarise(acc = mean(vstmCorr)) %>%
    ungroup() %>% 
    mutate(vstmCond = ifelse(vstmCond==1, "different", "same")) %>% 
    pivot_wider(id_cols = c(SN, vstmLoad), names_from = vstmCond, values_from = acc) %>% 
    mutate(SS = 3,
                 K = SS * (same - (1 - different))) %>% 
    select(SN, vstmLoad, K)

k3 %>% group_by(vstmLoad) %>% 
    get_summary_stats(K, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-2) %>% 
    kable(digits = 2, caption = "K: Descriptive Stats")
K: Descriptive Stats
vstmLoad n mean sd median iqr ci
High 20 1.93 0.45 1.97 0.42 0.21

3.3 Flanker task: Error

E3 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "err") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker % Error: Descriptive Stats")
Flanker % Error: Descriptive Stats
vstmLoad Congruency n mean sd median iqr ci
Low Congruent 20 3.96 4.05 3.12 4.69 1.90
Low Incongruent 20 4.90 5.71 2.08 4.17 2.67
Low Diff 20 0.94 4.25 1.04 4.69 1.99
High Congruent 20 6.04 5.10 5.21 6.25 2.39
High Incongruent 20 8.44 6.18 6.25 8.85 2.89
High Diff 20 2.40 5.03 2.08 7.29 2.35

E3 %>% group_by(SN, Congruency, vstmLoad) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "vstmLoad", values_from = "err") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, vstmLoad) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) 
## # A tibble: 6 × 9
##   Congruency  vstmLoad variable     n  mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      Error       20  3.96  4.05   3.12  4.69  1.90
## 2 Congruent   High     Error       20  6.04  5.10   5.21  6.25  2.39
## 3 Congruent   Diff     Error       20  2.08  5.36   1.04  3.12  2.51
## 4 Incongruent Low      Error       20  4.90  5.71   2.08  4.17  2.67
## 5 Incongruent High     Error       20  8.44  6.18   6.25  8.85  2.89
## 6 Incongruent Diff     Error       20  3.54  5.45   2.08  6.77  2.55

e3 <- E3 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(err = 100 - mean(Corr)*100) %>% ungroup()
e3g <- e3 %>% Rmisc::summarySEwithin(measurevar = "err", withinvars = c("vstmLoad", "Congruency"), idvar = "SN")

e3 %>% ggplot(aes(x=vstmLoad, y=err, fill=Congruency)) +
    geom_violin(width = 0.7, trim=TRUE) +
    ggbeeswarm::geom_quasirandom(dodge.width = 0.7, color = "gray80", size = 3, alpha = 0.4, show.legend = FALSE) +
    geom_errorbar(data=e3g, aes(x = vstmLoad, ymin = err-ci, ymax = err+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=e3g, aes(x = vstmLoad, y = err),
                         position=position_dodge(0.7), size=5, color = "darkred", show.legend = FALSE) + 
    coord_cartesian(ylim = c(0, 50), clip = "on") +
    labs(x = "VSTM Load", y = "% Error", fill="Congruency") +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


e3 %>% anova_test(dv = err, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
vstmLoad 1 19 7.32 0.01 * 0.28
Congruency 1 19 3.97 0.06 0.17
vstmLoad:Congruency 1 19 1.39 0.25 0.07

# arcsine transformation
E3 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(acc = asin(sqrt(mean(Corr)))) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "acc") %>% 
    mutate(Diff = Congruent - Incongruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Accuracy") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   vstmLoad Congruency  variable     n  mean    sd median   iqr    ci
##   <fct>    <fct>       <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Low      Congruent   Accuracy    20 1.41  0.126  1.40  0.217 0.059
## 2 Low      Incongruent Accuracy    20 1.38  0.127  1.43  0.108 0.06 
## 3 Low      Diff        Accuracy    20 0.028 0.132  0.016 0.2   0.062
## 4 High     Congruent   Accuracy    20 1.35  0.118  1.34  0.148 0.055
## 5 High     Incongruent Accuracy    20 1.30  0.122  1.32  0.163 0.057
## 6 High     Diff        Accuracy    20 0.05  0.108  0.047 0.185 0.051

s3 <- E3 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(acc = asin(sqrt(mean(Corr)))) %>% ungroup()
s3 %>% anova_test(dv = acc, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                Effect DFn DFd      F     p p<.05   pes
## 1            vstmLoad   1  19 10.314 0.005     * 0.352
## 2          Congruency   1  19  3.037 0.098       0.138
## 3 vstmLoad:Congruency   1  19  0.513 0.483       0.026

3.4 Flanker task: RT

# filtering out incorrect trials
cE3 <- E3 %>% filter(Corr==1 & vstmCorr==1) %>% mutate(RT = RT*1000)

# trimming
tE3 <- cE3 %>% filter(RT > 200) %>% 
    group_by(SN) %>% 
    nest() %>%
    mutate(lbound = map(data, ~mean(.$RT)-xcut*sd(.$RT)),
                 ubound = map(data, ~mean(.$RT)+xcut*sd(.$RT))) %>%
    unnest(c(lbound, ubound)) %>%
    unnest(data) %>%
    mutate(Outlier = (RT < lbound)|(RT > ubound)) %>%
    filter(Outlier == FALSE) %>%
    ungroup %>%
    select(SN, vstmLoad, Congruency, RT)

# percentage trimmed.
100*(nrow(cE3)-nrow(tE3))/nrow(E3)
## [1] 3.411458

tE3 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), 
                                                    labels = c("Low", "High"))) %>% 
    group_by(vstmLoad, Congruency) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker RT (ms): Descriptive Stats")
Flanker RT (ms): Descriptive Stats
vstmLoad Congruency n mean sd median iqr ci
Low Congruent 20 624.95 103.48 586.46 103.30 48.43
Low Incongruent 20 675.96 129.76 649.62 132.80 60.73
Low Diff 20 51.01 50.44 34.89 58.66 23.60
High Congruent 20 751.84 137.88 742.20 121.83 64.53
High Incongruent 20 808.49 170.92 766.11 208.23 80.00
High Diff 20 56.65 60.89 41.49 58.02 28.50

tE3 %>% group_by(SN, Congruency, vstmLoad) %>% 
    summarise(rt = mean(RT)) %>%
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "vstmLoad", values_from = "rt") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, vstmLoad) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  vstmLoad variable     n  mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      RT          20  625. 103.    586.  103.  48.4
## 2 Congruent   High     RT          20  752. 138.    742.  122.  64.5
## 3 Congruent   Diff     RT          20  127.  83.0   121.  100.  38.8
## 4 Incongruent Low      RT          20  676. 130.    650.  133.  60.7
## 5 Incongruent High     RT          20  808. 171.    766.  208.  80.0
## 6 Incongruent Diff     RT          20  133.  75.3   139.  108.  35.2

r3 <- tE3 %>% group_by(SN, vstmLoad, Congruency) %>% summarise(RT = mean(RT)) %>% ungroup()
r3w <- r3 %>%   unite("temp", c("vstmLoad", "Congruency")) %>% 
    pivot_wider(id_cols = SN, names_from = temp, values_from = RT)
r3g <- r3 %>% Rmisc::summarySEwithin(measurevar = "RT", withinvars = c("vstmLoad", "Congruency"), idvar = "SN")

F3 <- ggplot() + 
    geom_bar(data=r3g, aes(x=vstmLoad, y=RT, fill=Congruency),
                     stat="identity", width=0.7, color="black", position=position_dodge(.8)) + 
    geom_linerange(data=r3g, aes(x=vstmLoad, ymin=RT-ci, ymax=RT+ci, group=Congruency),
                                 linewidth=1, position=position_dodge(0.8)) +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    geom_point(data=r3, aes(x=vstmLoad, y=RT, group=Congruency),
                         position=position_dodge(0.6), color="gray80", size=1.8) +
    geom_segment(data=r3w, aes(x=1-.15, y=Low_Incongruent, xend=1+.15, yend=Low_Congruent), color="gray80") +
    geom_segment(data=r3w, aes(x=2-.15, y=High_Incongruent, xend=2+.15, yend=High_Congruent), color="gray80") +
    labs(x = "VSTM Load", y = "Response Time (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (0)", "High" = "High (3)")) +
    coord_cartesian(ylim = c(500, 1300), clip = "on") +
    scale_y_continuous(breaks=c(500,700,900,1100,1300)) +
    theme_bw(base_size = 18) +
    theme(legend.position="top",
                legend.spacing.x = unit(0.5, 'lines'),
                legend.margin = margin(0, 0, 0, 0),
                legend.title = element_blank(),
                legend.background = element_blank(),
                panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

r3ce <- tE3 %>% group_by(SN, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    select(SN, vstmLoad, Diff)
r3cew <- r3ce %>% pivot_wider(id_cols = SN, names_from = vstmLoad, values_from = Diff)
r3ceg <- r3ce %>% Rmisc::summarySEwithin(measurevar = "Diff", withinvars = "vstmLoad", idvar = "SN")

G3 <- ggplot(r3ce, aes(x=vstmLoad, y=Diff)) +
    geom_hline(yintercept = 0) +
    geom_violin(width = 0.5, trim=TRUE) + 
    geom_point(color="gray80", size=1.8) +
    geom_segment(data=r3cew, color="gray80", aes(x=1, y=Low, xend=2, yend=High)) +
    geom_errorbar(data=r3ceg, aes(x = vstmLoad, ymin = Diff-ci, ymax = Diff+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=r3ceg, aes(x = vstmLoad, y = Diff), 
                         position=position_dodge(0.7), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Congruency Effect (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (0)", "High" = "High (3)")) +
    coord_cartesian(ylim = c(-30, 270), clip = "on") +
    scale_y_continuous(breaks=c(-30, 0, 30, 90, 150, 210, 270)) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

F3 + G3 + plot_layout(nrow = 1, widths = c(2, 1.2))



r3 %>% anova_test(dv = RT, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
vstmLoad 1 19 56.70 0.0 * 0.75
Congruency 1 19 20.82 0.0 * 0.52
vstmLoad:Congruency 1 19 0.47 0.5 0.02






4 Experiment 4

참가자는 플랭커 과제만 수행. 지각부담 효과를 검증하기 위해 시각탐색 배열 크기(set size)가 고부담 조건은 6, 저부담 조건은 1.

ggdraw() + draw_image("fig_proc/procExp4.png")

4.1 Flanker task: Error

E4 %>% group_by(SN, PercLoad, Congruency) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "PercLoad"), names_from = "Congruency", values_from = "err") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 PercLoad = factor(.$PercLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(PercLoad, Congruency) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker % Error: Descriptive Stats")
Flanker % Error: Descriptive Stats
PercLoad Congruency n mean sd median iqr ci
Low Congruent 21 2.03 2.32 1.04 3.12 1.05
Low Incongruent 21 5.06 5.42 3.12 5.21 2.46
Low Diff 21 3.03 4.10 2.08 5.21 1.87
High Congruent 21 9.67 6.46 8.33 6.25 2.94
High Incongruent 21 14.24 8.90 11.46 11.46 4.05
High Diff 21 4.56 5.83 4.17 5.21 2.65

E4 %>% group_by(SN, Congruency, PercLoad) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "PercLoad", values_from = "err") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "PercLoad", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 PercLoad = factor(.$PercLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, PercLoad) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  PercLoad variable     n  mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      Error       21  2.03  2.32   1.04  3.12  1.06
## 2 Congruent   High     Error       21  9.67  6.46   8.33  6.25  2.94
## 3 Congruent   Diff     Error       21  7.64  4.93   6.25  3.12  2.25
## 4 Incongruent Low      Error       21  5.06  5.42   3.12  5.21  2.46
## 5 Incongruent High     Error       21 14.2   8.90  11.5  11.5   4.05
## 6 Incongruent Diff     Error       21  9.18  8.69   8.33  9.38  3.96

e4 <- E4 %>% group_by(SN, PercLoad, Congruency) %>% summarise(err = 100 - mean(Corr)*100) %>% ungroup()
e4g <- e4 %>% Rmisc::summarySEwithin(measurevar = "err", withinvars = c("PercLoad", "Congruency"), idvar = "SN")

e4 %>% ggplot(aes(x=PercLoad, y=err, fill=Congruency)) +
    geom_violin(width = 0.7, trim=TRUE) +
    ggbeeswarm::geom_quasirandom(dodge.width = 0.7, color = "gray80", size = 3, alpha = 0.4, show.legend = FALSE) +
    geom_errorbar(data=e4g, aes(x = PercLoad, ymin = err-ci, ymax = err+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=e4g, aes(x = PercLoad, y = err),
                         position=position_dodge(0.7), size=5, color = "darkred", show.legend = FALSE) + 
    coord_cartesian(ylim = c(0, 50), clip = "on") +
    labs(x = "Perceptual Load", y = "% Error", fill="Congruency") +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


e4 %>% anova_test(dv = err, wid = SN, within = c(PercLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
PercLoad 1 20 45.67 0.00 * 0.70
Congruency 1 20 37.77 0.00 * 0.65
PercLoad:Congruency 1 20 0.71 0.41 0.03

# arcsine transformation
E4 %>% group_by(SN, PercLoad, Congruency) %>% 
    summarise(acc = asin(sqrt(mean(Corr)))) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "PercLoad"), names_from = "Congruency", values_from = "acc") %>% 
    mutate(Diff = Congruent - Incongruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Accuracy") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 PercLoad = factor(.$PercLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(PercLoad, Congruency) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   PercLoad Congruency  variable     n  mean    sd median   iqr    ci
##   <fct>    <fct>       <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Low      Congruent   Accuracy    21 1.46  0.092  1.47  0.178 0.042
## 2 Low      Incongruent Accuracy    21 1.38  0.122  1.39  0.15  0.055
## 3 Low      Diff        Accuracy    21 0.083 0.097  0.096 0.15  0.044
## 4 High     Congruent   Accuracy    21 1.27  0.11   1.28  0.109 0.05 
## 5 High     Incongruent Accuracy    21 1.20  0.13   1.23  0.168 0.059
## 6 High     Diff        Accuracy    21 0.07  0.078  0.063 0.083 0.036

s4 <- E4 %>% group_by(SN, PercLoad, Congruency) %>% summarise(acc = asin(sqrt(mean(Corr)))) %>% ungroup()
s4 %>% anova_test(dv = acc, wid = SN, within = c(PercLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                Effect DFn DFd      F        p p<.05   pes
## 1            PercLoad   1  20 76.179 2.96e-08     * 0.792
## 2          Congruency   1  20 44.265 1.77e-06     * 0.689
## 3 PercLoad:Congruency   1  20  0.192 6.66e-01       0.010

4.2 Flanker task: RT

# filtering out incorrect trials
cE4 <- E4 %>% filter(Corr==1) %>% mutate(RT = RT*1000)

# trimming
tE4 <- cE4 %>% filter(RT > 200) %>% 
    group_by(SN) %>% 
    nest() %>%
    mutate(lbound = map(data, ~mean(.$RT)-xcut*sd(.$RT)),
                 ubound = map(data, ~mean(.$RT)+xcut*sd(.$RT))) %>%
    unnest(c(lbound, ubound)) %>%
    unnest(data) %>%
    mutate(Outlier = (RT < lbound)|(RT > ubound)) %>%
    filter(Outlier == FALSE) %>%
    ungroup %>%
    select(SN, PercLoad, Congruency, RT)

# percentage trimmed.
100*(nrow(cE4)-nrow(tE4))/nrow(E4)
## [1] 4.873512

tE4 %>% group_by(SN, PercLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "PercLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 PercLoad = factor(.$PercLoad, levels = c("Low", "High"), 
                                                    labels = c("Low", "High"))) %>% 
    group_by(PercLoad, Congruency) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "Flanker RT (ms): Descriptive Stats")
Flanker RT (ms): Descriptive Stats
PercLoad Congruency n mean sd median iqr ci
Low Congruent 21 576.56 54.10 566.07 45.72 24.63
Low Incongruent 21 624.13 56.35 606.52 61.74 25.65
Low Diff 21 47.57 16.66 49.13 21.82 7.59
High Congruent 21 726.07 75.05 728.64 70.18 34.16
High Incongruent 21 737.24 72.06 758.42 82.84 32.80
High Diff 21 11.18 24.86 13.54 27.92 11.32

tE4 %>% group_by(SN, Congruency, PercLoad) %>% 
    summarise(rt = mean(RT)) %>%
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Congruency"), names_from = "PercLoad", values_from = "rt") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "PercLoad", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 PercLoad = factor(.$PercLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Congruency, PercLoad) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 6 × 9
##   Congruency  PercLoad variable     n  mean    sd median   iqr    ci
##   <fct>       <fct>    <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
## 1 Congruent   Low      RT          21  577.  54.1   566.  45.7  24.6
## 2 Congruent   High     RT          21  726.  75.1   729.  70.2  34.2
## 3 Congruent   Diff     RT          21  150.  65.2   147.  49.9  29.7
## 4 Incongruent Low      RT          21  624.  56.3   607.  61.7  25.6
## 5 Incongruent High     RT          21  737.  72.1   758.  82.8  32.8
## 6 Incongruent Diff     RT          21  113.  59.7   115.  71.8  27.2

r4 <- tE4 %>% group_by(SN, PercLoad, Congruency) %>% summarise(RT = mean(RT)) %>% ungroup()
r4w <- r4 %>%   unite("temp", c("PercLoad", "Congruency")) %>% 
    pivot_wider(id_cols = SN, names_from = temp, values_from = RT)
r4g <- r4 %>% Rmisc::summarySEwithin(measurevar = "RT", withinvars = c("PercLoad", "Congruency"), idvar = "SN")

F4 <- ggplot() + 
    geom_bar(data=r4g, aes(x=PercLoad, y=RT, fill=Congruency),
                     stat="identity", width=0.7, color="black", position=position_dodge(.8)) + 
    geom_linerange(data=r4g, aes(x=PercLoad, ymin=RT-ci, ymax=RT+ci, group=Congruency),
                                 linewidth=1, position=position_dodge(0.8)) +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    geom_point(data=r4, aes(x=PercLoad, y=RT, group=Congruency),
                         position=position_dodge(0.6), color="gray80", size=1.8) +
    geom_segment(data=r4w, aes(x=1-.15, y=Low_Incongruent, xend=1+.15, yend=Low_Congruent), color="gray80") +
    geom_segment(data=r4w, aes(x=2-.15, y=High_Incongruent, xend=2+.15, yend=High_Congruent), color="gray80") +
    labs(x = "Perceptual Load", y = "Response Time (ms)") +
    coord_cartesian(ylim = c(400, 1000), clip = "on") +
    scale_y_continuous(breaks=seq(400,1000,by=100)) +
    theme_bw(base_size = 18) +
    theme(legend.position="top",
                legend.spacing.x = unit(0.5, 'lines'),
                legend.margin = margin(0, 0, 0, 0),
                legend.title = element_blank(),
                legend.background = element_blank(),
                panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

r4ce <- tE4 %>% group_by(SN, PercLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "PercLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    select(SN, PercLoad, Diff)
r4cew <- r4ce %>% pivot_wider(id_cols = SN, names_from = PercLoad, values_from = Diff)
r4ceg <- r4ce %>% Rmisc::summarySEwithin(measurevar = "Diff", withinvars = "PercLoad", idvar = "SN")

G4 <- ggplot(r4ce, aes(x=PercLoad, y=Diff)) +
    geom_hline(yintercept = 0) +
    geom_violin(width = 0.5, trim=TRUE) + 
    geom_point(color="gray80", size=1.8) +
    geom_segment(data=r4cew, color="gray80", aes(x=1, y=Low, xend=2, yend=High)) +
    geom_errorbar(data=r4ceg, aes(x = PercLoad, ymin = Diff-ci, ymax = Diff+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=r4ceg, aes(x = PercLoad, y = Diff), 
                         position=position_dodge(0.7), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Congruency Effect (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (0)", "High" = "High (3)")) +
    coord_cartesian(ylim = c(-40, 100), clip = "on") +
    scale_y_continuous(breaks=seq(-40, 100, by=20)) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

F4 + G4 + plot_layout(nrow = 1, widths = c(2, 1.2))



r4 %>% anova_test(dv = RT, wid = SN, within = c(PercLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
PercLoad 1 20 98.57 0 * 0.83
Congruency 1 20 84.92 0 * 0.81
PercLoad:Congruency 1 20 29.64 0 * 0.60

m4lo <- r4 %>% filter(PercLoad == "Low") %>% 
    anova_test(dv = RT, wid = SN, within = Congruency, effect.size = "pes") 
m4lo %>% kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
Congruency 1 20 171.1 0 * 0.9
m4hi <- r4 %>% filter(PercLoad == "High") %>% 
    anova_test(dv = RT, wid = SN, within = Congruency, effect.size = "pes") 
m4hi %>% kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
Congruency 1 20 4.24 0.05 0.17

pbon <- p.adjust(c(m4lo$p, m4hi$p), "bonferroni")
tibble(Load = c("Low", "High"),
             lowLoad = c(pbon[1], pbon[2])) %>% 
    kable(align = 'c', digits = 2, caption = "Bonferroni-corrected p")
Bonferroni-corrected p
Load lowLoad
Low 0.00
High 0.11

bind_rows(r3 %>% rename("Load" = vstmLoad) %>% mutate(Exp = 'Exp3', SN = paste('e3s', .$SN, sep = "")),
                    r4 %>% rename("Load" = PercLoad) %>% mutate(Exp = 'Exp4', SN = paste('e4s', .$SN, sep = ""))) %>% 
    anova_test(dv = RT, wid = SN, within = c(Load, Congruency), between = Exp, effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA: Expt 3 vs. 4")
ANOVA: Expt 3 vs. 4
Effect DFn DFd F p p<.05 pes
Exp 1 39 2.55 0.12 0.06
Load 1 39 146.16 0.00 * 0.79
Congruency 1 39 48.38 0.00 * 0.55
Exp:Load 1 39 0.00 0.94 0.00
Exp:Congruency 1 39 4.18 0.05 * 0.10
Load:Congruency 1 39 8.44 0.01 * 0.18
Exp:Load:Congruency 1 39 15.77 0.00 * 0.29






5 Experiment 5

Overlap 요인 추가.

ggdraw() + draw_image("fig_proc/procExp5.png")

5.1 VSTM: Accuracy

E5 %>% group_by(SN, Overlap, vstmLoad) %>% 
    summarise(acc = mean(vstmCorr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap"), names_from = "vstmLoad", values_from = "acc") %>% 
    mutate(Diff = Low - High) %>% 
    pivot_longer(cols = Low:Diff, names_to = "Load", values_to = "Accuracy") %>% 
    mutate(Load = factor(.$Load, levels = c("Low", "High", "Diff"), 
                                             labels = c("Low", "High", "Diff"))) %>% 
    group_by(Overlap, Load) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "VSTM: Descriptive Stats")
VSTM: Descriptive Stats
Overlap Load n mean sd median iqr ci
NonOverlap Low 20 93.96 2.80 93.23 3.65 1.31
NonOverlap High 20 73.12 6.04 72.92 3.91 2.83
NonOverlap Diff 20 20.83 6.26 19.79 7.81 2.93
Overlap Low 20 93.28 4.94 94.79 5.99 2.31
Overlap High 20 70.94 7.60 69.27 11.46 3.56
Overlap Diff 20 22.34 8.26 22.40 10.94 3.87


v5 <- E5 %>% group_by(SN, Overlap, vstmLoad) %>% summarise(acc = mean(vstmCorr)*100) %>% ungroup()
v5g <- v5 %>% Rmisc::summarySEwithin(measurevar = 'acc', withinvars = c('Overlap', 'vstmLoad'), idvar = 'SN')

over.labs <- c("Non-overlap", "Overlap")
names(over.labs) <- c("NonOverlap", "Overlap")

v5 %>% ggplot(aes(x=vstmLoad, y=acc)) +
    geom_violin(width = 0.5, trim=TRUE) + 
    facet_grid(. ~ Overlap, labeller = labeller(Overlap = over.labs)) +
    geom_point(color="gray80", size=1.8) +
    geom_line(aes(group = SN), color="gray80") +
    geom_errorbar(data=v5g, aes(x = vstmLoad, ymin = acc-ci, ymax = acc+ci),
                                position = position_dodge(0.8), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=v5g, aes(x = vstmLoad, y = acc),
                         position=position_dodge(0.8), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Change Detection Accuracy (%)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(50, 100), clip = "on") +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


v5 %>% anova_test(dv = acc, wid = SN, within = c(Overlap, vstmLoad), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
Overlap 1 19 2.82 0.11 0.13
vstmLoad 1 19 290.82 0.00 * 0.94
Overlap:vstmLoad 1 19 0.53 0.48 0.03

v5 %>% filter(Overlap == "NonOverlap") %>% pairwise_t_test(acc ~ vstmLoad, paired = TRUE)
## # A tibble: 1 × 10
##   .y.   group1 group2    n1    n2 statistic    df       p   p.adj p.adj.signif
## * <chr> <chr>  <chr>  <int> <int>     <dbl> <dbl>   <dbl>   <dbl> <chr>       
## 1 acc   Low    High      20    20      14.9    19 6.3e-12 6.3e-12 ****
v5 %>% filter(Overlap == "NonOverlap") %>% cohens_d(acc ~ vstmLoad, paired = TRUE)
## # A tibble: 1 × 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 acc   Low    High      3.33    20    20 large

v5 %>% filter(Overlap == "Overlap") %>% pairwise_t_test(acc ~ vstmLoad, paired = TRUE)
## # A tibble: 1 × 10
##   .y.   group1 group2    n1    n2 statistic    df        p    p.adj p.adj.signif
## * <chr> <chr>  <chr>  <int> <int>     <dbl> <dbl>    <dbl>    <dbl> <chr>       
## 1 acc   Low    High      20    20      12.1    19 2.26e-10 2.26e-10 ****
v5 %>% filter(Overlap == "Overlap") %>% cohens_d(acc ~ vstmLoad, paired = TRUE)
## # A tibble: 1 × 7
##   .y.   group1 group2 effsize    n1    n2 magnitude
## * <chr> <chr>  <chr>    <dbl> <int> <int> <ord>    
## 1 acc   Low    High      2.70    20    20 large

5.2 VSTM: K

k5 <- E5 %>% 
    group_by(SN, Overlap, vstmLoad, vstmCond) %>% # vstmCond: change = 1 or not = 2
    summarise(acc = mean(vstmCorr)) %>%
    ungroup() %>% 
    mutate(vstmCond = ifelse(vstmCond==1, "different", "same")) %>% 
    pivot_wider(id_cols = c(SN, Overlap, vstmLoad), names_from = vstmCond, values_from = acc) %>% 
    mutate(SS = ifelse(vstmLoad=="Low", 1, 4),
                 K = SS * (same - (1 - different))) %>% 
    select(SN, Overlap, vstmLoad, K)

k5 %>% pivot_wider(id_cols = c(SN, Overlap), names_from = vstmLoad, values_from = K) %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "K") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"))) %>% 
    group_by(Overlap, vstmLoad) %>% 
    get_summary_stats(K, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-3) %>% 
    kable(digits = 2, caption = "K: Descriptive Stats")
K: Descriptive Stats
Overlap vstmLoad n mean sd median iqr ci
NonOverlap Low 20 0.88 0.06 0.86 0.08 0.03
NonOverlap High 20 1.85 0.48 1.82 0.29 0.22
NonOverlap Diff 20 0.97 0.48 0.98 0.32 0.22
Overlap Low 20 0.87 0.10 0.90 0.11 0.05
Overlap High 20 1.67 0.61 1.57 1.02 0.29
Overlap Diff 20 0.80 0.60 0.73 0.94 0.28
k5 %>% anova_test(dv = K, wid = SN, within = c(Overlap, vstmLoad), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
Overlap 1 19 2.15 0.16 0.10
vstmLoad 1 19 80.99 0.00 * 0.81
Overlap:vstmLoad 1 19 1.44 0.24 0.07
k5 %>% filter(Overlap == "NonOverlap") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    pairwise_t_test(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
High Low 20 20 9.15 19 0 0 ****
k5 %>% filter(Overlap == "NonOverlap") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    cohens_d(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
High Low 2.05 20 20 large
k5 %>% filter(Overlap == "Overlap") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    pairwise_t_test(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
High Low 20 20 6.01 19 0 0 ****
k5 %>% filter(Overlap == "Overlap") %>% 
    mutate(vstmLoad = factor(.$vstmLoad, levels = c("High", "Low"))) %>% 
    cohens_d(K ~ vstmLoad, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
High Low 1.34 20 20 large

5.3 Flanker task: Error

E5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap", "vstmLoad"), names_from = "Congruency", values_from = "err") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(Overlap, vstmLoad, Congruency) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-4) %>%
    kable(digits = 2, caption = "Flanker % Error: Descriptive Stats")
Flanker % Error: Descriptive Stats
Overlap vstmLoad Congruency n mean sd median iqr ci
NonOverlap Low Congruent 20 3.54 5.11 2.08 6.25 2.39
NonOverlap Low Incongruent 20 4.38 5.53 2.08 6.25 2.59
NonOverlap Low Diff 20 0.83 4.40 0.00 4.17 2.06
NonOverlap High Congruent 20 2.08 2.34 2.08 2.60 1.10
NonOverlap High Incongruent 20 3.65 3.57 2.08 3.12 1.67
NonOverlap High Diff 20 1.56 4.16 0.00 4.69 1.95
Overlap Low Congruent 20 3.33 3.47 2.08 2.60 1.62
Overlap Low Incongruent 20 3.54 3.58 2.08 3.12 1.68
Overlap Low Diff 20 0.21 2.86 1.04 4.17 1.34
Overlap High Congruent 20 2.92 2.98 2.08 4.17 1.39
Overlap High Incongruent 20 3.44 3.26 2.08 6.25 1.53
Overlap High Diff 20 0.52 4.21 1.04 5.21 1.97

E5 %>% group_by(SN, Overlap, Congruency, vstmLoad) %>% 
    summarise(err = 100 - mean(Corr)*100) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap", "Congruency"), names_from = "vstmLoad", values_from = "err") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "Error") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Overlap, Congruency, vstmLoad) %>% 
    get_summary_stats(Error, show = c("mean", "sd", "median", "iqr", "ci")) 
## # A tibble: 12 × 10
##    Overlap    Congruency  vstmLoad varia…¹     n   mean    sd median   iqr    ci
##    <fct>      <fct>       <fct>    <fct>   <dbl>  <dbl> <dbl>  <dbl> <dbl> <dbl>
##  1 NonOverlap Congruent   Low      Error      20  3.54   5.11   2.08  6.25  2.39
##  2 NonOverlap Congruent   High     Error      20  2.08   2.34   2.08  2.60  1.10
##  3 NonOverlap Congruent   Diff     Error      20 -1.46   5.15   0     6.25  2.41
##  4 NonOverlap Incongruent Low      Error      20  4.38   5.53   2.08  6.25  2.59
##  5 NonOverlap Incongruent High     Error      20  3.65   3.57   2.08  3.12  1.67
##  6 NonOverlap Incongruent Diff     Error      20 -0.729  4.45   0     4.69  2.08
##  7 Overlap    Congruent   Low      Error      20  3.33   3.47   2.08  2.60  1.62
##  8 Overlap    Congruent   High     Error      20  2.92   2.98   2.08  4.17  1.39
##  9 Overlap    Congruent   Diff     Error      20 -0.417  3.35   0     6.25  1.57
## 10 Overlap    Incongruent Low      Error      20  3.54   3.58   2.08  3.12  1.68
## 11 Overlap    Incongruent High     Error      20  3.44   3.26   2.08  6.25  1.53
## 12 Overlap    Incongruent Diff     Error      20 -0.104  3.48   0     4.17  1.63
## # … with abbreviated variable name ¹​variable

e5 <- E5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% summarise(err = 100 - mean(Corr)*100) %>% ungroup()
e5g <- e5 %>% Rmisc::summarySEwithin(measurevar = "err", withinvars = c("Overlap", "vstmLoad", "Congruency"), idvar = "SN")

e5 %>% ggplot(aes(x=vstmLoad, y=err, fill=Congruency)) +
    geom_violin(width = 0.7, trim=TRUE) +
    facet_grid(. ~ Overlap, labeller = labeller(Overlap = over.labs)) +
    ggbeeswarm::geom_quasirandom(dodge.width = 0.7, color = "gray80", size = 3, alpha = 0.4, show.legend = FALSE) +
    geom_errorbar(data=e5g, aes(x = vstmLoad, ymin = err-ci, ymax = err+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=e5g, aes(x = vstmLoad, y = err),
                         position=position_dodge(0.7), size=5, color = "darkred", show.legend = FALSE) + 
    coord_cartesian(ylim = c(0, 50), clip = "on") +
    labs(x = "VSTM Load", y = "% Error", fill="Congruency") +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())


e5 %>% anova_test(dv = err, wid = SN, within = c(Overlap, vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
Overlap 1 19 0.05 0.82 0.00
vstmLoad 1 19 1.46 0.24 0.07
Congruency 1 19 2.84 0.11 0.13
Overlap:vstmLoad 1 19 0.98 0.34 0.05
Overlap:Congruency 1 19 0.92 0.35 0.05
vstmLoad:Congruency 1 19 0.56 0.46 0.03
Overlap:vstmLoad:Congruency 1 19 0.04 0.84 0.00

# arcsine transformation
E5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% 
    summarise(acc = asin(sqrt(mean(Corr)))) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap", "vstmLoad"), names_from = "Congruency", values_from = "acc") %>% 
    mutate(Diff = Congruent - Incongruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "Accuracy") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), labels = c("Low", "High"))) %>% 
    group_by(Overlap, vstmLoad, Congruency) %>% 
    get_summary_stats(Accuracy, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 12 × 10
##    Overlap    vstmLoad Congruency  variable     n  mean    sd median   iqr    ci
##    <fct>      <fct>    <fct>       <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
##  1 NonOverlap Low      Congruent   Accuracy    20 1.44  0.142  1.43  0.253 0.066
##  2 NonOverlap Low      Incongruent Accuracy    20 1.41  0.14   1.43  0.253 0.066
##  3 NonOverlap Low      Diff        Accuracy    20 0.031 0.152  0     0.217 0.071
##  4 NonOverlap High     Congruent   Accuracy    20 1.46  0.099  1.43  0.16  0.046
##  5 NonOverlap High     Incongruent Accuracy    20 1.41  0.113  1.43  0.109 0.053
##  6 NonOverlap High     Diff        Accuracy    20 0.05  0.134  0     0.161 0.063
##  7 Overlap    Low      Congruent   Accuracy    20 1.42  0.108  1.43  0.097 0.05 
##  8 Overlap    Low      Incongruent Accuracy    20 1.42  0.112  1.43  0.109 0.053
##  9 Overlap    Low      Diff        Accuracy    20 0.004 0.12   0.024 0.201 0.056
## 10 Overlap    High     Congruent   Accuracy    20 1.44  0.111  1.43  0.206 0.052
## 11 Overlap    High     Incongruent Accuracy    20 1.42  0.114  1.43  0.253 0.054
## 12 Overlap    High     Diff        Accuracy    20 0.016 0.173  0.024 0.29  0.081

s5 <- E5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% summarise(acc = asin(sqrt(mean(Corr)))) %>% ungroup()
s5 %>% anova_test(dv = acc, wid = SN, within = c(Overlap, vstmLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                        Effect DFn DFd     F     p p<.05      pes
## 1                     Overlap   1  19 0.226 0.640       0.012000
## 2                    vstmLoad   1  19 0.814 0.378       0.041000
## 3                  Congruency   1  19 2.404 0.138       0.112000
## 4            Overlap:vstmLoad   1  19 0.016 0.901       0.000839
## 5          Overlap:Congruency   1  19 0.811 0.379       0.041000
## 6         vstmLoad:Congruency   1  19 0.291 0.596       0.015000
## 7 Overlap:vstmLoad:Congruency   1  19 0.011 0.919       0.000555

5.4 Flanker task: RT

# filtering out incorrect trials
cE5 <- E5 %>% filter(Corr==1 & vstmCorr==1) %>% mutate(RT = RT*1000)

# trimming
tE5 <- cE5 %>% filter(RT > 200) %>% 
    group_by(SN) %>% 
    nest() %>%
    mutate(lbound = map(data, ~mean(.$RT)-xcut*sd(.$RT)),
                 ubound = map(data, ~mean(.$RT)+xcut*sd(.$RT))) %>%
    unnest(c(lbound, ubound)) %>%
    unnest(data) %>%
    mutate(Outlier = (RT < lbound)|(RT > ubound)) %>%
    filter(Outlier == FALSE) %>%
    ungroup %>%
    select(SN, Overlap, vstmLoad, Congruency, RT)

# percentage trimmed.
100*(nrow(cE5)-nrow(tE5))/nrow(E5)
## [1] 3.385417

tE5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    pivot_longer(cols = Incongruent:Diff, names_to = "Congruency", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High"), 
                                                    labels = c("Low", "High"))) %>% 
    group_by(Overlap, vstmLoad, Congruency) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    select(-4) %>% 
    kable(digits = 2, caption = "Flanker RT (ms): Descriptive Stats")
Flanker RT (ms): Descriptive Stats
Overlap vstmLoad Congruency n mean sd median iqr ci
NonOverlap Low Congruent 20 743.86 115.09 693.42 192.44 53.86
NonOverlap Low Incongruent 20 796.45 128.29 733.70 196.89 60.04
NonOverlap Low Diff 20 52.59 55.58 32.46 73.23 26.01
NonOverlap High Congruent 20 731.10 117.85 691.16 184.10 55.16
NonOverlap High Incongruent 20 807.32 127.57 753.77 174.40 59.70
NonOverlap High Diff 20 76.22 43.43 68.85 56.18 20.32
Overlap Low Congruent 20 750.15 114.03 717.14 175.36 53.37
Overlap Low Incongruent 20 806.30 125.12 750.49 179.79 58.56
Overlap Low Diff 20 56.15 59.35 43.28 59.57 27.78
Overlap High Congruent 20 738.48 118.42 704.04 189.18 55.42
Overlap High Incongruent 20 794.36 126.86 759.46 198.59 59.37
Overlap High Diff 20 55.88 50.48 59.45 61.01 23.62

tE5 %>% group_by(SN, Overlap, Congruency, vstmLoad) %>% 
    summarise(rt = mean(RT)) %>%
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap", "Congruency"), names_from = "vstmLoad", values_from = "rt") %>% 
    mutate(Diff = High - Low) %>% 
    pivot_longer(cols = Low:Diff, names_to = "vstmLoad", values_to = "RT") %>% 
    mutate(Congruency = factor(.$Congruency, levels = c("Congruent", "Incongruent", "Diff"), 
                                                         labels = c("Congruent", "Incongruent", "Diff")),
                 vstmLoad = factor(.$vstmLoad, levels = c("Low", "High", "Diff"), 
                                                    labels = c("Low", "High", "Diff"))) %>% 
    group_by(Overlap, Congruency, vstmLoad) %>% 
    get_summary_stats(RT, show = c("mean", "sd", "median", "iqr", "ci"))
## # A tibble: 12 × 10
##    Overlap    Congruency  vstmLoad variable     n  mean    sd median   iqr    ci
##    <fct>      <fct>       <fct>    <fct>    <dbl> <dbl> <dbl>  <dbl> <dbl> <dbl>
##  1 NonOverlap Congruent   Low      RT          20 744.  115.   693.  192.   53.9
##  2 NonOverlap Congruent   High     RT          20 731.  118.   691.  184.   55.2
##  3 NonOverlap Congruent   Diff     RT          20 -12.8  32.0  -17.6  35.5  15.0
##  4 NonOverlap Incongruent Low      RT          20 796.  128.   734.  197.   60.0
##  5 NonOverlap Incongruent High     RT          20 807.  128.   754.  174.   59.7
##  6 NonOverlap Incongruent Diff     RT          20  10.9  37.7   15.6  38.4  17.7
##  7 Overlap    Congruent   Low      RT          20 750.  114.   717.  175.   53.4
##  8 Overlap    Congruent   High     RT          20 738.  118.   704.  189.   55.4
##  9 Overlap    Congruent   Diff     RT          20 -11.7  45.0  -10.6  60.6  21.0
## 10 Overlap    Incongruent Low      RT          20 806.  125.   750.  180.   58.6
## 11 Overlap    Incongruent High     RT          20 794.  127.   759.  199.   59.4
## 12 Overlap    Incongruent Diff     RT          20 -11.9  37.3  -11.2  46.7  17.5

r5 <- tE5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% summarise(RT = mean(RT)) %>% ungroup()
r5w <- r5 %>%   unite("temp", c("vstmLoad", "Congruency")) %>% 
    pivot_wider(id_cols = c(SN, Overlap), names_from = temp, values_from = RT)
r5g <- r5 %>% Rmisc::summarySEwithin(measurevar = "RT", withinvars = c("Overlap", "vstmLoad", "Congruency"), idvar = "SN")

F5 <- ggplot() + 
    geom_bar(data=r5g, aes(x=vstmLoad, y=RT, fill=Congruency),
                     stat="identity", width=0.7, color="black", position=position_dodge(.8)) + 
    facet_grid(. ~ Overlap, labeller = labeller(Overlap = over.labs)) +
    geom_linerange(data=r5g, aes(x=vstmLoad, ymin=RT-ci, ymax=RT+ci, group=Congruency),
                                 linewidth=1, position=position_dodge(0.8)) +
    scale_fill_manual(values=c('#0073C2FF','#EFC000FF'),
                                        labels=c("Incongruent", "Congruent")) +
    geom_point(data=r5, aes(x=vstmLoad, y=RT, group=Congruency),
                         position=position_dodge(0.6), color="gray80", size=1.8) +
    geom_segment(data=r5w, aes(x=1-.15, y=Low_Incongruent, xend=1+.15, yend=Low_Congruent), color="gray80") +
    geom_segment(data=r5w, aes(x=2-.15, y=High_Incongruent, xend=2+.15, yend=High_Congruent), color="gray80") +
    labs(x = "VSTM Load", y = "Response Time (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(500, 1200), clip = "on") +
    scale_y_continuous(breaks=seq(500, 1200, by=100)) +
    theme_bw(base_size = 18) +
    theme(legend.position="top",
                legend.spacing.x = unit(0.5, 'lines'),
                legend.margin = margin(0, 0, 0, 0),
                legend.title = element_blank(),
                legend.background = element_blank(),
                panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

r5ce <- tE5 %>% group_by(SN, Overlap, vstmLoad, Congruency) %>% 
    summarise(rt = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c("SN", "Overlap", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
    mutate(Diff = Incongruent - Congruent) %>% 
    select(SN, Overlap, vstmLoad, Diff)
r5cew <- r5ce %>% pivot_wider(id_cols = c(SN, Overlap), names_from = vstmLoad, values_from = Diff)
r5ceg <- r5ce %>% Rmisc::summarySEwithin(measurevar = "Diff", withinvars = c("Overlap", "vstmLoad"), idvar = "SN")

G5 <- ggplot(r5ce, aes(x=vstmLoad, y=Diff)) +
    geom_hline(yintercept = 0) +
    geom_violin(width = 0.5, trim=TRUE) + 
    facet_grid(. ~ Overlap, labeller = labeller(Overlap = over.labs)) +
    geom_point(color="gray80", size=1.8) +
    geom_segment(data=r5cew, color="gray80", aes(x=1, y=Low, xend=2, yend=High)) +
    geom_errorbar(data=r5ceg, aes(x = vstmLoad, ymin = Diff-ci, ymax = Diff+ci),
                                position = position_dodge(0.7), width = 0.1, linewidth = 1, color = "darkred") +
    geom_point(data=r5ceg, aes(x = vstmLoad, y = Diff), 
                         position=position_dodge(0.7), size=4, color = "darkred", show.legend = FALSE) + 
    labs(x = "VSTM Load", y = "Congruency Effect (ms)") +
    scale_x_discrete(labels=c("Low" = "Low (1)", "High" = "High (4)")) +
    coord_cartesian(ylim = c(-50, 250), clip = "on") +
    scale_y_continuous(breaks=seq(-50, 250, by = 50)) +
    theme_bw(base_size = 18) +
    theme(panel.grid.major = element_blank(), 
                panel.grid.minor = element_blank())

F5 + G5 + plot_layout(nrow = 1, widths = c(2, 1.2))



r5 %>% anova_test(dv = RT, wid = SN, within = c(Overlap, vstmLoad, Congruency), effect.size = "pes") %>% 
    kable(digits = 2, format = "simple", caption = "ANOVA")
ANOVA
Effect DFn DFd F p p<.05 pes
Overlap 1 19 1.42 0.25 0.07
vstmLoad 1 19 0.82 0.38 0.04
Congruency 1 19 32.15 0.00 * 0.63
Overlap:vstmLoad 1 19 3.31 0.09 0.15
Overlap:Congruency 1 19 1.71 0.21 0.08
vstmLoad:Congruency 1 19 3.15 0.09 0.14
Overlap:vstmLoad:Congruency 1 19 8.47 0.01 * 0.31

r5 %>% filter(Overlap == "Overlap") %>% 
    anova_test(dv = RT, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                Effect DFn DFd      F       p p<.05      pes
## 1            vstmLoad   1  19  2.022 0.17100       9.60e-02
## 2          Congruency   1  19 23.194 0.00012     * 5.50e-01
## 3 vstmLoad:Congruency   1  19  0.001 0.97400       5.77e-05
    
r5 %>% filter(Overlap == "NonOverlap") %>% 
    anova_test(dv = RT, wid = SN, within = c(vstmLoad, Congruency), effect.size = "pes")
## ANOVA Table (type III tests)
## 
##                Effect DFn DFd      F        p p<.05     pes
## 1            vstmLoad   1  19  0.019 0.893000       0.00098
## 2          Congruency   1  19 37.429 0.000007     * 0.66300
## 3 vstmLoad:Congruency   1  19 10.291 0.005000     * 0.35100






6 Correlation

VSTM 부담에 의한 K 변화량과 일치효과(플랭커 간섭) 변화량의 상관.

Kdiff <- bind_rows(k1 %>% pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'K') %>% 
                                        mutate(Kdiff = High - Low) %>% select(SN, Kdiff) %>% 
                                        mutate(Exp = 'Exp1', SN = paste('e1s', .$SN, sep = "")),
                                     k2 %>% pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'K') %>% 
                                        mutate(Kdiff = High - Low) %>% select(SN, Kdiff) %>% 
                                        mutate(Exp = 'Exp2', SN = paste('e2s', .$SN, sep = "")), 
                                     E5 %>% group_by(SN, vstmLoad, vstmCond) %>% # vstmCond: change = 1 or not = 2
                                        summarise(acc = mean(vstmCorr)) %>% ungroup() %>% 
                                        mutate(vstmCond = ifelse(vstmCond==1, "different", "same")) %>%
                                        pivot_wider(id_cols = c(SN, vstmLoad), names_from = vstmCond, values_from = acc) %>% 
                                        mutate(SS = ifelse(vstmLoad=="Low", 1, 4), K = SS * (same - (1 - different))) %>% 
                                        select(SN, vstmLoad, K) %>% 
                                        pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'K') %>% 
                                        mutate(Kdiff = High - Low) %>% select(SN, Kdiff) %>% 
                                        mutate(Exp = 'Exp5', SN = paste('e5s', .$SN, sep = ""))) %>% select(SN, Kdiff)

Cdiff <- bind_rows(r1ce %>% pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'Diff') %>%
                                        mutate(Cdiff = High - Low) %>% select(SN, Cdiff) %>% 
                                        mutate(Exp = 'Exp1', SN = paste('e1s', .$SN, sep = "")),
                                     r2ce %>% pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'Diff') %>%
                                        mutate(Cdiff = High - Low) %>% select(SN, Cdiff) %>% 
                                        mutate(Exp = 'Exp2', SN = paste('e2s', .$SN, sep = "")),
                                     tE5 %>% group_by(SN, vstmLoad, Congruency) %>% 
                                        summarise(rt = mean(RT)) %>% ungroup() %>% 
                                        pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
                                        mutate(Diff = Incongruent - Congruent) %>% 
                                        select(SN, vstmLoad, Diff) %>% 
                                        pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'Diff') %>%
                                        mutate(Cdiff = High - Low) %>% select(SN, Cdiff) %>% 
                                        mutate(Exp = 'Exp5', SN = paste('e5s', .$SN, sep = ""))) %>% select(SN, Cdiff)

tibble(K_lo2hi = Kdiff$Kdiff, CE_lo2hi = Cdiff$Cdiff) %>% summarise(N = n())
## # A tibble: 1 × 1
##       N
##   <int>
## 1    60
tibble(K_lo2hi = Kdiff$Kdiff, CE_lo2hi = Cdiff$Cdiff) %>% cor_test()
## # A tibble: 1 × 8
##   var1    var2       cor statistic     p conf.low conf.high method 
##   <chr>   <chr>    <dbl>     <dbl> <dbl>    <dbl>     <dbl> <chr>  
## 1 K_lo2hi CE_lo2hi  -0.1    -0.766 0.447   -0.345     0.158 Pearson
tibble(K_lo2hi = Kdiff$Kdiff, CE_lo2hi = Cdiff$Cdiff) %>% 
    pairs.panels(smooth = TRUE, scale = FALSE, density = TRUE, 
                             ellipses = FALSE, method = "pearson", pch = 21, lm = TRUE, 
                             cor = TRUE, jiggle = FALSE, factor = 2, hist.col = 4, 
                             stars = TRUE, ci = TRUE)

tibble(K_lo2hi = Kdiff$Kdiff, CE_lo2hi = Cdiff$Cdiff) %>% 
    sjPlot::tab_corr(p.numeric = TRUE, corr.method = "pearson", triangle = "lower")
  K_lo2hi CE_lo2hi
K_lo2hi    
CE_lo2hi -0.100
(.447)
 
Computed correlation used pearson-method with listwise-deletion.






7 TOST

# murge experiments
d <- bind_rows(tE1 %>% mutate(Exp = 'Exp1', SN = paste('e1s', .$SN, sep = "")),
                             tE2 %>% mutate(Exp = 'Exp2', SN = paste('e2s', .$SN, sep = "")),
                             tE3 %>% mutate(Exp = 'Exp3', SN = paste('e3s', .$SN, sep = "")),
                             tE5 %>% mutate(Exp = 'Exp5', SN = paste('e5s', .$SN, sep = ""))) %>% 
    select(Exp, SN, vstmLoad, Congruency, RT) %>% 
    mutate(Exp = factor(.$Exp), 
                 SN = factor(.$SN))
headTail(d)
##    Exp    SN vstmLoad  Congruency    RT
## 1 Exp1  e1s1      Low Incongruent   845
## 2 Exp1  e1s1      Low Incongruent 922.5
## 3 Exp1  e1s1      Low Incongruent 944.8
## 4 Exp1  e1s1      Low   Congruent 823.5
## 5 <NA>  <NA>     <NA>        <NA>   ...
## 6 Exp5 e5s20      Low   Congruent 822.1
## 7 Exp5 e5s20      Low Incongruent 754.5
## 8 Exp5 e5s20      Low Incongruent   623
## 9 Exp5 e5s20      Low   Congruent 629.7
slice_sample(d, n = 10)
## # A tibble: 10 × 5
##    Exp   SN    vstmLoad Congruency     RT
##    <fct> <fct> <fct>    <fct>       <dbl>
##  1 Exp5  e5s18 Low      Congruent    836.
##  2 Exp3  e3s14 High     Congruent    894.
##  3 Exp1  e1s5  High     Congruent    581.
##  4 Exp3  e3s19 High     Incongruent  628.
##  5 Exp5  e5s15 Low      Congruent    887.
##  6 Exp5  e5s6  Low      Incongruent  876.
##  7 Exp2  e2s13 High     Congruent    645.
##  8 Exp1  e1s5  High     Congruent    751.
##  9 Exp5  e5s20 Low      Congruent    753.
## 10 Exp1  e1s15 Low      Congruent    812.

dd <- d %>% 
    group_by(Exp, SN, vstmLoad, Congruency) %>% 
    summarise(M = mean(RT)) %>% 
    ungroup() %>% 
    pivot_wider(id_cols = c(Exp, SN, vstmLoad), names_from = Congruency, values_from = M) %>% 
    mutate(Congruency = Incongruent - Congruent) %>% 
    select(Exp, SN, vstmLoad, Congruency) %>%
    pivot_wider(id_cols = c(Exp, SN), names_from = vstmLoad, values_from = Congruency) %>% 
    mutate(Difference = High - Low)
    # select(Exp, SN, Difference) 
mean(dd$Difference)
## [1] 4.945433

# dd %>% ggplot(aes(x=1, y=Difference)) +
#   geom_violin(width = 0.6, trim=TRUE) + 
#   ggbeeswarm::geom_quasirandom(aes(colour = Exp), size = 3, alpha = 0.9, width = 0.3) +
#   geom_hline(aes(yintercept=0), lty=1) +
#   stat_summary(fun.data="mean_cl_normal", shape=19,  colour="darkred", size = 1,
#                            position=position_dodge(0.9)) +
#   coord_flip() + 
#   labs(y = "Congruency Difference \n (High Load - Low Load)") +
#   theme_classic(base_size = 18) +
#   theme(axis.line.y = element_blank(),
#               axis.text.y = element_blank(),
#               axis.ticks.y = element_blank(),
#               axis.title.y = element_blank(),
#               legend.title = element_blank(),
#               legend.position = c(0.85, 0.8),
#               aspect.ratio = .5)

# beanplot::beanplot(Difference ~ Exp, data = dd)

# https://www.r-bloggers.com/2021/12/comparing-distributions/
grp_names <- c(`Exp1` = "Expt 1", `Exp2` = "Expt 2", `Exp3` = "Expt 3", `Exp5` = "Expt 5")
F6 <- dd %>% ggplot() + 
    geom_vline(xintercept = 0) +
    geom_density_ridges(mapping = aes(x = Difference, y = Exp, fill = Exp), 
                                                                color = "white", alpha = .7, scale = 2) + 
    scale_fill_manual(values = wesanderson::wes_palette(n=4, name="Cavalcanti1")) + 
    scale_y_discrete(labels = as_labeller(grp_names)) + 
    scale_x_continuous(breaks=seq(-150, 150, by = 50)) +
    coord_cartesian(xlim = c(-150, 150), clip = "on") +
    guides(color = "none", fill = "none") + 
    labs(x = "Difference in Congruency Effects\n(High Load - Low Load)", y = NULL) +
    labs(x = NULL, y = NULL) + 
    theme_classic(base_size = 18) +
    theme(axis.line.y = element_blank(),
                axis.ticks.y = element_blank(),
                axis.title.y = element_blank(),
                legend.title = element_blank(),
                legend.position = c(0.85, 0.8),
                aspect.ratio = .5)

# Simonsohn의 제안(링크 필요)에 따라, 원래 실험에서 검증력이 33%인 효과 크기를 계산한다. 
# Konstantinou, Beal, King, Lavie(2014, APP) 실험에서 실험 1b의 참가자 수는 N=22. 따라서,
E33 = pwr::pwr.t.test(n=22, power = .33, sig.level = .05, type="paired")
E33$d
## [1] 0.3393938
# 효과크기 d=0.3394보다 작은 효과는 효과가 없다고 할 수 있다. 
# 재현에 필요한 표본의 크기는 효과크기 d=0.3394에서 검증력이 80% 이상인 참가자 수이다.

required_N <- TOSTER::powerTOSTpaired(alpha = .05, statistical_power = .8, 
                                                                            low_eqbound_dz = -E33$d, high_eqbound_dz = E33$d)
## Note: this function is defunct. Please use power_t_TOST instead
## The required sample size to achieve 80 % power with equivalence bounds of -0.3393938 and 0.3393938 is 75 pairs
## 
pp <- power_t_TOST(alpha = .05, power = .8, low_eqbound = -E33$d, high_eqbound = E33$d, type = "paired.sample")
pp$n
## [1] 75.72011
# 최소 76명이 필요하다.

tm <- TOSTpaired(n = 80, 
                                 m1 = mean(dd$High), m2 = mean(dd$Low),
                                 sd1 = sd(dd$High), sd2 = sd(dd$Low),
                                 r12 = cor(dd$High, dd$Low),
                                 low_eqbound_dz = -E33$d, 
                                 high_eqbound_dz = E33$d, 
                                 alpha = 0.05, plot = FALSE)
## Note: this function is defunct. Please use tsum_TOST instead
## TOST results:
## t-value lower bound: 4.26    p-value lower bound: 0.00003
## t-value upper bound: -1.81   p-value upper bound: 0.037
## degrees of freedom : 79
## 
## Equivalence bounds (Cohen's dz):
## low eqbound: -0.3394 
## high eqbound: 0.3394
## 
## Equivalence bounds (raw scores):
## low eqbound: -12.2705 
## high eqbound: 12.2705
## 
## TOST confidence interval:
## lower bound 90% CI: -1.782
## upper bound 90% CI:  11.673
## 
## NHST confidence interval:
## lower bound 95% CI: -3.1
## upper bound 95% CI:  12.991
## 
## Equivalence Test Result:
## The equivalence test was significant, t(79) = -1.812, p = 0.0369, given equivalence bounds of -12.271 and 12.271 (on a raw scale) and an alpha of 0.05.
## 
## 
## Null Hypothesis Test Result:
## The null hypothesis test was non-significant, t(79) = 1.223, p = 0.225, given an alpha of 0.05.
## 
## NHST: don't reject null significance hypothesis that the effect is equal to 0 
## TOST: reject null equivalence hypothesis

G6 <- as.data.frame(tm) %>% 
    ggplot(aes(x=1, y=diff, ymin=LL_CI_TOST, ymax=UL_CI_TOST)) +
    geom_hline(yintercept = 0) +
    geom_errorbar(color = "darkred", width = 0.2, linewidth = 1) +
    geom_point(color = "darkred", size = 4) +
    coord_flip(ylim = c(tm$low_eqbound, tm$high_eqbound)) +
    geom_hline(yintercept = c(tm$high_eqbound, tm$low_eqbound),
                         linetype = "dashed") +
    labs(y = "Difference in Congruency Effects\n(High Load - Low Load)") +
    theme_classic(base_size = 18) +
    theme(axis.line.y = element_blank(),
                axis.text.y = element_blank(), 
                axis.ticks.y = element_blank(),
                axis.title.y = element_blank(),
                aspect.ratio = .2)

F6/G6 + plot_layout(nrow = 2, heights = c(2, 1.5))
## Picking joint bandwidth of 13.4






8 Split Analysis

저부담 조건과 고부담 조건의 Cowan’s K 차이가 상위 30%로 큰 참가자들의 플랭커 간섭을 비교하였다.

Kdiff2 <- Kdiff %>% mutate(q70 = quantile(Kdiff, prob = .70), hUpper = Kdiff > q70)
Cdiff2 <- bind_rows(r1ce %>% pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'Diff') %>%
                                        mutate(Exp = 'Exp1', SN = paste('e1s', .$SN, sep = "")),
                                     r2ce %>% pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'Diff') %>%
                                        mutate(Exp = 'Exp2', SN = paste('e2s', .$SN, sep = "")),
                                     tE5 %>% group_by(SN, vstmLoad, Congruency) %>% 
                                        summarise(rt = mean(RT)) %>% ungroup() %>% 
                                        pivot_wider(id_cols = c("SN", "vstmLoad"), names_from = "Congruency", values_from = "rt") %>% 
                                        mutate(Diff = Incongruent - Congruent) %>% 
                                        select(SN, vstmLoad, Diff) %>% 
                                        pivot_wider(id_cols = 'SN', names_from = 'vstmLoad', values_from = 'Diff') %>%
                                        mutate(Exp = 'Exp5', SN = paste('e5s', .$SN, sep = ""))) %>% select(SN, Low, High)

full_join(Kdiff2, Cdiff2, by = "SN") %>% 
    filter(hUpper == TRUE)
## # A tibble: 18 × 6
##    SN    Kdiff   q70 hUpper    Low   High
##    <chr> <dbl> <dbl> <lgl>   <dbl>  <dbl>
##  1 e1s5   2.62  1.57 TRUE    35.9   -3.52
##  2 e1s7   1.83  1.57 TRUE    92.3   91.5 
##  3 e1s9   2.29  1.57 TRUE    35.8   23.3 
##  4 e1s10  1.79  1.57 TRUE   -13.6   14.4 
##  5 e1s11  2.10  1.57 TRUE     5.76  11.0 
##  6 e1s12  1.81  1.57 TRUE   102.    72.4 
##  7 e1s14  1.65  1.57 TRUE    37.1  -21.4 
##  8 e1s15  2.23  1.57 TRUE    42.4   40.9 
##  9 e1s17  1.77  1.57 TRUE   -26.9   47.3 
## 10 e1s18  1.81  1.57 TRUE    26.0    4.21
## 11 e1s20  2.48  1.57 TRUE    17.4  -16.9 
## 12 e2s5   2.15  1.57 TRUE    39.6   76.2 
## 13 e2s6   1.96  1.57 TRUE    38.0   48.8 
## 14 e2s11  1.62  1.57 TRUE    64.9   30.8 
## 15 e2s16  2.25  1.57 TRUE    56.9  135.  
## 16 e2s19  1.85  1.57 TRUE    13.5    6.69
## 17 e5s5   1.66  1.57 TRUE    57.5   84.3 
## 18 e5s9   1.92  1.57 TRUE    77.6   76.5
h <- full_join(Kdiff2, Cdiff2, by = "SN") %>% 
    filter(hUpper == TRUE) %>% 
    select(SN, Low, High) %>% 
    pivot_longer(cols = c(Low, High), names_to = 'Load', values_to = 'Flanker')

h %>% group_by(Load) %>% 
    get_summary_stats(Flanker, show = c("mean", "sd", "median", "iqr", "ci")) %>% 
    kable(digits = 2, caption = "Flanker RT (ms): Descriptive Stats")
Flanker RT (ms): Descriptive Stats
Load variable n mean sd median iqr ci
High Flanker 18 40.06 42.37 35.81 67.47 21.07
Low Flanker 18 38.99 33.55 37.57 37.78 16.68

h %>% pairwise_t_test(Flanker ~ Load, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Pairwise t test")
Pairwise t test
group1 group2 n1 n2 statistic df p p.adj p.adj.signif
High Low 18 18 0.12 17 0.9 0.9 ns
h %>% cohens_d(Flanker ~ Load, paired = TRUE) %>% select(-1) %>% 
    kable(digits = 2, format = "simple", caption = "Effect Size")
Effect Size
group1 group2 effsize n1 n2 magnitude
High Low 0.03 18 18 negligible






9 Session Info

sessionInfo()
## R version 4.2.2 (2022-10-31)
## Platform: aarch64-apple-darwin20 (64-bit)
## Running under: macOS Ventura 13.2
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] icons_0.2.0          klippy_0.0.0.9500    patchwork_1.1.2.9000
##  [4] cowplot_1.1.1        pwr_1.3-0            TOSTER_0.6.0        
##  [7] rstatix_0.7.1        ggridges_0.5.4       knitr_1.42          
## [10] psych_2.2.9          forcats_0.5.2        stringr_1.5.0       
## [13] dplyr_1.0.10         purrr_1.0.1          readr_2.1.3         
## [16] tidyr_1.3.0          tibble_3.1.8         ggplot2_3.4.0       
## [19] tidyverse_1.3.2      Rmisc_1.5.1          plyr_1.8.8          
## [22] lattice_0.20-45     
## 
## loaded via a namespace (and not attached):
##   [1] readxl_1.4.1         backports_1.4.1      Hmisc_4.7-2         
##   [4] splines_4.2.2        TH.data_1.1-1        digest_0.6.31       
##   [7] htmltools_0.5.4      wesanderson_0.3.6    magick_2.7.3        
##  [10] fansi_1.0.4          magrittr_2.0.3       checkmate_2.1.0     
##  [13] googlesheets4_1.0.1  cluster_2.1.4        tzdb_0.3.0          
##  [16] modelr_0.1.10        sandwich_3.0-2       timechange_0.2.0    
##  [19] jpeg_0.1-10          colorspace_2.1-0     rvest_1.0.3         
##  [22] rappdirs_0.3.3       ggdist_3.2.1         haven_2.5.1         
##  [25] xfun_0.36            crayon_1.5.2         jsonlite_1.8.4      
##  [28] lme4_1.1-31          survival_3.5-0       zoo_1.8-11          
##  [31] glue_1.6.2           gtable_0.3.1         gargle_1.2.1        
##  [34] emmeans_1.8.4-1      sjstats_0.18.2       sjmisc_2.8.9        
##  [37] distributional_0.3.1 car_3.1-1            abind_1.4-5         
##  [40] scales_1.2.1         mvtnorm_1.1-3        DBI_1.1.3           
##  [43] ggeffects_1.1.5      Rcpp_1.0.10          xtable_1.8-4        
##  [46] performance_0.10.2   htmlTable_2.4.1      foreign_0.8-84      
##  [49] Formula_1.2-4        datawizard_0.6.5     htmlwidgets_1.6.1   
##  [52] httr_1.4.4           RColorBrewer_1.1-3   ellipsis_0.3.2      
##  [55] pkgconfig_2.0.3      farver_2.1.1         nnet_7.3-18         
##  [58] sass_0.4.5           dbplyr_2.3.0         deldir_1.0-6        
##  [61] utf8_1.2.2           tidyselect_1.2.0     labeling_0.4.2      
##  [64] rlang_1.0.6          munsell_0.5.0        cellranger_1.1.0    
##  [67] tools_4.2.2          cachem_1.0.6         cli_3.6.0           
##  [70] generics_0.1.3       pacman_0.5.1         sjlabelled_1.2.0    
##  [73] broom_1.0.3          evaluate_0.20        fastmap_1.1.0       
##  [76] yaml_2.3.7           fs_1.6.0             nlme_3.1-161        
##  [79] xml2_1.3.3           compiler_4.2.2       rstudioapi_0.14     
##  [82] beeswarm_0.4.0       png_0.1-8            reprex_2.0.2        
##  [85] bslib_0.4.2          stringi_1.7.12       highr_0.10          
##  [88] Matrix_1.5-3         nloptr_2.0.3         vctrs_0.5.2         
##  [91] pillar_1.8.1         lifecycle_1.0.3      jquerylib_0.1.4     
##  [94] estimability_1.4.1   data.table_1.14.6    insight_0.18.8      
##  [97] R6_2.5.1             latticeExtra_0.6-30  gridExtra_2.3       
## [100] vipor_0.4.5          codetools_0.2-18     boot_1.3-28.1       
## [103] MASS_7.3-58.2        assertthat_0.2.1     withr_2.5.0         
## [106] mnormt_2.1.1         multcomp_1.4-20      bayestestR_0.13.0   
## [109] parallel_4.2.2       hms_1.1.2            grid_4.2.2          
## [112] rpart_4.1.19         sjPlot_2.8.12        minqa_1.2.5         
## [115] coda_0.19-4          rmarkdown_2.20       carData_3.0-5       
## [118] googledrive_2.0.0    lubridate_1.9.1      base64enc_0.1-3     
## [121] ggbeeswarm_0.7.1     interp_1.1-3

View on Github