areal_spacetime_bisquare: Areal Space-Time Bisquare Basis

View source: R/areal_spacetime_bisquare.R

areal_spacetime_bisquareR 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 sf or sfc object with areas A_1, \ldots, A_n to evaluate.

period

A numeric vector of time periods v_1, \ldots, v_m to evaluate for each area.

knots

Spatio-temporal knots (\bm{c}_1,g_1), \ldots, (\bm{c}_r,g_r) for the basis. See "Details".

w_s

Spatial radius for the basis.

w_t

Temporal radius for the basis.

control

A list of control arguments. See "Details".

Details

Notes about arguments:

  • knots may be provided as either an sf or sfc object, or as a matrix of points.

  • If an sf or sfc object is provided for knots, r three-dimensional POINT entries are expected in st_geometry(knots). Otherwise, knots will be interpreted as an r \times 3 numeric matrix.

  • If knots is an sf or sfc object, it is checked to ensure the coordinate system matches dom.

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:

  • method specifies computation method: mc or rect. Default is mc.

  • mc_reps is number of repetitions to use for mc. Default is 1000.

  • nx is number of x-axis points to use for rect method. Default is 50.

  • ny is number of y-axis points to use for rect method. Default is 50.

  • report_period is an integer; print a message with progress each time this many areas are processed. Default is Inf so that message is suppressed.

  • verbose is a logical; if TRUE print descriptive messages about the computation. Default is FALSE.

  • mc_sampling_factor is a positive number; an oversampling factor used to compute blocksize in 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")


holans/ST-COS documentation built on Aug. 28, 2023, 5:50 a.m.