| areal_spacetime_bisquare {stcos} | R Documentation |
Areal Space-Time Bisquare Basis
Description
Space-Time bisquare basis on areal data.
Usage
areal_spacetime_bisquare(dom, period, knots, w_s, w_t, control = NULL)
Arguments
dom |
An |
period |
A numeric vector of time periods |
knots |
Spatio-temporal knots
|
w_s |
Spatial radius for the basis. |
w_t |
Temporal radius for the basis. |
control |
A |
Details
Notes about arguments:
-
knotsmay be provided as either ansforsfcobject, or as a matrix of points. If an
sforsfcobject is provided forknots,rthree-dimensionalPOINTentries are expected inst_geometry(knots). Otherwise,knotswill be interpreted as anr \times 3numeric matrix.If
knotsis ansforsfcobject, it is checked to ensure the coordinate system matchesdom.
For each area A in the given domain, and time period
\bm{v} = (v_1, \ldots, v_m) compute the basis
functions
\psi_j^{(m)}(A, \bm{v}) = \frac{1}{m} \sum_{k=1}^m \frac{1}{|A|} \int_A \psi_j(\bm{u},v_k) d\bm{u},
for j = 1, \ldots, r. Here, \varphi_j{(\bm{u},v)}
represent spacetime_bisquare basis functions defined at the point
level using \bm{c}_j, g_j, w_s, and w_t.
The basis requires an integration which may be computed using one
of two methods. The mc method uses a Monte Carlo approximation
\psi_j^{(m)}(A, \bm{v}) \approx \frac{1}{m} \sum_{k=1}^m
\frac{1}{Q} \sum_{q=1}^Q \psi_j(\bm{u}_q, v_k),
based on a random sample of locations \bm{u}_1, \ldots, \bm{u}_Q from
a uniform distribution on area A. The rect method uses
a simple quadrature approximation
\psi_j^{(m)}(A, \bm{v}) \approx \frac{1}{m} \sum_{k=1}^m
\frac{1}{|A|} \sum_{a=1}^{n_x} \sum_{b=1}^{n_y} \psi_j(\bm{u}_{ab}, v_k)
I(\bm{u}_{ab} \in A) \Delta_x \Delta_y.
Here, the bounding box st_bbox(A) is divided evenly into a grid of
n_x \times n_y rectangles, each of size \Delta_x \times \Delta_y.
Each \bm{u}_{ab} = (u_a, u_b) is a point from the (a,b)th
rectangle, for a = 1, \ldots, n_x and b = 1, \ldots, n_y.
Due to the treatment of A_i and \bm{c}_j as objects in a
Euclidean space, this basis is more suitable for coordinates from a map
projection than coordinates based on a globe representation.
The control argument is a list which may provide any of the following:
-
methodspecifies computation method:mcorrect. Default ismc. -
mc_repsis number of repetitions to use formc. Default is 1000. -
nxis number of x-axis points to use forrectmethod. Default is 50. -
nyis number of y-axis points to use forrectmethod. Default is 50. -
report_periodis an integer; print a message with progress each time this many areas are processed. Default isInfso that message is suppressed. -
verboseis a logical; ifTRUEprint descriptive messages about the computation. Default isFALSE. -
mc_sampling_factoris a positive number; an oversampling factor used to computeblocksizein the rdomain function. I.e.,blocksize = ceiling(mc_sampling_factor * mc_reps). Default is 1.2.
Value
A sparse n \times r matrix whose ith row
is
\bm{s}_i^\top =
\Big(
\psi_1^{(m)}(A_i), \ldots, \psi_r^{(m)}(A_i)
\Big).
See Also
Other bisquare:
areal_spatial_bisquare(),
spacetime_bisquare(),
spatial_bisquare()
Examples
set.seed(1234)
# Create knot points
seq_x = seq(0, 1, length.out = 3)
seq_y = seq(0, 1, length.out = 3)
seq_t = seq(0, 1, length.out = 3)
knots = expand.grid(x = seq_x, y = seq_y, t = seq_t)
knots_sf = st_as_sf(knots, coords = c("x","y","t"), crs = NA, dim = "XYM", agr = "constant")
# Create a simple domain (of rectangles) to evaluate
shape1 = matrix(c(0.0,0.0, 0.5,0.0, 0.5,0.5, 0.0,0.5, 0.0,0.0), ncol=2, byrow=TRUE)
shape2 = shape1 + cbind(rep(0.5,5), rep(0.0,5))
shape3 = shape1 + cbind(rep(0.0,5), rep(0.5,5))
shape4 = shape1 + cbind(rep(0.5,5), rep(0.5,5))
sfc = st_sfc(
st_polygon(list(shape1)),
st_polygon(list(shape2)),
st_polygon(list(shape3)),
st_polygon(list(shape4))
)
dom = st_sf(data.frame(geoid = 1:length(sfc), geom = sfc))
rad = 0.5
period = c(0.4, 0.7)
areal_spacetime_bisquare(dom, period, knots, w = rad, w_t = 1)
areal_spacetime_bisquare(dom, period, knots_sf, w_s = rad, w_t = 1)
# Plot the (spatial) knots and the (spatial) domain at which we evaluated
# the basis.
plot(knots[,1], knots[,2], pch = 4, cex = 1.5, col = "red")
plot(dom[,1], col = NA, add = TRUE)
# Draw a circle representing the basis' radius around one of the knot points
tseq = seq(0, 2*pi, length=100)
coords = cbind(rad * cos(tseq) + seq_x[2], rad * sin(tseq) + seq_y[2])
lines(coords, col = "red")