Municipality effects of remoteness and sanitation (simple figures) on BW, LBW and PTB


In this script, we compute municipality effects of remoteness and sanitation on birth outcomes. These figures are not presented in our paper.

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")
path_summarised <- file.path(path_data, "summarised")

source(file.path(path_proj, "src", "51-bamlss.R"))
source(file.path(path_proj, "src", "57-bamlss-vis-paper.R"))

bwdata_file <- file.path(path_processed, "bwdata_41_model.fst")
path_model_bw_full <- file.path(path_modelled, "bw-10-full-re-t-burned.rds")
path_model_bw_growth <- file.path(path_modelled, "bw-20-growth-re-t-burned.rds")
path_model_lbw_full <- file.path(path_modelled, "lbw-10-full-re-burned.rds")
path_model_lbw_growth <- file.path(path_modelled, "lbw-20-growth-re-burned.rds")
path_model_pre <- file.path(path_modelled, "pre-11-full-re-burned.rds")

bwdata_model <- fst::read_fst(bwdata_file)
model_bw_full <- readRDS(path_model_bw_full)
model_bw_growth <- readRDS(path_model_bw_growth)
model_lbw_full <- readRDS(path_model_lbw_full)
model_lbw_growth <- readRDS(path_model_lbw_growth)
model_pre <- readRDS(path_model_pre)

Create figure for remoteness effect

plot_eff_2d(
    bwdata_model, "remoteness", "Remoteness",
    file.path(path_summarised, "mod-eff-municipality-remoteness.pdf"),
    list(model_bw_full, model_bw_growth, model_lbw_full, model_lbw_growth, model_pre)
)
#> png 
#>   2

Create figure for sanitation effect

plot_eff_2d(
    bwdata_model, "prop_tap_toilet", "Percentage of population with sanitation",
    file.path(path_summarised, "mod-eff-municipality-sanitation.pdf"),
    list(model_bw_full, model_bw_growth, model_lbw_full, model_lbw_growth, model_pre)
)
#> png 
#>   2

Time to execute the task

Only useful when executed with Rscript.

proc.time()
#>    user  system elapsed 
#>  44.507   2.943  47.429