make_Q_alpha_2d {BayesMRA}R Documentation

Generate CAR precision matrix

Description

A function for setting up a conditional autoregressive (CAR) or simultaneous autoregressive (SAR) precision matrix for use as a prior in Bayesian models

Usage

make_Q_alpha_2d(n_dims, phi, use_spam = TRUE, prec_model = "CAR")

Arguments

n_dims

is a vector of length M that are the dimensions of the CAR/SAR matrix at each resolution

phi

is a vector of length M with each element between -1 and 1 that defines the strength of the autoregressive process. Typically this will be set to 1 for use as a prior in penalized Bayesian models

use_spam

is a boolean flag to determine whether the output is a list of spam matrix objects (use_spam = TRUE) or a an n x n sparse Matrix of class "dgCMatrix" use_spam = FALSE(see Matrix package for details)

prec_model

is a string that takes the values "CAR" or "SAR" and defines the graphical structure for the precision matrix.

Value

a list of n x n sparse spam matrices or Matrix matrices of class "dgCMatrix" (see Matrix package for details)

Examples

n_dims <- c(4, 8)
phi <- c(0.8, 0.9)
Q_alpha <- make_Q_alpha_2d(n_dims, phi)
## plot the precision matrix structure at each resolution
layout(matrix(1:2, 1, 2))
spam::display(Q_alpha[[1]])
spam::display(Q_alpha[[2]])


[Package BayesMRA version 1.0.0 Index]