Learn R Programming

spatstat.explore (version 3.2-3)

spatstat.explore-package: The spatstat.explore Package

Description

The spatstat.explore package belongs to the spatstat family of packages. It contains the core functionality for statistical analysis and modelling of spatial data.

Arguments

Structure of the spatstat family

The orginal spatstat package grew to be very large. It has now been divided into several sub-packages:

  • spatstat.utils containing basic utilities

  • spatstat.sparse containing linear algebra utilities

  • spatstat.data containing datasets

  • spatstat.geom containing geometrical objects and geometrical operations

  • spatstat.explore containing the functionality for exploratory data analysis and nonparametric analysis of spatial data.

  • spatstat.model containing the functionality for statistical modelling, model-fitting, formal statistical inference and informal model diagnostics.

  • spatstat.linnet containing functions for spatial data on a linear network

  • spatstat, which simply loads the other sub-packages listed above, and provides documentation.

When you install spatstat, these sub-packages are also installed. Then if you load the spatstat package by typing library(spatstat), the other sub-packages listed above will automatically be loaded or imported.

For an overview of all the functions available in the sub-packages of spatstat, see the help file for "spatstat-package" in the spatstat package.

Additionally there are several extension packages:

  • spatstat.gui for interactive graphics

  • spatstat.local for local likelihood (including geographically weighted regression)

  • spatstat.Knet for additional, computationally efficient code for linear networks

  • spatstat.sphere (under development) for spatial data on a sphere, including spatial data on the earth's surface

The extension packages must be installed separately and loaded explicitly if needed. They also have separate documentation.

Overview of Functionality in <span class="pkg">spatstat.explore</span>

The spatstat family of packages is designed to support a complete statistical analysis of spatial data. It supports

  • creation, manipulation and plotting of point patterns;

  • exploratory data analysis;

  • spatial random sampling;

  • simulation of point process models;

  • parametric model-fitting;

  • non-parametric smoothing and regression;

  • formal inference (hypothesis tests, confidence intervals);

  • model diagnostics.

For an overview, see the help file for "spatstat-package" in the spatstat package.

Following is a list of the functionality provided in the spatstat.explore package only.

To simulate a random point pattern:

Functions for generating random point patterns are now contained in the spatstat.random package.

To interrogate a point pattern:

density.pppkernel estimation of point pattern intensity
densityHeat.pppdiffusion kernel estimation of point pattern intensity
Smooth.pppkernel smoothing of marks of point pattern
sharpen.pppdata sharpening

Manipulation of pixel images:

An object of class "im" represents a pixel image.

blurapply Gaussian blur to image
Smooth.imapply Gaussian blur to image
transect.imline transect of image
pixelcentresextract centres of pixels
rnoiserandom pixel noise

Line segment patterns

An object of class "psp" represents a pattern of straight line segments.

density.pspkernel smoothing of line segments
rpoislinegenerate a realisation of the Poisson line process inside a window

Tessellations

An object of class "tess" represents a tessellation.

rpoislinetessgenerate tessellation using Poisson line process

Three-dimensional point patterns

An object of class "pp3" represents a three-dimensional point pattern in a rectangular box. The box is represented by an object of class "box3".

runifpoint3generate uniform random points in 3-D
rpoispp3generate Poisson random points in 3-D
envelope.pp3generate simulation envelopes for 3-D pattern

Multi-dimensional space-time point patterns

An object of class "ppx" represents a point pattern in multi-dimensional space and/or time.

runifpointxgenerate uniform random points
rpoisppxgenerate Poisson random points

Classical exploratory tools:

clarkevansClark and Evans aggregation index
fryplotFry plot
miplotMorisita Index plot

Smoothing:

density.pppkernel smoothed density/intensity
relriskkernel estimate of relative risk
Smooth.pppspatial interpolation of marks
bw.digglecross-validated bandwidth selection for density.ppp
bw.ppllikelihood cross-validated bandwidth selection for density.ppp
bw.CvLCronie-Van Lieshout bandwidth selection for density estimation
bw.scottScott's rule of thumb for density estimation
bw.abramAbramson's rule for adaptive bandwidths
bw.relriskcross-validated bandwidth selection for relrisk
bw.smoothpppcross-validated bandwidth selection for Smooth.ppp
bw.fracbandwidth selection using window geometry
bw.stoyanStoyan's rule of thumb for bandwidth for pcf

