View source: R/convenience-functions.R
prep_icar_data | R Documentation |
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
.
prep_icar_data(C, scale_factor = NULL)
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. |
This is used internally to prepare data for stan_icar
models. It can also be helpful for fitting custom ICAR models outside of geostan
.
list of data to add to Stan data list:
number of groups
number of nodes per group
number of connections between nodes (unique pairs only)
first node
second node. (node1[i]
and node2[i]
form a connected pair)
The element C[node1, node2]
.
indices for each observation belonging each group, ordered by group.
number of disconnected regions requiring their own intercept.
n-by-m matrix of dummy variables for the component-specific intercepts.
By default, this will be a k-length vector of ones. Placeholder for user-specified information. If user provided scale_factor
, then this will be 1/sqrt(scale_factor)
.
n-length vector indicating the group membership of each observation.
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.
edges
, shape2mat
, stan_icar
, prep_car_data
data(sentencing)
C <- shape2mat(sentencing)
icar.data.list <- prep_icar_data(C)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.