sp_balance: Calculate spatial balance metrics

View source: R/sp_balance.R

sp_balanceR Documentation

Calculate spatial balance metrics

Description

This function measures the spatial balance (with respect to the sampling frame) of design sites using Voronoi polygons (Dirichlet tessellations).

Usage

sp_balance(
  object,
  sframe,
  stratum_var = NULL,
  ip = NULL,
  metrics = "pielou",
  extents = FALSE
)

Arguments

object

An sf object containing some design sites.

sframe

The sampling frame as an sf object. The coordinate system for sframe must be one where distance for coordinates is meaningful.

stratum_var

The name of the stratum variable in object and sframe. If NULL (the default), no strata is assumed. If a single character vector is provided, it is assumed this is the name of the stratum variable in object and sframe. If a two-dimensional character vector is provided, one element must be named "object" and corresponds to the name of the stratum variable in object, while the other element must be named "sframe" and corresponds to the name of the stratum variable in sframe.

ip

Inclusion probabilities associated with each row of sframe. If these are not provided, an equal probability design is assumed (within strata).

metrics

A character vector of spatial balance metrics:

pielou

Pielou's Evenness Index (the default). This statistic can take on a value between zero and one.

simpsons

Simpsons Evenness Index. This statistic can take on a value between zero and logarithm of the sample size.

rmse

Root-Mean-Squared Error. This statistic can take on a value between zero and infinity.

mse

Mean-Squared Error. This statistic can take on a value between zero and infinity.

mae

Median-Absolute Error. This statistic can take on a value between zero and infinity.

medae

Mean-Absolute Error. This statistic can take on a value between zero and infinity.

chisq

Chi-Squared Loss. This statistic can take on a value between zero and infinity.

All spatial balance metrics have a lower bound of zero, which indicates perfect spatial balance. As the metric value increases, the spatial balance decreases.

extents

Should the extent (total units) within each Voronoi polygon be returned? Defaults to FALSE.

Value

A data frame with columns providing the stratum (stratum), spatial balance metric (metric), and spatial balance (value).

Author(s)

Michael Dumelle Dumelle.Michael@epa.gov

Examples

## Not run: 
sample <- grts(NE_Lakes, 30)
sp_balance(sample$sites_base, NE_Lakes)
strata_n <- c(low = 25, high = 30)
sample_strat <- grts(NE_Lakes, n_base = strata_n, stratum_var = "ELEV_CAT")
sp_balance(sample_strat$sites_base, NE_Lakes, stratum_var = "ELEV_CAT", metric = "rmse")

## End(Not run)

USEPA/spsurvey documentation built on Jan. 26, 2024, 4:18 p.m.