Without intercept: fitting
Load packages, read data and source custom scripts
Paths are defined relative to the git repository location.
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")
path_modelled_data <- file.path(path_modelled, "bw-02-nointer.rds")
path_modelled_sink <- gsub("\\.rds$", "\\.txt", path_modelled_data)
path_modelled_form <- gsub("(\\.rds)$", "-form\\1", path_modelled_data)
bwdata_model <- fst::read_fst(file.path(path_processed, "bwdata_51_test.fst"))
Define formula for our model
form_mu <- born_weight ~ 0 +
marital_status2 + marital_status3 +
race2 + race3 + race4 +
s(municipality, bs = "re") +
s(age)
form <- form_mu
Run the model of interest and save results
{
sink(path_modelled_sink)
bamlss_model <- bamlss(
form, data = bwdata_model,
n.iter = 1000, burnin = 0, cores = 4, combine = FALSE, light = TRUE
)
sink()
}
readLines(path_modelled_sink)
#> [1] "AICc 455722.5 logPost -229986. logLik -227854. edf 7.1512 eps 3.3642 iteration 1"
#> [2] "AICc 435783.9 logPost -217905. logLik -217885. edf 6.3785 eps 0.1855 iteration 2"
#> [3] "AICc 415953.1 logPost -207937. logLik -207970. edf 6.4159 eps 0.0312 iteration 3"
#> [4] "AICc 396405.0 logPost -198118. logLik -198195. edf 6.7845 eps 0.0591 iteration 4"
#> [5] "AICc 377605.8 logPost -188864. logLik -188796. edf 6.9204 eps 0.0393 iteration 5"
#> [6] "AICc 360679.6 logPost -180451. logLik -180332. edf 6.9793 eps 0.0418 iteration 6"
#> [7] "AICc 347826.0 logPost -174075. logLik -173905. edf 7.2284 eps 0.0325 iteration 7"
#> [8] "AICc 340747.0 logPost -170661. logLik -170361. edf 11.944 eps 0.1026 iteration 8"
#> [9] "AICc 334523.7 logPost -167806. logLik -167225. edf 36.253 eps 0.1295 iteration 9"
#> [10] "AICc 327817.5 logPost -164328. logLik -163862. edf 46.199 eps 0.0633 iteration 10"
#> [11] "AICc 320779.8 logPost -160828. logLik -160342. edf 47.703 eps 0.0464 iteration 11"
#> [12] "AICc 314008.7 logPost -157424. logLik -156954. edf 49.674 eps 0.0383 iteration 12"
#> [13] "AICc 307664.1 logPost -154246. logLik -153779. edf 51.977 eps 0.0313 iteration 13"
#> [14] "AICc 301651.8 logPost -151245. logLik -150773. edf 52.267 eps 0.0270 iteration 14"
#> [15] "AICc 296041.1 logPost -148443. logLik -147967. edf 52.554 eps 0.0235 iteration 15"
#> [16] "AICc 290920.3 logPost -145885. logLik -145407. edf 52.834 eps 0.0206 iteration 16"
#> [17] "AICc 286369.7 logPost -143611. logLik -143131. edf 53.099 eps 0.0179 iteration 17"
#> [18] "AICc 282445.5 logPost -141651. logLik -141169. edf 53.338 eps 0.0153 iteration 18"
#> [19] "AICc 279167.9 logPost -140013. logLik -139530. edf 53.541 eps 0.0128 iteration 19"
#> [20] "AICc 276516.4 logPost -138688. logLik -138204. edf 53.706 eps 0.0105 iteration 20"
#> [21] "AICc 274434.4 logPost -137648. logLik -137163. edf 53.834 eps 0.0084 iteration 21"
#> [22] "AICc 272842.4 logPost -136853. logLik -136367. edf 53.930 eps 0.0067 iteration 22"
#> [23] "AICc 271651.8 logPost -136258. logLik -135771. edf 54.001 eps 0.0052 iteration 23"
#> [24] "AICc 270777.3 logPost -135821. logLik -135334. edf 54.052 eps 0.0040 iteration 24"
#> [25] "AICc 270143.8 logPost -135505. logLik -135017. edf 54.088 eps 0.0031 iteration 25"
#> [26] "AICc 269689.7 logPost -135278. logLik -134790. edf 54.114 eps 0.0024 iteration 26"
#> [27] "AICc 269366.7 logPost -135117. logLik -134629. edf 54.133 eps 0.0019 iteration 27"
#> [28] "AICc 269138.2 logPost -135003. logLik -134514. edf 54.146 eps 0.0015 iteration 28"
#> [29] "AICc 268977.2 logPost -134923. logLik -134434. edf 54.156 eps 0.0011 iteration 29"
#> [30] "AICc 268864.2 logPost -134866. logLik -134377. edf 54.163 eps 0.0009 iteration 30"
#> [31] "AICc 268784.9 logPost -134827. logLik -134338. edf 54.168 eps 0.0007 iteration 31"
#> [32] "AICc 268729.4 logPost -134799. logLik -134310. edf 54.171 eps 0.0005 iteration 32"
#> [33] "AICc 268690.5 logPost -134780. logLik -134290. edf 54.174 eps 0.0004 iteration 33"
#> [34] "AICc 268663.4 logPost -134766. logLik -134277. edf 54.176 eps 0.0003 iteration 34"
#> [35] "AICc 268644.4 logPost -134757. logLik -134267. edf 54.177 eps 0.0003 iteration 35"
#> [36] "AICc 268631.1 logPost -134750. logLik -134261. edf 54.178 eps 0.0002 iteration 36"
#> [37] "AICc 268621.9 logPost -134746. logLik -134256. edf 54.179 eps 0.0002 iteration 37"
#> [38] "AICc 268615.4 logPost -134742. logLik -134253. edf 54.179 eps 0.0001 iteration 38"
#> [39] "AICc 268610.8 logPost -134740. logLik -134251. edf 54.180 eps 0.0001 iteration 39"
#> [40] "AICc 268607.7 logPost -134739. logLik -134249. edf 54.180 eps 0.0001 iteration 40"
#> [41] "AICc 268607.7 logPost -134739. logLik -134249. edf 54.180 eps 0.0001 iteration 40"
#> [42] "elapsed time: 7.32sec"
#> [43] "Starting the sampler...Starting the sampler...Starting the sampler..."
#> [44] ""
#> [45] ""
#> [46] "Starting the sampler..."
#> [47] ""
#> [48] ""
#> [49] ""
#> [50] ""
#> [51] "|| | | 0% | 0% 1.12min 1.12min | 0% 1.12min| | 0% 1.13min"
#> [52] "|* | 5% 1.10min 3.49sec"
#> [53] ""
#> [54] ""
#> [55] "|* | 5%|* | 5%|* | 5% 1.12min 1.12min 1.12min 3.53sec 3.53sec 3.53sec"
#> [56] "|** | 10% 57.36sec 6.37sec"
#> [57] "|** | 10% 57.91sec 6.43sec"
#> [58] "|** | 10% 57.96sec 6.44sec"
#> [59] "|** | 10% 58.01sec 6.45sec"
#> [60] "|*** | 15% 52.31sec 9.23sec"
#> [61] "|*** | 15% 52.63sec 9.29sec"
#> [62] "|*** | 15% 52.64sec 9.29sec"
#> [63] "|*** | 15% 52.65sec 9.29sec"
#> [64] "|**** | 20% 49.67sec 12.42sec"
#> [65] ""
#> [66] "|**** | 20%|**** | 20% 49.92sec49.92sec 12.48sec12.48sec"
#> [67] "|**** | 20% 50.02sec 12.50sec"
#> [68] "|***** | 25% 45.83sec 15.28sec"
#> [69] ""
#> [70] "|***** | 25%|***** | 25% 46.00sec46.00sec 15.33sec15.33sec"
#> [71] "|***** | 25% 46.19sec 15.40sec"
#> [72] "|****** | 30% 42.99sec 18.42sec"
#> [73] "|****** | 30% 43.11sec 18.48sec"
#> [74] "|****** | 30% 43.12sec 18.48sec"
#> [75] "|****** | 30% 43.26sec 18.54sec"
#> [76] "|******* | 35% 39.54sec 21.29sec"
#> [77] "|******* | 35% 39.67sec 21.36sec"
#> [78] "|******* | 35% 39.68sec 21.37sec"
#> [79] "|******* | 35% 39.78sec 21.42sec"
#> [80] "|******** | 40% 36.25sec 24.17sec"
#> [81] "|******** | 40% 36.33sec 24.22sec"
#> [82] "|******** | 40% 36.35sec 24.24sec"
#> [83] "|******** | 40% 36.43sec 24.29sec"
#> [84] "|********* | 45% 33.40sec 27.33sec"
#> [85] "|********* | 45% 33.49sec 27.40sec"
#> [86] "|********* | 45% 33.52sec 27.43sec"
#> [87] "|********* | 45% 33.55sec 27.45sec"
#> [88] "|********** | 50% 30.20sec 30.20sec"
#> [89] "|********** | 50% 30.26sec 30.26sec"
#> [90] "|********** | 50% 30.30sec 30.30sec"
#> [91] "|********** | 50% 30.32sec 30.32sec"
#> [92] "|*********** | 55% 27.30sec 33.37sec"
#> [93] "|*********** | 55% 27.36sec 33.44sec"
#> [94] "|*********** | 55% 27.40sec 33.49sec"
#> [95] "|*********** | 55% 27.43sec 33.53sec"
#> [96] "|************ | 60% 24.17sec 36.25sec"
#> [97] "|************ | 60% 24.24sec 36.36sec"
#> [98] "|************ | 60% 24.24sec 36.37sec"
#> [99] "|************ | 60% 24.28sec 36.42sec"
#> [100] "|************* | 65% 21.18sec 39.34sec"
#> [101] "|************* | 65% 21.23sec 39.42sec"
#> [102] "|************* | 65% 21.29sec 39.54sec"
#> [103] "|************* | 65% 21.30sec 39.55sec"
#> [104] "|************** | 70% 18.17sec 42.40sec"
#> [105] "|************** | 70% 18.22sec 42.50sec"
#> [106] "|************** | 70% 18.22sec 42.51sec"
#> [107] "|************** | 70% 18.26sec 42.60sec"
#> [108] "|*************** | 75% 15.12sec 45.37sec"
#> [109] "|*************** | 75% 15.16sec 45.49sec"
#> [110] "|*************** | 75% 15.18sec 45.53sec"
#> [111] "|*************** | 75% 15.22sec 45.65sec"
#> [112] "|**************** | 80% 12.11sec 48.46sec"
#> [113] "|**************** | 80% 12.14sec 48.56sec"
#> [114] "|**************** | 80% 12.15sec 48.61sec"
#> [115] "|**************** | 80% 12.18sec 48.72sec"
#> [116] "|***************** | 85% 9.09sec 51.50sec"
#> [117] "|***************** | 85% 9.10sec 51.55sec"
#> [118] "|***************** | 85% 9.10sec 51.57sec"
#> [119] "|***************** | 85% 9.12sec 51.69sec"
#> [120] "|****************** | 90% 6.07sec 54.59sec"
#> [121] "|****************** | 90% 6.07sec 54.64sec"
#> [122] "|****************** | 90% 6.08sec 54.70sec"
#> [123] "|****************** | 90% 6.09sec 54.82sec"
#> [124] "|******************* | 95% 3.02sec 57.45sec"
#> [125] "|******************* | 95% 3.03sec 57.50sec"
#> [126] "|******************* | 95% 3.03sec 57.55sec"
#> [127] "|******************* | 95% 3.04sec 57.67sec"
#> [128] "|********************| 100% 0.00sec 1.01min"
#> [129] ""
#> [130] "|********************| 100% 0.00sec 1.01min"
#> [131] ""
#> [132] "|********************| 100% 0.00sec 1.01min"
#> [133] ""
#> [134] "|********************| 100% 0.00sec 1.01min"
system.time(saveRDS(bamlss_model, file = path_modelled_data))
#> user system elapsed
#> 0.333 0.000 0.334
saveRDS(form, file = path_modelled_form)
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 257.826 1.193 73.230