View source: R/convenience-functions.R
| prep_sar_data | R Documentation |
Given a spatial weights matrix W, 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)
W |
Spatial weights matrix, typically row-standardized. |
quiet |
Controls printing behavior. By default, |
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.
Return's a list of data required as input for geostan's SAR models, as implemented in Stan. The list contains:
Numeric vector containing the non-zero elements of matrix (I - W).
An integer vector containing the column indices of the non-zero elements of (I - W).
An integer vector indicating where in ImW_w a given row's non-zero values start.
Number of entries in ImW_w.
Integer vector containing the indices corresponding to values of -W in ImW_w (i.e. non-diagonal entries of (I-W)).
Integer length of Widx.
Eigenvalues of W matrix.
Number of rows in W.
Sparse matrix representation of W
Minimum permissible value of \rho (1/min(eigenvalues_w)).
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).
shape2mat, stan_sar, prep_car_data, prep_icar_data
data(georgia)
W <- shape2mat(georgia, "W")
sar_dl <- prep_sar_data(W)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.