Skip to contents

Extract posterior distributions of spatially-varying coefficients (SVCs) from a fitted ratio model with SVC specification.

Usage

svc(object, terms = NULL, summary = FALSE, probs = c(0.025, 0.5, 0.975), ...)

# S3 method for class 'ratiod_fit'
svc(object, terms = NULL, summary = FALSE, probs = c(0.025, 0.5, 0.975), ...)

Arguments

object

A ratiod_fit object fitted with svc argument

terms

Which SVC terms to extract. If NULL (default), extracts all.

summary

Logical; if TRUE, return summary statistics instead of full posterior draws.

probs

Quantiles to compute if summary = TRUE.

...

Ignored

Value

A ratiod_svc_posterior object containing:

  • draws: Array of posterior draws (draws x locations x terms)

  • coords: Coordinate matrix

  • term_names: Names of SVC terms

Examples

if (FALSE) { # \dontrun{
# Generate synthetic spatial data (not run - SVC not fully supported)
set.seed(303)
n <- 40
df <- data.frame(
  lon = runif(n, 0, 10),
  lat = runif(n, 0, 10),
  depth = rnorm(n),
  count = rpois(n, 20),
  effort = rgamma(n, shape = 4, rate = 1)
)

# Fit model with SVC
fit <- tratio(
  count | effort ~ depth,
  data = df,
  family = ratiod_poisson_gamma(),
  svc = spatial_svc(~ lon + lat, terms = c(1, 2)),
  control = list(iter = 200, warmup = 100, chains = 1)
)

# Extract SVC posteriors
svc_post <- svc(fit)
summary(svc_post)
} # }