Skip to contents

On this article, we will compare the population estimates available at the brpop package.

Currently, the package present population estimates by municipalities, sex and age groups computed by the DataSUS (Brazilian Health Ministry) old and news estimates and by the UFRN-PPGDEM-LEPP laboratory. The package also have the total estimates computed by IBGE for inter-census years, and population data for Census and population inquiries years.

names_helper <- tibble(
  uf_code = c("11","12","13","14","15","16","17","21","22","23","24","25","26","27","28","29","31","32","33","35","41","42","43","50","51","52","53"),
  uf_name = c("Rondônia","Acre","Amazonas","Roraima","Pará","Amapá","Tocantins","Maranhão","Piauí","Ceará","Rio Grande do Norte","Paraíba","Pernambuco","Alagoas","Sergipe","Bahia","Minas Gerais","Espírito Santo","Rio de Janeiro","São Paulo","Paraná","Santa Catarina","Rio Grande do Sul","Mato Grosso do Sul","Mato Grosso","Goiás","Distrito Federal"),
  cap_code7 = c(1100205,1200401,1302603,1400100,1501402,1600303,1721000,2111300,2211001,2304400,2408102,2507507,2611606,2704302,2800308,2927408,3106200,3205309,3304557,3550308,4106902,4205407,4314902,5002704,5103403,5208707,5300108),
  cap_code6 = c(110020,120040,130260,140010,150140,160030,172100,211130,221100,230440,240810,250750,261160,270430,280030,292740,310620,320530,330455,355030,410690,420540,431490,500270,510340,520870,530010),
  cap_name = c("Porto Velho","Rio Branco","Manaus","Boa Vista","Belém","Macapá","Palmas","São Luís","Teresina","Fortaleza","Natal","João Pessoa","Recife","Maceió","Aracaju","Salvador","Belo Horizonte","Vitória","Rio de Janeiro","São Paulo","Curitiba","Florianópolis","Porto Alegre","Campo Grande","Cuiabá","Goiânia","Brasília")
)

Total population per UF

datasus_pop_uf <- uf_pop_totals(source = "datasus") |>
  mutate(source = "DataSUS") |>
  filter(uf != "5e")
#> Setting `max_tries = 2`.
#> Setting `max_tries = 2`.

ufrn_pop_uf <- uf_pop_totals(source = "ufrn") |>
  mutate(source = "UFRN")
#> Setting `max_tries = 2`.
#> Setting `max_tries = 2`.

ibge_pop_uf <- uf_pop_totals(source = "ibge") |>
  mutate(source = "IBGE")
#> Setting `max_tries = 2`.

datasus2024_pop_uf <- uf_pop_totals(source = "datasus2024") |>
  mutate(source = "DataSUS 2024")
#> Setting `max_tries = 2`.
#> Setting `max_tries = 2`.

bind_rows(datasus_pop_uf, ufrn_pop_uf, ibge_pop_uf, datasus2024_pop_uf) |>
  left_join(names_helper, by = c("uf" = "uf_code")) |>
  ggplot(aes(x = year, y = pop, color = source, group = source)) +
  geom_line(stat = "identity", alpha = .7, lwd = 1) +
  geom_vline(xintercept = c(2000, 2010, 2022), alpha = .5, linetype = "longdash") +
  scale_y_continuous(labels = unit_format(accuracy = 1, scale = 0.00001, unit = NULL)) + 
  facet_wrap(~uf_name, scales = "free_y", ncol = 3) +
  theme_bw() + 
  theme(legend.position = "bottom", legend.direction = "horizontal") +
  labs(title = "Population estimates per UF from different sources",
       subtitle = "in 100,000 units",
       color = "Source", x = "Year", y = "Population estimate")

Total population per capitals

datasus_pop_mun <- mun_pop_totals(source = "datasus") |>
  mutate(source = "DataSUS") |>
  right_join(names_helper, by = c("code_muni" = "cap_code6"))

ufrn_pop_mun <- mun_pop_totals(source = "ufrn") |>
  mutate(source = "UFRN") |>
  right_join(names_helper, by = c("code_muni" = "cap_code7"))

ibge_pop_mun <- mun_pop_totals(source = "ibge") |>
  mutate(source = "IBGE") |>
  right_join(names_helper, by = c("code_muni" = "cap_code7"))

datasus2024_pop_mun <- mun_pop_totals(source = "datasus2024") |>
  mutate(source = "DataSUS 2024") |>
  right_join(names_helper, by = c("code_muni" = "cap_code7"))

bind_rows(datasus_pop_mun, ufrn_pop_mun, ibge_pop_mun, datasus2024_pop_mun) |>
  ggplot(aes(x = year, y = pop, color = source, group = source)) +
  geom_line(stat = "identity", alpha = .7, lwd = 1) +
  geom_vline(xintercept = c(2000, 2010, 2022), alpha = .5, linetype = "longdash") +
  scale_y_continuous(labels = unit_format(accuracy = 1, scale = 0.00001, unit = NULL)) + 
  facet_wrap(~cap_name, scales = "free_y", ncol = 3) +
  theme_bw() + 
  theme(legend.position = "bottom", legend.direction = "horizontal") +
  labs(title = "Population estimates per capital from different sources",
       subtitle = "in 100,000 units",
       color = "Source", x = "Year", y = "Population estimate")

Session info

sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.1 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> time zone: UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] brpop_0.6.0   scales_1.3.0  ggplot2_3.5.1 tibble_3.2.1  dplyr_1.1.4  
#> 
#> loaded via a namespace (and not attached):
#>  [1] rappdirs_0.3.3    sass_0.4.9        generics_0.1.3    tidyr_1.3.1      
#>  [5] bitops_1.0-9      digest_0.6.37     magrittr_2.0.3    evaluate_1.0.3   
#>  [9] grid_4.4.2        fastmap_1.2.0     jsonlite_1.9.0    backports_1.5.0  
#> [13] purrr_1.0.4       httr2_1.1.0       textshaping_1.0.0 jquerylib_0.1.4  
#> [17] cli_3.6.4         rlang_1.1.5       munsell_0.5.1     withr_3.0.2      
#> [21] cachem_1.1.0      yaml_2.3.10       tools_4.4.2       checkmate_2.3.2  
#> [25] colorspace_2.1-1  curl_6.2.1        vctrs_0.6.5       R6_2.6.1         
#> [29] lifecycle_1.0.4   fs_1.6.5          ragg_1.3.3        pkgconfig_2.0.3  
#> [33] desc_1.4.3        pkgdown_2.1.1     pillar_1.10.1     bslib_0.9.0      
#> [37] gtable_0.3.6      data.table_1.17.0 glue_1.8.0        systemfonts_1.2.1
#> [41] zendown_0.1.0     xfun_0.51         tidyselect_1.2.1  knitr_1.49       
#> [45] farver_2.1.2      htmltools_0.5.8.1 rmarkdown_2.29    labeling_0.4.3   
#> [49] compiler_4.4.2    RCurl_1.98-1.16   dtplyr_1.3.1