```
# NOT RUN {
X <- simdat
# Envelope of K function under CSR
# }
# NOT RUN {
plot(envelope(X))
# }
# NOT RUN {
# }
# NOT RUN {
# Translation edge correction (this is also FASTER):
# }
# NOT RUN {
plot(envelope(X, correction="translate"))
# }
# NOT RUN {
# }
# NOT RUN {
# Global envelopes
# }
# NOT RUN {
plot(envelope(X, Lest, global=TRUE))
plot(envelope(X, Kest, global=TRUE, scale=function(r) { r }))
# }
# NOT RUN {
# }
# NOT RUN {
# Envelope of K function for simulations from Gibbs model
# }
# NOT RUN {
fit <- ppm(cells ~1, Strauss(0.05))
plot(envelope(fit))
plot(envelope(fit), global=TRUE)
# }
# NOT RUN {
# }
# NOT RUN {
# Envelope of K function for simulations from cluster model
fit <- kppm(redwood ~1, "Thomas")
# }
# NOT RUN {
plot(envelope(fit, Gest))
plot(envelope(fit, Gest, global=TRUE))
# }
# NOT RUN {
# }
# NOT RUN {
# Envelope of G function under CSR
# }
# NOT RUN {
plot(envelope(X, Gest))
# }
# NOT RUN {
# }
# NOT RUN {
# Envelope of L function under CSR
# L(r) = sqrt(K(r)/pi)
# }
# NOT RUN {
E <- envelope(X, Kest)
plot(E, sqrt(./pi) ~ r)
# }
# NOT RUN {
# }
# NOT RUN {
# Simultaneous critical envelope for L function
# (alternatively, use Lest)
# }
# NOT RUN {
plot(envelope(X, Kest, transform=expression(sqrt(./pi)), global=TRUE))
# }
# NOT RUN {
# }
# NOT RUN {
## One-sided envelope
# }
# NOT RUN {
plot(envelope(X, Lest, alternative="less"))
# }
# NOT RUN {
# }
# NOT RUN {
# 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'
# }
# NOT RUN {
plot(envelope(demopat, Jcross, i="A", j="B"))
# }
# NOT RUN {
# }
# NOT RUN {
# Use of `simulate' expression
# }
# NOT RUN {
plot(envelope(cells, Gest, simulate=expression(runifpoint(42))))
plot(envelope(cells, Gest, simulate=expression(rMaternI(100,0.02))))
# }
# NOT RUN {
# }
# NOT RUN {
# Use of `simulate' function
# }
# NOT RUN {
plot(envelope(amacrine, Kcross, simulate=rlabel))
# }
# NOT RUN {
# }
# NOT RUN {
# Envelope under random toroidal shifts
# }
# NOT RUN {
plot(envelope(amacrine, Kcross, i="on", j="off",
simulate=expression(rshift(amacrine, radius=0.25))))
# }
# NOT RUN {
# Envelope under random shifts with erosion
# }
# NOT RUN {
plot(envelope(amacrine, Kcross, i="on", j="off",
simulate=expression(rshift(amacrine, radius=0.1, edge="erode"))))
# }
# NOT RUN {
# Envelope of INHOMOGENEOUS K-function with fitted trend
# The following is valid.
# Setting lambda=fit means that the fitted model is re-fitted to
# each simulated pattern to obtain the intensity estimates for Kinhom.
# (lambda=NULL would also be valid)
fit <- kppm(redwood ~1, clusters="MatClust")
# }
# NOT RUN {
plot(envelope(fit, Kinhom, lambda=fit, nsim=19))
# }
# NOT RUN {
# }
# NOT RUN {
# Note that the principle of symmetry, essential to the validity of
# simulation envelopes, requires that both the observed and
# simulated patterns be subjected to the same method of intensity
# estimation. In the following example it would be incorrect to set the
# argument 'lambda=red.dens' in the envelope command, because this
# would mean that the inhomogeneous K functions of the simulated
# patterns would be computed using the intensity function estimated
# from the original redwood data, violating the symmetry. There is
# still a concern about the fact that the simulations are generated
# from a model that was fitted to the data; this is only a problem in
# small datasets.
# }
# NOT RUN {
red.dens <- density(redwood, sigma=bw.diggle)
plot(envelope(redwood, Kinhom, sigma=bw.diggle,
simulate=expression(rpoispp(red.dens))))
# }
# NOT RUN {
# Precomputed list of point patterns
# }
# NOT RUN {
nX <- npoints(X)
PatList <- list()
for(i in 1:19) PatList[[i]] <- runifpoint(nX)
E <- envelope(X, Kest, nsim=19, simulate=PatList)
# }
# NOT RUN {
# re-using the same point patterns
# }
# NOT RUN {
EK <- envelope(X, Kest, savepatterns=TRUE)
EG <- envelope(X, Gest, simulate=EK)
# }
```

Run the code above in your browser using DataCamp Workspace