forked from paul-buerkner/LFO-CV-paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsim_run.R
41 lines (36 loc) · 892 Bytes
/
sim_run.R
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
source("sim_functions.R")
library(tidyverse)
library(foreach)
library(doParallel)
chains <- 1
iter <- 5000
warmup <- 1000
control <- list(adapt_delta = 0.95)
nsims <- 5
conditions <- expand.grid(
N = 200,
M = c(1, 4),
L = 25,
B = c(NA, 10),
model = c(
"constant", "linear", "quadratic",
"AR2-only", "AR2-linear", "AR2-quadratic"
),
k_thres = c(0.5, 0.6, 0.7),
sim = seq_len(nsims)
)
conditions$res <- list(list())
cl <- makeCluster(2)
registerDoParallel(cl)
J <- seq_len(nrow(conditions))
conditions$res[J] <-
foreach(j = J, .packages = c("brms", "loo")) %dopar%
sim_fun(j, conditions, chains = chains, iter = iter,
warmup = warmup, control = control)
stopCluster(cl)
file <- "results/lfo_sims.rds"
if (file.exists(file)) {
old_conditions <- read_rds(file)
conditions <- bind_rows(old_conditions, conditions)
}
write_rds(conditions, file)