Title: | Geometric Spatial Point Analysis |
---|---|
Description: | The implementation to perform the geometric spatial point analysis developed in Hernández & Solís (2022) <doi:10.1007/s00180-022-01244-1>. It estimates the geometric goodness-of-fit index for a set of variables against a response one based on the 'sf' package. The package has methods to print and plot the results. |
Authors: | Maikol Solís [aut, cre], Alberto Hernández [ctb], Carlos Pasquier [ctb] |
Maintainer: | Maikol Solís <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0 |
Built: | 2024-10-31 20:35:17 UTC |
Source: | https://github.com/maikol-solis/spatgeom |
Generate data points with the shape of a donut.
donut_data(n, a, b, theta)
donut_data(n, a, b, theta)
n |
Number of data points. |
a |
Lower bound of the second variable. |
b |
Upper bound of the second variable. |
theta |
Angle of the donut. |
A data frame with three variables. Variable 'y' is the response, variable 'x1' makes the donut shape with 'y', and 'x2' is a uniform random variable between a and b. '
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi)
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi)
Generate data points with a linear relationship.
linear_data(n = 100, a = -3, b = 3)
linear_data(n = 100, a = -3, b = 3)
n |
Number of data points. |
a , b
|
Lower and upper bound of the uniform distribution. |
A data frame with three variables. Variable 'y = 0.6 * x1 + 0.3 * x2
0.1 * x3' is the response, and 'x1', 'x2' and 'x3' are uniform random variables between a and b.
xy <- linear_data(n = 30, a = -1, b = 1)
xy <- linear_data(n = 30, a = -1, b = 1)
spatgeom
objectsPlot alpha-shape for spatgeom
objects.
plot_alpha_shape(x, alpha, font_size = 12)
plot_alpha_shape(x, alpha, font_size = 12)
x |
an object of class |
alpha |
value of |
font_size |
a integer that increases the font size in the plot. |
a ggplot
object with the raw alpha-shape for
the original data at resolution alpha
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) plot_alpha_shape(estimation, alpha = c(0.9, 1.2))
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) plot_alpha_shape(estimation, alpha = c(0.9, 1.2))
spatgeom
objectsPlot method for objects of class spatgeom
.
plot_curve(x, type = "curve", font_size = 12)
plot_curve(x, type = "curve", font_size = 12)
x |
an object of class |
type |
a string that could be |
font_size |
a integer that increases the font size in the plot. |
a ggplot
object with the geometric indices (or
its derivative). The plot is generated with the nalphas
point of
alpha
and geom_corr
from the function
spatgeom
.
In each panel, the theoretical CSR process is drawn using
exp(-intensity * pi * x^2)
. where the intensity depends on each
panel.
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) plot_curve(estimation, type = "curve") plot_curve(estimation, type = "deriv")
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) plot_curve(estimation, type = "curve") plot_curve(estimation, type = "deriv")
spatgeom
objectPrint method for objects of class spatgeom
.
## S3 method for class 'spatgeom' print(x, return_table = FALSE, ...)
## S3 method for class 'spatgeom' print(x, return_table = FALSE, ...)
x |
an object of class |
return_table |
if |
... |
further arguments passed to the |
Print the estimate given by spatgeom
.
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) print(estimation)
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) print(estimation)
Function to estimate the geometric correlation between variables.
spatgeom( x, y, scale_pts = FALSE, nalphas = 100, envelope = FALSE, domain_type = c("bounding-box", "convex-hull"), mc_cores = 1 )
spatgeom( x, y, scale_pts = FALSE, nalphas = 100, envelope = FALSE, domain_type = c("bounding-box", "convex-hull"), mc_cores = 1 )
x |
numeric matrix or data.frame of covariables. |
y |
numeric vector of responses in a model. |
scale_pts |
boolean to make the estimations with scaled variables.
Default |
nalphas |
number of alphas generated for creating the geometric measure of fit index. Default 100. |
envelope |
boolean to determine if the Monte-Carlo should be estimated.
Default |
domain_type |
character with the type of domain to use. It can be either "bounding-box" or "convex-hull". Default "bounding-box". |
mc_cores |
integer with the number of parallel process to run (if
available). Default |
A list of class spatgeom
with the following elements:
The function call.
x
input.
y
output.
A list of size ncol(x)
corresponding to each
column of x
. Each element of the list has:
a data frame of class sfc
(see
sf::st_sf()
)with columns geometry
, segments
,
max_length
and alpha
. The data.frame contains the whole
Delanauy triangulation for the corresponding column of x
and y
.
The segments
column are the segments of each individual triangle and
max_length
is the maximum length of them.
a data frame with columns alpha
and
geom_survival
. The alpha
column is a numeric vector of size
nalphas
from the minimum to the maximum distance between points
estimated in the data. The geom_survival
column is the value 1
- (alpha shape Area)/(containing box Area).
the intensity estimated for the corresponding
column of x
and y
.
the mean number of points in the point process.
a data frame in tidy format with 40 runs of a
CSR process, if envelope=TRUE
, The CSR is created by generating
n uniform points in the plane, where n is drawn from Poisson
distribution with parameter mean_n
.
Hernández, A.J., Solís, M. Geometric goodness of fit measure to detect patterns in data point clouds. Comput Stat (2022). https://doi.org/10.1007/s00180-022-01244-1
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) # If you want to estimate the envelope, you can use the envelope argument to # TRUE. This will take a while to run. ## Not run: estimation_with_envelope <- spatgeom( y = xy[, 1], x = xy[, -1], envelope = TRUE ) ## End(Not run)
xy <- donut_data(n = 30, a = -1, b = 1, theta = 2 * pi) estimation <- spatgeom(y = xy[, 1], x = xy[, -1]) # If you want to estimate the envelope, you can use the envelope argument to # TRUE. This will take a while to run. ## Not run: estimation_with_envelope <- spatgeom( y = xy[, 1], x = xy[, -1], envelope = TRUE ) ## End(Not run)