-
Notifications
You must be signed in to change notification settings - Fork 0
/
easyABC_Steps.R
43 lines (33 loc) · 1.24 KB
/
easyABC_Steps.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
42
43
library("EasyABC")
prior <- list(c("unif", -10, 10))
model <- function(x) {
set.seed(x[1])
var1 <- 1.0 / 100.0
var2 <- 1.0
if(runif(1) < 0.5) {
rnorm(1, x[2], var1)
} else {
rnorm(1, x[2], var2)
}
}
observed <- 0
setwd("output/easyABC/simulationResult/5steps/")
result <- ABC_sequential("Lenormand", model=model, use_seed=TRUE, prior=prior,
alpha = 0.1, p_acc_min = 0.01, nb_simul=5000, summary_stat_target=observed, n_cluster=1, verbose=TRUE)
setwd("../../../..")
for (i in 1:length(result$intermediary)) {
write.table(
result$intermediary[[i]]$posterior[,1:2],
paste("output/easyABC/simulationResult/5steps/lenormand2012_5000_0.1_0.01_",i,"_1.csv", sep=""),
row.names=FALSE, col.names=FALSE)
}
setwd("output/easyABC/simulationResult/5steps/")
result <- ABC_sequential("Beaumont", model=model, use_seed=TRUE, prior=prior,
tolerance_tab = c(2, 1.5, 1.0, 0.5, 0.1, 0.05, 0.01), nb_simul=5000, summary_stat_target=observed, n_cluster=4, verbose=TRUE)
setwd("../../../..")
for (i in 1:length(result$intermediary)) {
write.table(
result$intermediary[[i]]$posterior[,1:2],
paste("output/easyABC/simulationResult/5steps/beaumont2009_5000_2.00_0.01_",i,"_1.csv", sep=""),
row.names=FALSE, col.names=FALSE)
}