Bayesian spatial models for survey data, such as Demographic and Health Survey (DHS), with spatial cluster location displacement adjustments. The package implements models for (1) continuous, (2) binary, (3) count and (4) spatially varying models for continuous outcomes. For more details see Bakar et al. (2026)
svyLocAdj is an R package for adjusting and analyzing Demographic and Health Survey (DHS) data using Bayesian modeling approaches implemented through Stan.
Before installing svyLocAdj, users must ensure that:
rstan package is successfully installed and configured.Since svyLocAdj uses Stan for Bayesian computation, proper compiler and rstan installation are required.
Install Rtools corresponding to your version of R:
https://cran.r-project.org/bin/windows/Rtools/
After installation, verify that the compiler is available:
install.packages("pkgbuild")
pkgbuild::has_build_tools(debug = TRUE)
A return value of TRUE indicates that the build tools are correctly configured.
Install Apple's Command Line Tools:
xcode-select --install
For Ubuntu/Debian systems:
sudo apt update
sudo apt install build-essential
For other Linux distributions, install the equivalent GNU compiler tools.
Install rstan and its dependencies:
install.packages(c("StanHeaders", "rstan"), dependencies = TRUE)
Load rstan and verify that it is working correctly:
library(rstan)
rstan_options(auto_write = TRUE)
options(mc.cores = parallel::detectCores())
For detailed installation instructions and platform-specific guidance, see:
https://mc-stan.org/users/interfaces/rstan
If devtools is not already installed:
install.packages("devtools")
Install the latest development version from GitHub:
devtools::install_github("ksbakar/svyLocAdj")
Replace USERNAME with the GitHub username or organization hosting the repository.
library(svyLocAdj)
Confirm the installation:
packageVersion("svyLocAdj")
If Stan models fail to compile:
rstan and StanHeaders:install.packages(c("StanHeaders", "rstan"))
pkgbuild::has_build_tools(debug = TRUE)
Ensure that:
library(svyLocAdj)
# Example workflow
# ... will add package-specific examples here soon ...
If you encounter bugs or installation problems, please open an issue in the GitHub repository.
See the LICENSE file for licensing information.