Skip to contents

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

Usage

spatial_indep(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

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