Parametric remoteness: 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-06-remote-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)
#> -
#> Parametric coefficients:
#>                       Mean  2.5%   50% 97.5% parameters
#> (Intercept)           3220  3218  3220  3221       3219
#> poly(remoteness, 2)1 -8453 -9096 -8367 -8020      -9694
#> poly(remoteness, 2)2 -4022 -4790 -4051 -3406      -4628
#> -
#> Acceptance probabilty:
#>            Mean      2.5%       50% 97.5%
#> alpha 1.907e-02 6.178e-12 8.898e-07 0.151
#> ---
#> 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.9992 0.9931 1.0000     1
#> ---
#> Sampler summary:
#> -
#> runtime = 278.194
#> ---
#> Optimizer summary:
#> -
#> AICc = 4458361 edf = 4 logLik = -2229177
#> logPost = -2229271 nobs = 291479 runtime = 0.443

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(remoteness, 2)", grid = 50, FUN = c95)

Time to execute the task

Only useful when executed with Rscript.

proc.time()
#>    user  system elapsed 
#>   2.785   0.121   2.925