Demographic characteristics of Amazonian mothers


In this script, we compute the demographic characteristics of the population under study. The resulting table can be seen at section Show demographic characteristics. This output corresponds to Supplementary Table 1 of our paper.

Load packages, read data and source custom scripts

Paths are defined relative to the git repository location. Only birthweight data used for modelling is required.

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
path_proj <- day2day::git_path()
path_data <- file.path(path_proj, "data")
path_processed <- file.path(path_data, "processed")
path_summarised <- file.path(path_data, "summarised")

source(file.path(path_proj, "src", "52-summary.R"))

bwdata_model <- fst::read_fst(file.path(path_processed, "bwdata_41_model.fst"))

Socio-economic characteristics

socio_vars <- c("Maternal age (years)" = "age",
                "Formal education (years)" = "study_years",
                "Marital status" = "marital_status",
                "Anetanal care (number of consultations)" = "consult_num",
                "Birth Place" = "birth_place",
                "Newborn ethnicity" = "born_race",
                "Gestational age" = "gestation_weeks")
age_cuts <- seq(10, 40, 5)
n_ind <- nrow(bwdata_model)

bwdata_demo <- bwdata_model[socio_vars] %>%
  mutate(age = cut(age, c(age_cuts, 65), right = FALSE, include.lowest = TRUE,
                   labels = paste(age_cuts, "to", c(age_cuts[-1] - 1, 65)))) %>%
  purrr::map2_df(names(socio_vars), table_rel)
bwdata_demo <- within(bwdata_demo, Category[is.na(Category)] <- "missing")

Save demography characteristics

readr::write_csv(bwdata_demo, file.path(path_summarised, "paper-data-mothers-demography.csv"))

Show demographic characteristics

bwdata_demo$Percentage <- scales::label_percent(scale = 1)(bwdata_demo$Percentage)
knitr::kable(bwdata_demo, "html", table.attr = "class=\"table\"", align = "lcrr",
             caption = "Demographic characteristics of Amazonian mothers")
Table 1: Demographic characteristics of Amazonian mothers
Variable Category Count Percentage
Maternal age (years) 10 to 14 6605 2.270%
Maternal age (years) 15 to 19 84566 29.010%
Maternal age (years) 20 to 24 87070 29.870%
Maternal age (years) 25 to 29 57028 19.570%
Maternal age (years) 30 to 34 33355 11.440%
Maternal age (years) 35 to 39 16689 5.730%
Maternal age (years) 40 to 65 6166 2.120%
Formal education (years) 0 17335 5.950%
Formal education (years) 1 to 3 39376 13.510%
Formal education (years) 4 to 7 99269 34.060%
Formal education (years) 8 to 11 118492 40.650%
Formal education (years) >= 12 14821 5.080%
Formal education (years) missing 2186 0.750%
Marital status Single 162607 55.790%
Marital status Married 36788 12.620%
Marital status Widow 295 0.100%
Marital status Divorced 386 0.130%
Marital status Consensual union 87528 30.030%
Marital status missing 3875 1.330%
Anetanal care (number of consultations) 0 18734 6.430%
Anetanal care (number of consultations) 1 to 3 63904 21.920%
Anetanal care (number of consultations) 4 to 6 115889 39.760%
Anetanal care (number of consultations) >= 7 90360 31.000%
Anetanal care (number of consultations) missing 2592 0.890%
Birth Place Hospital 240700 82.580%
Birth Place Another health center 1064 0.370%
Birth Place Home 44897 15.400%
Birth Place Other 2335 0.800%
Birth Place missing 2483 0.850%
Newborn ethnicity Non-indigenous 234228 80.360%
Newborn ethnicity Indigenous 55201 18.940%
Newborn ethnicity missing 2050 0.700%
Gestational age >= 37 264970 90.910%
Gestational age 32 to 36 23954 8.220%
Gestational age 28 to 31 1888 0.650%
Gestational age 22 to 27 667 0.230%

Time to execute the task

Only useful when executed with Rscript.

proc.time()
#>    user  system elapsed 
#>   9.625   0.473  10.078