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, "pre-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...Starting the sampler...Starting the sampler..."
#> [2] ""
#> [3] ""
#> [4] "Starting the sampler..."
#> [5] ""
#> [6] ""
#> [7] ""
#> [8] "| | | 0% | 232.06min | 0% 232.06min | 0% 232.06min"
#> [9] "| | 0% 230.81min"
#> [10] ""
#> [11] "|* | 5% 211.60min 11.14min"
#> [12] "|* | 5% 211.60min 11.14min|* | 5% 211.54min 11.13min"
#> [13] "|* | 5% 211.60min 11.14min"
#> [14] ""
#> [15] "|** | 10% 199.86min 22.21min|** | 10% 199.89min 22.21min"
#> [16] ""
#> [17] "|** | 10% 199.89min 22.21min|** | 10% 199.89min 22.21min"
#> [18] "|*** | 15% 188.52min 33.27min"
#> [19] "|*** | 15% 188.52min 33.27min"
#> [20] "|*** | 15% 188.51min 33.27min"
#> [21] "|*** | 15% 188.56min 33.28min"
#> [22] "|**** | 20% 177.64min 44.41min"
#> [23] ""
#> [24] "|**** | 20% 177.64min 44.41min|**** | 20% 177.63min 44.41min"
#> [25] "|**** | 20% 177.67min 44.42min"
#> [26] ""
#> [27] "|***** | 25%|***** | 25% 166.70min166.69min 55.57min55.56min"
#> [28] "|***** | 25% 166.70min 55.57min"
#> [29] "|***** | 25% 166.72min 55.57min"
#> [30] ""
#> [31] "|****** | 30%|****** | 30% 155.65min155.65min 66.71min66.71min"
#> [32] "|****** | 30% 155.66min 66.71min"
#> [33] "|****** | 30% 155.67min 66.72min"
#> [34] ""
#> [35] "|******* | 35%|******* | 35% 144.74min144.75min 77.94min77.94min"
#> [36] "|******* | 35% 144.75min 77.94min"
#> [37] "|******* | 35% 144.78min 77.96min"
#> [38] ""
#> [39] ""
#> [40] "|******** | 40% 133.78min 89.19min|******** | 40% 133.78min 89.19min|******** | 40% 133.78min 89.18min"
#> [41] "|******** | 40% 133.80min 89.20min"
#> [42] ""
#> [43] ""
#> [44] "|********* | 45% 122.76min 100.44min|********* | 45% 122.76min 100.44min|********* | 45% 122.76min 100.44min"
#> [45] "|********* | 45% 122.78min 100.46min"
#> [46] "|********** | 50% 111.68min 111.68min"
#> [47] ""
#> [48] "|********** | 50% 111.68min 111.68min|********** | 50% 111.68min 111.68min"
#> [49] "|********** | 50% 111.70min 111.70min"
#> [50] "|*********** | 55% 100.82min 123.22min"
#> [51] "|*********** | 55% 100.82min 123.23min"
#> [52] "|*********** | 55% 100.89min 123.31min"
#> [53] "|*********** | 55% 100.91min 123.34min"
#> [54] "|************ | 60% 89.79min 134.69min"
#> [55] "|************ | 60% 89.80min 134.70min"
#> [56] "|************ | 60% 89.86min 134.78min"
#> [57] "|************ | 60% 89.87min 134.81min"
#> [58] "|************* | 65% 78.69min 146.14min"
#> [59] "|************* | 65% 78.69min 146.15min"
#> [60] "|************* | 65% 78.74min 146.23min"
#> [61] "|************* | 65% 78.75min 146.26min"
#> [62] "|************** | 70% 67.52min 157.55min"
#> [63] "|************** | 70% 67.53min 157.56min"
#> [64] "|************** | 70% 67.56min 157.64min"
#> [65] "|************** | 70% 67.57min 157.67min"
#> [66] "|*************** | 75% 56.34min 169.03min"
#> [67] "|*************** | 75% 56.35min 169.04min"
#> [68] "|*************** | 75% 56.37min 169.12min"
#> [69] "|*************** | 75% 56.38min 169.15min"
#> [70] "|**************** | 80% 45.13min 180.54min"
#> [71] "|**************** | 80% 45.14min 180.55min"
#> [72] "|**************** | 80% 45.16min 180.62min"
#> [73] "|**************** | 80% 45.16min 180.65min"
#> [74] ""
#> [75] "|***************** | 85% 33.85min 191.84min|***************** | 85% 33.85min 191.84min"
#> [76] "|***************** | 85% 33.87min 191.90min"
#> [77] "|***************** | 85% 33.87min 191.95min"
#> [78] "|****************** | 90% 22.56min 203.01min"
#> [79] "|****************** | 90% 22.56min 203.01min"
#> [80] "|****************** | 90% 22.56min 203.08min"
#> [81] "|****************** | 90% 22.57min 203.13min"
#> [82] "|******************* | 95% 11.29min 214.46min"
#> [83] "|******************* | 95% 11.29min 214.47min"
#> [84] "|******************* | 95% 11.29min 214.54min"
#> [85] "|******************* | 95% 11.29min 214.59min"
#> [86] "|********************| 100% 0.00sec 225.94min"
#> [87] ""
#> [88] "|********************| 100% 0.00sec 225.95min"
#> [89] ""
#> [90] "|********************| 100% 0.00sec 226.00min"
#> [91] ""
#> [92] "|********************| 100% 0.00sec 226.03min"
system.time(saveRDS(bamlss_model, file = path_modelled_continue))
#> user system elapsed
#> 5.246 0.015 5.282
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 54423.831 18.753 13663.496