spatial_car: CAR / ICAR spatial structure

View source: R/spatial_car.R

spatial_carR Documentation

CAR / ICAR spatial structure

Description

Constructs a conditional autoregressive spatial random effect from an adjacency matrix. With proper = FALSE (the default) this is the improper CAR / ICAR (type = "car"); with proper = TRUE it returns the same object as spatial_car_proper().

Usage

spatial_car(
  adjacency,
  level = c("group", "obs"),
  group_var = NULL,
  proper = FALSE,
  shared = NULL,
  parameterization = c("standard", "collapsed")
)

Arguments

adjacency

Symmetric adjacency matrix (⁠[n_units x n_units]⁠).

level

Either "group" (one effect per level of group_var) or "obs" (one effect per row of the data; nrow(data) must equal nrow(adjacency)).

group_var

Name of the grouping variable in the data; required when level = "group".

proper

If TRUE, use proper CAR (type = "car_proper"); else ICAR (type = "car").

shared

Optional shared-effect handle (see model docs).

parameterization

"standard" (default) or "collapsed" (deprecated).

Value

A tulpa_spatial object with type = "car" (or "car_proper" when proper = TRUE).

See Also

spatial_car_proper(), spatial_bym2().

Examples

adj <- matrix(0, 10, 10)
for (i in 1:9) adj[i, i + 1] <- adj[i + 1, i] <- 1
spatial_car(adj, level = "group", group_var = "region")

tulpa documentation built on Oct. 19, 2026, 5:09 p.m.