
Per-trait spatial marginal field: spatial_indep(0 + trait | coords)
Source: R/brms-sugar.R
spatial_indep.RdCanonical name for T per-trait spatial fields coupled by the SPDE
precision matrix \(\mathbf Q\). Mathematically identical to
spatial_unique(0 + trait | coords) standalone; standalone =
T univariate spatial fits stacked.
Arguments
- formula
0 + trait | coordsstyle formula (LHS is the trait factor0 + trait; RHS is thecoordsplaceholder symbol that points at themake_mesh()coordinate columns).- coords
Character; the column-name pair of spatial coordinates in
data(e.g.c("lon", "lat")). Resolved by the parser when supplied as keyword argument;NULLwhen the orientation expresses the coordinates via the formula RHS.- mesh
Optional
fmeshermesh object built viamake_mesh(). IfNULL, the engine constructs a default mesh fromcoords.
Details
Each trait \(t\) gets its own variance \(\tau^2_t\) on a Matern \(\nu = 1\) GMRF, with a shared range parameter \(\kappa\).
Use spatial_indep() for an explicit marginal-only spatial fit (no
cross-trait spatial decomposition). Use spatial_latent() for
K shared spatial fields driving all T traits via a T x K loading
matrix.
Formula orientation
Same convention as the rest of the spatial_* keywords: the
canonical orientation is 0 + trait | coords (LHS = trait factor,
RHS = the coords placeholder). Spatial keywords adopted this
orientation at gllvmTMB 0.1.4; spatial_indep is born with it
(no legacy coords | trait orientation is accepted).
Mutual exclusion with spatial_latent()
Combining spatial_indep(0 + trait | coords) with
spatial_latent(0 + trait | coords, d = K) is over-parameterised
and the parser raises a cli::cli_abort(). Combining spatial_indep
with spatial_unique is redundant and also errors.
Examples
if (FALSE) { # \dontrun{
sim <- simulate_site_trait(
n_sites = 20, n_species = 4, mean_species_per_site = 4,
spatial_range = 0.4, sigma2_spa = rep(0.3, 4), seed = 1
)
fit <- gllvmTMB(
value ~ 0 + trait +
spatial_indep(0 + trait | site, coords = c("lon", "lat")),
data = sim$data
)
} # }