-
Notifications
You must be signed in to change notification settings - Fork 2
/
.Rhistory
156 lines (156 loc) · 8.4 KB
/
.Rhistory
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
setwd("~/Master_Köln/WS19/Projekt_Stahl_Aust/Zusammenfassung_Frederik_Ich/For Github")
knitr::opts_chunk$set(cache = TRUE)
source("minerva-al.R")
source("supplementary_functions.R")
# setup constant variables over all simulations
n_features <- 120
cue_features <- 1:100
a <- b <- c <- d <- context <- outcome <- rep(0, n_features)
# setup stimuli
a[1:20] <- b [21:40] <- c[41:60] <- d[61:80] <- 1
context[81:100] <- 1
outcome[101:120] <- 1
# number of replications
n_replications <- 100
# learning rates
p_encode <- c(0.33, 0.67, 1)
# specify models
model = "Minerva AL"
##############################################
### Direct Test for conditioned Inhibition ###
##############################################
# No further information about how to intermix A -> X and AB trials,
# therefore I used the odd/even solution
# specify events
training_ax_event <- a + context + outcome
training_ab_event <- a + b + context
probe_a <- a + context
probe_b <- b + context
probe_ab <-a + b + context
# setup trial number
n_trials <- 100
# prepare results object as matrix[n_trials, n_replications]
sim_results_xa <- matrix(0, ncol = n_replications, nrow = length(p_encode))
sim_results_xb <- matrix(0, ncol = n_replications, nrow = length(p_encode))
# specify object for normalized echo for every trial as 3D array[p_encode, n_trials, n_replications]
# with cells containing normalized echo vector
normalized_echos <- array(list(rep(NA, n_features)), dim = c(length(p_encode), n_trials, n_replications))
#--------------- execute simulations--------------#
for (m in 1:length(model)){
for (r in 1:n_replications) {
for(i in 1:length(p_encode)) {
# Memory is empty on first trial
normalized_echo <- probe_memory(probe_a, NULL, cue_features, model = model[m])
memory <- learn(
normalized_echo
, training_ax_event
, p_encode[i]
, NULL
, model = model[m]
)
normalized_echos[[i,1,r]] <- normalized_echo
# A -> X trials on every even number
for(j in 2:(n_trials)) {
if (j %% 2 == 0){
normalized_echo <- probe_memory(probe_a, memory, cue_features, model = model[m])
memory <- learn(
normalized_echo
, training_ax_event
, p_encode[i]
, memory
, model = model[m]
)
normalized_echos[[i,j,r]] <- normalized_echo
}
else {
# AB trials on every odd number
normalized_echo <- probe_memory(probe_ab, memory, cue_features, model = model[m])
memory <- learn(
normalized_echo
, training_ab_event
, p_encode[i]
, memory
, model = model[m]
)
normalized_echos[[i,j,r]] <- normalized_echo
}
}
# Test X|A and X|B after the Training trials
normalized_echo_a <- probe_memory(probe_a, memory, cue_features, model = model[m])
normalized_echo_b <- probe_memory(probe_b, memory, cue_features, model = model[m])
sim_results_xa[i,r] <- expect_event(outcome = outcome, normalized_echo = normalized_echo_a)
sim_results_xb[i,r] <- expect_event(outcome = outcome, normalized_echo = normalized_echo_b)
}
}
}
#-----calculate mean and standard error of results objects-----#
res_mat <- matrix(NA, nrow = 2, ncol = 3)
#compute means over replications
x <- rowMeans(sim_results_xa)
#compute standard errors over replications
y <- apply(sim_results_xa, 1, FUN = std_err)
for (i in 1:length(p_encode)){
res_mat[1,i] <- table_fun(x[i], y[i])
}
#compute means over replications
x <- rowMeans(sim_results_xb)
#compute standard errors over replications
y <- apply(sim_results_xb, 1, FUN = std_err)
for (i in 1:length(p_encode)){
res_mat[2,i] <- table_fun(x[i], y[i])
}
# Reproduction of Table 2
knitr::kable(cbind(Condition = c("X|A", "X|B"), res_mat), col.names = c("Condition", round(p_encode, 2)), caption = "Reproduction of Table 2")
#Table 2 as reported by Jamieson et al. (2012)
knitr::kable(cbind(Condition = c("X|A", "X|B"), res_mat), col.names = c("Condition", round(p_encode, 2)), caption = "Table 2 as reported by Jamieson et al. (2012)")
res_mat
data <- c(".93 (0.2)",".97(.01)","99 (.01)","-16 (.01)","-21 (.02)","-32 (.04)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3)
res_mat2
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
res_mat2
data <- c(".93 (0.2)",".97(.01)",".99 (.01)","-.16 (.01)","-.21 (.02)","-.32 (.04)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|A", "X|B"), res_mat), col.names = c("Condition", round(p_encode, 2)), caption = "Table 2 as reported by Jamieson et al. (2012)")
data <- c(".93 (0.2)",".97(.01)",".99 (.01)","-.16 (.01)","-.21 (.02)","-.32 (.04)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|A", "X|B"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 2 as reported by Jamieson et al. (2012)")
data <- c(".93 (0.2)",".97 (.01)",".99 (.01)","-.16 (.01)","-.21 (.02)","-.32 (.04)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|A", "X|B"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 2 as reported by Jamieson et al. (2012)")
#Table 3 as reported by Jamieson et al. (2012)
data <- c(".13 (.02)",".18 (.02)",".05 (.07)",".93 (.01)",".92 (.01)","-.89 (.02)", ".99 (.00)", ".99 (.00)", "1 (.00)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|BC", "X|CD", "X|C"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 3 as reported by Jamieson et al. (2012)")
data <- c(".13 (.02)",".18 (.02)",".05 (.07)",".93 (.01)",".92 (.01)","-.89 (.02)", ".99 (.00)", ".99 (.00)", "1 (.00)")
res_mat2 <- matrix(data = data, nrow = 3, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|BC", "X|CD", "X|C"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 3 as reported by Jamieson et al. (2012)")
#Table 3 as reported by Jamieson et al. (2012)
data <- c(".13 (.02)",".18 (.02)",".05 (.07)",".93 (.01)",".92 (.01)",".89 (.02)", ".99 (.00)", ".99 (.00)", "1 (.00)")
res_mat2 <- matrix(data = data, nrow = 3, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|BC", "X|CD", "X|C"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 3 as reported by Jamieson et al. (2012)")
getwd()
#Table 4 as reported by Jamieson et al. (2012)
data <- c("46.6 (3.7)","16.3 (0.9)","5.6 (0.7)","29.4 (1.5)","13.2 (1.0)","4.2 (0.2)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("Experimental", "Control"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 4 as reported by Jamieson et al. (2012)")
#Table 5 as reported by Jamieson et al. (2012)
data <- c("0.80 (.02)","0.85 (.02)","0.90 (.02)","0.98 (.00)","0.99 (.00)","1.0 (.00)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("External Inhibition", "Control"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 5 as reported by Jamieson et al. (2012)")
#Table 2 as reported by Jamieson et al. (2012)
data <- c("0.93 (0.2)","0.97 (.01)","0.99 (.01)","-0.16 (.01)","-0.21 (.02)","-0.32 (.04)")
res_mat2 <- matrix(data = data, nrow = 2, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("X|A", "X|B"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 2 as reported by Jamieson et al. (2012)")
#Table 3 as reported by Jamieson et al. (2012)
data <- c(".13 (.02)",".18 (.02)",".05 (.07)",".93 (.01)",".92 (.01)",".89 (.02)", ".99 (.00)", ".99 (.00)", "1 (.00)")
res_mat2 <- matrix(data = data, nrow = 3, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("Summation", "Control (1)", "Control (2)"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 3 as reported by Jamieson et al. (2012)")
#Table 3 as reported by Jamieson et al. (2012)
data <- c("0.13 (.02)","0.18 (.02)","0.05 (.07)","0.93 (.01)","0.92 (.01)","0.89 (.02)", "0.99 (.00)", "0.99 (.00)", "1.0 (.00)")
res_mat2 <- matrix(data = data, nrow = 3, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("Summation", "Control (1)", "Control (2)"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 3 as reported by Jamieson et al. (2012)")
#Table 6 as reported by Jamieson et al. (2012)
data <- c("32.1 (1.7)","13.4 (1.0)","6.3 (0.5)","54.2 (3.0)","31.2 (3.3)","6.2 (0.5)", "61.6 (4.9)", "35.8 (5.6)", "6.4 (0.3)")
res_mat2 <- matrix(data = data, nrow = 3, ncol = 3, byrow = TRUE)
knitr::kable(cbind(Condition = c("0 Pretrials", "10 Pretrials", "30 Pretrials"), res_mat2), col.names = c("Condition", round(p_encode, 2)), caption = "Table 6 as reported by Jamieson et al. (2012)")