Title: | Spatial Association of Different Types of Polygon |
---|---|
Description: | In ecology, spatial data is often represented using polygons. These polygons can represent a variety of spatial entities, such as ecological patches, animal home ranges, or gaps in the forest canopy. Researchers often need to determine if two spatial processes, represented by these polygons, are independent of each other. For instance, they might want to test if the home range of a particular animal species is influenced by the presence of a certain type of vegetation. To address this, Godoy et al. (2022) (<doi:10.1016/j.spasta.2022.100695>) developed conditional Monte Carlo tests. These tests are designed to assess spatial independence while taking into account the shape and size of the polygons. |
Authors: | Lucas da Cunha Godoy [aut, cre] |
Maintainer: | Lucas da Cunha Godoy <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.8.0 |
Built: | 2024-10-12 05:59:16 UTC |
Source: | https://github.com/lcgodoy/sapo |
from matrixComputes the (K or L) based on a distance matrix
based on a method
calc_h(x, var_st = FALSE, dists = NULL)
calc_h(x, var_st = FALSE, dists = NULL)
x |
distance matrix |
var_st |
logical scalar indicating if the L function should be used instead |
dists |
vector of distances to compute |
a numeric vector
A Monte Carlo test to verify if two sets of polygons are
associated based in a global envelope of the functions
and
using different test statistics.
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" )
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" )
p1 |
a |
p2 |
a |
id_col |
a |
n_sim |
an |
alpha |
a |
var_st |
use the variance stabilizing funciton? |
ts |
a |
distances |
a |
hausdorff |
a |
method |
(default = "rng_poly") a |
a list
with values:
a numeric
scalar giving the p-value of the test
a numeric
vector giving the test statistic for each of the Monte Carlo simulations
a matrix
where each line correspond to the function ( or
) estimated
for the Monte Carlo simulations
numeric vector
containing the distances where mc_func were evaluated.
a numeric
scalar giving the significance level
a logical
scalar, TRUE if the null hypothesis is reject
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
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
Create jumps for random movements
create_jump(unique_bb)
create_jump(unique_bb)
unique_bb |
a bbox shared between both "Polygon Patterns" |
This is an internal function.
a sfc
object representing a random jump or shift.
Lucas Godoy
fix a polygons' distance matrix based on a given method. This function assumes the polygon that has been broken is represented by the rows of the distance matrix.
fix_dist(x, method = "rnd_poly")
fix_dist(x, method = "rnd_poly")
x |
distance matrix |
method |
method used to fix. The options are "min", "max", "mean", "rnd_poly", "rnd_dist", "min_norm", "max_norm", "hybrid", "hyb_center", "hybrid_nc", "old_min" |
a distance matrix
from polygonsComputes the (K or L) based on a distance matrix
based on a method
h_func( p1, p2, hausdorff = TRUE, method = "rnd_poly", var_st = FALSE, dists = NULL ) h_func.list(x, ...)
h_func( p1, p2, hausdorff = TRUE, method = "rnd_poly", var_st = FALSE, dists = NULL ) h_func.list(x, ...)
p1 |
sf object |
p2 |
sf object |
hausdorff |
logical parameter indicating whether the Hausdorff distance should be used |
method |
method to deal with broken polygons |
var_st |
logical scalar indicating if the L function should be used instead |
dists |
vector of distances to compute |
x |
a list with two sf objects. |
... |
Parameters to be used with |
a numeric vector
Distance between polygons accounting for toroidal shift.
iadist(p1, p2, hausdorff = TRUE, method = "rnd_poly")
iadist(p1, p2, hausdorff = TRUE, method = "rnd_poly")
p1 |
a |
p2 |
a |
hausdorff |
|
method |
method for "fixing" the distance matrix. |
a distance matrix.
Lucas Godoy
Integram Measure
im(x, h = 1)
im(x, h = 1)
x |
|
h |
|
numeric vector
Integram Measure with Assimetry Correction
im_ac(x, h = 1)
im_ac(x, h = 1)
x |
|
h |
|
numeric vector
Maximum Absolute Deviation
mad(x)
mad(x)
x |
|
numeric vector
Maximum Absolute Deviation with Assimetry Correction
mad_ac(x)
mad_ac(x)
x |
|
numeric vector
aux function to calculate the mean of a vector when removing each of its elements one by one.
mean_aux(x)
mean_aux(x)
x |
a numeric vector |
a numeric vector
Lucas Godoy
Create rigid copies of a polygon. This function an auxilliary function for the Toroidal Shift method
pre_ts(poly, bb = NULL, id_col = NULL)
pre_ts(poly, bb = NULL, id_col = NULL)
poly |
an object of class |
bb |
(optional) a unique bounding box. |
id_col |
a |
an sf
with 8 additional rigid copies of poly
.
Lucas Godoy
Studentized Integram Measure
s_im(x, h = 1)
s_im(x, h = 1)
x |
|
h |
|
numeric vector
Studentized Maximum Absolute Deviation
s_mad(x)
s_mad(x)
x |
|
numeric vector
Toroidal Shift
toroidal_shift(x, y, shifted = FALSE, unique_bb = NULL)
toroidal_shift(x, y, shifted = FALSE, unique_bb = NULL)
x |
a |
y |
a |
shifted |
|
unique_bb |
a bbox shared between both "Polygon Patterns" |
a list
Lucas Godoy
sf
object by a "point"Translate an sf
object by a "point"
translate_by_pt(pt, poly)
translate_by_pt(pt, poly)
pt |
|
poly |
|
a sf
or sfc
representing poly
shifted by pt
Lucas Godoy