CAR-Normal | R Documentation |
Density function and random generation for the improper (intrinsic) Gaussian conditional autoregressive (CAR) distribution.
dcar_normal(
x,
adj,
weights = adj/adj,
num,
tau,
c = CAR_calcNumIslands(adj, num),
zero_mean = 0,
log = FALSE
)
rcar_normal(
n = 1,
adj,
weights = adj/adj,
num,
tau,
c = CAR_calcNumIslands(adj, num),
zero_mean = 0
)
x |
vector of values. |
adj |
vector of indices of the adjacent locations (neighbors) of each spatial location. This is a sparse representation of the full adjacency matrix. |
weights |
vector of symmetric unnormalized weights associated with each pair of adjacent locations, of the same length as adj. If omitted, all weights are taken to be one. |
num |
vector giving the number of neighboring locations of each spatial location, with length equal to the total number of locations. |
tau |
scalar precision of the Gaussian CAR prior. |
c |
integer number of constraints to impose on the improper density function. If omitted, |
zero_mean |
integer specifying whether to set the mean of all locations to zero during MCMC sampling of a node specified with this distribution in BUGS code (default |
log |
logical; if |
n |
number of observations. |
When specifying a CAR distribution in BUGS model code, the zero_mean
parameter should be specified as either 0
or 1
(rather than TRUE
or FALSE
).
Note that because the distribution is improper, rcar_normal
does not generate a sample from the distribution. However, as discussed in Rue and Held (2005), it is possible to generate a sample from the distribution under constraints imposed based on the eigenvalues of the precision matrix that are zero.
dcar_normal
gives the density, while rcar_normal
returns the current process values, since this distribution is improper.
Daniel Turek
Banerjee, S., Carlin, B.P., and Gelfand, A.E. (2015). Hierarchical Modeling and Analysis for Spatial Data, 2nd ed. Chapman and Hall/CRC.
Rue, H. and L. Held (2005). Gaussian Markov Random Fields, Chapman and Hall/CRC.
CAR-Proper, Distributions for other standard distributions
x <- c(1, 3, 3, 4)
num <- c(1, 2, 2, 1)
adj <- c(2, 1,3, 2,4, 3)
weights <- c(1, 1, 1, 1, 1, 1)
lp <- dcar_normal(x, adj, weights, num, tau = 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.