distCovarModel: R function to model (and test) the dependence of a point...

Description Usage Arguments Details See Also Examples

View source: R/distCovarModel.R

Description

The function is a wrapper for a number of functions out of the extremely useful 'spatstat' package (specifically, ppm(), cdf.test(), auc(), roc(), effectfun()). It allows to test if there is a significant dependence of the input point pattern on a spatial covariate (first-order effect), the latter being the distance to another feature (of either point or line type).
The function takes as input two datasets: a point patter (SpatialPointsDataFrame class) and a feature (either SpatialPointsDataFrame or SpatialLinesDataFrame class) the distance to which is used as spatial covariate for the input point pattern.

Usage

1
2
distCovarModel(feature, cov.var, studyplot = NULL, buffer = 0,
  Foxall = FALSE, oneplot = FALSE)

Arguments

feature:

feature (of point type; SpatialPointsDataFrame class) representing the spatial point pattern of interest.

cov.var:

feature (of either point or line type; SpatialPointsDataFrame or SpatialLinesDataFrame class) the distance to which represents the spatial covariate.

studyplot:

feature (of polygon type; SpatialPolygonsDataFrame) representing the study area; if not provided, the study area is internally worked out as the bounding polygon based on the union the convex hulls of the feature and of the cov.var data.

buffer:

add a buffer to the convex hull of the study area (0 by default); the unit depends upon the units of the input data.

oneplot:

set to TRUE (default), will plot the charts into a single visualization.

Foxall:

set to TRUE, will plot the Foxall's J function.

Details

The function fits a inhomogeneous Poisson point process (Alternative Model-H1) with the distance to the second feature entered by the user ('cov.var' parameter) used as spatial covariate. In other words, the fitted alternative model is a Poisson point process with intensity of the point pattern as a loglinear function of the distance to the second pattern entered by the user (see Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 309-313). The distance to the second feature is internally calculated via the spatstat's 'distfun()' function.

Also, the function fits a homogeneous Poisson point model (Null Model-H0, equivalent to Complete Spatial Randomness: Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 305-306), that is used as comparison for the inhomogeneous point process model in a Likelihood Ratio test (Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 334-335). A significant result, i.e. a low p-value, suggests rejecting the Null Hypothesis of CSR in favour of the Alternative Hypothesis of a Poisson point process affected by a covariate effect (i.e., inhomogeneous intensity due to the influence of the covariate) (Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 305).

The function returns a 4 plots, which can be arranged in just one visualization setting the parameter oneplot to TRUE:

-plot of the study area along with the point pattern of interest and the second feature entered by the user (whose distance is the spatial covariate);

-plot of the fitted intensity against the spatial covariate (Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 308);

-plot of the cumulative distribution of the covariate at the data points against the cumulative distribution of the covariate at all the spatial location within the study area (rationale: Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 184-185);

-plot of the ROC curve, which help assessing the strenght of the dependence on the covariate (Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 187-188).

Setting the parameter Foxall to TRUE, the third plot will be replaced by the chart of the Foxall's J function, which is another "useful statistic" when the covariate is the distance to a spatial pattern (Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 187, 282-284). Values of J are uqual to 1 when the two patterns are independent random patterns; values <1 indicate that the input point pattern tends to be closer to the cov.var pattern than expected for random points; values >1 indicate that the input point pattern avoid the cov.var pattern, i.e. the point pattern is more likely than random points to lie far away from the cov.var pattern (see Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 284).

A list is also returned, containing what follows:

-$H0-model: info and relevant statistics regarding the Null Model;
-$H1-model: info and relevant statistics regarding the Alternative Model;
-$Model comparison (LRT): results of the Likelihood Ratio test;
-$AIC-H0: AIC of the Null Model;
-$AIC-H1: AIC of the Atlernative Model;
-$KS test: information regarding the cumulative distribution comparison via Kolmogorov-Smirnov test;
-$AUC: the AUC statistics.

See Also

distRandSign , Aindex , pointsCovarModel

Examples

1
2
3
4
data(faults) #load the polyline dataset representing geological faultilines, the distance to which is used as spatial covariate
data(springs) #load the point dataset representing springs location
data(malta_polyg) # load the polygon representing the study area
results <- distCovarModel(springs, faults, malta_polyg) #perform the analysis

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