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
- visit cran.r-project.org/web/packages/spatstat
and click on
Getting Started with Spatstat
-
start R, type
library(spatstat)
and vignette('getstart')
-
start R, type
help.start()
to open the help
browser, and navigate to Packages > spatstat > Vignettes
.
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, spatstat.github.io/book. For information about handling data in shapefiles,
see Chapter 3, or the Vignette
Handling shapefiles in the spatstat package,
installed with spatstat, accessible as
vignette('shapefiles')
.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 |
I. CREATING AND MANIPULATING DATA
Types of spatial data: The main types of spatial data supported by spatstat are:
ppp |
point pattern |
owin |
window (spatial region) |
im |
pixel image |
psp |
line segment pattern |
tess |
tessellation |
pp3 |
three-dimensional point pattern |
ppx |
point pattern in any number of dimensions |
To create a point pattern:
ppp |
create 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.ppp |
convert other types of data to a ppp object |
clickppp |
interactively add points to a plot |
To simulate a random point pattern:
runifpoint |
generate $n$ independent uniform random points |
rpoint |
generate $n$ independent random points |
rmpoint |
generate $n$ independent multitype random points |
rpoispp |
simulate the (in)homogeneous Poisson point process |
rmpoispp |
simulate the (in)homogeneous multitype Poisson point process |
runifdisc |
generate $n$ independent uniform random points in disc |
rstrat |
stratified random sample of points |
rsyst |
systematic random sample of points |
rjitter |
apply random displacements to points in a pattern |
rMaternI |
simulate the Matern Model I inhibition process |
rMaternII |
simulate the Matern Model II inhibition process |
rSSI |
simulate Simple Sequential Inhibition process |
rStrauss |
simulate Strauss process (perfect simulation) |
rHardcore |
simulate Hard Core process (perfect simulation) |
rStraussHard |
simulate Strauss-hard core process (perfect simulation) |
rDiggleGratton |
simulate Diggle-Gratton process (perfect simulation) |
rDGS |
simulate Diggle-Gates-Stibbard process (perfect simulation) |
rPenttinen |
simulate Penttinen process (perfect simulation) |
rNeymanScott |
simulate a general Neyman-Scott process |
rPoissonCluster |
simulate a general Poisson cluster process |
rMatClust |
simulate the Matern Cluster process |
rThomas |
simulate the Thomas process |
rGaussPoisson |
simulate the Gauss-Poisson cluster process |
rCauchy |
simulate Neyman-Scott Cauchy cluster process |
rVarGamma |
simulate Neyman-Scott Variance Gamma cluster process |
rthin |
random thinning |
rcell |
simulate the Baddeley-Silverman cell process |
rmh |
simulate Gibbs point process using Metropolis-Hastings |
simulate.ppm |
simulate Gibbs point process using Metropolis-Hastings |
runifpointOnLines |
generate $n$ random points along specified line segments |
To randomly change an existing point pattern:
rshift |
random shifting of points |
rjitter |
apply random displacements to points in a pattern |
rthin |
random thinning |
rlabel |
random (re)labelling of a multitype
point pattern |
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.
amacrine |
Austin Hughes' rabbit amacrine cells |
anemones |
Upton-Fingleton sea anemones data |
ants |
Harkness-Isham ant nests data |
bdspots |
Breakdown spots in microelectrodes |
bei |
Tropical rainforest trees |
betacells |
Waessle et al. cat retinal ganglia data |
bramblecanes |
Bramble Canes data |
bronzefilter |
Bronze Filter Section data |
cells |
Crick-Ripley biological cells data |
chicago |
Chicago street crimes |
chorley |
Chorley-Ribble cancer data |
clmfires |
Castilla-La Mancha forest fires |
copper |
Berman-Huntington copper deposits data |
dendrite |
Dendritic spines |
demohyper |
Synthetic point patterns |
demopat |
Synthetic point pattern |
finpines |
Finnish Pines data |
flu |
Influenza virus proteins |
gordon |
People in Gordon Square, London |
gorillas |
Gorilla nest sites |
hamster |
Aherne's hamster tumour data |
humberside |
North Humberside childhood leukaemia data |
hyytiala |
Mixed forest in
Hyytiala, Finland |
japanesepines |
Japanese Pines data |
lansing |
Lansing Woods data |
longleaf |
Longleaf Pines data |
mucosa |
Cells in gastric mucosa |
murchison |
Murchison gold deposits |
nbfires |
New Brunswick fires data |
nztrees |
Mark-Esler-Ripley trees data |
osteo |
Osteocyte lacunae (3D, replicated) |
paracou |
Kimboto trees in Paracou, French Guiana |
ponderosa |
Getis-Franklin ponderosa pine trees data |
pyramidal |
Pyramidal neurons from 31 brains |
redwood |
Strauss-Ripley redwood saplings data |
redwoodfull |
Strauss redwood saplings data (full set) |
residualspaper |
Data from Baddeley et al (2005) |
shapley |
Galaxies in an astronomical survey |
simdat |
Simulated point pattern (inhomogeneous, with interaction) |
spiders |
Spider webs on mortar lines of brick wall |
sporophores |
Mycorrhizal fungi around a tree |
spruces |
Spruce trees in Saxonia |
swedishpines |
Strand-Ripley Swedish pines data |
urkiola |
Urkiola Woods data |
waka |
Trees in Waka national park |
To manipulate a point pattern:
See spatstat.options
to control plotting behaviour. To create a window: An object of class "owin"
describes a spatial region
(a window of observation).
owin |
Create a window object |
|
owin(xlim, ylim) for rectangular window |
|
owin(poly) for polygonal window |
|
owin(mask) for binary image window |
Window |
Extract window of another object |
Frame |
Extract the containing rectangle ('frame') of another object |
as.owin |
Convert other data to a window object |
square |
make a square window |
disc |
make a circular window |
ellipse |
make an elliptical window |
ripras |
Ripley-Rasson estimator of window, given only the points |
convexhull |
compute convex hull of something |
letterR |
polygonal window in the shape of the R logo |
clickpoly |
interactively draw a polygonal window |
To manipulate a window: Digital approximations:
See spatstat.options
to control the approximation Geometrical computations with windows: 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
.
Line segment patterns An object of class "psp"
represents a pattern of straight line
segments.
psp |
create a line segment pattern |
as.psp |
convert other data into a line segment pattern |
edges |
extract edges of a window |
is.psp |
determine whether a dataset has class "psp" |
plot.psp |
plot a line segment pattern |
print.psp |
print basic information |
summary.psp |
print summary information |
[.psp |
extract a subset of a line segment pattern |
as.data.frame.psp |
convert line segment pattern to data frame |
marks.psp |
extract marks of line segments |
marks<-.psp |
assign new marks to line segments |
unmark.psp |
delete marks from line segments |
midpoints.psp |
compute the midpoints of line segments |
endpoints.psp |
extract the endpoints of line segments |
lengths.psp |
compute the lengths of line segments |
angles.psp |
compute the orientation angles of line segments |
superimpose |
combine several line segment patterns |
flipxy |
swap $x$ and $y$ coordinates |
rotate.psp |
rotate a line segment pattern |
shift.psp |
shift a line segment pattern |
periodify |
make several shifted copies |
affine.psp |
apply an affine transformation |
pixellate.psp |
approximate line segment pattern
by pixel image |
as.mask.psp |
approximate line segment pattern
by binary mask |
distmap.psp |
compute the distance map of a line
segment pattern |
distfun.psp |
compute the distance map of a line
segment pattern |
density.psp |
kernel smoothing of line segments |
selfcrossing.psp |
find crossing points between
line segments |
selfcut.psp |
cut segments where they cross |
crossing.psp |
find crossing points between
two line segment patterns |
nncross |
find distance to nearest line segment
from a given point |
nearestsegment |
find line segment closest to a
given point |
project2segment |
find location along a line segment
closest to a given point |
pointsOnLines |
generate points evenly spaced
along line segment |
rpoisline |
generate a realisation of the
Poisson line process inside a window |
Tessellations An object of class "tess"
represents a tessellation.
tess |
create a tessellation |
quadrats |
create a tessellation of rectangles |
hextess |
create a tessellation of hexagons |
quantess |
quantile tessellation |
as.tess |
convert other data to a tessellation |
plot.tess |
plot a tessellation |
tiles |
extract all the tiles of a tessellation |
[.tess |
extract some tiles of a tessellation |
[<-.tess |
change some tiles of a tessellation |
intersect.tess |
intersect two tessellations |
|
or restrict a tessellation to a window |
chop.tess |
subdivide a tessellation by a line |
dirichlet |
compute Dirichlet-Voronoi tessellation of points |
delaunay |
compute Delaunay triangulation of points |
rpoislinetess |
generate tessellation using Poisson line
process |
tile.areas |
area of each tile in tessellation |
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"
. Multi-dimensional space-time point patterns An object of class "ppx"
represents a
point pattern in multi-dimensional space and/or time. Point patterns on a linear network An object of class "linnet"
represents a linear network
(for example, a road network). An object of class "lpp"
represents a
point pattern on a linear network (for example,
road accidents on a road network).
lpp |
create a point pattern on a linear network |
methods.lpp |
methods for lpp objects |
subset.lpp |
method for subset |
rpoislpp |
simulate Poisson points on linear network |
runiflpp |
simulate random points on a linear network |
chicago |
Chicago street crime data |
dendrite |
Dendritic spines data |
Hyperframes A hyperframe is like a data frame, except that the entries
may be objects of any kind. Layered objects A layered object represents data that should be plotted in
successive layers, for example, a background and a foreground. 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. II. EXPLORATORY DATA ANALYSIS
Inspection of data:
summary(X) |
print useful summary of point pattern X |
X |
print basic description of point pattern X |
any(duplicated(X)) |
check for duplicated points in pattern X |
istat(X) |
Interactive exploratory analysis |
Classical exploratory tools:
Smoothing:
Modern exploratory tools:
clusterset |
Allard-Fraley feature detection |
nnclean |
Byers-Raftery feature detection |
sharpen.ppp |
Choi-Hall data sharpening |
rhohat |
Kernel estimate of covariate effect |
rho2hat |
Kernel estimate of effect of two covariates |
spatialcdf |
Spatial cumulative distribution function |
Summary statistics for a point pattern:
Type demo(sumfun)
for a demonstration of many
of the summary statistics.
intensity |
Mean intensity |
quadratcount |
Quadrat counts |
intensity.quadratcount |
Mean intensity in quadrats |
Fest |
empty space function $F$ |
Gest |
nearest neighbour distribution function $G$ |
Jest |
$J$-function $J = (1-G)/(1-F)$ |
Kest |
Ripley's $K$-function |
Lest |
Besag $L$-function |
Tstat |
Third order $T$-function |
allstats |
all four functions $F$, $G$, $J$, $K$ |
pcf |
pair correlation function |
Kinhom |
$K$ for inhomogeneous point patterns |
Linhom |
$L$ for inhomogeneous point patterns |
pcfinhom |
pair correlation for inhomogeneous patterns |
Finhom |
$F$ for inhomogeneous point patterns |
Ginhom |
$G$ for inhomogeneous point patterns |
Jinhom |
$J$ for inhomogeneous point patterns |
localL |
Getis-Franklin neighbourhood density function |
localK |
neighbourhood K-function |
localpcf |
local pair correlation function |
localKinhom |
local $K$ for inhomogeneous point patterns |
localLinhom |
local $L$ for inhomogeneous point patterns |
localpcfinhom |
local pair correlation for inhomogeneous patterns |
Ksector |
Directional $K$-function |
Kscaled |
locally scaled $K$-function |
Kest.fft |
fast $K$-function using FFT for large datasets |
Kmeasure |
reduced second moment measure |
envelope |
simulation envelopes for a summary
function |
varblock |
variances and confidence intervals |
|
for a summary function |
Related facilities:
plot.fv |
plot a summary function |
eval.fv |
evaluate any expression involving
summary functions |
harmonise.fv |
make functions compatible |
eval.fasp |
evaluate any expression involving
an array of functions |
with.fv |
evaluate an expression for a
summary function |
Smooth.fv |
apply smoothing to a summary function |
deriv.fv |
calculate derivative of a summary function |
pool.fv |
pool several estimates of a summary function |
nndist |
nearest neighbour distances |
nnwhich |
find nearest neighbours |
pairdist |
distances between all pairs of points |
crossdist |
distances between points in two patterns |
nncross |
nearest neighbours between two point patterns |
exactdt |
distance from any location to nearest data point |
distmap |
distance map image |
distfun |
distance map function |
nnmap |
nearest point image |
nnfun |
nearest point function |
density.ppp |
kernel smoothed density |
Smooth.ppp |
spatial interpolation of marks |
relrisk |
kernel estimate of relative risk |
sharpen.ppp |
data sharpening |
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.
relrisk |
kernel estimation of relative risk |
scan.test |
spatial scan test of elevated risk |
Gcross,Gdot,Gmulti |
multitype nearest neighbour distributions
$G[i,j], G[i.]$ |
Kcross,Kdot, Kmulti |
multitype $K$-functions
$K[i,j], K[i.]$ |
Lcross,Ldot |
multitype $L$-functions
$L[i,j], L[i.]$ |
Jcross,Jdot,Jmulti |
multitype $J$-functions
$J[i,j],J[i.]$ |
pcfcross |
multitype pair correlation function $g[i,j]$ |
pcfdot |
multitype pair correlation function $g[i.]$ |
pcfmulti |
general pair correlation function |
markconnect |
marked connection function $p[i,j]$ |
alltypes |
estimates of the above
for all $i,j$ pairs |
Iest |
multitype $I$-function |
Kcross.inhom,Kdot.inhom |
inhomogeneous counterparts of Kcross , Kdot |
Lcross.inhom,Ldot.inhom |
inhomogeneous counterparts of Lcross , Ldot |
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:
markmean |
smoothed local average of marks |
markvar |
smoothed local variance of marks |
markcorr |
mark correlation function |
markcrosscorr |
mark cross-correlation function |
markvario |
mark variogram |
Kmark |
mark-weighted $K$ function |
Emark |
mark independence diagnostic $E(r)$ |
Vmark |
mark independence diagnostic $V(r)$ |
nnmean |
nearest neighbour mean index |
For marks of any type, there are the following:
Gmulti |
multitype nearest neighbour distribution |
Kmulti |
multitype $K$-function |
Alternatively use cut.ppp
to convert a marked point pattern
to a multitype point pattern. Programming tools:
applynbd |
apply function to every neighbourhood
in a point pattern |
markstat |
apply function to the marks of neighbours
in a point pattern |
marktable |
tabulate the marks of neighbours
in a point pattern |
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 |
linearKinhom |
inhomogeneous $K$ function on linear network |
linearpcf |
pair correlation function on linear network |
For multitype patterns:
Related facilities: 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
).
F3est |
empty space function $F$ |
G3est |
nearest neighbour function $G$ |
K3est |
$K$-function |
Related facilities:
Computations for multi-dimensional point pattern: These are for multi-dimensional space-time
point pattern objects (class ppx
). Summary statistics for random sets: These work for point patterns (class ppp
),
line segment patterns (class psp
)
or windows (class owin
).
Hest |
spherical contact distribution $H$ |
Gfox |
Foxall $G$-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. For model selection, you can also use
the generic functions step
, drop1
and AIC
on fitted point process models. 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: 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"
):
command |
model |
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 |
It is also possible to fit models that depend on
other covariates. Manipulating the fitted model:
For model selection, you can also use
the generic functions step
, drop1
and AIC
on fitted point process models. 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 ~ 1 |
No trend (stationary) |
X ~ x |
Loglinear 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 ~ Z |
Loglinear function of covariate Z |
The higher order (``interaction'') components are described by
an object of class "interact"
. Such objects are created by:
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
.
quadscheme |
default quadrature scheme |
|
using rectangular cells or Dirichlet cells |
pixelquad |
quadrature scheme based on image pixels |
To inspect a quadrature scheme:
plot(Q) |
plot quadrature scheme Q |
print(Q) |
print basic information about quadrature scheme Q |
A quadrature scheme consists of data points, dummy points, and
weights. To generate dummy points:
To compute weights:
gridweights |
quadrature weights by the grid-counting rule |
Simulation and goodness-of-fit for fitted models:
rmh.ppm |
simulate realisations of a fitted model |
simulate.ppm |
simulate realisations of 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.
lppm |
point process model on linear network |
anova.lppm |
analysis of deviance for |
|
point process model on linear network |
envelope.lppm |
simulation envelopes for |
|
point process model on linear network |
fitted.lppm |
fitted intensity values |
predict.lppm |
model prediction on linear network |
linim |
pixel image on linear network |
plot.linim |
plot a pixel image on linear network |
eval.linim |
evaluate expression involving images |
linfun |
function defined on linear network |
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"
):
command |
model |
slrm(X ~ 1) |
Complete Spatial Randomness |
slrm(X ~ x) |
Poisson process with |
|
intensity loglinear in $x$ coordinate |
slrm(X ~ Z) |
Poisson process with |
Manipulating a fitted spatial logistic regression
anova.slrm |
Analysis of deviance |
coef.slrm |
Extract fitted coefficients |
vcov.slrm |
Variance-covariance matrix of fitted coefficients |
fitted.slrm |
Compute fitted probabilities or
intensity |
logLik.slrm |
Evaluate loglikelihood of fitted
model |
plot.slrm |
Plot fitted probabilities or
intensity |
predict.slrm |
Compute predicted probabilities or
intensity with new data |
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
.VII. SIMULATION
There are many ways to generate a random point pattern,
line segment pattern, pixel image or tessellation
in spatstat. Random point patterns:
runifpoint |
generate $n$ independent uniform random points |
rpoint |
generate $n$ independent random points |
rmpoint |
generate $n$ independent multitype random points |
rpoispp |
simulate the (in)homogeneous Poisson point process |
rmpoispp |
simulate the (in)homogeneous multitype Poisson point process |
runifdisc |
generate $n$ independent uniform random points in disc |
rstrat |
stratified random sample of points |
rsyst |
systematic random sample (grid) of points |
rMaternI |
simulate the Matern Model I inhibition process |
rMaternII |
simulate the Matern Model II inhibition process |
rSSI |
simulate Simple Sequential Inhibition process |
rHardcore |
simulate hard core process (perfect simulation) |
rStrauss |
simulate Strauss process (perfect simulation) |
rStraussHard |
simulate Strauss-hard core process (perfect simulation) |
rDiggleGratton |
simulate Diggle-Gratton process (perfect simulation) |
rDGS |
simulate Diggle-Gates-Stibbard process (perfect simulation) |
rPenttinen |
simulate Penttinen process (perfect simulation) |
rNeymanScott |
simulate a general Neyman-Scott process |
rMatClust |
simulate the Matern Cluster process |
rThomas |
simulate the Thomas process |
rLGCP |
simulate the log-Gaussian Cox process |
rGaussPoisson |
simulate the Gauss-Poisson cluster process |
rCauchy |
simulate Neyman-Scott process with Cauchy clusters |
rVarGamma |
simulate Neyman-Scott process with Variance Gamma clusters |
rcell |
simulate the Baddeley-Silverman cell process |
runifpointOnLines |
generate $n$ random points along specified line segments |
Resampling a point pattern: 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:
rlinegrid |
generate a random array of parallel lines through a window |
rpoisline |
simulate the Poisson line process within a window |
rpoislinetess |
generate random tessellation using Poisson line process |
rMosaicSet |
generate random set by selecting some tiles of a tessellation |
Simulation-based inference VIII. TESTS AND DIAGNOSTICS
Classical hypothesis tests: Sensitivity diagnostics: Classical measures of model sensitivity such as leverage and influence
have been adapted to point process models. Diagnostics for covariate effect: Classical diagnostics for covariate effects have been adapted to
point process models.
parres |
Partial residual plot |
addvar |
Added variable plot |
rhohat |
Kernel estimate of covariate effect |
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.ppm |
diagnostic plots for spatial trend |
qqplot.ppm |
diagnostic Q-Q plot for interpoint interaction |
residualspaper |
examples from Baddeley et al (2005) |
Kcom |
model compensator of $K$ function |
Gcom |
model compensator of $G$ function |
Kres |
score residual of $K$ function |
Gres |
score residual of $G$ function |
psst |
pseudoscore residual of summary function |
psstA |
pseudoscore residual of empty space function |
psstG |
pseudoscore residual of $G$ function |
Resampling and randomisation procedures You can build your own tests based on randomisation
and resampling using the following capabilities: 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.Acknowledgements
Kasper Klitgaard Berthelsen,
Ottmar Cronie,
Yongtao Guan,
Ute Hahn,
Abdollah Jalilian,
Marie-Colette van Lieshout,
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,
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,
Julian Burgos,
Simon Byers,
Ya-Mei Chang,
Jianbao Chen,
Igor Chernayavsky,
Y.C. Chin,
Bjarke Christensen,
Jean-Francois Coeurjolly,
Kim Colyvas,
Robin Corria Ainslie,
Marcelino de la Cruz,
Peter Dalgaard,
Mario D'Antuono,
Sourav Das,
Tilman Davies,
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,
Paul Hewson,
Kassel Hingee,
Kurt Hornik,
Philipp Hunziker,
Jack Hywood,
Ross Ihaka,
Cenk Icos,
Aruna Jammalamadaka,
Robert John-Chandran,
Devin Johnson,
Mahdieh Khanmohammadi,
Bob Klaver,
Peter Kovesi,
Mike Kuhn,
Jeff Laake,
Frederic Lavancier,
Tom Lawrence,
Robert Lamb,
Jonathan Lee,
George Leser,
Li Haitao,
George Limitsios,
Andrew Lister,
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,
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,
Mike Porter,
Sergiy Protsiv,
Adrian Raftery,
Suman Rakshit,
Ben Ramage,
Pablo Ramon,
Xavier Raynaud,
Matt Reiter,
Ian Renner,
Tom Richardson,
Brian Ripley,
Ted Rosenbaum,
Barry Rowlingson,
Jason Rudokas,
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,
Ida-Maria Sintorn,
Yong Song,
Malte Spiess,
Mark Stevenson,
Kaspar Stucki,
Michael Sumner,
P. Surovy,
Ben Taylor,
Thordis Linda Thorarinsdottir,
Berwin Turlach,
Torben Tvedebrink,
Kevin Ummer,
Medha Uppala,
Andrew van Burgel,
Tobias Verbeke,
Mikko Vihtakari,
Alexendre Villers,
Fabrice Vinatier,
Sasha Voss,
Sven Wagner,
Hao Wang,
H. Wendrock,
Jan Wild,
Carl G. Witthoft,
Selene Wong,
Maxime Woringer,
Mike Zamboni
and
Achim Zeileis.