Skip to contents

Canonical 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.

Usage

spatial_unique(formula, coords = NULL, mesh = NULL)

Arguments

formula

0 + trait | coords style formula (LHS is the trait factor 0 + trait; RHS is the coords placeholder symbol that points at the make_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; NULL when the orientation expresses the coordinates via the formula RHS.

mesh

Optional fmesher mesh object built via make_mesh(). If NULL, the engine constructs a default mesh from coords.

Value

A formula marker; never evaluated.

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

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
  )
} # }