The deviation test is based on a test function \(T(r)\) and it works as follows:
1) The test function estimated for the data, \(T_1(r)\), and for nsim simulations
from the null model, \(T_2(r), ...., T_{nsim+1}(r)\), must be saved in 'curve_set'
and given to the deviation_test function.
2) The deviation_test function then
Crops the functions to the chosen range of distances \([r_{\min}, r_{\max}]\).
If the curve_set does not consist of residuals (see residual),
then the residuals \(d_i(r) = T_i(r) - T_0(r)\) are calculated, where \(T_0(r)\) is the
expectation of \(T(r)\) under the null hypothesis.
If use_theo = TRUE, the theoretical value given in the curve_set$theo is used for
as \(T_0(r)\), if it is given. Otherwise, \(T_0(r)\) is estimated by the mean of \(T_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<U+00E4>ki et al. (2013).
Calculates the global deviation measure \(u_i\), \(i=1,...,nsim+1\), see options
for 'measure'.
'max' is the maximum deviation measure
$$u_i = \max_{r \in [r_{\min}, r_{\max}]} | w(r)(T_i(r) - T_0(r))|$$
'int2' is the integral deviation measure
$$u_i = \int_{r_{\min}}^{r_{\max}} ( w(r)(T_i(r) - T_0(r)) )^2 dr$$
'int' is the 'absolute' integral deviation measure
$$u_i = \int_{r_{\min}}^{r_{\max}} |w(r)(T_i(r) - T_0(r))| dr$$
Calculates the p-value.
Currently, there is no special way to take care of the same values of \(T_i(r)\)
occuring possibly for small distances. Thus, it is preferable to exclude from
the test the very small distances r for which ties occur.