local_jc_uni: Compute local univariate join count

View source: R/joincount-uni-impl.R

local_jc_uniR Documentation

Compute local univariate join count

Description

The univariate local join count statistic is used to identify clusters of rarely occurring binary variables. The binary variable of interest should occur less than half of the time.

Usage

local_jc_uni(
  x,
  nb,
  wt = st_weights(nb, style = "B"),
  nsim = 499,
  alternative = "two.sided"
)

Arguments

x

a binary variable either numeric or logical

nb

a neighbors list object.

wt

default st_weights(nb, style = "B"). A binary weights list as created by st_weights(nb, style = "B").

nsim

the number of conditional permutation simulations

alternative

default "greater". One of "less" or "greater".

Details

The local join count statistic requires a binary weights list which can be generated with st_weights(nb, style = "B"). Additionally, ensure that the binary variable of interest is rarely occurring in no more than half of observations.

P-values are estimated using a conditional permutation approach. This creates a reference distribution from which the observed statistic is compared. For more see Geoda Glossary.

Value

a data.frame with two columns join_count and p_sim and number of rows equal to the length of arguments x, nb, and wt.

Examples

res <- dplyr::transmute(
  guerry,
  top_crime = crime_prop > 9000,
  nb = st_contiguity(geometry),
  wt = st_weights(nb, style = "B"),
  jc = local_jc_uni(top_crime, nb, wt))
tidyr::unnest(res, jc)

sfdep documentation built on Aug. 15, 2022, 5:09 p.m.