prep_icar_data {geostan} | R Documentation |
Prepare data for ICAR models
Description
Given a symmetric n x n connectivity matrix, prepare data for intrinsic conditional autoregressive models in Stan. This function may be used for building custom ICAR models in Stan. This is used internally by stan_icar
.
Usage
prep_icar_data(C, scale_factor = NULL)
Arguments
C |
Connectivity matrix |
scale_factor |
Optional vector of scale factors for each connected portion of the graph structure. If not provided by the user it will be fixed to a vector of ones. |
Details
This is used internally to prepare data for stan_icar
models. It can also be helpful for fitting custom ICAR models outside of geostan
.
Value
list of data to add to Stan data list:
- k
number of groups
- group_size
number of nodes per group
- n_edges
number of connections between nodes (unique pairs only)
- node1
first node
- node2
second node. (
node1[i]
andnode2[i]
form a connected pair)- weight
The element
C[node1, node2]
.- group_idx
indices for each observation belonging each group, ordered by group.
- m
number of disconnected regions requiring their own intercept.
- A
n-by-m matrix of dummy variables for the component-specific intercepts.
- inv_sqrt_scale_factor
By default, this will be a k-length vector of ones. Placeholder for user-specified information. If user provided
scale_factor
, then this will be1/sqrt(scale_factor)
.- comp_id
n-length vector indicating the group membership of each observation.
Source
Besag, Julian, Jeremy York, and Annie Mollié. 1991. “Bayesian Image Restoration, with Two Applications in Spatial Statistics.” Annals of the Institute of Statistical Mathematics 43 (1): 1–20.
Donegan, Connor. Flexible Functions for ICAR, BYM, and BYM2 Models in Stan. Code Repository. 2021. Available online: https://github.com/ConnorDonegan/Stan-IAR/ (accessed Sept. 10, 2021).
Freni-Sterrantino, Anna, Massimo Ventrucci, and Håvard Rue. 2018. “A Note on Intrinsic Conditional Autoregressive Models for Disconnected Graphs.” Spatial and Spatio-Temporal Epidemiology 26: 25–34.
Morris, Mitzi, Katherine Wheeler-Martin, Dan Simpson, Stephen J Mooney, Andrew Gelman, and Charles DiMaggio. 2019. “Bayesian Hierarchical Spatial Models: Implementing the Besag York Mollié Model in Stan.” Spatial and Spatio-Temporal Epidemiology 31: 100301.
Riebler, Andrea, Sigrunn H Sørbye, Daniel Simpson, and Håvard Rue. 2016. “An Intuitive Bayesian Spatial Model for Disease Mapping That Accounts for Scaling.” Statistical Methods in Medical Research 25 (4): 1145–65.
See Also
edges
, shape2mat
, stan_icar
, prep_car_data
Examples
data(sentencing)
C <- shape2mat(sentencing)
icar.data.list <- prep_icar_data(C)