spatstat-package

0th

Percentile

The Spatstat Package

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

Keywords
package, spatial
Details

spatstat is a package for the statistical analysis of spatial data. Currently, it deals mainly with the analysis of spatial patterns of points in two-dimensional space. The points may carry auxiliary data (`marks'), and the spatial region in which the points were recorded may have arbitrary shape.

The package supports

  • creation, manipulation and plotting of point patterns
  • exploratory data analysis
  • simulation of point process models
  • parametric model-fitting
  • hypothesis tests and 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 or Huang-Ogata approximate maximum likelihood)
  • Cox/cluster process models (by Waagepetersen's two-step fitting procedure and minimum contrast)
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.

Getting Started

For a quick introduction to spatstat, see the package vignette Getting started with spatstat installed with spatstat. (To see this document online, start R, type help.start() to open the help browser, and navigate to Packages > spatstat > Vignettes).

For a complete 2-day course on using spatstat, see the workshop notes by Baddeley (2010), available on the internet.

Type demo(spatstat) for a demonstration of the package's capabilities. Type demo(data) to see all the datasets available in the package. For information about handling data in shapefiles, see the Vignette Handling shapefiles in the spatstat package installed with spatstat.

To learn about spatial point process methods, see the short book by Diggle (2003) and the handbook Gelfand et al (2010).

Updates

New versions of spatstat are produced about once a month. 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. 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) where name is the name of the function or dataset.

CONTENTS:

ll{ I. Creating and manipulating data II. Exploratory Data Analysis III. Model fitting (cluster models) IV. Model fitting (Poisson and Gibbs models) V. Model fitting (spatial logistic regression) VI. Simulation VII. Tests and diagnostics VIII. Documentation }

I. CREATING AND MANIPULATING DATA

Types of spatial data:

The main types of spatial data supported by spatstat are:

ll{ 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 lpp point pattern on a linear network }

To create a point pattern: ll{ 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 marks<-, %mark% attach/reassign marks to a point pattern } To simulate a random point pattern: ll{ 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 latex{Mat'ern}{Matern} Model I inhibition process rMaternII simulate the latex{Mat'ern}{Matern} Model II inhibition process rSSI simulate Simple Sequential Inhibition process rStrauss simulate Strauss process (perfect simulation) rHardcore simulate Hard Core process (perfect simulation) rDiggleGratton simulate Diggle-Gratton process (perfect simulation) rDGS simulate Diggle-Gates-Stibbard process (perfect simulation) rNeymanScott simulate a general Neyman-Scott process rPoissonCluster simulate a general Neyman-Scott process rNeymanScott simulate a general Neyman-Scott process rMatClust simulate the latex{Mat'ern}{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 rpoisppOnLines generate Poisson random points along specified line segments }

To randomly change an existing point pattern: ll{ 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 quadratresample block 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. ll{ amacrine Austin Hughes' rabbit amacrine cells anemones Upton-Fingleton sea anemones data ants Harkness-Isham ant nests data 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 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 latex{Hyyti{"a}l{"a}}{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 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) spruces Spruce trees in Saxonia swedishpines Strand-Ripley Swedish pines data urkiola Urkiola Woods data waka Trees in Waka national park

bold

  • To manipulate a point pattern:
  • To create a window:
  • To manipulate a window:
  • Digital approximations:
  • Geometrical computations with windows:
  • Pixel images:
  • Line segment patterns
  • Tessellations
  • Three-dimensional point patterns
  • Multi-dimensional space-time point patterns
  • Point patterns on a linear network
  • Hyperframes
  • Layered objects
  • Colour maps

tabular

  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll
  • ll

code

colourmap

tab

pkg

spatstat

II. EXPLORATORY DATA ANALYSIS

Inspection of data: ll{ 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: ll{ clarkevans Clark and Evans aggregation index fryplot Fry plot miplot Morishita Index plot }

Smoothing: ll{ density.ppp kernel smoothed density relrisk kernel estimate of relative risk Smooth.ppp spatial interpolation of marks bw.diggle cross-validated bandwidth selection for density.ppp bw.ppl likelihood cross-validated bandwidth selection for density.ppp bw.scott Scott's rule of thumb for density estimation bw.relrisk cross-validated bandwidth selection for relrisk bw.smoothppp cross-validated bandwidth selection for Smooth.ppp bw.frac bandwidth selection using window geometry bw.stoyan Stoyan's rule of thumb for bandwidth for pcf }

Modern exploratory tools: ll{ 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 covariate effect }

Summary statistics for a point pattern: ll{ quadratcount Quadrat counts 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 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 lohboot bootstrap for a summary function }

Related facilities: ll{ plot.fv plot a summary function eval.fv evaluate any expression involving summary functions 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 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 density.ppp kernel smoothed density Smooth.ppp spatial interpolation of marks relrisk kernel estimate of relative risk sharpen.ppp data sharpening rknn theoretical 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. ll{ relrisk kernel estimation of relative risk scan.test spatial scan test of elevated risk Gcross,Gdot,Gmulti multitype nearest neighbour distributions $G_{ij}, G_{i\bullet}$ Kcross,Kdot, Kmulti multitype $K$-functions $K_{ij}, K_{i\bullet}$ Lcross,Ldot multitype $L$-functions $L_{ij}, L_{i\bullet}$ Jcross,Jdot,Jmulti multitype $J$-functions $J_{ij}, J_{i\bullet}$ pcfcross multitype pair correlation function $g_{ij}$ pcfdot multitype pair correlation function $g_{i\bullet}$ markconnect marked connection function $p_{ij}$ 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 pcfcross.inhom,pcfdot.inhom inhomogeneous counterparts of pcfcross, pcfdot }

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: ll{ markmean smoothed local average of marks markvar smoothed local variance of marks markcorr mark correlation function markvario mark variogram markcorrint mark correlation integral Emark mark independence diagnostic $E(r)$ Vmark mark independence diagnostic $V(r)$ nnmean nearest neighbour mean index nnvario nearest neighbour mark variance index } For marks of any type, there are the following: ll{ Gmulti multitype nearest neighbour distribution Kmulti multitype $K$-function Jmulti multitype $J$-function } Alternatively use cut.ppp to convert a marked point pattern to a multitype point pattern.

Programming tools: ll{ 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 pppdist find 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: ll{ linearK $K$ function on linear network linearKinhom inhomogeneous $K$ function on linear network linearpcf pair correlation function on linear network linearpcfinhom inhomogeneous pair correlation on linear network }

For multitype patterns: ll{ linearKcross $K$ function between two types of points linearKdot $K$ function from one type to any type linearKcross.inhom Inhomogeneous version of linearKcross linearKdot.inhom Inhomogeneous version of linearKdot linearmarkconnect Mark connection function on linear network linearmarkequal Mark equality function on linear network linearpcfcross Pair correlation between two types of points linearpcfdot Pair correlation from one type to any type linearpcfcross.inhom Inhomogeneous version of linearpcfcross linearpcfdot.inhom Inhomogeneous version of linearpcfdot }

Related facilities: ll{ pairdist.lpp distances between pairs crossdist.lpp distances between pairs nndist.lpp nearest neighbour distances nncross.lpp nearest neighbour distances nnwhich.lpp find nearest neighbours nnfun.lpp find nearest data point distfun.lpp distance transform envelope.lpp simulation envelopes rpoislpp simulate Poisson points on linear network runiflpp simulate 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).

ll{ F3est empty space function $F$ G3est nearest neighbour function $G$ K3est $K$-function pcf3est pair correlation function }

Related facilities: ll{ envelope.pp3 simulation envelopes pairdist.pp3 distances between all pairs of points crossdist.pp3 distances between points in two patterns nndist.pp3 nearest neighbour distances nnwhich.pp3 find nearest neighbours nncross.pp3 find nearest neighbours in another pattern }

Computations for multi-dimensional point pattern:

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

ll{ pairdist.ppx distances between all pairs of points crossdist.ppx distances between points in two patterns nndist.ppx nearest neighbour distances nnwhich.ppx find nearest neighbours }

Summary statistics for random sets: These work for point patterns (class ppp), line segment patterns (class psp) or windows (class owin). ll{ Hest spherical contact distribution $H$ Gfox Foxall $G$-function Jfox Foxall $J$-function }

III. MODEL FITTING (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.

ll{ kppm Fit model plot.kppm Plot the fitted model fitted.kppm Compute fitted intensity predict.kppm Compute fitted intensity update.kppm Update the model simulate.kppm Generate simulated realisations vcov.kppm Variance-covariance matrix of coefficients Kmodel.kppm $K$ function of fitted model pcfmodel.kppm Pair correlation of fitted model } 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:

ll{ lgcp.estK fit a log-Gaussian Cox process model lgcp.estpcf fit a log-Gaussian Cox process model thomas.estK fit the Thomas process model thomas.estpcf fit the Thomas process model matclust.estK fit the Matern Cluster process model matclust.estpcf fit the Matern Cluster process model cauchy.estK fit a Neyman-Scott Cauchy cluster process cauchy.estpcf fit a Neyman-Scott Cauchy cluster process vargamma.estK fit a Neyman-Scott Variance Gamma process vargamma.estpcf fit a Neyman-Scott Variance Gamma process mincontrast low-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 Poison 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"): ll{ 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 conditional intensity loglinear in $x$ } It is also possible to fit models that depend on other covariates.

Manipulating the fitted model:

ll{ plot.ppm Plot the fitted model predict.ppm Compute the spatial trend and conditional intensity of the fitted point process model coef.ppm Extract the fitted model coefficients formula.ppm Extract the trend formula fitted.ppm Compute fitted conditional intensity at quadrature points residuals.ppm Compute point process residuals at quadrature points update.ppm Update the fit vcov.ppm Variance-covariance matrix of estimates rmh.ppm Simulate from fitted model simulate.ppm Simulate from fitted model print.ppm Print basic information about a fitted model summary.ppm Summarise a fitted model effectfun Compute the fitted effect of one covariate logLik.ppm log-likelihood or log-pseudolikelihood anova.ppm Analysis of deviance model.frame.ppm Extract data frame used to fit model model.images Extract spatial data used to fit model model.depends Identify variables in the model as.interact Interpoint interaction component of model fitin Extract fitted interpoint interaction is.hybrid Determine whether the model is a hybrid valid.ppm Check the model is a valid point process project.ppm Ensure 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. 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. ll{ ~1 No trend (stationary) ~x Loglinear trend $\lambda(x,y) = \exp(\alpha + \beta x)$ where $x,y$ are Cartesian coordinates ~polynom(x,y,3) Log-cubic polynomial trend ~harmonic(x,y,2) Log-harmonic polynomial trend }

The higher order (``interaction'') components are described by an object of class "interact". Such objects are created by: ll{ 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 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 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. ll{ quadscheme default quadrature scheme using rectangular cells or Dirichlet cells pixelquad quadrature scheme based on image pixels quad create an object of class "quad" } To inspect a quadrature scheme: ll{ 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: ll{ default.dummy default pattern of dummy points gridcentres dummy points in a rectangular grid rstrat stratified random dummy pattern spokes radial pattern of dummy points corners dummy points at corners of the window } To compute weights: ll{ gridweights quadrature weights by the grid-counting rule dirichlet.weights quadrature weights are Dirichlet tile areas }

Simulation and goodness-of-fit for fitted models: ll{ rmh.ppm simulate realisations of a fitted model simulate.ppm simulate realisations of a fitted model envelope compute 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.

ll{ 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 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 methods.linfun conversion facilities }

V. 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"): ll{ 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 intensity loglinear in covariate Z }

Manipulating a fitted spatial logistic regression ll{ 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 simulate.slrm Simulate 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.

VI. SIMULATION

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

Random point patterns:

ll{ 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 latex{Mat'ern}{Matern} Model I inhibition process rMaternII simulate the latex{Mat'ern}{Matern} Model II inhibition process rSSI simulate Simple Sequential Inhibition process rStrauss simulate Strauss process (perfect simulation) rNeymanScott simulate a general Neyman-Scott process rMatClust simulate the latex{Mat'ern}{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 rpoisppOnLines generate Poisson random points along specified line segments } Resampling a point pattern:

ll{ quadratresample block resampling rjitter apply random displacements to points in a pattern rshift random shifting of (subsets of) points rthin random 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:

ll{ 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 rMosaicField generate random pixel image by assigning random values in each tile of a tessellation }

Simulation-based inference

ll{ envelope critical envelope for Monte Carlo test of goodness-of-fit qqplot.ppm diagnostic plot for interpoint interaction scan.test spatial scan statistic/test }

VII. TESTS AND DIAGNOSTICS

Classical hypothesis tests: ll{ quadrat.test $\chi^2$ goodness-of-fit test on quadrat counts clarkevans.test Clark and Evans test kstest Kolmogorov-Smirnov goodness-of-fit test bermantest Berman's goodness-of-fit tests envelope critical envelope for Monte Carlo test of goodness-of-fit scan.test spatial scan statistic/test dclf.test Diggle-Cressie-Loosmore-Ford test mad.test Mean Absolute Deviation test dclf.progress Progress plot for DCLF test mad.progress Progress plot for MAD test anova.ppm Analysis of Deviance for point process models }

Sensitivity diagnostics:

Classical measures of model sensitivity such as leverage and influence have been adapted to point process models. ll{ leverage.ppm Leverage for point process model influence.ppm Influence for point process model dfbetas.ppm Parameter influence } Diagnostics for covariate effect:

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

ll{ parres Partial residual plot addvar Added variable plot rhohat Kernel estimate of covariate effect rho2hat Kernel 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.

ll{ 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 compareFit compare compensators of several fitted models }

Resampling and randomisation procedures

You can build your own tests based on randomisation and resampling using the following capabilities: ll{ quadratresample block resampling rjitter apply random displacements to points in a pattern rshift random shifting of (subsets of) points rthin random thinning }

VIII. DOCUMENTATION

The online manual entries are quite detailed and should be consulted first for information about a particular function. The paper by Baddeley and Turner (2005a) is a brief overview of the package. Baddeley and Turner (2005b) is a more detailed explanation of how to fit point process models to data. Baddeley (2010) is a complete set of notes from a 2-day workshop on the use of spatstat.

Type citation("spatstat") to get 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, Abdollah Jalilian, Marie-Colette van Lieshout, Ege Rubak, Dominic Schuhmacher and Rasmus Waagepetersen made substantial contributions of code.

Additional contributions by Ang Qi Wei, Sandro Azaele, Colin Beale, Thomas Bendtsen, Ricardo Bernhardt, Andrew Bevan, Brad Biggerstaff, 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, Robin Corria Ainslie, Marcelino de la Cruz, Peter Dalgaard, Peter Diggle, Patrick Donnelly, Ian Dryden, Stephen Eglen, Olivier Flores, Neba Funwi-Gabga, Agnes Gault, Marc Genton, Julian Gilbey, Jason Goldstick, Pavel Grabarnik, C. Graf, Janet Franklin, Ute Hahn, Andrew Hardegen, Mandy Hering, Martin Bogsted Hansen, Martin Hazelton, Juha Heikkinen, Kurt Hornik, Ross Ihaka, Aruna Jammalamadaka, Robert John-Chandran, Devin Johnson, Mike Kuhn, Jeff Laake, Frederic Lavancier, Tom Lawrence, Robert Lamb, Jonathan Lee, George Leser, Li Haitao, George Limitsios, Ben Madin, Kiran Marchikanti, Jeff Marcus, Robert Mark, Jorge Mateu Mahiques, Monia Mahling, Peter McCullagh, Ulf Mehlig, Sebastian Wastl Meyer, Mi Xiangcheng, Jesper Moller, Erika Mudrak, Linda Stougaard Nielsen, Felipe Nunes, Jens Oehlschlaegel, Thierry Onkelinx, Sean O'Riordan, Evgeni Parilov, Jeff Picka, Nicolas Picard, Sergiy Protsiv, Adrian Raftery, Matt Reiter, Tom Richardson, Brian Ripley, Ted Rosenbaum, Barry Rowlingson, John Rudge, Farzaneh Safavimanesh, Aila Sarkka, Katja Schladitz, Bryan Scott, Vadim Shcherbakov, Shen Guochun, Ida-Maria Sintorn, Yong Song, Malte Spiess, Mark Stevenson, Kaspar Stucki, Michael Sumner, P. Surovy, Ben Taylor, Thordis Linda Thorarinsdottir, Berwin Turlach, Andrew van Burgel, Tobias Verbeke, Alexendre Villers, Fabrice Vinatier, Hao Wang, H. Wendrock, Jan Wild, Selene Wong, Mike Zamboni and Achim Zeileis.

References

Baddeley, A. (2010) Analysing spatial point patterns in R. Workshop notes. Version 4.1. CSIRO online technical publication. URL: www.uwa.edu.au/resources/pf16h.html Baddeley, A. and Turner, R. (2005a) Spatstat: an R package for analyzing spatial point patterns. Journal of Statistical Software 12:6, 1--42. URL: www.jstatsoft.org, ISSN: 1548-7660.

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. http://www.jstatsoft.org/v55/i11/

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

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.

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

Aliases
  • spatstat-package
  • spatstat
Documentation reproduced from package spatstat, version 1.34-1, License: GPL (>= 2)

Community examples

Looks like there are no examples yet.