Parametric terms: 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")
source(file.path(path_proj, "src", "51-bamlss.R"))
bwdata_file <- file.path(path_processed, "bwdata_41_model.fst")
model_file <- file.path(path_modelled, "bw-muni-02-covs-param.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)
paramed 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 ~ poly(remoteness, 2) + poly(prop_tap_toilet, 2)
#> -
#> Parametric coefficients:
#> Mean 2.5% 50% 97.5% parameters
#> (Intercept) 3220 3218 3220 3221 3219
#> poly(remoteness, 2)1 -6024 -6984 -6049 -4729 -6573
#> poly(remoteness, 2)2 -4796 -5677 -4741 -4011 -5638
#> poly(prop_tap_toilet, 2)1 5192 3797 5298 6200 5870
#> poly(prop_tap_toilet, 2)2 -3256 -3936 -3280 -2395 -3811
#> -
#> Acceptance probabilty:
#> Mean 2.5% 50% 97.5%
#> alpha 2.098e-02 8.798e-12 9.910e-07 0.157
#> ---
#> Formula sigma:
#> ---
#> sigma ~ 1
#> -
#> Parametric coefficients:
#> Mean 2.5% 50% 97.5% parameters
#> (Intercept) 6.229 6.226 6.229 6.231 6.229
#> -
#> Acceptance probabilty:
#> Mean 2.5% 50% 97.5%
#> alpha 0.9993 0.9940 1.0000 1
#> ---
#> Sampler summary:
#> -
#> runtime = 289.503
#> ---
#> Optimizer summary:
#> -
#> AICc = 4458217 edf = 6 logLik = -2229102
#> logPost = -2229216 nobs = 291479 runtime = 0.738
Parametric effects
par(mar = c(4, 4, 0.5, 0), mfrow = c(1, 2), cex.axis = 0.7)
plot2d_bamlss(model, bwdata_model, model = "mu", term = "poly(prop_tap_toilet, 2)", grid = 50, FUN = c95)
plot2d_bamlss(model, bwdata_model, model = "mu", term = "poly(remoteness, 2)", grid = 50, FUN = c95)
Time to execute the task
Only useful when executed with Rscript
.
proc.time()
#> user system elapsed
#> 2.810 0.157 2.986