Only covariates: 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_41_model.fst")
model_file <- file.path(path_modelled, "bw-muni-00-covs.rds")
form_file <- gsub("(\\.rds)$", "-form\\1", model_file)
# model_file_burned <- gsub("(\\.rds)$", "-burned\\1", model_file)
model_file_burned <- 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 ~ s(remoteness) + s(prop_tap_toilet)
#> -
#> Parametric coefficients:
#>             Mean 2.5%  50% 97.5% parameters
#> (Intercept) 3219 3218 3219  3221       3219
#> -
#> Acceptance probabilty:
#>         Mean   2.5%    50% 97.5%
#> alpha 0.9983 0.9918 0.9999     1
#> -
#> Smooth terms:
#>                               Mean      2.5%       50%     97.5% parameters
#> s(remoteness).tau21      7.115e+04 2.196e+04 5.726e+04 1.938e+05  7.960e+04
#> s(remoteness).alpha      1.000e+00 1.000e+00 1.000e+00 1.000e+00         NA
#> s(remoteness).edf        8.690e+00 8.342e+00 8.712e+00 8.909e+00  8.787e+00
#> s(prop_tap_toilet).tau21 7.417e+05 2.390e+05 6.022e+05 2.031e+06  1.375e+06
#> s(prop_tap_toilet).alpha 1.000e+00 1.000e+00 1.000e+00 1.000e+00         NA
#> s(prop_tap_toilet).edf   8.927e+00 8.837e+00 8.933e+00 8.980e+00  8.970e+00
#> ---
#> Formula sigma:
#> ---
#> sigma ~ 1
#> -
#> Parametric coefficients:
#>              Mean  2.5%   50% 97.5% parameters
#> (Intercept) 6.227 6.225 6.227 6.230      6.227
#> -
#> Acceptance probabilty:
#>         Mean   2.5%    50% 97.5%
#> alpha 0.9992 0.9936 1.0000     1
#> ---
#> Sampler summary:
#> -
#> runtime = 648.732
#> ---
#> Optimizer summary:
#> -
#> AICc = 4457417 edf = 19.7571 logLik = -2228689
#> logPost = -2228859 nobs = 291479 runtime = 22.54

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 
#>   2.826   0.122   2.965