Package 'svyLocAdj'

Title: Modelling Survey Data (E.g., DHS) with Adjustment for Location Perturbations
Description: 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) <doi:10.1093/jrsssa/qnag068>.
Authors: K. Shuvo Bakar [aut, cre] (ORCID: <https://orcid.org/0000-0003-3215-4496>), Jahidur Rahman Khan [ctb] (ORCID: <https://orcid.org/0000-0002-3029-6303>), Bernard Baffour [ctb] (ORCID: <https://orcid.org/0000-0002-9820-2617>)
Maintainer: K. Shuvo Bakar <[email protected]>
License: GPL (>= 2)
Version: 1.0.1
Built: 2026-10-08 12:15:56 UTC
Source: https://github.com/ksbakar/svylocadj

Help Index


Plot Method for svyLocAdj Objects

Description

Produces graphical summaries of a fitted svyLocAdj model. Depending on the selected plot type, the method displays either a spatial map of adjusted survey locations or a forest plot of fixed-effect parameter estimates and their uncertainty intervals.

Usage

## S3 method for class 'svyLocAdj'
plot(x, type, title, drop_intercept, ...)

Arguments

x

An object of class "svyLocAdj".

type

Character string specifying the type of plot to produce. Supported values are:

"map"

Displays the spatial map stored in the fitted model object.

"para"

Displays a forest plot of fixed-effect parameter estimates and their uncertainty intervals.

title

Title used for the forest plot when type = "para".

drop_intercept

TRUE or FALSE argument, if TRUE then plot intercept.

...

Additional arguments passed to or from other methods.

Details

The plotting method provides two complementary visualizations of a fitted svyLocAdj model:

  • Map plot (type = "map"): displays the spatial output associated with the fitted model, typically showing adjusted survey cluster locations and related geographic information.

  • Parameter plot (type = "para"): displays a forest plot of the fixed-effect parameter estimates. Point estimates are shown together with their corresponding uncertainty intervals on the odds-ratio scale.

The parameter plot is useful for assessing the magnitude and direction of covariate effects, while the map plot provides a visual summary of the spatial component of the model.

Value

Plot output.

See Also

svymodel, summary.svyLocAdj

Examples

## Not run:

head(sample_data)

fit <- svymodel(
  formula = ch_stunt ~ age_of_child,
  data = sample_data
)

# Spatial map

plot(fit)

# Forest plot of fixed effects

plot(fit, type = "para")

# Forest plot with custom title

plot(fit, type = "para", title = "Adjusted Odds Ratios")

# Plot map

plot(fit, type = "map")

## End(Not run)

Sample survey data with displaced locations.

Description

This data set contains values of daily 8-hour maximum average ozone concentrations (parts per billion (ppb)), maximum temperature (in degree Celsius), wind speed (knots), and relative humidity, obtained from 28 monitoring sites of New York, USA.

NYgrid: This dataset contains total 6200 rows for 62 days of observations for 10x10 = 100 grid points.

Usage

sample_data

Format

Columns: each contains 435 observations.

  • 1st col = DHSCLUST,

  • 2nd col = maternal_age,

  • 3rd col = maternal_education,

  • 4th col = wealth_index,

  • 5th col = breastfeeding,

  • 6th col = sex_of_child,

  • 7th col = age_of_child,

  • 8th col = hw70,

  • 9th col = URBAN_RURA.

  • 10th col = LONGNUM.

  • 11th col = LATNUM.

  • 12th col = Precipitation_2020.

  • 13th col = Mean_Temperature_2020.

  • 14th col = ch_stunt.

See Also

svymodel, summary.svyLocAdj, plot.svyLocAdj

Examples

##

head(sample_data)

##

Summary for svyLocAdj Objects

Description

Produces a summary of a fitted svyLocAdj model, including fixed-effect parameter estimates, variability parameters, and model fit statistics based on the Watanabe-Akaike Information Criterion (WAIC).

Usage

## S3 method for class 'svyLocAdj'
summary(object, ...)

Arguments

object

An object of class "svyLocAdj".

...

Additional arguments passed to or from other methods. Currently ignored.

Details

The summary method displays:

  • The model family used for fitting the DHS spatial location displacement model.

  • Estimated fixed parameters.

  • Estimated variability parameters.

  • The log pointwise predictive density (lppd).

  • An approximation to the Watanabe-Akaike Information Criterion (WAIC).

The method is intended for a concise inspection of model estimates and overall model fit.

Value

Summary output.

See Also

svymodel, plot.svyLocAdj

Examples

## Not run:

head(sample_data)

fit <- svymodel(
  formula = ch_stunt ~ age_of_child,
  data = sample_data
)

summary(fit)

## End(Not run)

Fit a Bayesian Location Displacement Adjustment Model for Survey Data

Description

Fits a Bayesian model that accounts for the spatial displacement of survey data (e.g., DHS) cluster locations and obtains Maximum A Posteriori (MAP) estimates of model parameters. The function supports Gaussian, binomial, and Poisson response models.

Usage

svymodel(formula, data, family = "binomial", id_var, coord_var,
       cluster_var, urban_rural_var, grid_x, grid_y, sigma_u_prior,
       sigma_r_prior, sigma_nu_prior, beta_prior, zeta_prior,
       digits=4, draws = 10)

Arguments

formula

A model formula specifying the response variable and covariates.

data

A data frame containing the response variable, covariates, cluster identifiers, coordinates, and other variables required by the model.

family

The response distribution. Supported values are "gaussian", "binomial", and "poisson".

id_var

Character string specifying the cluster identifier variable in data.

coord_var

Character vector of length two specifying the longitude and latitude variables in data, e.g., c("lon", "lat").

cluster_var

Character vector specifying cluster-level predictor variables included in the displacement model.

urban_rural_var

Character string specifying the variable that identifies urban and rural DHS clusters.

grid_x

Number of grid points used along the x-axis when constructing the spatial grid.

grid_y

Number of grid points used along the y-axis when constructing the spatial grid.

sigma_u_prior

Numeric vector of length two specifying the shape and rate parameters of the Gamma prior distribution for the urban-area variability parameter, e.g., c(20, 20).

sigma_r_prior

Numeric vector of length two specifying the shape and rate parameters of the Gamma prior distribution for the rural-area variability parameter, e.g., c(10, 25).

sigma_nu_prior

Numeric vector of length two specifying the shape and rate parameters of the Gamma prior distribution for the ν\nu variability parameter, e.g., c(2, 1).

beta_prior

Numeric vector of length two specifying the mean and standard deviation of the Normal prior distribution for regression coefficients, e.g., c(0, 2).

zeta_prior

Numeric vector of length two specifying the mean and standard deviation of the Normal prior distribution for displacement-model coefficients, e.g., c(0, 2).

digits

Integer specifying the number of decimal places displayed in printed output.

draws

Number of posterior draws used when obtaining MAP estimates and related summaries.

Details

The model explicitly accounts for the spatial perturbation applied to DHS cluster coordinates for confidentiality protection. Spatial grids are constructed over the study region, and uncertainty arising from location displacement is incorporated into the estimation procedure.

The returned object is of class "svyLocAdj" and includes methods for summarization and visualization.

Value

An object of class "svyLocAdj" containing:

results

Estimated model parameters, uncertainty measures, and model fit statistics.

data

The data used for model fitting.

sp_data

Spatial information used during estimation, including the generated spatial grid.

References

Bakar, K. S., et al. (2026). A Bayesian model adjusted for location perturbations in sample surveys: with application to the analysis of demographic and health survey data. Journal of the Royal Statistical Society Series A. doi:10.1093/jrsssa/qnag068

See Also

summary.svyLocAdj, plot.svyLocAdj

Examples

head(sample_data)

# logistic model

out_bino = svymodel(formula = ch_stunt ~ age_of_child,
             data = sample_data, family = "binomial",
             id_var = c("DHSCLUST"),
             coord_var = c("LONGNUM","LATNUM"),
             cluster_var = c("Precipitation_2020"),
             urban_rural_var = c("URBAN_RURA"))
out_bino
summary(out_bino)
plot(out_bino, type="para", title = "Binomial model")
plot(out_bino, type="para", drop_intercept = TRUE,
     title = "Binomial model")
plot(out_bino, type="map")

# gaussian model

sample_data$hw70_scale <- scale(sample_data$hw70)

out_cont = svymodel(formula = hw70_scale ~ age_of_child,
             data = sample_data, family = "gaussian",
             id_var = c("DHSCLUST"),
             coord_var = c("LONGNUM","LATNUM"),
             cluster_var = c("Precipitation_2020"),
             urban_rural_var = c("URBAN_RURA"))
out_cont
summary(out_cont)
plot(out_cont, type="para", title = "Gaussian model")
plot(out_cont, type="map")

# gaussian spatially varying model

sample_data$hw70_scale <- scale(sample_data$hw70)

out_cont_sp = svymodel(formula = hw70_scale ~ age_of_child,
             data = sample_data, family = "gaussian_sp",
             id_var = c("DHSCLUST"),
             coord_var = c("LONGNUM","LATNUM"),
             cluster_var = c("Precipitation_2020"),
             urban_rural_var = c("URBAN_RURA"))
out_cont_sp
summary(out_cont_sp)
plot(out_cont_sp, type="para", title = "Varying model")
plot(out_cont_sp, type="map")
out_cont_sp$results$spatial_parameters