
Per-trait independent spatial random fields: spatial_unique(0 + trait | coords)
Source: R/brms-sugar.R
spatial_unique.RdCanonical name for the SPDE / GMRF Matern spatial random field with one independent field per trait (per-trait variance \(\tau^{2}_t\), shared range parameter \(\kappa\)). This is the "unique-rank" cell of the spatial column of the API grid.
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
Formerly spde(0 + trait | coords) and spatial(0 + trait | coords)
– same engine, new name. See spde() for the technical details on
the Matern \(\nu = 1\) kernel.
Compare to spatial_scalar() (ONE shared variance across traits)
and spatial_latent() (K-dim spatial latent factors with a loading
matrix).
Formula orientation
The canonical orientation is 0 + trait | coords (LHS = trait factor,
RHS = the coords placeholder), parallel to latent(),
unique(), and glmmTMB's gau(0 + trait | pos) / exp(0 + trait | pos).
The earlier orientation coords | trait is accepted as a deprecated
alias: it emits a one-shot lifecycle::deprecate_warn() per session
(introduced at gllvmTMB 0.1.4) and is internally normalised to the
canonical orientation, so existing fits remain byte-identical.
See also
spatial_scalar(), spatial_latent(), spde() (deprecated alias).
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_unique(0 + trait | site, coords = c("lon", "lat")),
data = sim$data
)
} # }