| spatial_multiscale | R Documentation |
Specify a multi-scale spatial random effect that decomposes spatial variation into local (fine-scale) and regional (broad-scale) components. Each scale has its own range and variance parameters.
This is particularly useful for large datasets (>100k observations) where spatial patterns exist at multiple scales.
spatial_multiscale(
coords,
scales = c("local", "regional"),
approx = c("nngp", "hsgp"),
m = 6L,
c_boundary = 1.5,
range_local = c(0.01, 1),
range_regional = c(1, 10),
cov = c("exponential", "matern"),
nu = 1.5,
nn_local = 10,
nn_regional = 30,
shared = NULL,
scale_coords = TRUE,
sampler = c("auto", "noncentered", "centered", "interweaved")
)
## S3 method for class 'tulpa_multiscale'
print(x, ...)
coords |
A one-sided formula specifying coordinate columns (e.g.,
|
scales |
Character vector specifying scale names. Default: |
approx |
Approximation method: |
m |
Number of HSGP basis functions per dimension (default 6). Only
used when |
c_boundary |
Boundary factor for HSGP domain extension (default 1.5).
Only used when |
range_local |
Plausible range interval for the local scale as
|
range_regional |
Plausible range interval for the regional scale, read
the same way. Default: |
cov |
Covariance function: |
nu |
Smoothness parameter for Matern covariance, one of |
nn_local |
Number of nearest neighbors for local scale. Default 10. |
nn_regional |
Number of nearest neighbors for regional scale. Default 30. |
shared |
Logical; if TRUE (default), spatial effects enter both all processes. |
scale_coords |
Logical; if TRUE (default), coordinates are centred
and divided by one common factor before computing distances (see
|
sampler |
Latent parameterization for the exact-NUTS field. |
x |
A |
... |
Ignored. |
The multi-scale model decomposes spatial variation additively:
\eta(s) = X\beta + w_{local}(s) + w_{regional}(s)
where each component follows an independent Gaussian process:
w_{local}(s) \sim GP(0, \sigma^2_{local} C(\phi_{local}))
w_{regional}(s) \sim GP(0, \sigma^2_{regional} C(\phi_{regional}))
Identifiability: With sufficient data (>500 locations), the two scales are typically well-identified when prior ranges are non-overlapping. PC priors on variance components help prevent overfitting.
Computational cost: Approximately 1.5-2x the cost of single-scale GP, as two NNGP likelihoods must be evaluated.
A tulpa_multiscale object
spatial_gp() for single-scale GP, temporal_multiscale() for
multi-scale temporal effects
# Create multi-scale spatial structure
ms <- spatial_multiscale(
~ lon + lat,
range_local = c(0.1, 0.5),
range_regional = c(1, 5)
)
print(ms)
set.seed(101)
n <- 25
df <- data.frame(
lon = runif(n, 0, 10),
lat = runif(n, 0, 10),
depth = rnorm(n),
temp = rnorm(n)
)
df$count <- rpois(n, exp(1 + 0.2 * df$depth))
# Both scales are sampled by exact NUTS (mode = "exact"); the field is
# returned as gp_local[i] / gp_regional[i] draws.
fit <- tulpa(
count ~ depth + temp,
data = df,
family = "poisson",
spatial = spatial_multiscale(
~ lon + lat,
range_local = c(0.1, 0.5),
range_regional = c(1, 5),
nn_local = 5L,
nn_regional = 8L
),
mode = "exact",
control = list(n_iter = 60L, n_warmup = 30L, seed = 1L)
)
summary(fit)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.