NNa: R function for Nearest Neighbor analysis of point patterns

Description Usage Arguments Details See Also Examples

View source: R/NNa.R

Description

The function allows to perform the Nearest Neighbor analysis of point patterns to formally test for the presence of a clustered, dispersed, or random spatial arrangement (second-order effect). It also allows to control for a first-order effect (i.e., influence of an underlaying numerical covariate) while performing the analysis. The covariate must be of RasterLayer class. Significance is assessed via a randomized approach.

Usage

1
2
NNa(feature, studyplot = NULL, buffer = 0, B = 199, cov.var = NULL,
  addmap = TRUE)

Arguments

feature:

feature dataset (of point type; SpatialPointsDataFrame class).

studyplot:

shapefile (of polygon type; SpatialPolygonsDataFrame class) representing the study area; if not provided, the study area is internally worked out as the convex hull enclosing the input feature dataset.

buffer:

add a buffer to the studyplot (0 by default); the unit depends upon the units of the input data.

cov.var:

numeric covariate (of RasterLayer class).

B:

number of randomizations to be used (199 by default).

addmap:

TRUE (default) or FALSE if the user wants or does not want a map of the study area and of feature dataset to be also displayed.

Details

The function uses a randomized approach to test the significance of the Clark-Evans R statistic: the observed R value is set against the distribution of R values computed across B iterations (199 by default) in which a set of random points (with a sample size equal to the number of points of the input feature) is drawn and the statistic recomputed.

The function produces a histogram of the randomized R values, with a black dot indicating the observed value and a hollow dot representing the average of the randomized R values. P-values (computed following Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, p. 387), are reported at the bottom of the same chart. Two reference lines represent the two tails of the randomized distribution (left tail, indicating a significant clustered pattern; right tail, indicating a significant dispersed pattern).

The function also returns a list storing the following:
-$obs.NN.dist: observed NN distances;
-$obs.R: observed R value;
-$aver.rand.R: average randomized R;
-$p.value clustered: p-value for a clustered pattern;
-$p.value.dispersed: p-value for a dispersed pattern;
-$p.value.diff.from.random: p-value for a pattern different from random.

See Also

refNNa

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
data(springs)
res <- NNa(springs) #perform the analysis using all default values; the result points to a significant clustering

data(springs)
data(malta_polyg)
res <- NNa(springs, studyplot=malta_polyg) #same as above but using a polygon (SpatialPolygonsDataFrame) as studyplot

data(rndpoints)
res <- NNa(rndpoints, buffer=100, B=999) #perform the analysis using the 'rndpoints' dataset, add a 100m buffer arounf the points' convexhull, and use 499 iterations; the result points to a random arrangement

data(Starbucks)
data(popdensity)
res <- NNa(Starbucks, cov.var=popdensity)  #perform the analysis, while controlling for the effect of the population density covariate

gianmarcoalberti/GmAMisc documentation built on May 3, 2019, 6:44 p.m.