AgePopDenom
is an R package designed to
facilitate the generation of fine-scale, age-structured population
denominators for public health decision-making and service delivery. By
combining census and household survey data with a novel parameter-based
geostatistical modeling approach, the package produces high-resolution
(5km x 5km) population estimates disaggregated by age.
Before installing AgePopDenom, ensure your system meets the following requirements:
Windows
# Check if Rtools is installed and properly configured
::has_build_tools() pkgbuild
If FALSE, download and install Rtools from: CRAN Rtools
echo 'export PATH="C:/rtools43/usr/bin;C:/rtools43/mingw64/bin:$PATH"' >> ~/.Renviron
Sys.getenv("PATH")
It should include C:/rtools43/usr/bin
and
C:/rtools43/mingw64/bin
.
g++ --version
It should output GCC version 10 or later.
mkdir -p ~/.R
nano ~/.R/Makevars.win
Add the following lines:
CXX14=C:/rtools43/mingw64/bin/g++
CXX17=C:/rtools43/mingw64/bin/g++
CXX20=C:/rtools43/mingw64/bin/g++
Save and exit (CTRL+X
, then Y
, then
Enter
).
macOS
xcode-select --install
brew install gcc
brew install llvm
For Zsh (default on macOS):
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc
echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"' >> ~/.zshrc
source ~/.zshrc
For Bash:
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.bashrc
echo 'export LDFLAGS="-L/opt/homebrew/opt/llvm/lib"' >> ~/.bashrc
echo 'export CPPFLAGS="-I/opt/homebrew/opt/llvm/include"' >> ~/.bashrc
source ~/.bashrc
clang++ --version
It should output Homebrew Clang (e.g.,
Homebrew clang version XXXXX
).
~/.R/Makevars
file:
nano ~/.R/Makevars
Add the following lines:
CXX=/opt/homebrew/opt/llvm/bin/clang++
CXX11=/opt/homebrew/opt/llvm/bin/clang++
CXX14=/opt/homebrew/opt/llvm/bin/clang++
CXX17=/opt/homebrew/opt/llvm/bin/clang++
CXX20=/opt/homebrew/opt/llvm/bin/clang++
Save and exit (CTRL+X
, then Y
, then
Enter
).
Linux (Ubuntu/Debian)
sudo apt-get update
sudo apt-get install build-essential libxml2-dev
sudo apt-get install g++
sudo apt-get install clang
g++ --version
clang++ --version
Restart R and install TMB:
install.packages("TMB", type = "source")
Once the setup is complete, follow the instructions below to download AgePopDenom
Note: AgePopDenom is currently under development. Once it is available on CRAN, you will be able to install it using the following command:
# install.packages("AgePopDenom")
To get the development version from GitHub, use:
# install.packages("devtools")
::install_github("truenomad/AgePopDenom") devtools
Then load it in R:
library(AgePopDenom)
init()
# Example for Kenya and Uganda
<- c("KEN", "UGA")
countries
# Get DHS data
download_dhs_datasets(countries,
email = "my_email@example.com",
project = "Population denominator project")
# Process DHS data
process_dhs_data()
# Download shapefiles
download_shapefile(countries)
# Download population rasters from worldpop
download_pop_rasters(countries)
# Extract urban extent raster
extract_afurextent()
run_full_workflow(countries)
For detailed documentation and examples, visit our package website.
For support, bug reports, or feature requests, please contact:
Alternatively, open an issue on the GitHub repository.
We welcome contributions from the community to improve
AgePopDenom
.