Discrete: effects
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")
bwdata_file <- file.path(path_processed, "bwdata_51_test.fst")
model_file <- file.path(path_modelled, "bw-06-discrete.rds")
form_file <- gsub("(\\.rds)$", "-form\\1", model_file)
model_file_burned <- gsub("(\\.rds)$", "-burned\\1", model_file)
bwdata_model <- fst::read_fst(bwdata_file)
form <- readRDS(form_file)
model <- readRDS(model_file_burned)
Compute results
model$results <- results.bamlss.default(model)
Fixed effects
summary(model)
#>
#> Call:
#> bamlss(formula = form, data = bwdata_model, cores = 4, combine = FALSE,
#> light = TRUE, n.iter = 1000, burnin = 0)
#> ---
#> Family: gaussian
#> Link function: mu = identity, sigma = log
#> *---
#> Formula mu:
#> ---
#> born_weight ~ marital_status + race + s(municipality, bs = "re") +
#> s(age_bin)
#> -
#> Parametric coefficients:
#> Mean 2.5% 50% 97.5% parameters
#> (Intercept) 2829.028 2822.322 2828.970 2836.003 2829.10
#> marital_status2 -13.086 -20.022 -13.018 -6.418 -13.19
#> marital_status3 -136.823 -143.495 -136.853 -130.141 -136.86
#> race2 14.634 6.811 14.601 22.493 14.65
#> race3 35.453 27.658 35.451 43.362 35.49
#> race4 57.400 49.460 57.426 65.236 57.45
#> -
#> Acceptance probabilty:
#> Mean 2.5% 50% 97.5%
#> alpha 0.9944 0.9718 1.0000 1
#> -
#> Smooth terms:
#> Mean 2.5% 50% 97.5% parameters
#> s(municipality).tau21 4.157e+04 2.630e+04 4.015e+04 6.559e+04 3.744e+04
#> s(municipality).alpha 1.000e+00 1.000e+00 1.000e+00 1.000e+00 NA
#> s(municipality).edf 3.992e+01 3.988e+01 3.992e+01 3.995e+01 3.991e+01
#> s(age_bin).tau21 1.163e+06 3.741e+05 9.549e+05 3.307e+06 6.165e+05
#> s(age_bin).alpha 1.000e+00 1.000e+00 1.000e+00 1.000e+00 NA
#> s(age_bin).edf 8.313e+00 7.755e+00 8.335e+00 8.764e+00 8.093e+00
#> ---
#> Formula sigma:
#> ---
#> sigma ~ 1
#> -
#> Parametric coefficients:
#> Mean 2.5% 50% 97.5% parameters
#> (Intercept) 5.295 5.286 5.295 5.305 5.294
#> -
#> Acceptance probabilty:
#> Mean 2.5% 50% 97.5%
#> alpha 0.9975 0.9794 1.0000 1
#> ---
#> Sampler summary:
#> -
#> runtime = 64.438
#> ---
#> Optimizer summary:
#> -
#> AICc = 268628.3 edf = 55.008 logLik = -134259
#> logPost = -134649.2 nobs = 20000 runtime = 1.812
Smoothed effects
There seems to be a problem with the labels of the random effects plot.
par(mar = c(4, 4, 0.5, 0), mfrow = c(1, 2), cex.axis = 0.7)
plot(model, scale = 0, scheme = 2, spar = FALSE)
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 10.228 0.116 10.366