Growth model with t-distribution: 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, "bw-20-growth-re-t.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 = TF, data = bwdata_model,
start = starting_value, optimizer = FALSE,
n.iter = 4000, burnin = 0, cores = 3, combine = FALSE, light = TRUE
)
sink()
}
readLines(path_modelled_sink)
#> [1] "Starting the sampler..."
#> [2] "Starting the sampler...Starting the sampler..."
#> [3] ""
#> [4] ""
#> [5] "| | 0% 613.16min"
#> [6] "| | 0% 619.33min"
#> [7] "| | 0% 619.41min"
#> [8] "|* | 5% 557.10min 29.32min"
#> [9] "|* | 5% 557.61min 29.35min"
#> [10] "|* | 5% 557.61min 29.35min"
#> [11] "|** | 10% 519.84min 57.76min"
#> [12] "|** | 10% 520.45min 57.83min"
#> [13] "|** | 10% 521.07min 57.90min"
#> [14] "|*** | 15% 487.50min 86.03min"
#> [15] "|*** | 15% 487.94min 86.11min"
#> [16] "|*** | 15% 488.26min 86.16min"
#> [17] "|**** | 20% 456.96min 114.24min"
#> [18] "|**** | 20% 457.37min 114.34min"
#> [19] "|**** | 20% 457.45min 114.36min"
#> [20] "|***** | 25% 428.19min 142.73min"
#> [21] "|***** | 25% 428.91min 142.97min"
#> [22] "|***** | 25% 428.92min 142.97min"
#> [23] "|****** | 30% 400.04min 171.45min"
#> [24] "|****** | 30% 400.63min 171.70min"
#> [25] "|****** | 30% 400.76min 171.75min"
#> [26] "|******* | 35% 371.09min 199.82min"
#> [27] "|******* | 35% 371.53min 200.06min"
#> [28] "|******* | 35% 371.75min 200.17min"
#> [29] "|******** | 40% 342.56min 228.37min"
#> [30] "|******** | 40% 342.93min 228.62min"
#> [31] "|******** | 40% 343.12min 228.74min"
#> [32] "|********* | 45% 313.73min 256.69min"
#> [33] "|********* | 45% 314.04min 256.94min"
#> [34] "|********* | 45% 314.19min 257.06min"
#> [35] "|********** | 50% 284.90min 284.90min"
#> [36] "|********** | 50% 285.15min 285.15min"
#> [37] "|********** | 50% 285.27min 285.27min"
#> [38] "|*********** | 55% 256.23min 313.17min"
#> [39] "|*********** | 55% 256.45min 313.44min"
#> [40] "|*********** | 55% 256.51min 313.52min"
#> [41] "|************ | 60% 227.57min 341.35min"
#> [42] "|************ | 60% 227.75min 341.63min"
#> [43] "|************ | 60% 227.81min 341.72min"
#> [44] "|************* | 65% 199.16min 369.87min"
#> [45] "|************* | 65% 199.29min 370.11min"
#> [46] "|************* | 65% 199.32min 370.16min"
#> [47] "|************** | 70% 171.11min 399.25min"
#> [48] "|************** | 70% 171.26min 399.60min"
#> [49] "|************** | 70% 171.38min 399.89min"
#> [50] "|*************** | 75% 142.77min 428.30min"
#> [51] "|*************** | 75% 143.02min 429.05min"
#> [52] "|*************** | 75% 143.11min 429.32min"
#> [53] "|**************** | 80% 114.35min 457.39min"
#> [54] "|**************** | 80% 114.50min 457.99min"
#> [55] "|**************** | 80% 114.52min 458.08min"
#> [56] "|***************** | 85% 85.73min 485.81min"
#> [57] "|***************** | 85% 85.83min 486.36min"
#> [58] "|***************** | 85% 85.84min 486.44min"
#> [59] "|****************** | 90% 57.14min 514.29min"
#> [60] "|****************** | 90% 57.20min 514.84min"
#> [61] "|****************** | 90% 57.21min 514.93min"
#> [62] "|******************* | 95% 28.56min 542.56min"
#> [63] "|******************* | 95% 28.58min 543.11min"
#> [64] "|******************* | 95% 28.59min 543.19min"
#> [65] "|********************| 100% 0.00sec 570.75min"
#> [66] ""
#> [67] "|********************| 100% 0.00sec 571.22min"
#> [68] ""
#> [69] "|********************| 100% 0.00sec 571.30min"
system.time(saveRDS(bamlss_model, file = path_modelled_continue))
#> user system elapsed
#> 9.523 0.038 9.607
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 103003.346 20.949 34402.574