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-get-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_continue2 <- gsub("(\\.rds)$", "-continue2\\1", path_modelled_data)
path_modelled_sink <- gsub("\\.rds$", "\\.txt", path_modelled_continue2)
bamlss_model_continue <- readRDS(path_modelled_continue)
form <- readRDS(path_modelled_form)
Continue with sampling
starting_value <- get_last_sample(bamlss_model_continue)
{
sink(path_modelled_sink)
bamlss_model <- bamlss(
form, family = TF, data = bwdata_model,
start = starting_value, optimizer = FALSE,
n.iter = 5000, burnin = 0, cores = 3, combine = FALSE, light = TRUE
)
sink()
}
readLines(path_modelled_sink)
#> [1] "Starting the sampler..."
#> [2] "Starting the sampler..."
#> [3] "Starting the sampler..."
#> [4] ""
#> [5] "| | 0% 778.35min"
#> [6] "| | 0% 779.69min"
#> [7] "| | 0% 779.74min"
#> [8] "|* | 5% 680.38min 35.81min"
#> [9] "|* | 5% 680.77min 35.83min"
#> [10] "|* | 5% 681.37min 35.86min"
#> [11] "|** | 10% 637.82min 70.87min"
#> [12] "|** | 10% 637.95min 70.88min"
#> [13] "|** | 10% 638.59min 70.95min"
#> [14] "|*** | 15% 599.90min 105.86min"
#> [15] "|*** | 15% 599.91min 105.87min"
#> [16] "|*** | 15% 600.35min 105.94min"
#> [17] "|**** | 20% 564.03min 141.01min"
#> [18] "|**** | 20% 564.08min 141.02min"
#> [19] "|**** | 20% 564.38min 141.10min"
#> [20] "|***** | 25% 528.68min 176.23min"
#> [21] "|***** | 25% 528.72min 176.24min"
#> [22] "|***** | 25% 528.96min 176.32min"
#> [23] "|****** | 30% 493.26min 211.40min"
#> [24] "|****** | 30% 493.29min 211.41min"
#> [25] "|****** | 30% 493.48min 211.49min"
#> [26] "|******* | 35% 457.82min 246.52min"
#> [27] "|******* | 35% 457.87min 246.54min"
#> [28] "|******* | 35% 457.99min 246.61min"
#> [29] "|******** | 40% 422.37min 281.58min"
#> [30] "|******** | 40% 422.42min 281.61min"
#> [31] "|******** | 40% 422.51min 281.67min"
#> [32] "|********* | 45% 386.74min 316.43min"
#> [33] "|********* | 45% 386.79min 316.47min"
#> [34] "|********* | 45% 386.85min 316.52min"
#> [35] "|********** | 50% 351.36min 351.36min"
#> [36] "|********** | 50% 351.40min 351.40min"
#> [37] "|********** | 50% 351.45min 351.45min"
#> [38] "|*********** | 55% 316.09min 386.33min"
#> [39] "|*********** | 55% 316.13min 386.38min"
#> [40] "|*********** | 55% 316.15min 386.40min"
#> [41] "|************ | 60% 281.21min 421.82min"
#> [42] "|************ | 60% 281.22min 421.83min"
#> [43] "|************ | 60% 281.31min 421.96min"
#> [44] "|************* | 65% 246.42min 457.64min"
#> [45] "|************* | 65% 246.50min 457.79min"
#> [46] "|************* | 65% 246.59min 457.94min"
#> [47] "|************** | 70% 211.26min 492.94min"
#> [48] "|************** | 70% 211.33min 493.11min"
#> [49] "|************** | 70% 211.33min 493.11min"
#> [50] "|*************** | 75% 175.98min 527.94min"
#> [51] "|*************** | 75% 176.03min 528.10min"
#> [52] "|*************** | 75% 176.04min 528.11min"
#> [53] "|**************** | 80% 140.73min 562.91min"
#> [54] "|**************** | 80% 140.77min 563.07min"
#> [55] "|**************** | 80% 140.77min 563.09min"
#> [56] "|***************** | 85% 105.52min 597.96min"
#> [57] "|***************** | 85% 105.55min 598.11min"
#> [58] "|***************** | 85% 105.55min 598.14min"
#> [59] "|****************** | 90% 70.43min 633.84min"
#> [60] ""
#> [61] "|****************** | 90% 70.46min 634.17min|****************** | 90% 70.46min 634.16min"
#> [62] "|******************* | 95% 35.28min 670.24min"
#> [63] "|******************* | 95% 35.29min 670.57min"
#> [64] "|******************* | 95% 35.31min 670.81min"
#> [65] "|********************| 100% 0.00sec 705.43min"
#> [66] ""
#> [67] "|********************| 100% 0.00sec 705.74min"
#> [68] ""
#> [69] "|********************| 100% 0.00sec 705.93min"
system.time(saveRDS(bamlss_model, file = path_modelled_continue2))
#> user system elapsed
#> 11.436 0.080 11.789
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 127232.108 31.233 42490.239