Skip to contents

Canonical name for the full unstructured cross-trait spatial covariance \(\boldsymbol\Sigma_{\text{spa}} \otimes \mathbf{Q}^{-1}\), with \(T(T+1)/2\) free parameters (\(\boldsymbol\Sigma_{\text{spa}}\) parameterised via Cholesky). Mathematically identical to spatial_latent(0 + trait | coords, d = T) standalone; the keyword choice is documentary.

Usage

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

Use spatial_dep() when you want an explicit full-unstructured cross-trait spatial covariance fit. Use spatial_latent() for the rank-reduced K-factor model. Use spatial_indep() for the marginal-only per-trait spatial fit.

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_dep is born with this orientation; the legacy coords | trait form is not accepted.

Mutual exclusion with spatial_latent() / spatial_unique() / spatial_indep()

Combining spatial_dep(0 + trait | coords) with spatial_latent is over-parameterised; combining with spatial_unique or spatial_indep is redundant. The parser raises cli::cli_abort() in any of these cases.

Examples

if (FALSE) { # \dontrun{
  sim <- simulate_site_trait(
    n_sites = 30, n_species = 6, mean_species_per_site = 5,
    spatial_range = 0.4, sigma2_spa = rep(0.3, 6), seed = 1
  )
  fit <- gllvmTMB(
    value ~ 0 + trait +
            spatial_dep(0 + trait | site, coords = c("lon", "lat")),
    data = sim$data
  )
} # }