#####################
## Same example as in pc.estK
data(gypsophylous)
## Estimate K function ("Kobs").
gyps.env <- envelope(gypsophylous, Kest, correction="iso", nsim=99)
plot(gyps.env, sqrt(./pi)-r~r)
## Fit Poisson Cluster Process. The limits of integration
## rmin and rmax are setup to 0 and 60, respectively.
cosa.pc2 <- ipc.estK(gypsophylous, r = gyps.env$r[gyps.env$r<=60])
## Add fitted Kclust function to the plot.
plot(cosa.pc2, add=T, lwd=c(3,3))
## A kind of pointwise test of the gypsophylous pattern been a realisation
## of the fitted model, simulating with sim.poissonc and using function J (Jest).
gyps.env.sim2 <- envelope(gypsophylous, Jest, nsim=99,
simulate=expression(rIPCP(cosa.pc2)))
plot(gyps.env.sim2, main="")
#####################
## Inhomogeneous example
data(urkiola)
# get univariate pp
I.ppp <- split.ppp(urkiola)$birch
#estimate inhomogeneous intensity function
I.lam <- predict (ppm(I.ppp, ~polynom(x,y,2)), type="trend", ngrid=200)
# Compute and plot envelopes to Kinhom, simulating from an Inhomogeneous Poisson Process:
I2.env <- envelope( I.ppp,Kinhom, lambda=I.lam, correction="trans",
nsim=99, simulate=expression(rpoispp(I.lam)))
plot(I2.env, sqrt(./pi)-r~r)
# It seems that there is short scale clustering; lets fit an IPCP:
I.ki <- ipc.estK(mippp=I.ppp, lambda=I.lam, correction="trans")
# Compute and plot envelopes to Kinhom, simulating from the fitted IPCP:
Ipc.env= Ki(I.ki, correction="trans", nsim=99, ngrid=200)
plot (Ipc.env)
Run the code above in your browser using DataLab