Learn R Programming

spsurvey (version 5.5.1)

sp_balance: 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
)

Value

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

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.

Author

Michael Dumelle Dumelle.Michael@epa.gov

Examples

Run this code
if (FALSE) {
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")
}

Run the code above in your browser using DataLab