cmc_psat: Polygons Spatial Association Test - Global Envelope

View source: R/mc-test.R

cmc_psatR Documentation

Polygons Spatial Association Test - Global Envelope

Description

A Monte Carlo test to verify if two sets of polygons are associated based in a global envelope of the functions K_{12}(d) and L_{12}(d) using different test statistics.

Usage

cmc_psat(
  p1,
  p2,
  id_col = NULL,
  n_sim = 499L,
  alpha = 0.01,
  var_st = TRUE,
  ts = "SMAD",
  distances = NULL,
  hausdorff = TRUE,
  method = "rnd_poly"
)

Arguments

p1

a sf object containing one column specifying the objects id.

p2

a sf object containing one column specifying the objects id.

id_col

a character or integer indicating the column of p1 storing the unique identifier for the polygons/sample units.

n_sim

an integer corresponding to the number of Monte Carlo simulations for the test

alpha

a numeric indicating the confidence level.

var_st

use the variance stabilizing funciton?

ts

a character associated to a test statistic. Inputs acepted: c('IM', 'MAD', 'SIM', 'SMAD', 'IMDQ', 'MADDQ').

distances

a numeric vector indicating the distances to evaluate H(d). If NULL then the range considered goes from 5% to 20% of the max distance that can be observed inside the study region.

hausdorff

a logical scalar indicating whether the Hausdorff distance should be used (default is TRUE).

method

(default = "rng_poly") a character indicating the method used to deal with broken polygons in the Toroidal Shift. Valid options are c("min", "max", "mean", "rnd_poly", "rnd_dist", "min_norm", "max_norm", "hybrid", "hyb_center", "hybrid_nc", "old_min").

Value

a list with values:

p_value

a numeric scalar giving the p-value of the test

mc_sample

a numeric vector giving the test statistic for each of the Monte Carlo simulations

mc_funct

a matrix where each line correspond to the function (K or L) estimated for the Monte Carlo simulations

distances

numeric vector containing the distances where mc_func were evaluated.

alpha

a numeric scalar giving the significance level

rejects

a logical scalar, TRUE if the null hypothesis is reject

Examples

library(sapo)
library(sf)
set.seed(2024)

 ## loading toy data
poly1 <- system.file("extdata", "poly1.rds", package = "sapo") |>
  readRDS()
poly2 <- system.file("extdata", "poly2.rds", package = "sapo") |>
  readRDS()

my_ht <- cmc_psat(poly1, poly2, n_sim = 199)
my_ht$p_value


lcgodoy/tpsa documentation built on Oct. 12, 2024, 11:37 a.m.