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

Description Usage Arguments Details See Also Examples

View source: R/pointsCovarModel.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 underlying spatial numeric covariate (first-order effect).
The function takes as input three datasets: a point patter (SpatialPointsDataFrame class), a covariate layer (of RasterLayer class), and a polygon feature (SpatialPolygonsDataFrame class) representing the study area and exactly matching the extent of the covariate layer. If the latter is not provided, it is internally worked out from the covariate raster and may make the whole function take a while to complete.

Usage

1
pointsCovarModel(feature, cov.var, studyplot = NULL, oneplot = FALSE)

Arguments

feature:

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

cov.var:

numeric covariate (of RasterLayer class).

studyplot:

feature (of polygon type; SpatialPolygonsDataFrame) representing the study area and exactly matching the extent of the covariate layer. If NULL, it is worked out from the covariate layer (may make the whole function take a while to complete).

oneplot:

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

Details

The function fits a inhomogeneous Poisson point process (Alternative Model-H1) with intensity of the point pattern as a loglinear function of the underlaying numerical covariate (see Baddeley et al., "Spatial Point Patterns. Methodology and Applications with R", CRC Press 2016, 307-309). 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 point pattern along with the underlaying covariate raster;

-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).

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

distCovarModel , distRandSign

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(Starbucks) #load the point dataset representing the location of Starbucks shops
data(Massachusetts) #load the polygon dataset representing the study area
data(popdensity) #load the raster representing the population density, to be used as covariate
results <- pointsCovarModel(Starbucks, popdensity, Massachusetts) #note: a warning message reporting that 4 out of 699 points
have values of the covariate undefined is expected

data(springs) #load the point dataset representing the location of springs
data(malta_polyg) #load the polygon dataset representing the study area
data(malta_dtm_40) #load the raster representing the elevation dataset, to be used as covariate
results <- pointsCovarModel(springs, malta_dtm_40, malta_polyg)

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