Two versions of local covariance matrices can be defined:
'lcov': $$ LCov(f) = 1/n \sum_{i,j} f(d_{i,j}) (x(s_i)-\bar{x}) (x(s_j)-\bar{x})',$$
'ldiff': $$ LDiff(f) = 1/n \sum_{i,j} f(d_{i,j}) (x(s_i)-x(s_j)) (x(s_i)-x(s_j))',$$
'lcov_norm': $$ LCov^*(f) = 1/(n F^{1/2}_{f,n}) \sum_{i,j} f(d_{i,j}) (x(s_i)-\bar{x}) (x(s_j)-\bar{x})',$$ with $$ F_{f,n} = 1 / n \sum_{i,j} f^2(d_{i,j}).$$
Where \(d_{i,j} \ge 0\) correspond to the pairwise distances between coordinates, \(x(s_i)\) are the p random field values at location \(s_i\), \(\bar{x}\) is the sample mean vector, and the kernel function \(f(d)\) determines the locality. The function spatial_kernel_matrix computes a list of c(n,n) matrices where each entry of these matrices correspond to the spatial kernel function evaluated at the distance between two points, mathematically the entry ij of each kernel matrix is \(f(d_{i,j})\). The following kernel functions are implemented and chosen with the argument kernel_type:
'ring': parameters are inner radius \(r_i\) and outer radius \(r_o\), with \(r_i < r_o\), and \(r_i, r_o \ge 0\): $$f(d;r_i, r_o) = I(r_i < d \le r_o)$$
'ball': parameter is the radius \(r\), with \(r \ge 0\): $$f(d;r) = I(d \le r)$$
'gauss': Gaussian function where 95% of the mass is inside the parameter \(r\), with \(r \ge 0\): $$f(d;r) = exp(-0.5 (\Phi^{-1}(0.95) d/r)^2)$$
The argument kernel_type determines the used kernel function as presented above, the argument kernel_parameters gives the corresponding parameters for the kernel function. Specifically, if kernel_type equals 'ball' or 'gauss' then kernel_parameters is a numeric vector where each entry corresponds to one parameter. Hence, length(kernel_parameters) spatial kernel matrices of type kernel_type are computed. Whereas, if kernel_type equals 'ring', then kernel_parameters must be a numeric vector of even length where subsequently the inner and outer radii must be given (informally: c(r_i1, r_o1, r_i2, r_o2, ...)). In that case length(kernel_parameters) / 2 spatial kernel matrices of type 'ring' are computed.
If the optional argument angles is provided, the computed spatial kernel matrices incorporate anisotropic constraints. The angles argument must be a list of numeric vectors, where each vector consists of two values: \(\alpha_1\) (the main direction) and \(\alpha_2\) (the angular tolerance). The directional constraint ensures that only spatial relationships within the specified angle range are considered:
When angles is not NULL, the function applies the kernel function only to points satisfying \(d_{ij} \angle e_{\alpha_1} \in [0, \alpha_2]\). If angles is NULL, the kernels are computed isotropically.
The output of this function can be used with the function sbss to avoid unnecessary computation of kernel matrices when sbss is called multiple times with the same coordinate/kernel function setting. Additionally, the output can be used with the function local_covariance_matrix to actually compute local covariance matrices as defined above based on a given set of spatial kernel matrices.