build_zones: Build Candidate Spatial Zones Using Circular Windows

View source: R/build_zones.R

build_zonesR Documentation

Build Candidate Spatial Zones Using Circular Windows

Description

Constructs the set of candidate spatial zones for the circular scan statistic. Each zone is defined by a circular window centered on a region's centroid, containing all regions whose centroids fall within the circle.

Usage

build_zones(regions, max_pop = NULL)

Arguments

regions

A data.frame with columns region_id, population, x, and y. Coordinates x and y represent centroids of each region.

max_pop

A numeric value specifying the maximum population allowed inside a zone. If NULL (default), it is set to 50% of the total population.

Details

For each region j, regions are sorted by distance from j. Regions are added incrementally to the zone as long as the total population does not exceed max_pop. This generates a nested set of circular windows centered on each region.

Value

A list of zones. Each zone is a list with elements:

center

Integer index of the center region.

region_idx

Integer vector of region indices inside the zone.

population

Total population inside the zone.

References

Kulldorff, M. (1997). A spatial scan statistic. Communications in Statistics - Theory and Methods, 26(6), 1481–1496.

Examples

regions <- data.frame(
  region_id = 1:5,
  population = c(1000, 2000, 1500, 800, 1200),
  x = c(0, 1, 2, 0.5, 1.5),
  y = c(0, 0, 0, 1, 1)
)
zones <- build_zones(regions, max_pop = 3000)
length(zones) # number of candidate zones

treeSS documentation built on May 16, 2026, 1:08 a.m.