MyNixOS website logo
Description

Fast Local Indicators of Spatial Association (LISA).

Computes various Local Indicators of Spatial Association (LISA) statistics, including univariate and bivariate local Moran's I, Empirical Bayes local Moran's I, univariate and multivariate local Geary's C, and Getis-Ord G and G* statistics. The methods follow Anselin (1995), Getis and Ord (1992), and Anselin (2019). Leverages a high-performance, plain-C backend with optional 'OpenMP' multi-core support for fast permutation-based pseudo-p-value calculation. Accepts any 'spdep' listw spatial weight matrix, including custom and non-contiguity weights. Uses sample standardisation (n-1) and 'rgeoda'-style permutation p-values. Output cluster codes match 'rgeoda' conventions, including the Isolated category for observations without neighbours.

fastLISA

Fast, reproducible Local Indicators of Spatial Association (LISA) with arbitrary spatial weights.

fastLISA computes seven families of LISA statistics with a plain-C backend, optional OpenMP multi-threading, and a modern xoshiro256++ random number generator for permutation-based inference. It accepts anyspdeplistw spatial weights object — including custom and non-contiguity (e.g. distance-decay) weights — and returns compact, inspectable, spdep-compatible matrices.

Why fastLISA

The two established R tools force a trade-off:

  • spdep accepts any listw and integrates with the R spatial ecosystem, but its conditional-permutation inference runs largely in R and is slow on large maps.
  • rgeoda is fast, but builds its own weights internally — so custom weight values are ignored (it falls back to binary contiguity) — and returns objects that need package-specific accessors.

fastLISA closes the gap:

  • Honours custom weight values. It uses the actual listw weights, so distance-decay and other non-binary schemes are respected (unlike rgeoda).
  • Fast. At equal thread counts, the OpenMP-parallelised C kernels run about 2.5× faster than the compiled peer rgeoda, and roughly 8–10× faster than spdep, whose permutation loops run largely in R.
  • Reproducible at any thread count. The permutation RNG is re-seeded per observation, so for a fixed iseed the pseudo-p-values are identical regardless of n.cores — a guarantee neither spdep nor rgeoda offers.
  • Inspectable output. Results are plain matrices with spdep-style classes and cluster/quadrant attributes, not opaque pointers.

Statistics

FunctionStatistic
local_moran()Univariate local Moran's I
local_moran_bv()Bivariate local Moran's I
local_moran_eb()Empirical-Bayes-rate local Moran's I
local_geary()Univariate local Geary's C
local_multigeary()Multivariate local Geary's C
local_g()Getis-Ord local G
local_gstar()Getis-Ord local G*

Each returns the observed statistic, a permutation z-score, and a pseudo p-value (folded for Moran/G/G*, tail-adaptive for Geary), with optional permutation-moment columns. Cluster codes follow rgeoda conventions, including an Isolated category for observations with no neighbours.

Installation

Install the released version from CRAN:

install.packages("fastLISA")

Or the development version from source (requires a C99 compiler; OpenMP is used when available):

# install.packages("remotes")
remotes::install_github("lizhongc/fastLISA")

Or from a local clone:

R CMD INSTALL fastLISA

spdep is suggested for constructing listw weights and for the examples.

Quick start

library(spdep)
library(fastLISA)

nb <- cell2nb(7, 7)             # 49 cells on a 7 x 7 grid
lw <- nb2listw(nb, style = "W") # row-standardised weights
x  <- as.numeric(seq_len(49))   # a simple gradient

res <- local_moran(x, lw, nsim = 999L, iseed = 1L, n.cores = 1L)
head(res)

attr(res, "cluster")            # High-High / Low-Low / outliers / Isolated ...

Custom (e.g. distance-decay) weights are passed through unchanged:

coords  <- as.matrix(expand.grid(x = 1:7, y = 1:7))   # 49 grid points
dnb     <- dnearneigh(coords, 0, 2)                    # neighbours within distance 2
glist   <- lapply(nbdists(dnb, coords), function(d) exp(-d))  # distance decay
lw_exp  <- nb2listw(dnb, glist = glist, style = "B")
res_exp <- local_g(x, lw_exp, nsim = 999L, iseed = 1L)

All functions share the same interface: nsim permutations, an optional integer iseed for reproducibility, a significance cutoff p.value, n.cores (default 1L; raise it to use multiple OpenMP threads), and p.method to choose the pseudo-p-value rule — the standard "count" (default), or spdep's ties-averaged "rank", which differ only under exact ties.

Reproducibility

Because the RNG is re-seeded per observation rather than per thread, the same iseed yields bit-identical pseudo-p-values whether you run on 1 core or many:

a <- local_moran(x, lw, nsim = 999L, iseed = 42L, n.cores = 1L)
b <- local_moran(x, lw, nsim = 999L, iseed = 42L, n.cores = 8L)
identical(c(a), c(b))   # TRUE -- same statistics and pseudo-p-values

(c() strips attributes; the full objects differ only in the recorded call, which stores the n.cores value you passed.)

Documentation

See the package help (?local_moran, ?local_g, ?local_geary, ...) and the package vignette:

vignette("fastLISA")

References

License

GPL-3.

Metadata

Version

1.0.1

License

Unknown

Platforms (79)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    wasip1
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arc-linux
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • sh4-linux
  • vc4-none
  • wasm32-wasip1
  • wasm64-wasip1
  • x86_64-cygwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows