
Full unstructured spatial trait covariance: spatial_dep(0 + trait | coords)
Source: R/brms-sugar.R
spatial_dep.RdCanonical 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.
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
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
)
} # }