Full model: continue mcmc
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", "43-mcmc-continue-light.R"))
source(file.path(path_proj, "src", "45-mcmc-reshape.R"))
source(file.path(path_proj, "src", "46-mcmc-last-sample.R"))
bwdata_model <- fst::read_fst(file.path(path_processed, "bwdata_41_model.fst"))
path_modelled_data <- file.path(path_modelled, "lbw-10-full-re.rds")
path_modelled_form <- gsub("(\\.rds)$", "-form\\1", path_modelled_data)
path_modelled_continue <- gsub("(\\.rds)$", "-continue\\1", path_modelled_data)
path_modelled_sink <- gsub("\\.rds$", "\\.txt", path_modelled_continue)
bamlss_model <- readRDS(path_modelled_data)
form <- readRDS(path_modelled_form)
Continue with sampling
starting_value <- last_sample(bamlss_model)
{
sink(path_modelled_sink)
bamlss_model <- bamlss(
form, family = "binomial", data = bwdata_model,
start = starting_value, optimizer = FALSE,
n.iter = 4000, burnin = 0, cores = 4, combine = FALSE, light = TRUE
)
sink()
}
readLines(path_modelled_sink)
#> [1] "Starting the sampler..."
#> [2] "Starting the sampler..."
#> [3] "Starting the sampler..."
#> [4] "Starting the sampler..."
#> [5] ""
#> [6] "| | 0% 577.51min"
#> [7] "| | 0% 626.74min"
#> [8] "| | 0% 611.40min"
#> [9] "| | 0% 629.89min"
#> [10] "|* | 5% 467.09min 24.58min"
#> [11] "|* | 5% 468.31min 24.65min"
#> [12] "|* | 5% 471.00min 24.79min"
#> [13] "|* | 5% 470.62min 24.77min"
#> [14] "|** | 10% 429.67min 47.74min"
#> [15] "|** | 10% 430.17min 47.80min"
#> [16] "|** | 10% 431.08min 47.90min"
#> [17] "|** | 10% 431.67min 47.96min"
#> [18] "|*** | 15% 401.34min 70.82min"
#> [19] "|*** | 15% 401.85min 70.92min"
#> [20] "|*** | 15% 402.67min 71.06min"
#> [21] "|*** | 15% 403.18min 71.15min"
#> [22] "|**** | 20% 375.64min 93.91min"
#> [23] "|**** | 20% 376.14min 94.04min"
#> [24] "|**** | 20% 376.85min 94.21min"
#> [25] "|**** | 20% 377.38min 94.35min"
#> [26] "|***** | 25% 351.05min 117.02min"
#> [27] "|***** | 25% 351.48min 117.16min"
#> [28] "|***** | 25% 352.06min 117.35min"
#> [29] "|***** | 25% 352.62min 117.54min"
#> [30] "|****** | 30% 327.12min 140.19min"
#> [31] "|****** | 30% 327.46min 140.34min"
#> [32] "|****** | 30% 327.72min 140.45min"
#> [33] "|****** | 30% 328.25min 140.68min"
#> [34] "|******* | 35% 303.57min 163.46min"
#> [35] "|******* | 35% 303.93min 163.66min"
#> [36] "|******* | 35% 304.16min 163.78min"
#> [37] "|******* | 35% 304.61min 164.02min"
#> [38] "|******** | 40% 279.84min 186.56min"
#> [39] "|******** | 40% 280.26min 186.84min"
#> [40] "|******** | 40% 280.36min 186.91min"
#> [41] "|******** | 40% 280.75min 187.17min"
#> [42] "|********* | 45% 256.27min 209.68min"
#> [43] "|********* | 45% 256.61min 209.95min"
#> [44] "|********* | 45% 256.79min 210.10min"
#> [45] "|********* | 45% 257.06min 210.32min"
#> [46] "|********** | 50% 232.80min 232.80min"
#> [47] "|********** | 50% 233.07min 233.07min"
#> [48] "|********** | 50% 233.29min 233.29min"
#> [49] "|********** | 50% 233.46min 233.46min"
#> [50] "|*********** | 55% 209.39min 255.92min"
#> [51] "|*********** | 55% 209.61min 256.19min"
#> [52] "|*********** | 55% 209.84min 256.48min"
#> [53] "|*********** | 55% 209.92min 256.57min"
#> [54] "|************ | 60% 186.05min 279.07min"
#> [55] "|************ | 60% 186.21min 279.31min"
#> [56] "|************ | 60% 186.42min 279.64min"
#> [57] "|************ | 60% 186.43min 279.65min"
#> [58] "|************* | 65% 162.70min 302.15min"
#> [59] "|************* | 65% 162.87min 302.48min"
#> [60] "|************* | 65% 163.06min 302.83min"
#> [61] "|************* | 65% 163.02min 302.75min"
#> [62] "|************** | 70% 139.41min 325.29min"
#> [63] "|************** | 70% 139.55min 325.62min"
#> [64] "|************** | 70% 139.65min 325.85min"
#> [65] "|************** | 70% 139.72min 326.00min"
#> [66] "|*************** | 75% 116.15min 348.46min"
#> [67] "|*************** | 75% 116.28min 348.83min"
#> [68] "|*************** | 75% 116.32min 348.97min"
#> [69] "|*************** | 75% 116.36min 349.08min"
#> [70] "|**************** | 80% 92.91min 371.65min"
#> [71] "|**************** | 80% 93.01min 372.05min"
#> [72] "|**************** | 80% 93.04min 372.14min"
#> [73] "|**************** | 80% 93.02min 372.07min"
#> [74] "|***************** | 85% 69.68min 394.83min"
#> [75] "|***************** | 85% 69.74min 395.21min"
#> [76] "|***************** | 85% 69.74min 395.20min"
#> [77] "|***************** | 85% 69.75min 395.27min"
#> [78] "|****************** | 90% 46.44min 418.00min"
#> [79] "|****************** | 90% 46.48min 418.28min"
#> [80] "|****************** | 90% 46.48min 418.31min"
#> [81] "|****************** | 90% 46.50min 418.49min"
#> [82] "|******************* | 95% 23.22min 441.17min"
#> [83] "|******************* | 95% 23.23min 441.35min"
#> [84] "|******************* | 95% 23.23min 441.41min"
#> [85] "|******************* | 95% 23.25min 441.70min"
#> [86] "|********************| 100% 0.00sec 464.36min"
#> [87] ""
#> [88] "|********************| 100% 0.00sec 464.42min"
#> [89] ""
#> [90] "|********************| 100% 0.00sec 464.53min"
#> [91] ""
#> [92] "|********************| 100% 0.00sec 464.90min"
system.time(saveRDS(bamlss_model, file = path_modelled_continue))
#> user system elapsed
#> 26.030 0.124 26.157
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 112142.811 65.764 28291.466