# See more examples in ?global_envelope_test
## Testing complete spatial randomness (CSR)
#-------------------------------------------
if(require("spatstat.explore", quietly=TRUE)) {
X <- spruces
nsim <- 999 # Number of simulations
nsim <- 19 # Number of simulations for testing
## Test for complete spatial randomness (CSR)
# 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)))
res_qdir <- qdir_envelope(env) # The directional quantile envelope test
plot(res_qdir)
## Advanced use:
# Create a curve set, choosing the interval of distances [r_min, r_max]
curve_set <- crop_curves(env, r_min=1, r_max=8)
# The directional quantile envelope test
res_qdir <- qdir_envelope(curve_set); plot(res_qdir)
# The studentised envelope test
res_st <- st_envelope(curve_set); plot(res_st)
# The unscaled envelope test
res_unscaled <- unscaled_envelope(curve_set); plot(res_unscaled)
}
Run the code above in your browser using DataLab