With intercept: 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-00-inter.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)
#> -
#> Parametric coefficients:
#> Mean 2.5% 50% 97.5% parameters
#> (Intercept) 2828.795 2822.061 2828.769 2835.629 2828.94
#> marital_status2 -13.222 -20.007 -13.207 -6.543 -13.21
#> marital_status3 -136.790 -143.336 -136.736 -130.230 -136.83
#> race2 14.932 7.405 14.913 22.628 14.93
#> race3 35.948 28.131 35.986 43.666 35.87
#> race4 57.447 49.723 57.440 65.340 57.43
#> -
#> Acceptance probabilty:
#> Mean 2.5% 50% 97.5%
#> alpha 0.9946 0.9741 0.9998 1
#> -
#> Smooth terms:
#> Mean 2.5% 50% 97.5% parameters
#> s(municipality).tau21 4.079e+04 2.611e+04 3.940e+04 6.276e+04 3.745e+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).tau21 7.493e+05 2.403e+05 6.071e+05 2.174e+06 2.286e+05
#> s(age).alpha 1.000e+00 1.000e+00 1.000e+00 1.000e+00 NA
#> s(age).edf 8.613e+00 8.208e+00 8.640e+00 8.892e+00 8.181e+00
#> ---
#> Formula sigma:
#> ---
#> sigma ~ 1
#> -
#> Parametric coefficients:
#> Mean 2.5% 50% 97.5% parameters
#> (Intercept) 5.295 5.285 5.295 5.304 5.293
#> -
#> Acceptance probabilty:
#> Mean 2.5% 50% 97.5%
#> alpha 0.9973 0.9763 1.0000 1
#> ---
#> Sampler summary:
#> -
#> runtime = 62.596
#> ---
#> Optimizer summary:
#> -
#> AICc = 268602.2 edf = 55.096 logLik = -134245.9
#> logPost = -134634.7 nobs = 20000 runtime = 1.688
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.975 0.107 11.150