SPIFA Urban Ipixuna: DIC


Visualise and summarise the resulst of CIFA models.

Load required libraries and data

rm(list = ls())
library(day2day)
library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(mirt)
#> Loading required package: stats4
#> Loading required package: lattice
library(spifa)
library(tidyr)
library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.1, PROJ 8.2.1; sf_use_s2() is TRUE
library(purrr)
library(ggplot2)

path_main <- git_path()
path_data <- file.path(path_main, "data")
path_raw <- file.path(path_data, "raw")
path_processed <- file.path(path_data, "processed")
path_modelled <- file.path(path_data, "modelled")

fidata <- file.path(path_processed, "fi-items-ipixuna-urban.gpkg") |>
    st_read(as_tibble = TRUE)
#> Reading layer `fi-items-ipixuna-urban' from data source 
#>   `/home/rstudio/documents/projects/food-insecurity-mapping/data/processed/fi-items-ipixuna-urban.gpkg' 
#>   using driver `GPKG'
#> Simple feature collection with 200 features and 36 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -71.70038 ymin: -7.06058 xmax: -71.68109 ymax: -7.03724
#> Geodetic CRS:  WGS 84
samples1 <- readRDS(file.path(path_modelled, "spifa-ipixuna-urban-1gp.rds"))
samples2 <- readRDS(file.path(path_modelled, "spifa-ipixuna-urban-2gp.rds"))
samples3 <- readRDS(file.path(path_modelled, "spifa-ipixuna-urban-3gp.rds"))
iter <- nrow(samples1[["theta"]])

DIC computation

dic(as_tibble(samples1, burnin = 1 * iter/5))
#> $average_of_deviance
#> [1] 1866.667
#> 
#> $n_effec_params
#> [1] 335.1415
#> 
#> $dic
#> [1] 2201.808
dic(as_tibble(samples2, burnin = 1 * iter/5))
#> $average_of_deviance
#> [1] 1861.217
#> 
#> $n_effec_params
#> [1] 338.6363
#> 
#> $dic
#> [1] 2199.853
dic(as_tibble(samples3, burnin = 1 * iter/5))
#> $average_of_deviance
#> [1] 1857.537
#> 
#> $n_effec_params
#> [1] 341.2626
#> 
#> $dic
#> [1] 2198.799

Time to execute the task

Only useful when executed with Rscript.

proc.time()
#>    user  system elapsed 
#>  15.957   2.736  58.882