Modern exploratory tools:

clustersetAllard-Fraley feature detection
nncleanByers-Raftery feature detection
sharpen.pppChoi-Hall data sharpening
rhohatKernel estimate of covariate effect
rho2hatKernel estimate of effect of two covariates
spatialcdfSpatial cumulative distribution function
rocReceiver operating characteristic curve

Summary statistics for a point pattern:

Festempty space function \(F\)
Gestnearest neighbour distribution function \(G\)
Jest\(J\)-function \(J = (1-G)/(1-F)\)
KestRipley's \(K\)-function
LestBesag \(L\)-function
TstatThird order \(T\)-function
allstatsall four functions \(F\), \(G\), \(J\), \(K\)
pcfpair correlation function
Kinhom\(K\) for inhomogeneous point patterns
Linhom\(L\) for inhomogeneous point patterns
pcfinhompair correlation for inhomogeneous patterns
Finhom\(F\) for inhomogeneous point patterns
Ginhom\(G\) for inhomogeneous point patterns
Jinhom\(J\) for inhomogeneous point patterns
localLGetis-Franklin neighbourhood density function
localKneighbourhood K-function
localpcflocal pair correlation function
localKinhomlocal \(K\) for inhomogeneous point patterns
localLinhomlocal \(L\) for inhomogeneous point patterns
localpcfinhomlocal pair correlation for inhomogeneous patterns
KsectorDirectional \(K\)-function
Kscaledlocally scaled \(K\)-function
Kest.fftfast \(K\)-function using FFT for large datasets
Kmeasurereduced second moment measure
envelopesimulation envelopes for a summary function
varblockvariances and confidence intervals
for a summary function
lohbootbootstrap for a summary function

Related facilities:

plot.fvplot a summary function
eval.fvevaluate any expression involving summary functions
harmonise.fvmake functions compatible
eval.faspevaluate any expression involving an array of functions
with.fvevaluate an expression for a summary function
Smooth.fvapply smoothing to a summary function
deriv.fvcalculate derivative of a summary function
pool.fvpool several estimates of a summary function
density.pppkernel smoothed density
densityHeat.pppdiffusion kernel smoothed density
Smooth.pppspatial interpolation of marks
relriskkernel estimate of relative risk
sharpen.pppdata sharpening
rknntheoretical distribution of nearest neighbour distance

Summary statistics for a multitype point pattern: A multitype point pattern is represented by an object X of class "ppp" such that marks(X) is a factor.

relriskkernel estimation of relative risk
scan.testspatial scan test of elevated risk
Gcross,Gdot,Gmultimultitype nearest neighbour distributions \(G_{ij}, G_{i\bullet}\)
Kcross,Kdot, Kmultimultitype \(K\)-functions \(K_{ij}, K_{i\bullet}\)
Lcross,Ldotmultitype \(L\)-functions \(L_{ij}, L_{i\bullet}\)
Jcross,Jdot,Jmultimultitype \(J\)-functions \(J_{ij}, J_{i\bullet}\)
pcfcrossmultitype pair correlation function \(g_{ij}\)
pcfdotmultitype pair correlation function \(g_{i\bullet}\)
pcfmultigeneral pair correlation function
markconnectmarked connection function \(p_{ij}\)
alltypesestimates of the above for all \(i,j\) pairs
Iestmultitype \(I\)-function
Kcross.inhom,Kdot.inhominhomogeneous counterparts of Kcross, Kdot
Lcross.inhom,Ldot.inhominhomogeneous counterparts of Lcross, Ldot
pcfcross.inhom,pcfdot.inhominhomogeneous counterparts of pcfcross, pcfdot
localKcross,localKdotlocal counterparts of Kcross, Kdot
localLcross,localLdotlocal counterparts of Lcross, Ldot
localKcross.inhom,localLcross.inhomlocal counterparts of Kcross.inhom, Lcross.inhom

Summary statistics for a marked point pattern: A marked point pattern is represented by an object X of class "ppp" with a component X$marks. The entries in the vector X$marks may be numeric, complex, string or any other atomic type. For numeric marks, there are the following functions:

markmeansmoothed local average of marks
markvarsmoothed local variance of marks
markcorrmark correlation function
markcrosscorrmark cross-correlation function
markvariomark variogram
markmarkscattermark-mark scatterplot
Kmarkmark-weighted \(K\) function
Emarkmark independence diagnostic \(E(r)\)
Vmarkmark independence diagnostic \(V(r)\)
nnmeannearest neighbour mean index
nnvarionearest neighbour mark variance index

