stkmat {SpaceTimeBSS} | R Documentation |
Spatio-Temporal Kernel Matrices
Description
Computation of spatio-temporal kernel matrices for given kernel functions.
Usage
stkmat(coords, time, kernel_type, kernel_parameters, lags)
Arguments
coords |
a numeric matrix of dimension |
time |
an integer vector of length |
kernel_type |
either a string or a string vector of length |
kernel_parameters |
a numeric vector of length |
lags |
an integer vector of length |
Details
The following kernel functions are implemented and chosen with the argument kernel_type
:
-
'ring'
: the spatial parameters are inner radiusr_i
and outer radiusr_o
, withr_i < r_o
, andr_i, r_o \ge 0
, the temporal parameter is the temporal lagu
:f(d_s,d_t) = I(r_i < d_s \le r_o)I(d_t = u)
-
'ball'
: the spatial parameter is the radiusr
, withr \ge 0
, the temporal parameter is the temporal lagu
:f(d_s,d_t) = I(d_s \le r)I(d_t = u)
-
'gauss'
: Gaussian function where 95% of the mass is inside the spatial parameterr
, withr \ge 0
, the temporal parameter is the temporal lagu
:f(d_s,d_t) = exp(-0.5 (\Phi^{-1}(0.95) d_s/r)^2)I(d_t = u)
Above, I()
represents the indicator function. The argument kernel_type
determines the used kernel function as presented above, the argument lags
provides the used temporal lags for the kernel functions (u
in the above formulas) and the argument kernel_parameters
gives the spatial parameters for the kernel function. Each of the arguments kernel_type
, lags
and kernel_parameters
can be of length K
or 1
. Specifically, kernel_type
can be either one kernel, then each local autocovariance matrix use the same kernel type, or of length K
which leads to different kernel functions for the provided kernel parameters. lags
can be either one integer, then for each kernel the same temporal lag is used, or an integer vector of length K
which leads to different temporal lags. In the same fashion kernel_parameters
is a vector of length K
or 1
. If kernel_type
equals 'ball'
or 'gauss'
then the corresponding entry of kernel_parameters
gives the single spatial radius parameter. In contrast, if (at least one entry of) kernel_type
equals 'ring'
, then kernel_parameters
must be a list of length K
(or 1
) where each entry is a numeric vector of length 2
defining the inner and outer spatial radius. See examples below.
The output of this function can be used with the function stbss
to avoid unnecessary computation of kernel matrices when stbss
is called multiple times with the same coordinate/kernel function setting. Additionally, the output can be used with the function lacov
.
Value
stkmat
returns a list of length K
containing numeric matrices of dimension c(n,n)
corresponding to the spatio-temporal kernel matrices.
References
Muehlmann, C., De Iaco, S. and Nordhausen, K. (2023), Blind Recovery of Sources for Multivariate Space-Time Environmental Data. Stochastic and Environmental Research and Risk Assessment, 37, 1593–1613, <doi:10.1007/s00477-022-02348-2>.
See Also
Examples
# space and time coordinates
n_t <- 50
n_sp <- 10
coords <- runif(n_sp ^ 2 * 2) * n_sp
dim(coords) <- c(n_sp ^ 2, 2)
time <- 1:n_t
st_coords <- as.matrix(expand.grid(1:nrow(coords), 1:length(time)))
st_coords <- cbind(coords[st_coords[, 1], ], time[st_coords[, 2]])
# different ring kernels and same lags
stkmat_r <- stkmat(coords = st_coords[, 1:2], time = st_coords[, 3],
kernel_type = 'ring',
kernel_parameters = list(c(0, 1), c(1, 2)), lags = c(1, 1))
# same ball kernels and different lags
stkmat_b <- stkmat(coords = st_coords[, 1:2], time = st_coords[, 3],
kernel_type = 'ball', kernel_parameters = 1:3, lags = c(1, 2, 3))
# different gauss kernels and different lags
stkmat_g <- stkmat(coords = st_coords[, 1:2], time = st_coords[, 3],
kernel_type = 'gauss', kernel_parameters = 1:3, lags = 1:3)
# mixed kernels
stkmat_m <- stkmat(coords = st_coords[, 1:2], time = st_coords[, 3],
kernel_type = c('ball', 'ring', 'gauss'),
kernel_parameters = list(1, c(1:2), 3), lags = 1:3)