Full model with smoother prior: rectify samples


Load packages, read data and source custom scripts

rm(list = ls())
library(bamlss)
#> Loading required package: coda
#> Loading required package: colorspace
#> Loading required package: mgcv
#> Loading required package: nlme
#> This is mgcv 1.8-31. For overview type 'help("mgcv-package")'.
#> 
#> Attaching package: 'bamlss'
#> The following object is masked from 'package:mgcv':
#> 
#>     smooth.construct
library(gamlss.dist)
#> Loading required package: MASS
path_proj <- day2day::git_path()
path_data <- file.path(path_proj, "data")
path_processed <- file.path(path_data, "processed")
path_modelled <- file.path(path_data, "modelled")

source(file.path(path_proj, "src", "41-mcmc-rectify-re.R"))

path_modelled_data <- file.path(path_modelled, "lbw-12-full-re-p2.rds")
path_modelled_rectified <- gsub("(\\.rds)$", "-rectified\\1", path_modelled_data)

model <- readRDS(path_modelled_data)

Rectify mcmc samples and save

model$samples <- rectify_re_list(model$samples, "res_muni", "pi")

system.time(saveRDS(model, file = path_modelled_rectified))
#>    user  system elapsed 
#>   7.470   0.080   7.617

Maximum auto-correlation function (ACF)

par(mar = c(4, 4, 0.5, 0), mfrow = c(1, 2))
plot(model, model = "pi", which = "max-acf", spar = FALSE)
Maximum ACF of samples for $\pi$

Figure 1: Maximum ACF of samples for \(\pi\)

MCMC convergence

par(mar = c(4, 4, 3, 1), mfrow = c(1, 2))
plot(model, which = "samples")

Time to execute the task

Only useful when executed with Rscript.

proc.time()
#>    user  system elapsed 
#> 280.085   0.768 283.331