For marks of any type, there are the following:

Gmultimultitype nearest neighbour distribution
Kmultimultitype \(K\)-function
Jmultimultitype \(J\)-function

Alternatively use cut.ppp to convert a marked point pattern to a multitype point pattern.

Programming tools:

marktabletabulate the marks of neighbours in a point pattern

Summary statistics for a three-dimensional point pattern:

These are for 3-dimensional point pattern objects (class pp3).

F3estempty space function \(F\)
G3estnearest neighbour function \(G\)
K3est\(K\)-function
pcf3estpair correlation function

Related facilities:

envelope.pp3simulation envelopes

Summary statistics for random sets:

These work for point patterns (class ppp), line segment patterns (class psp) or windows (class owin).

Hestspherical contact distribution \(H\)
GfoxFoxall \(G\)-function
JfoxFoxall \(J\)-function

Model fitting

Functions for fitting point process models are now contained in the spatstat.model package.

Simulation

There are many ways to generate a random point pattern, line segment pattern, pixel image or tessellation in spatstat.

Random point patterns: Functions for random generation are now contained in the spatstat.random package.

See also varblock for estimating the variance of a summary statistic by block resampling, and lohboot for another bootstrap technique.

Fitted point process models:

If you have fitted a point process model to a point pattern dataset, the fitted model can be simulated.

Methods for simulating a fitted model are now contained in the spatstat.model package.

Other random patterns: Functions for random generation are now contained in the spatstat.random package.

Simulation-based inference

envelopecritical envelope for Monte Carlo test of goodness-of-fit
bits.envelopecritical envelope for balanced two-stage Monte Carlo test
qqplot.ppmdiagnostic plot for interpoint interaction
scan.testspatial scan statistic/test
studpermu.teststudentised permutation test
segregation.testtest of segregation of types

Hypothesis tests:

quadrat.test\(\chi^2\) goodness-of-fit test on quadrat counts
clarkevans.testClark and Evans test
cdf.testSpatial distribution goodness-of-fit test
berman.testBerman's goodness-of-fit tests
envelopecritical envelope for Monte Carlo test of goodness-of-fit
scan.testspatial scan statistic/test
dclf.testDiggle-Cressie-Loosmore-Ford test
mad.testMean Absolute Deviation test
anova.ppmAnalysis of Deviance for point process models

More recently-developed tests:

dg.testDao-Genton test
bits.testBalanced independent two-stage test
dclf.progressProgress plot for DCLF test
mad.progressProgress plot for MAD test

Model diagnostics:

Classical measures of model sensitivity such as leverage and influence, and classical model diagnostic tools such as residuals, partial residuals, and effect estimates, have been adapted to point process models. These capabilities are now provided in the spatstat.model package.

Resampling and randomisation procedures

You can build your own tests based on randomisation and resampling using the following capabilities:

quadratresampleblock resampling
rshiftrandom shifting of (subsets of) points
rthinrandom thinning

Licence

This library and its documentation are usable under the terms of the "GNU General Public License", a copy of which is distributed with the package.

Author

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

Acknowledgements

Kasper Klitgaard Berthelsen, Ottmar Cronie, Tilman Davies, Julian Gilbey, Yongtao Guan, Ute Hahn, Kassel Hingee, Abdollah Jalilian, Marie-Colette van Lieshout, Greg McSwiggan, Tuomas Rajala, Suman Rakshit, Dominic Schuhmacher, Rasmus Waagepetersen and Hangsheng Wang made substantial contributions of code.

