Learn R Programming

spatstat (version 3.0-8)

spatstat-package: The Spatstat Package

Description

This is a summary of the features of spatstat, a family of R packages for the statistical analysis of spatial point patterns.

Arguments

Getting Started

For a quick introduction to spatstat, read the package vignette Getting started with spatstat installed with spatstat. To read that document, you can either

Once you have installed spatstat, start R and type library(spatstat). Then type beginner for a beginner's introduction, or demo(spatstat) for a demonstration of the package's capabilities.

For a complete course on spatstat, and on statistical analysis of spatial point patterns, read the book by Baddeley, Rubak and Turner (2015). Other recommended books on spatial point process methods are Diggle (2014), Gelfand et al (2010) and Illian et al (2008).

The spatstat package includes over 50 datasets, which can be useful when learning the package. Type demo(data) to see plots of all datasets available in the package. Type vignette('datasets') for detailed background information on these datasets, and plots of each dataset.

For information on converting your data into spatstat format, read Chapter 3 of Baddeley, Rubak and Turner (2015). This chapter is available free online, as one of the sample chapters at the book companion website, https://book.spatstat.org/.

Structure of the spatstat family

The original 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 functionality for geometrical operations, and defining the main classes of spatial objects

  • spatstat.explore containing the main functions for exploratory analysis of spatial data

  • spatstat.model containing the main functions for parametric statistical modelling and analysis, and formal inference, for spatial data

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

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

The breakup has been done in such a way that the user should not notice any difference. Source code that worked with the old spatstat package should work with the new spatstat family. Code that is documented in our books, journal articles and vignettes should still work.

When you install spatstat, the sub-packages listed above 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.

This help file covers all the functionality and datasets that are provided in the sub-packages listed above.

Extension packages

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.

Updates

New versions of spatstat are released every 8 weeks. Users are advised to update their installation of spatstat regularly.

Type latest.news to read the news documentation about changes to the current installed version of spatstat.

See the Vignette Summary of recent updates, installed with spatstat, which describes the main changes to spatstat since the book (Baddeley, Rubak and Turner, 2015) was published. It is accessible as vignette('updates').

Type news(package="spatstat") to read news documentation about all previous versions of the package.

FUNCTIONS AND DATASETS

Following is a summary of the main functions and datasets in the spatstat package. Alternatively an alphabetical list of all functions and datasets is available by typing library(help=spatstat).

For further information on any of these, type help(name) or ?name where name is the name of the function or dataset.

CONTENTS:

I.Creating and manipulating data
II.Exploratory Data Analysis
III.Model fitting (Cox and cluster models)
IV.Model fitting (Poisson and Gibbs models)
V.Model fitting (determinantal point processes)
VI.Model fitting (spatial logistic regression)
VII.Simulation
VIII.Tests and diagnostics
IX.Documentation

I. CREATING AND MANIPULATING DATA

Types of spatial data:

The main types of spatial data supported by spatstat are:

ppppoint pattern
owinwindow (spatial region)
impixel image
pspline segment pattern
tesstessellation
pp3three-dimensional point pattern
ppxpoint pattern in any number of dimensions
lpppoint pattern on a linear network

To create a point pattern:

pppcreate a point pattern from \((x,y)\) and window information
ppp(x, y, xlim, ylim) for rectangular window
ppp(x, y, poly) for polygonal window
ppp(x, y, mask) for binary image window
as.pppconvert other types of data to a ppp object
clickpppinteractively add points to a plot
marks<-, %mark%attach/reassign marks to a point pattern

To simulate a random point pattern:

runifpointgenerate \(n\) independent uniform random points
rpointgenerate \(n\) independent random points
rmpointgenerate \(n\) independent multitype random points
rpoisppsimulate the (in)homogeneous Poisson point process
rmpoisppsimulate the (in)homogeneous multitype Poisson point process
runifdiscgenerate \(n\) independent uniform random points in disc
rstratstratified random sample of points
rsystsystematic random sample of points
rjitterapply random displacements to points in a pattern
rMaternIsimulate the Matern Model I inhibition process
rMaternIIsimulate the Matern Model II inhibition process
rSSIsimulate Simple Sequential Inhibition process
rStrausssimulate Strauss process (perfect simulation)
rHardcoresimulate Hard Core process (perfect simulation)
rStraussHardsimulate Strauss-hard core process (perfect simulation)
rDiggleGrattonsimulate Diggle-Gratton process (perfect simulation)
rDGSsimulate Diggle-Gates-Stibbard process (perfect simulation)
rPenttinensimulate Penttinen process (perfect simulation)
rNeymanScottsimulate a general Neyman-Scott process
rPoissonClustersimulate a general Poisson cluster process
rMatClustsimulate the Matern Cluster process
rThomassimulate the Thomas process
rGaussPoissonsimulate the Gauss-Poisson cluster process
rCauchysimulate Neyman-Scott Cauchy cluster process
rVarGammasimulate Neyman-Scott Variance Gamma cluster process
rthinrandom thinning
rcellsimulate the Baddeley-Silverman cell process
rmhsimulate Gibbs point process using Metropolis-Hastings
simulate.ppmsimulate Gibbs point process using Metropolis-Hastings
runifpointOnLinesgenerate \(n\) random points along specified line segments
rpoisppOnLinesgenerate Poisson random points along specified line segments

