areal_spatial_bisquare {stcos} | R Documentation |
Areal Spatial Bisquare Basis
Description
Spatial bisquare basis on areal data.
Usage
areal_spatial_bisquare(dom, knots, w, control = NULL)
Arguments
dom |
An |
knots |
Knots |
w |
Radius for the basis. |
control |
A |
Details
Notes about arguments:
-
knots
may be provided as either ansf
orsfc
object, or as a matrix of points. If an
sf
orsfc
object is provided forknots
,r
two-dimensionalPOINT
entries are expected inst_geometry(knots)
. Otherwise,knots
will be interpreted as anr \times 2
numeric matrix.If
knots
is ansf
orsfc
object, it is checked to ensure the coordinate system matchesdom
.
For each area A
in the given domain, compute an the basis functions
\bar{\varphi}_j(A) = \frac{1}{|A|} \int_A \varphi_j(\bm{u}) d\bm{u}
for j = 1, \ldots, r
. Here, \varphi_j(\bm{u})
represent
spatial_bisquare basis functions defined at the point level
using \bm{c}_j
and w
.
The basis requires an integration which may be computed using one
of two methods. The mc
method uses
\bar{\varphi}_j(A) \approx
\frac{1}{Q} \sum_{q=1}^Q \varphi_j(\bm{u}_q),
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
\bar{\varphi}_j(A) \approx
\frac{1}{|A|} \sum_{a=1}^{n_x} \sum_{b=1}^{n_y} \varphi_j(\bm{u}_{ab})
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
orrect
. Default ismc
. -
mc_reps
is number of repetitions to use formc
. Default is 1000. -
nx
is number of x-axis points to use forrect
method. Default is 50. -
ny
is number of y-axis oints to use forrect
method. Default is 50. -
report_period
is an integer; print a message with progress each time this many areas are processed. Default isInf
so that message is suppressed. -
verbose
is a logical; ifTRUE
print descriptive messages about the computation. Default isFALSE
. -
mc_sampling_factor
is a positive number; an oversampling factor used to computeblocksize
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 i
th row
is
\bm{s}_i^\top =
\Big(
\bar{\varphi}_1(A_i), \ldots, \bar{\varphi}_r(A_i)
\Big).
See Also
Other bisquare:
areal_spacetime_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)
knots = expand.grid(x = seq_x, y = seq_y)
knots_sf = st_as_sf(knots, coords = c("x","y"), crs = NA, 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
areal_spatial_bisquare(dom, knots, rad)
areal_spatial_bisquare(dom, knots_sf, rad)
# Plot the knots and the points 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")