-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathS3_fit_models.R
33 lines (29 loc) · 1.13 KB
/
S3_fit_models.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
#setwd("") # set directory to the folder where the folders "data", "models" and "panels" are
library(Hmsc)
load(file = "models/unfitted_models") #models, modelnames
# samples_list = c(5,250,250,250,250)
# thin_list = c(1,1,10,100,1000)
samples_list = c(5,50, 250, 250, 250)
thin_list = c(1,10, 100, 1000, 10000)
nChains = 4
for(Lst in 1:length(samples_list)){
thin = thin_list[Lst]
samples = samples_list[Lst]
print(paste0("thin = ",as.character(thin),"; samples = ", as.character(samples)))
nm = length(models)
for (model in 1:nm) {
print(paste0("model = ",modelnames[model]))
m = models[[model]]
m = sampleMcmc(m, samples = samples, thin=thin,
adaptNf=rep(ceiling(0.4*samples*thin),m$nr),
transient = ceiling(0.5*samples*thin),
nChains = nChains,
nParallel = nChains)
models[[model]] = m
}
filename = paste("models/models_thin_", as.character(thin),
"_samples_", as.character(samples),
"_chains_",as.character(nChains),
".Rdata",sep = "")
save(models,modelnames,file=filename)
}