To randomly change an existing point pattern:

rshiftrandom shifting of points
rjitterapply random displacements to points in a pattern
rthinrandom thinning
rlabelrandom (re)labelling of a multitype point pattern
quadratresampleblock resampling

Standard point pattern datasets:

Datasets in spatstat are lazy-loaded, so you can simply type the name of the dataset to use it; there is no need to type data(amacrine) etc.

Type demo(data) to see a display of all the datasets installed with the package.

Type vignette('datasets') for a document giving an overview of all datasets, including background information, and plots.

amacrineAustin Hughes' rabbit amacrine cells
anemonesUpton-Fingleton sea anemones data
antsHarkness-Isham ant nests data
bdspotsBreakdown spots in microelectrodes
beiTropical rainforest trees
betacellsWaessle et al. cat retinal ganglia data
bramblecanesBramble Canes data
bronzefilterBronze Filter Section data
cellsCrick-Ripley biological cells data
chicagoChicago crimes
chorleyChorley-Ribble cancer data
clmfiresCastilla-La Mancha forest fires
copperBerman-Huntington copper deposits data
dendriteDendritic spines
demohyperSynthetic point patterns
demopatSynthetic point pattern
finpinesFinnish Pines data
fluInfluenza virus proteins
gordonPeople in Gordon Square, London
gorillasGorilla nest sites
hamsterAherne's hamster tumour data
humbersideNorth Humberside childhood leukaemia data
hyytialaMixed forest in Hyytiala, Finland
japanesepinesJapanese Pines data
lansingLansing Woods data
longleafLongleaf Pines data
mucosaCells in gastric mucosa
murchisonMurchison gold deposits
nbfiresNew Brunswick fires data
nztreesMark-Esler-Ripley trees data
osteoOsteocyte lacunae (3D, replicated)
paracouKimboto trees in Paracou, French Guiana
ponderosaGetis-Franklin ponderosa pine trees data
pyramidalPyramidal neurons from 31 brains
redwoodStrauss-Ripley redwood saplings data
redwoodfullStrauss redwood saplings data (full set)
residualspaperData from Baddeley et al (2005)
shapleyGalaxies in an astronomical survey
simdatSimulated point pattern (inhomogeneous, with interaction)
spidersSpider webs on mortar lines of brick wall
sporophoresMycorrhizal fungi around a tree
sprucesSpruce trees in Saxonia
swedishpinesStrand-Ripley Swedish pines data
urkiolaUrkiola Woods data
wakaTrees in Waka national park
waterstridersInsects on water surface

To manipulate a point pattern:

