# See ?global_envelope_test for more examples
## Testing complete spatial randomness (CSR)
#-------------------------------------------
if(require("spatstat.explore", quietly=TRUE)) {
X <- unmark(spruces)
nsim <- 2499 # Number of simulations
nsim <- 19 # Number of simulations for testing
# Generate nsim simulations under CSR, calculate centred L-function for the data and simulations
env <- envelope(X, fun="Lest", nsim=nsim, savefuns=TRUE,
correction="translate", transform=expression(.-r),
simulate=expression(runifpoint(ex=X)))
# The rank envelope test
res <- rank_envelope(env)
# Plot the result.
plot(res)
## Advanced use:
# Choose the interval of distances [r_min, r_max] (at the same time create a curve_set from 'env')
curve_set <- crop_curves(env, r_min=1, r_max=7)
# Do the rank envelope test
res <- rank_envelope(curve_set); plot(res)
}
Run the code above in your browser using DataLab