X <- simdat
# Envelope of K function under CSR
plot(envelope(X))
<testonly>plot(envelope(X, nsim=3))</testonly>
# Translation edge correction (this is also FASTER):
plot(envelope(X, correction="translate"))
<testonly>E <- envelope(X, nsim=3, correction="translate")</testonly>
# Envelope of K function for simulations from Gibbs model
fit <- ppm(cells, ~1, Strauss(0.05))
plot(envelope(fit))
plot(envelope(fit), global=TRUE)
<testonly>fit <- ppm(cells, ~1, Strauss(0.05), nd=20)
E <- envelope(fit, nsim=3, correction="border", nrep=100)
E <- envelope(fit, nsim=3, correction="border", global=TRUE, nrep=100)</testonly>
# Envelope of K function for simulations from cluster model
fit <- kppm(redwood, ~1, "Thomas")
plot(envelope(fit, Gest))
plot(envelope(fit, Gest, global=TRUE))
<testonly>E <- envelope(fit, Gest, correction="rs", nsim=3, global=TRUE, nrep=100)</testonly>
# Envelope of G function under CSR
plot(envelope(X, Gest))
<testonly>E <- envelope(X, Gest, correction="rs", nsim=3)</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, correction="border", nsim=3)
plot(E, sqrt(./pi) ~ r)</testonly>
# Simultaneous critical envelope for L function
# (alternatively, use Lest)
plot(envelope(X, Kest, transform=expression(sqrt(./pi)), global=TRUE))
<testonly>E <- envelope(X, Kest, nsim=3, correction="border",
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'
data(demopat)
plot(envelope(demopat, Jcross, i="A", j="B"))
<testonly>plot(envelope(demopat, Jcross, correction="rs", i="A", j="B", nsim=3))</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, correction="rs", simulate=expression(runifpoint(42)), nsim=3))
plot(envelope(cells, Gest, correction="rs", simulate=expression(rMaternI(100, 0.02)),
nsim=3, global=TRUE))</testonly>
# Envelope under random toroidal shifts
data(amacrine)
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
# 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.
red.dens <- density(redwood, sigma=bw.diggle)
plot(envelope(redwood, Kinhom, sigma=bw.diggle,
simulate=expression(rpoispp(red.dens))))
# Precomputed list of point patterns
nX <- npoints(X)
PatList <- list()
for(i in 1:19) PatList[[i]] <- runifpoint(nX)
E <- envelope(X, Kest, nsim=19, simulate=PatList)
<testonly>PatList <- list()
for(i in 1:3) PatList[[i]] <- runifpoint(10)
E <- envelope(X, Kest, nsim=3, simulate=PatList)</testonly>
# re-using the same point patterns
EK <- envelope(X, Kest, savepatterns=TRUE)
EG <- envelope(X, Gest, simulate=EK)
<testonly>EK <- envelope(X, Kest, nsim=3, savepatterns=TRUE)
EG <- envelope(X, Gest, nsim=3, simulate=EK)</testonly>
Run the code above in your browser using DataLab