Simulation envelopes of summary function

Computes simulation envelopes of a summary function.

hplot, htest, spatial, iteration
envelope(Y, fun=Kest, nsim=99, nrank=1, verbose=TRUE, ...,
  simulate=NULL, clipdata=TRUE, start=NULL,control=list(nrep=1e5,expand=1.5),
Either a point pattern (object of class "ppp") or a fitted point process model (object of class "ppm").
Function that computes the desired summary statistic for a point pattern.
Number of simulated point patterns to be generated when computing the envelopes.
Integer. Rank of the envelope value amongst the nsim simulated values. A rank of 1 means that the minimum and maximum simulated values will be used.
Logical flag indicating whether to print progress reports during the simulations.
Extra arguments passed to fun.
Optional. An expression. If this is present, then the simulated point patterns will be generated by evaluating this expression nsim times.
Logical flag indicating whether the data point pattern should be clipped to the same window as the simulated patterns, before the summary function for the data is computed. This should usually be TRUE to ensure that the
Optional. These specify the arguments start and control of rmh, giving complete control over the simulation algorithm.
Optional. A transformation to be applied to the function values, before the envelopes are computed. An expression object (see Details).
Logical flag indicating whether envelopes should be pointwise (global=FALSE) or simultaneous (global=TRUE).
Optional. A vector of length 2 specifying the interval of $r$ values for the simultaneous critical envelopes. Only relevant if global=TRUE.

Simulation envelopes can be used to assess the goodness-of-fit of a point process model to point pattern data. See the References.

This function first generates nsim random point patterns in one of the following ways.

  • IfYis a point pattern (an object of class"ppp") andsimulate=NULL, then this routine generatesnsimsimulations of Complete Spatial Randomness (i.e.nsimsimulated point patterns each being a realisation of the uniform Poisson point process) with the same intensity as the patternY. (IfYis a multitype point pattern, then the simulated patterns are also given independent random marks; the probability distribution of the random marks is determined by the relative frequencies of marks inY.)
  • IfYis a fitted point process model (an object of class"ppm") andsimulate=NULL, then this routine generatesnsimsimulated realisations of that model.
  • Ifsimulateis supplied, then it must be an expression. It will be evaluatednsimtimes to yieldnsimpoint patterns.
The summary statistic fun is applied to each of these simulated patterns. Typically fun is one of the functions Kest, Gest, Fest, Jest, pcf, Kcross, Kdot, Gcross, Gdot, Jcross, Jdot, Kmulti, Gmulti, Jmulti or Kinhom. It may also be a character string containing the name of one of these functions.

The statistic fun can also be a user-supplied function; if so, then it must have arguments X and r like those in the functions listed above, and it must return an object of class "fv".

Upper and lower critical envelopes are computed in one of the following ways: [object Object],[object Object] The return value is an object of class "fv" containing the summary function for the data point pattern and the upper and lower simulation envelopes. It can be plotted using plot.fv.

Arguments can be passed to the function fun through .... This makes it possible to select the edge correction used to calculate the summary statistic. See the Examples. Selecting only a single edge correction will make the code run much faster.

If Y is a fitted point process model, and simulate=NULL, then the model is simulated by running the Metropolis-Hastings algorithm rmh. Complete control over this algorithm is provided by the arguments start and control which are passed to rmh.

For simultaneous critical envelopes (global=TRUE) the following options are also useful: [object Object],[object Object]


  • An object of class "fv", see fv.object, which can be plotted directly using plot.fv.

    Essentially a data frame containing columns

  • rthe vector of values of the argument $r$ at which the summary function fun has been estimated
  • obsvalues of the summary function for the data point pattern
  • lolower envelope of simulations
  • hiupper envelope of simulations


Cressie, N.A.C. Statistics for spatial data. John Wiley and Sons, 1991.

Diggle, P.J. Statistical analysis of spatial point patterns. Arnold, 2003.

Ripley, B.D. (1981) Spatial statistics. John Wiley and Sons.

Ripley, B.D. Statistical inference for spatial processes. Cambridge University Press, 1988.

Stoyan, D. and Stoyan, H. (1994) Fractals, random shapes and point fields: methods of geometrical statistics. John Wiley and Sons.

See Also

fv.object, plot.fv, Kest, Gest, Fest, Jest, pcf, ppp, ppm

  • envelope
 X <- simdat

 # Envelope of K function under CSR
 <testonly>plot(envelope(X, nsim=4))</testonly>

 # Translation edge correction (this is also FASTER):
 plot(envelope(X, correction="translate"))
 <testonly>plot(envelope(X, nsim=4, correction="translate"))</testonly>

 # Envelope of K function for simulations from model 
 fit <- ppm(cells, ~1, Strauss(0.05))
 <testonly>plot(envelope(fit, nsim=4))</testonly>

 # Envelope of G function under CSR
 plot(envelope(X, Gest))
 <testonly>plot(envelope(X, Gest, nsim=4))</testonly>

 # Envelope of L function under CSR
 #  L(r) = sqrt(K(r)/pi)
 E <- envelope(X, Kest)
  plot(E, sqrt(./pi) ~ r)
 <testonly>E <- envelope(X, Kest, nsim=4)
  plot(E, sqrt(./pi) ~ r)</testonly>

 # Simultaneous critical envelope for L function
 plot(envelope(X, Kest, transform=expression(sqrt(./pi)), global=TRUE))
 <testonly>plot(envelope(X, Kest, nsim=4,transform=expression(sqrt(./pi)), global=TRUE))</testonly>

 # How to pass arguments needed to compute the summary functions:
 # We want envelopes for Jcross(X, "A", "B") 
 # where "A" and "B" are types of points in the dataset 'demopat'

 plot(envelope(demopat, Jcross, i="A", j="B"))
 <testonly>plot(envelope(demopat, Jcross, i="A", j="B", nsim=4))</testonly>
 # Use of `simulate'
 plot(envelope(cells, Gest, simulate=expression(runifpoint(42))))
 plot(envelope(cells, Gest, simulate=expression(rMaternI(100,0.02))))
 <testonly>plot(envelope(cells, Gest, simulate=expression(runifpoint(42)), nsim=4))
  plot(envelope(cells, Gest, simulate=expression(rMaternI(100, 0.02)), nsim=4))</testonly>

 # Envelope under random toroidal shifts
 plot(envelope(amacrine, Kcross, i="on", j="off",
               simulate=expression(rshift(amacrine, radius=0.25))))

 # Envelope under random shifts with erosion
 plot(envelope(amacrine, Kcross, i="on", j="off",
              simulate=expression(rshift(amacrine, radius=0.1, edge="erode"))))
 # Envelope of INHOMOGENEOUS K-function with fitted trend
trend <- density.ppp(X, 1.5)
 plot(envelope(X, Kinhom, lambda=trend,
Documentation reproduced from package spatstat, version 1.10-1, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.