-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSectionC_Supplementary.R
57 lines (33 loc) · 1.64 KB
/
SectionC_Supplementary.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
rm(list=ls())
setwd(dirname(rstudioapi::getSourceEditorContext()$path))
# Load packages
library(INLA)
# Load the results: partitioned ST models
load("ST_models_ICAR_partitioned.Rdata")
MODELS.bigDM <- list(TypeI.ICAR, TypeII.ICAR, TypeIII.ICAR, TypeIV.ICAR)
rm(TypeI.ICAR, TypeII.ICAR, TypeIII.ICAR, TypeIV.ICAR)
# Load the results: global ST models
load("ST_TypeI_ICAR_global.Rdata")
load("ST_TypeII_ICAR_global.Rdata")
load("ST_TypeIII_ICAR_global.Rdata")
load("ST_TypeIV_ICAR_global.Rdata")
MODELS.INLA <- list(TypeI.ICAR, TypeII.ICAR, TypeIII.ICAR, TypeIV.ICAR)
rm(TypeI.ICAR, TypeII.ICAR, TypeIII.ICAR, TypeIV.ICAR)
###########################################
# Table C1: goodness of fit of the models #
###########################################
fun.DIC.WAIC <- function(x){
data.frame(mean.deviance=x$dic$mean.deviance, ## posterior mean deviance
pD=x$dic$p.eff, ## effective number of parameters
DIC=x$dic$dic, ## Deviance Information Criterion
WAIC=x$waic$waic)} ## Watanabe-Akaike information criterion
Table.bigDM <- do.call(rbind,lapply(MODELS.bigDM, fun.DIC.WAIC))
rownames(Table.bigDM) <- c("TypeI ICAR", "TypeII ICAR", "TypeIII ICAR", "TypeIV ICAR")
Table.INLA <- do.call(rbind,lapply(MODELS.INLA, fun.DIC.WAIC))
rownames(Table.INLA) <- c("TypeI ICAR", "TypeII ICAR", "TypeIII ICAR", "TypeIV ICAR")
Tab <- rbind(Table.bigDM, Table.INLA)
Tab <- round(Tab, 4)
Tab[, 3] <- Tab[, 3]-min(Tab[, 3])
Tab[, 4] <- Tab[, 4]-min(Tab[, 4])
Tab.final <- cbind(Tab[1:4, ], Tab[5:8, ])
print(Tab.final)