Learn R Programming

trafficCAR (version 0.1.0)

sample_proper_car: Gibbs sampler for a proper CAR latent Gaussian model

Description

Model: $$y \mid x, \tau \sim N(x, \tau^{-1} I)$$ $$x \mid \kappa \sim N(0, (\kappa Q)^{-1}), \quad Q = D - \rho A \text{ (proper CAR)}$$ $$\tau \sim \mathrm{Gamma}(a_{\tau}, b_{\tau}) \quad \text{(shape-rate)}$$ $$\kappa \sim \mathrm{Gamma}(a_{\kappa}, b_{\kappa}) \quad \text{(shape-rate)}$$

Usage

sample_proper_car(
  y,
  A,
  rho = 0.99,
  n_iter,
  burn = 0L,
  thin = 1L,
  a_tau = 1,
  b_tau = 1,
  a_kappa = 1,
  b_kappa = 1,
  init = NULL,
  symmetrize = FALSE,
  check = TRUE
)

Value

List with x (matrix), tau, kappa, and settings.

Arguments

y

Numeric vector of observations (length n).

A

Adjacency matrix (dense or sparse). Diagonal ignored.

rho

Proper CAR dependence parameter (must satisfy car_precision checks).

n_iter

Integer number of iterations.

burn

Integer burn-in iterations to drop (default 0).

thin

Integer thinning interval (default 1).

a_tau, b_tau

Gamma(shape, rate) prior for tau.

a_kappa, b_kappa

Gamma(shape, rate) prior for kappa.

init

Optional list with elements x, tau, kappa.

symmetrize

Passed to car_precision().

check

Passed to car_precision().