plot.pppplot a point pattern (e.g. plot(X))
spatstat.gui::iplotplot a point pattern interactively
edit.pppinteractive text editor
[.pppextract or replace a subset of a point pattern
pp[subset] or pp[subwindow]
subset.pppextract subset of point pattern satisfying a condition
superimposecombine several point patterns
by.pppapply a function to sub-patterns of a point pattern
cut.pppclassify the points in a point pattern
split.pppdivide pattern into sub-patterns
unmarkremove marks
npointscount the number of points
coordsextract coordinates, change coordinates
marksextract marks, change marks or attach marks
rotaterotate pattern
shift translate pattern
flipxy swap \(x\) and \(y\) coordinates
reflect reflect in the origin
periodify make several translated copies
affineapply affine transformation
scalardilateapply scalar dilation
density.pppkernel estimation of point pattern intensity
densityHeat.pppdiffusion kernel estimation of point pattern intensity
Smooth.pppkernel smoothing of marks of point pattern
nnmarkmark value of nearest data point
sharpen.pppdata sharpening
identify.pppinteractively identify points
unique.pppremove duplicate points
duplicated.pppdetermine which points are duplicates
uniquemap.pppmap duplicated points to unique points
connected.pppfind clumps of points
dirichletcompute Dirichlet-Voronoi tessellation
delaunaycompute Delaunay triangulation
delaunayDistancegraph distance in Delaunay triangulation
convexhullcompute convex hull
discretisediscretise coordinates
pixellate.pppapproximate point pattern by pixel image
as.im.pppapproximate point pattern by pixel image

See spatstat.options to control plotting behaviour.

To create a window:

An object of class "owin" describes a spatial region (a window of observation).

owinCreate a window object
owin(xlim, ylim) for rectangular window
owin(poly) for polygonal window
owin(mask) for binary image window
WindowExtract window of another object
FrameExtract the containing rectangle ('frame') of another object
as.owinConvert other data to a window object
squaremake a square window
discmake a circular window
ellipsemake an elliptical window
riprasRipley-Rasson estimator of window, given only the points
convexhullcompute convex hull of something
letterRpolygonal window in the shape of the R logo
clickpolyinteractively draw a polygonal window
clickboxinteractively draw a rectangle

To manipulate a window:

plot.owinplot a window.
plot(W)
boundingboxFind a tight bounding box for the window
erosionerode window by a distance r
dilationdilate window by a distance r
closingclose window by a distance r
openingopen window by a distance r
borderdifference between window and its erosion/dilation
complement.owininvert (swap inside and outside)
simplify.owinapproximate a window by a simple polygon
rotaterotate window
flipxyswap \(x\) and \(y\) coordinates
shift translate window
periodify make several translated copies
affineapply affine transformation
as.data.frame.owinconvert window to data frame

Digital approximations:

as.maskMake a discrete pixel approximation of a given window
as.im.owinconvert window to pixel image
pixellate.owinconvert window to pixel image
commonGridfind common pixel grid for windows
nearest.raster.pointmap continuous coordinates to raster locations
raster.xraster x coordinates
raster.yraster y coordinates
raster.xyraster x and y coordinates
as.polygonalconvert pixel mask to polygonal window

See spatstat.options to control the approximation

Geometrical computations with windows:

edgesextract boundary edges
intersect.owinintersection of two windows
union.owinunion of two windows
setminus.owinset subtraction of two windows
inside.owindetermine whether a point is inside a window
area.owincompute area
perimetercompute perimeter length
diameter.owincompute diameter
incirclefind largest circle inside a window
inradiusradius of incircle
connected.owinfind connected components of window
eroded.areascompute areas of eroded windows
dilated.areascompute areas of dilated windows
bdist.pointscompute distances from data points to window boundary
bdist.pixelscompute distances from all pixels to window boundary
bdist.tilesboundary distance for each tile in tessellation
distmap.owindistance transform image
distfun.owindistance transform
centroid.owincompute centroid (centre of mass) of window
is.subset.owindetermine whether one window contains another
is.convexdetermine whether a window is convex
convexhullcompute convex hull
triangulate.owindecompose into triangles
as.maskpixel approximation of window
as.polygonalpolygonal approximation of window
is.rectangletest whether window is a rectangle
is.polygonaltest whether window is polygonal
is.masktest whether window is a mask
setcovspatial covariance function of window
pixelcentresextract centres of pixels in mask
clickdistmeasure distance between two points clicked by user

Pixel images: An object of class "im" represents a pixel image. Such objects are returned by some of the functions in spatstat including Kmeasure, setcov and density.ppp.

imcreate a pixel image
as.imconvert other data to a pixel image
pixellateconvert other data to a pixel image
as.matrix.imconvert pixel image to matrix
as.data.frame.imconvert pixel image to data frame
as.function.imconvert pixel image to function
plot.implot a pixel image on screen as a digital image
contour.imdraw contours of a pixel image
persp.imdraw perspective plot of a pixel image
rgbimcreate colour-valued pixel image
hsvimcreate colour-valued pixel image
[.imextract a subset of a pixel image
[<-.imreplace a subset of a pixel image
rotate.imrotate pixel image
shift.imapply vector shift to pixel image
affine.imapply affine transformation to image
Xprint very basic information about image X
summary(X)summary of image X
hist.imhistogram of image
mean.immean pixel value of image
integral.imintegral of pixel values
quantile.imquantiles of image
cut.imconvert numeric image to factor image
is.imtest whether an object is a pixel image
interp.iminterpolate a pixel image
blurapply Gaussian blur to image
Smooth.imapply Gaussian blur to image
connected.imfind connected components
compatible.imtest whether two images have compatible dimensions
harmonise.immake images compatible
commonGridfind a common pixel grid for images
eval.imevaluate any expression involving images
im.applyevaluate a function of several images
scaletointervalrescale pixel values
zapsmall.imset very small pixel values to zero
levelsetlevel set of an image
solutionsetregion where an expression is true
imcovspatial covariance function of image
convolve.imspatial convolution of images
transect.imline transect of image
pixelcentresextract centres of pixels
transmatconvert matrix of pixel values
to a different indexing convention
rnoiserandom pixel noise

Line segment patterns

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

pspcreate a line segment pattern
as.pspconvert other data into a line segment pattern
edgesextract edges of a window
is.pspdetermine whether a dataset has class "psp"
plot.pspplot a line segment pattern
print.pspprint basic information
summary.pspprint summary information
[.pspextract a subset of a line segment pattern
subset.pspextract subset of line segment pattern
as.data.frame.pspconvert line segment pattern to data frame
marks.pspextract marks of line segments
marks<-.pspassign new marks to line segments
unmark.pspdelete marks from line segments
midpoints.pspcompute the midpoints of line segments
endpoints.pspextract the endpoints of line segments
lengths_pspcompute the lengths of line segments
angles.pspcompute the orientation angles of line segments
superimposecombine several line segment patterns
flipxyswap \(x\) and \(y\) coordinates
rotate.psprotate a line segment pattern
shift.pspshift a line segment pattern
periodifymake several shifted copies
affine.pspapply an affine transformation
pixellate.pspapproximate line segment pattern by pixel image
psp2maskapproximate line segment pattern by binary mask
distmap.pspcompute the distance map of a line segment pattern
distfun.pspcompute the distance map of a line segment pattern
density.pspkernel smoothing of line segments
selfcrossing.pspfind crossing points between line segments
selfcut.pspcut segments where they cross
crossing.pspfind crossing points between two line segment patterns
extrapolate.pspextrapolate line segments to infinite lines
nncrossfind distance to nearest line segment from a given point
nearestsegmentfind line segment closest to a given point
project2segmentfind location along a line segment closest to a given point
pointsOnLinesgenerate points evenly spaced along line segment
rpoislinegenerate a realisation of the Poisson line process inside a window
rlinegridgenerate a random array of parallel lines through a window

Tessellations

An object of class "tess" represents a tessellation.

tesscreate a tessellation
quadratscreate a tessellation of rectangles
hextesscreate a tessellation of hexagons
polartesstessellation using polar coordinates
quantessquantile tessellation
venn.tessVenn diagram tessellation
dirichletcompute Dirichlet-Voronoi tessellation of points
delaunaycompute Delaunay triangulation of points
as.tessconvert other data to a tessellation
plot.tessplot a tessellation
tilesextract all the tiles of a tessellation
[.tessextract some tiles of a tessellation
[<-.tesschange some tiles of a tessellation
intersect.tessintersect two tessellations
or restrict a tessellation to a window
chop.tesssubdivide a tessellation by a line
rpoislinetessgenerate tessellation using Poisson line process
tile.areasarea of each tile in tessellation
bdist.tilesboundary distance for each tile in tessellation
connected.tessfind connected components of tiles
shift.tessshift a tessellation
rotate.tessrotate a tessellation
reflect.tessreflect about the origin
flipxy.tessreflect about the diagonal
affine.tessapply affine transformation

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

pp3create a 3-D point pattern
plot.pp3plot a 3-D point pattern
coordsextract coordinates
as.hyperframeextract coordinates
subset.pp3extract subset of 3-D point pattern
unitname.pp3name of unit of length
npointscount the number of points
runifpoint3generate uniform random points in 3-D
rpoispp3generate Poisson random points in 3-D
envelope.pp3generate simulation envelopes for 3-D pattern
box3create a 3-D rectangular box
as.box3convert data to 3-D rectangular box
unitname.box3name of unit of length
diameter.box3diameter of box
volume.box3volume of box
shortside.box3shortest side of box
eroded.volumesvolumes of erosions of box

Multi-dimensional space-time point patterns

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

ppxcreate a multidimensional space-time point pattern
coordsextract coordinates
as.hyperframeextract coordinates
subset.ppxextract subset
unitname.ppxname of unit of length
npointscount the number of points
runifpointxgenerate uniform random points
rpoisppxgenerate Poisson random points
boxxdefine multidimensional box
diameter.boxxdiameter of box
volume.boxxvolume of box
shortside.boxxshortest side of box
eroded.volumes.boxxvolumes of erosions of box

Point patterns on a linear network

An object of class "linnet" represents a linear network (for example, a road network).

linnetcreate a linear network
clickjoininteractively join vertices in network
spatstat.gui::iplot.linnetinteractively plot network
simplenetsimple example of network
lineardiscdisc in a linear network
delaunayNetworknetwork of Delaunay triangulation
dirichletNetworknetwork of Dirichlet edges
methods.linnetmethods for linnet objects
vertices.linnetnodes of network
joinVerticesjoin existing vertices in a network
insertVerticesinsert new vertices at positions along a network
addVerticesadd new vertices, extending a network
thinNetworkremove vertices or lines from a network
repairNetworkrepair internal format
pixellate.linnetapproximate by pixel image

An object of class "lpp" represents a point pattern on a linear network (for example, road accidents on a road network).

lppcreate a point pattern on a linear network
methods.lppmethods for lpp objects
subset.lppmethod for subset
rpoislppsimulate Poisson points on linear network
runiflppsimulate random points on a linear network
chicagoChicago crime data
dendriteDendritic spines data
spidersSpider webs on mortar lines of brick wall

Hyperframes

A hyperframe is like a data frame, except that the entries may be objects of any kind.

hyperframecreate a hyperframe
as.hyperframeconvert data to hyperframe
plot.hyperframeplot hyperframe
with.hyperframeevaluate expression using each row of hyperframe
cbind.hyperframecombine hyperframes by columns
rbind.hyperframecombine hyperframes by rows
as.data.frame.hyperframeconvert hyperframe to data frame
subset.hyperframemethod for subset
head.hyperframefirst few rows of hyperframe
tail.hyperframelast few rows of hyperframe

Layered objects

A layered object represents data that should be plotted in successive layers, for example, a background and a foreground.

layeredcreate layered object
plot.layeredplot layered object
[.layeredextract subset of layered object

Colour maps

A colour map is a mechanism for associating colours with data. It can be regarded as a function, mapping data to colours. Using a colourmap object in a plot command ensures that the mapping from numbers to colours is the same in different plots.

colourmapcreate a colour map
plot.colourmapplot the colour map only
tweak.colourmapalter individual colour values
interp.colourmapmake a smooth transition between colours
beachcolourmapone special colour map

II. EXPLORATORY DATA ANALYSIS

Inspection of data:

summary(X)print useful summary of point pattern X
Xprint basic description of point pattern X
any(duplicated(X))check for duplicated points in pattern X
spatstat.gui::istat(X)Interactive exploratory analysis
spatstat.gui::View.ppp(X)spreadsheet-style viewer

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: Type demo(sumfun) for a demonstration of many of the summary statistics.

intensityMean intensity
quadratcountQuadrat counts
intensity.quadratcountMean intensity in quadrats
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
nndistnearest neighbour distances
nnwhichfind nearest neighbours
pairdistdistances between all pairs of points
crossdistdistances between points in two patterns
nncrossnearest neighbours between two point patterns
exactdtdistance from any location to nearest data point
distmapdistance map image
distfundistance map function
nnmapnearest point image
nnfunnearest point 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:

applynbdapply function to every neighbourhood in a point pattern
markstatapply function to the marks of neighbours in a point pattern
marktabletabulate the marks of neighbours in a point pattern
pppdistfind the optimal match between two point patterns

Summary statistics for a point pattern on a linear network:

These are for point patterns on a linear network (class lpp). For unmarked patterns:

linearK\(K\) function on linear network
linearKinhominhomogeneous \(K\) function on linear network
linearpcfpair correlation function on linear network
linearpcfinhominhomogeneous pair correlation on linear network

For multitype patterns:

linearKcross\(K\) function between two types of points
linearKdot\(K\) function from one type to any type
linearKcross.inhomInhomogeneous version of linearKcross
linearKdot.inhomInhomogeneous version of linearKdot
linearmarkconnectMark connection function on linear network
linearmarkequalMark equality function on linear network
linearpcfcrossPair correlation between two types of points
linearpcfdotPair correlation from one type to any type
linearpcfcross.inhomInhomogeneous version of linearpcfcross
linearpcfdot.inhomInhomogeneous version of linearpcfdot

Related facilities:

pairdist.lppdistances between pairs
crossdist.lppdistances between pairs
nndist.lppnearest neighbour distances
nncross.lppnearest neighbour distances
nnwhich.lppfind nearest neighbours
nnfun.lppfind nearest data point
density.lppkernel smoothing estimator of intensity
densityHeat.lppdiffusion kernel estimate
distfun.lppdistance transform
envelope.lppsimulation envelopes
rpoislppsimulate Poisson points on linear network
runiflppsimulate random points on a linear network

It is also possible to fit point process models to lpp objects. See Section IV.

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
pairdist.pp3distances between all pairs of points
crossdist.pp3distances between points in two patterns
nndist.pp3nearest neighbour distances
nnwhich.pp3find nearest neighbours
nncross.pp3find nearest neighbours in another pattern

Computations for multi-dimensional point pattern:

These are for multi-dimensional space-time point pattern objects (class ppx).

pairdist.ppxdistances between all pairs of points
crossdist.ppxdistances between points in two patterns
nndist.ppxnearest neighbour distances
nnwhich.ppxfind nearest neighbours

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

III. MODEL FITTING (COX AND CLUSTER MODELS)

Cluster process models (with homogeneous or inhomogeneous intensity) and Cox processes can be fitted by the function kppm. Its result is an object of class "kppm". The fitted model can be printed, plotted, predicted, simulated and updated.

kppmFit model
plot.kppmPlot the fitted model
summary.kppmSummarise the fitted model
fitted.kppmCompute fitted intensity
predict.kppmCompute fitted intensity
update.kppmUpdate the model
improve.kppmRefine the estimate of trend
simulate.kppmGenerate simulated realisations
vcov.kppmVariance-covariance matrix of coefficients
coef.kppmExtract trend coefficients
formula.kppmExtract trend formula
parametersExtract all model parameters
clusterfield.kppmCompute offspring density
clusterradius.kppmRadius of support of offspring density
Kmodel.kppm\(K\) function of fitted model
pcfmodel.kppmPair correlation of fitted model

For model selection, you can also use the generic functions step, drop1 and AIC on fitted point process models. For variable selection, see sdr.

The theoretical models can also be simulated, for any choice of parameter values, using rThomas, rMatClust, rCauchy, rVarGamma, and rLGCP.

Lower-level fitting functions include:

lgcp.estKfit a log-Gaussian Cox process model
lgcp.estpcffit a log-Gaussian Cox process model
thomas.estKfit the Thomas process model
thomas.estpcffit the Thomas process model
matclust.estKfit the Matern Cluster process model
matclust.estpcffit the Matern Cluster process model
cauchy.estKfit a Neyman-Scott Cauchy cluster process
cauchy.estpcffit a Neyman-Scott Cauchy cluster process
vargamma.estKfit a Neyman-Scott Variance Gamma process
vargamma.estpcffit a Neyman-Scott Variance Gamma process
mincontrastlow-level algorithm for fitting models
by the method of minimum contrast

IV. MODEL FITTING (POISSON AND GIBBS MODELS)

Types of models

Poisson point processes are the simplest models for point patterns. A Poisson model assumes that the points are stochastically independent. It may allow the points to have a non-uniform spatial density. The special case of a Poisson process with a uniform spatial density is often called Complete Spatial Randomness.

Poisson point processes are included in the more general class of Gibbs point process models. In a Gibbs model, there is interaction or dependence between points. Many different types of interaction can be specified.

For a detailed explanation of how to fit Poisson or Gibbs point process models to point pattern data using spatstat, see Baddeley and Turner (2005b) or Baddeley (2008).

To fit a Poisson or Gibbs point process model:

Model fitting in spatstat is performed mainly by the function ppm. Its result is an object of class "ppm".

Here are some examples, where X is a point pattern (class "ppp"):

commandmodel
ppm(X)Complete Spatial Randomness
ppm(X ~ 1)Complete Spatial Randomness
ppm(X ~ x)Poisson process with
intensity loglinear in \(x\) coordinate
ppm(X ~ 1, Strauss(0.1))Stationary Strauss process
ppm(X ~ x, Strauss(0.1))Strauss process with
conditional intensity loglinear in \(x\)

It is also possible to fit models that depend on other covariates.

Manipulating the fitted model:

plot.ppmPlot the fitted model
predict.ppmCompute the spatial trend and conditional intensity
of the fitted point process model
coef.ppmExtract the fitted model coefficients
parametersExtract all model parameters
formula.ppmExtract the trend formula
intensity.ppmCompute fitted intensity
Kmodel.ppm\(K\) function of fitted model
pcfmodel.ppmpair correlation of fitted model
fitted.ppmCompute fitted conditional intensity at quadrature points
residuals.ppmCompute point process residuals at quadrature points
update.ppmUpdate the fit
vcov.ppmVariance-covariance matrix of estimates
rmh.ppmSimulate from fitted model
simulate.ppmSimulate from fitted model
print.ppmPrint basic information about a fitted model
summary.ppmSummarise a fitted model
effectfunCompute the fitted effect of one covariate
logLik.ppmlog-likelihood or log-pseudolikelihood
anova.ppmAnalysis of deviance
model.frame.ppmExtract data frame used to fit model
model.imagesExtract spatial data used to fit model
model.dependsIdentify variables in the model
as.interactInterpoint interaction component of model
fitinExtract fitted interpoint interaction
is.hybridDetermine whether the model is a hybrid
valid.ppmCheck the model is a valid point process
project.ppmEnsure the model is a valid point process

For model selection, you can also use the generic functions step, drop1 and AIC on fitted point process models. For variable selection, see sdr.

See spatstat.options to control plotting of fitted model.

To specify a point process model:

The first order ``trend'' of the model is determined by an R language formula. The formula specifies the form of the logarithm of the trend.

X ~ 1No trend (stationary)
X ~ xLoglinear trend \(\lambda(x,y) = \exp(\alpha + \beta x)\)
where \(x,y\) are Cartesian coordinates
X ~ polynom(x,y,3)Log-cubic polynomial trend
X ~ harmonic(x,y,2)Log-harmonic polynomial trend
X ~ ZLoglinear function of covariate Z
\(\lambda(x,y) = \exp(\alpha + \beta Z(x,y))\)

The higher order (``interaction'') components are described by an object of class "interact". Such objects are created by:

Poisson()the Poisson point process
AreaInter()Area-interaction process
BadGey()multiscale Geyer process
Concom()connected component interaction
DiggleGratton() Diggle-Gratton potential
DiggleGatesStibbard() Diggle-Gates-Stibbard potential
Fiksel()Fiksel pairwise interaction process
Geyer()Geyer's saturation process
Hardcore()Hard core process
HierHard()Hierarchical multiype hard core process
HierStrauss()Hierarchical multiype Strauss process
HierStraussHard()Hierarchical multiype Strauss-hard core process
Hybrid()Hybrid of several interactions
LennardJones() Lennard-Jones potential
MultiHard()multitype hard core process
MultiStrauss()multitype Strauss process
MultiStraussHard()multitype Strauss/hard core process
OrdThresh()Ord process, threshold potential
Ord()Ord model, user-supplied potential
PairPiece()pairwise interaction, piecewise constant
Pairwise()pairwise interaction, user-supplied potential
Penttinen()Penttinen pairwise interaction
SatPiece()Saturated pair model, piecewise constant potential
Saturated()Saturated pair model, user-supplied potential
Softcore()pairwise interaction, soft core potential
Strauss()Strauss process
StraussHard()Strauss/hard core point process
Triplets()Geyer triplets process

Note that it is also possible to combine several such interactions using Hybrid.

Finer control over model fitting:

A quadrature scheme is represented by an object of class "quad". To create a quadrature scheme, typically use quadscheme.

quadschemedefault quadrature scheme
using rectangular cells or Dirichlet cells
pixelquadquadrature scheme based on image pixels
quadcreate an object of class "quad"

To inspect a quadrature scheme:

plot(Q)plot quadrature scheme Q
print(Q)print basic information about quadrature scheme Q
summary(Q)summary of quadrature scheme Q

A quadrature scheme consists of data points, dummy points, and weights. To generate dummy points:

default.dummydefault pattern of dummy points
gridcentresdummy points in a rectangular grid
rstratstratified random dummy pattern
spokesradial pattern of dummy points
cornersdummy points at corners of the window

To compute weights:

gridweightsquadrature weights by the grid-counting rule
dirichletWeightsquadrature weights are Dirichlet tile areas

Simulation and goodness-of-fit for fitted models:

rmh.ppmsimulate realisations of a fitted model
simulate.ppmsimulate realisations of a fitted model
envelopecompute simulation envelopes for a fitted model

Point process models on a linear network:

An object of class "lpp" represents a pattern of points on a linear network. Point process models can also be fitted to these objects. Currently only Poisson models can be fitted.

lppmpoint process model on linear network
anova.lppmanalysis of deviance for
point process model on linear network
envelope.lppmsimulation envelopes for
point process model on linear network
fitted.lppmfitted intensity values
predict.lppmmodel prediction on linear network
linimpixel image on linear network
plot.linimplot a pixel image on linear network
eval.linimevaluate expression involving images
linfunfunction defined on linear network
methods.linfunconversion facilities

V. MODEL FITTING (DETERMINANTAL POINT PROCESS MODELS)

Code for fitting determinantal point process models has recently been added to spatstat.

For information, see the help file for dppm.

VI. MODEL FITTING (SPATIAL LOGISTIC REGRESSION)

Logistic regression

Pixel-based spatial logistic regression is an alternative technique for analysing spatial point patterns that is widely used in Geographical Information Systems. It is approximately equivalent to fitting a Poisson point process model.

In pixel-based logistic regression, the spatial domain is divided into small pixels, the presence or absence of a data point in each pixel is recorded, and logistic regression is used to model the presence/absence indicators as a function of any covariates.

Facilities for performing spatial logistic regression are provided in spatstat for comparison purposes.

Fitting a spatial logistic regression

Spatial logistic regression is performed by the function slrm. Its result is an object of class "slrm". There are many methods for this class, including methods for print, fitted, predict, simulate, anova, coef, logLik, terms, update, formula and vcov.

For example, if X is a point pattern (class "ppp"):

commandmodel
slrm(X ~ 1)Complete Spatial Randomness
slrm(X ~ x)Poisson process with
intensity loglinear in \(x\) coordinate
slrm(X ~ Z)Poisson process with
intensity loglinear in covariate Z

Manipulating a fitted spatial logistic regression

anova.slrmAnalysis of deviance
coef.slrmExtract fitted coefficients
vcov.slrmVariance-covariance matrix of fitted coefficients
fitted.slrmCompute fitted probabilities or intensity
logLik.slrmEvaluate loglikelihood of fitted model
plot.slrmPlot fitted probabilities or intensity
predict.slrmCompute predicted probabilities or intensity with new data
simulate.slrmSimulate model

There are many other undocumented methods for this class, including methods for print, update, formula and terms. Stepwise model selection is possible using step or stepAIC. For variable selection, see sdr.

VII. SIMULATION

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

Random point patterns:

runifpointgenerate \(n\) independent uniform random points
rpointgenerate \(n\) independent random points
rmpointgenerate \(n\) independent multitype random points
rpoisppsimulate the (in)homogeneous Poisson point process
rmpoisppsimulate the (in)homogeneous multitype Poisson point process
runifdiscgenerate \(n\) independent uniform random points in disc
rstratstratified random sample of points
rsystsystematic random sample (grid) of points
rMaternIsimulate the Matern Model I inhibition process
rMaternIIsimulate the Matern Model II inhibition process
rSSIsimulate Simple Sequential Inhibition process
rHardcoresimulate hard core process (perfect simulation)
rStrausssimulate Strauss process (perfect simulation)
rStraussHardsimulate Strauss-hard core process (perfect simulation)
rDiggleGrattonsimulate Diggle-Gratton process (perfect simulation)
rDGSsimulate Diggle-Gates-Stibbard process (perfect simulation)
rPenttinensimulate Penttinen process (perfect simulation)
rNeymanScottsimulate a general Neyman-Scott process
rMatClustsimulate the Matern Cluster process
rThomassimulate the Thomas process
rLGCPsimulate the log-Gaussian Cox process
rGaussPoissonsimulate the Gauss-Poisson cluster process
rCauchysimulate Neyman-Scott process with Cauchy clusters
rVarGammasimulate Neyman-Scott process with Variance Gamma clusters
rcellsimulate the Baddeley-Silverman cell process
runifpointOnLinesgenerate \(n\) random points along specified line segments
rpoisppOnLinesgenerate Poisson random points along specified line segments

Resampling a point pattern:

quadratresampleblock resampling
rjitterapply random displacements to points in a pattern
rshiftrandom shifting of (subsets of) points
rthinrandom thinning

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.

Cluster process models are fitted by the function kppm yielding an object of class "kppm". To generate one or more simulated realisations of this fitted model, use simulate.kppm.

Gibbs point process models are fitted by the function ppm yielding an object of class "ppm". To generate a simulated realisation of this fitted model, use rmh. To generate one or more simulated realisations of the fitted model, use simulate.ppm.

Other random patterns:

rlinegridgenerate a random array of parallel lines through a window
rpoislinesimulate the Poisson line process within a window
rpoislinetessgenerate random tessellation using Poisson line process
rMosaicSetgenerate random set by selecting some tiles of a tessellation
rMosaicFieldgenerate random pixel image by assigning random values in each tile of a tessellation

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

VIII. TESTS AND DIAGNOSTICS

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

Sensitivity diagnostics:

Classical measures of model sensitivity such as leverage and influence have been adapted to point process models.

leverage.ppmLeverage for point process model
influence.ppmInfluence for point process model
dfbetas.ppmParameter influence
dffit.ppmEffect change diagnostic

Diagnostics for covariate effect:

Classical diagnostics for covariate effects have been adapted to point process models.

parresPartial residual plot
addvarAdded variable plot
rhohatKernel estimate of covariate effect
rho2hatKernel estimate of covariate effect (bivariate)

Residual diagnostics:

Residuals for a fitted point process model, and diagnostic plots based on the residuals, were introduced in Baddeley et al (2005) and Baddeley, Rubak and Moller (2011).

Type demo(diagnose) for a demonstration of the diagnostics features.

diagnose.ppmdiagnostic plots for spatial trend
qqplot.ppmdiagnostic Q-Q plot for interpoint interaction
residualspaperexamples from Baddeley et al (2005)
Kcommodel compensator of \(K\) function
Gcommodel compensator of \(G\) function
Kresscore residual of \(K\) function
Gresscore residual of \(G\) function
psstpseudoscore residual of summary function
psstApseudoscore residual of empty space function
psstGpseudoscore residual of \(G\) function
compareFitcompare compensators of several fitted models

Resampling and randomisation procedures

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

quadratresampleblock resampling
rjitterapply random displacements to points in a pattern
rshiftrandom shifting of (subsets of) points
rthinrandom thinning

IX. DOCUMENTATION

The online manual entries are quite detailed and should be consulted first for information about a particular function.

The book Baddeley, Rubak and Turner (2015) is a complete course on analysing spatial point patterns, with full details about spatstat.

Older material (which is now out-of-date but is freely available) includes Baddeley and Turner (2005a), a brief overview of the package in its early development; Baddeley and Turner (2005b), a more detailed explanation of how to fit point process models to data; and Baddeley (2010), a complete set of notes from a 2-day workshop on the use of spatstat.

Type citation("spatstat") to get a list of these references.

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 rolfturner@posteo.net and Ege Rubak rubak@math.aau.dk.

Acknowledgements

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

Additional contributions and suggestions from 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, Julian Gilbey, 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, Kassel Hingee, 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, Bethany Macdonald, Ben Madin, Martin Maechler, Daniel Manrique-Castano, 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, Suman Rakshit, Ben Ramage, Pablo Ramon, Xavier Raynaud, Nicholas Read, Matt Reiter, Ian Renner, Tom Richardson, Brian Ripley, Yonatan Rosen, 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.

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

Apart from two-dimensional point patterns and point processes, spatstat also supports point patterns in three dimensions, point patterns in multidimensional space-time, point patterns on a linear network, patterns of line segments in two dimensions, and spatial tessellations and random sets in two dimensions.

The package can fit several types of point process models to a point pattern dataset:

  • Poisson point process models (by Berman-Turner approximate maximum likelihood or by spatial logistic regression)

  • Gibbs/Markov point process models (by Baddeley-Turner approximate maximum pseudolikelihood, Coeurjolly-Rubak logistic likelihood, or Huang-Ogata approximate maximum likelihood)

  • Cox/cluster point process models (by Waagepetersen's two-step fitting procedure and minimum contrast, composite likelihood, or Palm likelihood)

  • determinantal point process models (by Waagepetersen's two-step fitting procedure and minimum contrast, composite likelihood, or Palm likelihood)

The models may include spatial trend, dependence on covariates, and complicated interpoint interactions. Models are specified by a formula in the R language, and are fitted using a function analogous to lm and glm. Fitted models can be printed, plotted, predicted, simulated and so on.

References

Baddeley, A. (2010) Analysing spatial point patterns in R. Workshop notes, Version 4.1. Online technical publication, CSIRO. https://research.csiro.au/software/wp-content/uploads/sites/6/2015/02/Rspatialcourse_CMIS_PDF-Standard.pdf

Baddeley, A., Rubak, E. and Turner, R. (2015) Spatial Point Patterns: Methodology and Applications with R. Chapman and Hall/CRC Press.

Baddeley, A. and Turner, R. (2005a) Spatstat: an R package for analyzing spatial point patterns. Journal of Statistical Software 12:6, 1--42. DOI: 10.18637/jss.v012.i06.

Baddeley, A. and Turner, R. (2005b) Modelling spatial point patterns in R. In: A. Baddeley, P. Gregori, J. Mateu, R. Stoica, and D. Stoyan, editors, Case Studies in Spatial Point Pattern Modelling, Lecture Notes in Statistics number 185. Pages 23--74. Springer-Verlag, New York, 2006. ISBN: 0-387-28311-0.

Baddeley, A., Turner, R., Moller, J. and Hazelton, M. (2005) Residual analysis for spatial point processes. Journal of the Royal Statistical Society, Series B 67, 617--666.

Baddeley, A., Rubak, E. and Moller, J. (2011) Score, pseudo-score and residual diagnostics for spatial point process models. Statistical Science 26, 613--646.

Baddeley, A., Turner, R., Mateu, J. and Bevan, A. (2013) Hybrids of Gibbs point process models and their implementation. Journal of Statistical Software 55:11, 1--43. https://www.jstatsoft.org/v55/i11/

Diggle, P.J. (2003) Statistical analysis of spatial point patterns, Second edition. Arnold.

Diggle, P.J. (2014) Statistical Analysis of Spatial and Spatio-Temporal Point Patterns, Third edition. Chapman and Hall/CRC.

Gelfand, A.E., Diggle, P.J., Fuentes, M. and Guttorp, P., editors (2010) Handbook of Spatial Statistics. CRC Press.

Huang, F. and Ogata, Y. (1999) Improvements of the maximum pseudo-likelihood estimators in various spatial statistical models. Journal of Computational and Graphical Statistics 8, 510--530.

Illian, J., Penttinen, A., Stoyan, H. and Stoyan, D. (2008) Statistical Analysis and Modelling of Spatial Point Patterns. Wiley.

Waagepetersen, R. An estimating function approach to inference for inhomogeneous Neyman-Scott processes. Biometrics 63 (2007) 252--258.