prep_sar_data function

Prepare data for a simultaneous autoregressive (SAR) model

Prepare data for a simultaneous autoregressive (SAR) model

Given a spatial weights matrix WW, this function prepares data for the simultaneous autoregressive (SAR) model (a.k.a spatial error model (SEM)) in Stan. This is used internally by stan_sar, and may also be used for building custom SAR models in Stan.

prep_sar_data(W, quiet = FALSE)

Arguments

  • W: Spatial weights matrix, typically row-standardized.
  • quiet: Controls printing behavior. By default, quiet = FALSE and the range of permissible values for the spatial dependence parameter is printed to the console.

Returns

Return's a list of data required as input for geostan's SAR models, as implemented in Stan. The list contains:

  • ImW_w: Numeric vector containing the non-zero elements of matrix (IW)(I - W).
  • ImW_v: An integer vector containing the column indices of the non-zero elements of (IW)(I - W).
  • ImW_u: An integer vector indicating where in ImW_w a given row's non-zero values start.
  • nImW_w: Number of entries in ImW_w.
  • Widx: Integer vector containing the indices corresponding to values of -W in ImW_w (i.e. non-diagonal entries of (IW)(I-W)).
  • nW: Integer length of Widx.
  • eigenvalues_w: Eigenvalues of WW matrix.
  • n: Number of rows in WW.
  • W: Sparse matrix representation of WW
  • rho_min: Minimum permissible value of ρ\rho (1/min(eigenvalues_w)).
  • rho_max: Maximum permissible value of ρ\rho (1/max(eigenvalues_w).

The function will also print the range of permissible ρ\rho values to the console (unless quiet = TRUE).

Details

This is used internally to prepare data for stan_sar models. It can also be helpful for fitting custom SAR models in Stan (outside of geostan), as described in the geostan vignette on custom spatial models.

Examples

data(georgia) W <- shape2mat(georgia, "W") sar_dl <- prep_sar_data(W)

See Also

shape2mat , stan_sar , prep_car_data , prep_icar_data

  • Maintainer: Connor Donegan
  • License: GPL (>= 3)
  • Last published: 2024-12-04