Type: | Package |
Title: | Spatial Association of Different Types of Polygon |
Version: | 0.8.0 |
Date: | 2024-10-02 |
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. |
License: | GPL (≥ 3) |
Encoding: | UTF-8 |
SystemRequirements: | GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0) |
Imports: | sf, methods, stats |
Depends: | R (≥ 4.0) |
URL: | https://github.com/lcgodoy/sapo/ |
BugReports: | https://github.com/lcgodoy/sapo/issues/ |
RoxygenNote: | 7.3.2 |
Language: | en-US |
Suggests: | knitr, rmarkdown |
VignetteBuilder: | knitr |
NeedsCompilation: | no |
Packaged: | 2024-10-08 22:13:31 UTC; lcgodoy |
Author: | Lucas da Cunha Godoy
|
Maintainer: | Lucas da Cunha Godoy <lcgodoy@duck.com> |
Repository: | CRAN |
Date/Publication: | 2024-10-11 08:20:02 UTC |
h_{12}(t)
from matrix
Description
Computes the h_{12}
(K or L) based on a distance matrix
based on a method
Usage
calc_h(x, var_st = FALSE, dists = NULL)
Arguments
x |
distance matrix |
var_st |
logical scalar indicating if the L function should be used instead |
dists |
vector of distances to compute |
Value
a numeric vector
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 |
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 |
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
orL
) 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
Create jumps for random movements
Description
Create jumps for random movements
Usage
create_jump(unique_bb)
Arguments
unique_bb |
a bbox shared between both "Polygon Patterns" |
Details
This is an internal function.
Value
a sfc
object representing a random jump or shift.
Author(s)
Lucas Godoy
Fix distance matrix containing broken polygons
Description
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.
Usage
fix_dist(x, method = "rnd_poly")
Arguments
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" |
Value
a distance matrix
h_{12}(t)
from polygons
Description
Computes the h_{12}
(K or L) based on a distance matrix
based on a method
Usage
h_func(
p1,
p2,
hausdorff = TRUE,
method = "rnd_poly",
var_st = FALSE,
dists = NULL
)
h_func.list(x, ...)
Arguments
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 |
Value
a numeric vector
ID aware distance matrix
Description
Distance between polygons accounting for toroidal shift.
Usage
iadist(p1, p2, hausdorff = TRUE, method = "rnd_poly")
Arguments
p1 |
a |
p2 |
a |
hausdorff |
|
method |
method for "fixing" the distance matrix. |
Value
a distance matrix.
Author(s)
Lucas Godoy
Integram Measure
Description
Integram Measure
Usage
im(x, h = 1)
Arguments
x |
|
h |
|
Value
numeric vector
Integram Measure with Assimetry Correction
Description
Integram Measure with Assimetry Correction
Usage
im_ac(x, h = 1)
Arguments
x |
|
h |
|
Value
numeric vector
Maximum Absolute Deviation
Description
Maximum Absolute Deviation
Usage
mad(x)
Arguments
x |
|
Value
numeric vector
Maximum Absolute Deviation with Assimetry Correction
Description
Maximum Absolute Deviation with Assimetry Correction
Usage
mad_ac(x)
Arguments
x |
|
Value
numeric vector
auxiliary mean
Description
aux function to calculate the mean of a vector when removing each of its elements one by one.
Usage
mean_aux(x)
Arguments
x |
a numeric vector |
Value
a numeric vector
Author(s)
Lucas Godoy
Pre-TS
Description
Create rigid copies of a polygon. This function an auxilliary function for the Toroidal Shift method
Usage
pre_ts(poly, bb = NULL, id_col = NULL)
Arguments
poly |
an object of class |
bb |
(optional) a unique bounding box. |
id_col |
a |
Value
an sf
with 8 additional rigid copies of poly
.
Author(s)
Lucas Godoy
Studentized Integram Measure
Description
Studentized Integram Measure
Usage
s_im(x, h = 1)
Arguments
x |
|
h |
|
Value
numeric vector
Studentized Maximum Absolute Deviation
Description
Studentized Maximum Absolute Deviation
Usage
s_mad(x)
Arguments
x |
|
Value
numeric vector
sapo: Spatial Association of Polygon Types
Description
sapo: Spatial Association of Polygon Types
Toroidal Shift
Description
Toroidal Shift
Usage
toroidal_shift(x, y, shifted = FALSE, unique_bb = NULL)
Arguments
x |
a |
y |
a |
shifted |
|
unique_bb |
a bbox shared between both "Polygon Patterns" |
Value
a list
Author(s)
Lucas Godoy
Translate an sf
object by a "point"
Description
Translate an sf
object by a "point"
Usage
translate_by_pt(pt, poly)
Arguments
pt |
|
poly |
|
Value
a sf
or sfc
representing poly
shifted by pt
Author(s)
Lucas Godoy