Skip to content

nripstein/DAST

Repository files navigation

R-CMD-check Codecov test coverage

DAST (DisAggregation in Space and Time)

DAST fits spatial disaggregation models for areal data observed on maps where polygon boundaries change over time. It combines polygon responses, optional fine-scale covariates, and population rasters to infer fine-scale spatial risk surfaces.

Installation

You can install from GitHub with:

# install.packages("remotes")

remotes::install_github("nripstein/DAST")

or the development branch from

remotes::install_github("nripstein/DAST", ref = "development")

Data Requirements

  • polygon_shapefile_list: one sf polygon object per time point, with area_id and response columns by default.

  • covariate_rasters_list: optional matching list of terra::SpatRaster covariate stacks.

  • aggregation_rasters_list: optional matching list of terra::SpatRaster aggregation or population rasters; if omitted, uniform aggregation weights are used.

  • Polygon and raster inputs should use compatible coordinate reference systems and aligned raster grids within each time point.

Workflow

# polygon_list: list of sf polygon objects, one per time point

# covariate_list: optional list of terra::SpatRaster covariate stacks

# aggregation_list: optional list of terra::SpatRaster aggregation/population rasters

dat <- prepare_data_mmap(
	polygon_shapefile_list = polygon_list,
	covariate_rasters_list = covariate_list,
	aggregation_rasters_list = aggregation_list
)

fit <- disag_model_mmap(dat, engine = "AGHQ")

pred <- predict(fit)

Predictions are returned as fine-scale rate or risk surfaces. When the aggregation raster represents population or exposure, expected fine-cell counts can be obtained by multiplying the predicted surface by the matching aggregation raster.

Fitting Algorithms

It is straightforward to use the model-fitting algorithm of your choice by specifying an engine argument in disag_model_mmap().

Engine Description Recommended use
AGHQ Approximate Bayesian inference using Adaptive Gauss-Hermite Quadrature. Default option for fast approximate fully Bayesian inference.
TMB Laplace approximation through Template Model Builder. Fastest option, using Empirical Bayes instead of full Bayes.
MCMC NUTS algorithm implimented in tmbstan. Provides asymptotically exact posterior sampling, but is very slow; predict() is not currently implemented.

Passing Engine-Specific Arguments

Use engine.args to pass arguments specific to the fitting algorithm selected.

# AGHQ controls
fit_aghq <- disag_model_mmap(
	dat,
	engine = "AGHQ",
	engine.args = list(
		aghq_k = 2,
		optimizer = "BFGS"
	)
)

# TMB controls
fit_tmb <- disag_model_mmap(
	dat,
	engine = "TMB",
	engine.args = list(
		iterations = 1000,
		hess_control_ndeps = 1e-4
	)
)

# MCMC controls via tmbstan
fit_mcmc <- disag_model_mmap(
	dat,
	engine = "MCMC",
	engine.args = list(
		chains = 4,
		iter = 2000,
		warmup = 1000
	)
)

summary(fit_mcmc)

About

R package for spatial disaggregation over maps with changing areal boundaries

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

 
 
 

Contributors