stcov
objects and interpolate spatio-temporal covariates on a regular gridThis function interpolates the covariate values observed
at some observed sites to a regular grid. The imput object
should be either a matrix or a dataframe with four columns:
x
, y
, t
, and the covariate values, named as the
covariate later called in the model formula (see stppm
).
The interpolation is performed through Inverse Distance Weighting (IDW).
See the Details.
stcov(
x,
interp = TRUE,
nx = NULL,
mult = 1,
p = 81,
names = NULL,
verbose = FALSE
)
A stpm
object, to be imputed as list object in stppm
.
A data.frame with four columns, containing the spatio-temporal coordinates and the covariate values.
Logical value indicating whether to interpolate the covariate
on a regular grid. Default to TRUE
.
Number of coordinates to generate for each dimention.
The default is floor((mult * nrow(cov)) ^ (1/3))
.
The multiplicand of the number of points in the default for nx
.
Power of IDW distances.
Factor string to name the covariate.
Default to FALSE. If TRUE, the elapsed minutes are printed.
Nicoletta D'Angelo
The function builds a regular grid with equispaced values along the three coordinates and interpolates the covariate values at the new locations. The interpolation at a point location \(x_k\) is performed through the inverse-distance weighting smoothing procedure of the covariate values \(Z(x_j)\) at their sampling locations \(j=1, \ldots, J\). In such a case, the smoothed value at location \(x_k\) is $$Z(x_k) = \frac{\sum_j w_j Z(x_j)}{\sum_j w_j},$$ where the weight \(w_j\) is the \(j\)-th element of the inverse \(p\)th powers of distance, $$\textbf{w}=\{w_j\}_{j=1}^J=\{\frac{1}{d(x_k-x_j)^p}\}_{j=1}^J,$$ with $$d(x_k-x_j) = ||x_k-x_j||$$ the Euclidean distance from \(x_k\) to \(x_j\).
stppm
set.seed(2)
df <- data.frame(runif(100), runif(100), runif(100), rpois(100, 15))
cov <- stcov(df, interp = FALSE)
Run the code above in your browser using DataLab