For comments, corrections, bug alerts and suggestions, we thank Monsuru Adepeju, Corey Anderson, Ang Qi Wei, Ryan Arellano, Jens Astrom, Robert Aue, Marcel Austenfeld, Sandro Azaele, Malissa Baddeley, Guy Bayegnak, Colin Beale, Melanie Bell, Thomas Bendtsen, Ricardo Bernhardt, Andrew Bevan, Brad Biggerstaff, Anders Bilgrau, Leanne Bischof, Christophe Biscio, Roger Bivand, Jose M. Blanco Moreno, Florent Bonneu, Jordan Brown, Ian Buller, Julian Burgos, Simon Byers, Ya-Mei Chang, Jianbao Chen, Igor Chernayavsky, Y.C. Chin, Bjarke Christensen, Lucia Cobo Sanchez, Jean-Francois Coeurjolly, Kim Colyvas, Hadrien Commenges, Rochelle Constantine, Robin Corria Ainslie, Richard Cotton, Marcelino de la Cruz, Peter Dalgaard, Mario D'Antuono, Sourav Das, Peter Diggle, Patrick Donnelly, Ian Dryden, Stephen Eglen, Ahmed El-Gabbas, Belarmain Fandohan, Olivier Flores, David Ford, Peter Forbes, Shane Frank, Janet Franklin, Funwi-Gabga Neba, Oscar Garcia, Agnes Gault, Jonas Geldmann, Marc Genton, Shaaban Ghalandarayeshi, Jason Goldstick, Pavel Grabarnik, C. Graf, Ute Hahn, Andrew Hardegen, Martin Bogsted Hansen, Martin Hazelton, Juha Heikkinen, Mandy Hering, Markus Herrmann, Maximilian Hesselbarth, Paul Hewson, Hamidreza Heydarian, Kurt Hornik, Philipp Hunziker, Jack Hywood, Ross Ihaka, Cenk Icos, Aruna Jammalamadaka, Robert John-Chandran, Devin Johnson, Mahdieh Khanmohammadi, Bob Klaver, Lily Kozmian-Ledward, Peter Kovesi, Mike Kuhn, Jeff Laake, Robert Lamb, Frederic Lavancier, Tom Lawrence, Tomas Lazauskas, Jonathan Lee, George Leser, Angela Li, Li Haitao, George Limitsios, Andrew Lister, Nestor Luambua, Ben Madin, Martin Maechler, Kiran Marchikanti, Jeff Marcus, Robert Mark, Peter McCullagh, Monia Mahling, Jorge Mateu Mahiques, Ulf Mehlig, Frederico Mestre, Sebastian Wastl Meyer, Mi Xiangcheng, Lore De Middeleer, Robin Milne, Enrique Miranda, Jesper Moller, Annie Mollie, Ines Moncada, Mehdi Moradi, Virginia Morera Pujol, Erika Mudrak, Gopalan Nair, Nader Najari, Nicoletta Nava, Linda Stougaard Nielsen, Felipe Nunes, Jens Randel Nyengaard, Jens Oehlschlaegel, Thierry Onkelinx, Sean O'Riordan, Evgeni Parilov, Jeff Picka, Nicolas Picard, Tim Pollington, Mike Porter, Sergiy Protsiv, Adrian Raftery, Ben Ramage, Pablo Ramon, Xavier Raynaud, Nicholas Read, Matt Reiter, Ian Renner, Tom Richardson, Brian Ripley, Ted Rosenbaum, Barry Rowlingson, Jason Rudokas, Tyler Rudolph, John Rudge, Christopher Ryan, Farzaneh Safavimanesh, Aila Sarkka, Cody Schank, Katja Schladitz, Sebastian Schutte, Bryan Scott, Olivia Semboli, Francois Semecurbe, Vadim Shcherbakov, Shen Guochun, Shi Peijian, Harold-Jeffrey Ship, Tammy L Silva, Ida-Maria Sintorn, Yong Song, Malte Spiess, Mark Stevenson, Kaspar Stucki, Jan Sulavik, Michael Sumner, P. Surovy, Ben Taylor, Thordis Linda Thorarinsdottir, Leigh Torres, Berwin Turlach, Torben Tvedebrink, Kevin Ummer, Medha Uppala, Andrew van Burgel, Tobias Verbeke, Mikko Vihtakari, Alexendre Villers, Fabrice Vinatier, Maximilian Vogtland, Sasha Voss, Sven Wagner, Hao Wang, H. Wendrock, Jan Wild, Carl G. Witthoft, Selene Wong, Maxime Woringer, Luke Yates, Mike Zamboni and Achim Zeileis.

Details

spatstat is a family of R packages for the statistical analysis of spatial data. Its main focus is the analysis of spatial patterns of points in two-dimensional space.

The original spatstat package has now been split into several sub-packages.

This sub-package spatstat.explore contains the user-level functions that perform exploratory data analysis and nonparametric data analysis of spatial data.

(The main exception is that functions for linear networks are in the separate sub-package spatstat.linnet.)