Modelling Survey Data (E.g., DHS) with Adjustment for Location Perturbations

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

svyLocAdj is an R package for adjusting and analyzing Demographic and Health Survey (DHS) data using Bayesian modeling approaches implemented through Stan.

Prerequisites

Before installing svyLocAdj, users must ensure that:

  1. A working C++ compiler/toolchain is installed.
  2. The rstan package is successfully installed and configured.

Since svyLocAdj uses Stan for Bayesian computation, proper compiler and rstan installation are required.


Step 1: Verify Compiler Installation

Windows

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.

macOS

Install Apple's Command Line Tools:

xcode-select --install

Linux

For Ubuntu/Debian systems:

sudo apt update
sudo apt install build-essential

For other Linux distributions, install the equivalent GNU compiler tools.


Step 2: Install RStan

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


Step 3: Install devtools

If devtools is not already installed:

install.packages("devtools")

Step 4: Install svyLocAdj from GitHub

Install the latest development version from GitHub:

devtools::install_github("ksbakar/svyLocAdj")

Replace USERNAME with the GitHub username or organization hosting the repository.


Step 5: Load the Package

library(svyLocAdj)

Confirm the installation:

packageVersion("svyLocAdj")

Troubleshooting

Stan Model Compilation Errors

If Stan models fail to compile:

  1. Verify that the compiler toolchain is installed correctly.
  2. Restart R after installing Rtools (Windows) or Command Line Tools (macOS).
  3. Reinstall or update rstan and StanHeaders:
install.packages(c("StanHeaders", "rstan"))
  1. Check compiler availability:
pkgbuild::has_build_tools(debug = TRUE)

Windows-Specific Issues

Ensure that:

  • The correct version of Rtools is installed.
  • Rtools is available on the system PATH.
  • Your R version is compatible with the installed Rtools version.

Example

library(svyLocAdj)

# Example workflow
# ... will add package-specific examples here soon ...

Reporting Issues

If you encounter bugs or installation problems, please open an issue in the GitHub repository.

License

See the LICENSE file for licensing information.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("svyLocAdj")

1.0.2 by K. Shuvo Bakar, 17 hours ago


Browse source code at https://github.com/cran/svyLocAdj


Authors: K. Shuvo Bakar [aut, cre] (ORCID: , Jahidur Rahman Khan [ctb] (ORCID: , Bernard Baffour [ctb]


Documentation:   PDF Manual  


GPL (>= 2) license


Imports rstan, sf, geodist, ggplot2, dplyr, tibble, spTimer


See at CRAN