Crop the curve set to the interval of distances [r_min, r_max], calculate residuals, scale the residuals and perform a deviation test with a chosen deviation measure. The deviation tests are well known in spatial statistics; in GET they are provided for comparative purposes. Some (maximum type) of the deviation test have their corresponding envelope tests available, see Myllymäki et al., 2017 (and 'unscaled', 'st' and 'qdir' in global_envelope_test).
curve_set: A residual curve_set object. Can be obtained by using residual().
r_min: The minimum radius to include.
r_max: The maximum radius to include.
use_theo: Whether to use the theoretical summary function or the mean of the functions in the curve_set.
scaling: The name of the scaling to use. Options include 'none', 'q', 'qdir' and 'st'. 'qdir' is default.
measure: The deviation measure to use. Default is 'max'. Must be one of the following: 'max', 'int' or 'int2'.
alternative: A character string specifying the alternative hypothesis when measure = 'max'; otherwise ignored. Must be one of the following: "two.sided" (default), "less" or "greater".
savedevs: Logical. Should the global rank values k_i, i=1,...,nsim+1 be returned? Default: FALSE.
Returns
If 'savedevs=FALSE' (default), the p-value is returned. If 'savedevs=TRUE', then a list containing the p-value and calculated deviation measures ui, i=1,...,nsim+1 (where u1 corresponds to the data pattern) is returned.
Details
The deviation test is based on a test function T(r) and it works as follows:
The test function estimated for the data, T1(r), and for nsim simulations from the null model, T2(r),....,Tnsim+1(r), must be saved in 'curve_set' and given to the deviation_test function.
The deviation_test function then
Crops the functions to the chosen range of distances [rmin,rmax].
If the curve_set does not consist of residuals (see residual), then the residuals di(r)=Ti(r)−T0(r) are calculated, where T0(r) is the expectation of T(r) under the null hypothesis. If use_theo = TRUE, the theoretical value given in the curve_settheoisusedforasT_0(r),ifitisgiven.Otherwise,T_0(r)isestimatedbythemeanofT_j(r),j=2,...,nsim+1$.
Scales the residuals. Options are
'none' No scaling. Nothing done.
'q' Quantile scaling.
'qdir' Directional quantile scaling.
'st' Studentised scaling.
See for details Myllymäki et al. (2013).
Calculates the global deviation measure ui, i=1,...,nsim+1, see options for 'measure'.
'max' is the maximum deviation measure
ui=r∈[rmin,rmax]max∣w(r)(Ti(r)−T0(r))∣
If `alternative = "greater"`, then instead
ui=r∈[rmin,rmax]max[w(r)(Ti(r)−T0(r))]
i.e. the largest values will have the largest $u_i$.
If `alternative = "less"`, then instead
ui=r∈[rmin,rmax]max[−w(r)(Ti(r)−T0(r))]
i.e. the smallest values will have the largest $u_i$.
* 'int2' is the integral deviation measure
ui=∫rminrmax(w(r)(Ti(r)−T0(r)))2dr
* 'int' is the 'absolute' integral deviation measure
ui=∫rminrmax∣w(r)(Ti(r)−T0(r))∣dr
Calculates the p-value.
Examples
## Testing complete spatial randomness (CSR)#-------------------------------------------if(require("spatstat.explore", quietly=TRUE)){ pp <- unmark(spruces) nsim <-999# Generate nsim simulations under CSR, calculate L-function for the data and simulations env <- envelope(pp, fun="Lest", nsim=nsim, savefuns=TRUE, correction="translate")# The deviation test using the integral deviation measure res <- deviation_test(env, measure='int') res
# or res <- deviation_test(env, r_min=0, r_max=7, measure='int2')}
References
Myllymäki, M., Grabarnik, P., Seijo, H. and Stoyan. D. (2015). Deviation test construction and power comparison for marked spatial point patterns. Spatial Statistics 11: 19-34. doi: 10.1016/j.spasta.2014.11.004
Myllymäki, M., Mrkvička, T., Grabarnik, P., Seijo, H. and Hahn, U. (2017). Global envelope tests for spatial point patterns. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 79: 381–404. doi: 10.1111/rssb.12172