### SHOULD BE RUN ON CLUSTER with lots of memory###

rm(list=ls())
library(foreign)
library(rstanarm)
library(rstan)
library(Hmisc)
library(data.table)
library(parallel)
library(loo)

setwd('~/research/gTiger/Article_citsci/open_code')
source('settings/parameters.r')
source('settings/paths.r')
source('settings/functions.r')

setwd(path_to_data)


these_models = c("ovitrap_model", "ovitrap_model_M0a","ovitrap_model_M0b", "ovitrap_model_M0c","ovitrap_model_M0d","ovitrap_model_M0e")

this_model = these_models[1]

for(this_model in these_models){

	M = readRDS(paste0('untracked/', this_model, '.Rds'))

#	M_loo = loo(M)

#	saveRDS(M_loo, paste0('untracked/', this_model, '_loo.Rds'))

#	rm(M_loo)

	M_waic = waic(M) 

	saveRDS(M_waic, paste0('untracked/', this_model, '_waic.Rds'))

	rm(M_waic)
	rm(M)
}

