Density function and random generation for the improper (intrinsic) Gaussian conditional autoregressive (CAR) distribution.
dcar_normal(x, adj, weights, num, tau, c = CAR_calcNumIslands(adj, num),
zero_mean = 0, log = FALSE)rcar_normal(n = 1, adj, weights, num, tau, c = CAR_calcNumIslands(adj, num),
zero_mean = 0)
vector of values.
vector of indices of the adjacent locations (neighbors) of each spatial location. This is a sparse representation of the full adjacency matrix.
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.
vector giving the number of neighbors of each spatial location, with length equal to the total number of locations.
scalar precision of the Gaussian CAR prior.
integer number of constraints to impose on the improper density function. If omitted, c
is calculated as the number of disjoint groups of spatial locations in the adjacency structure. Note that c
should be equal to the number of eigenvalues of the precision matrix that are zero. For example if the neighborhood structure is based on a second-order Markov random field in one dimension has two zero eigenvalue and in two dimensinos has three zero eigenvalues. See Rue and Held (2005) for more information.
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 0
). This argument is used only in BUGS model code when specifying models in NIMBLE. If 0
, the overall process mean is included implicitly in the value of each location in a BUGS model; if 1
, then during MCMC sampling, the mean of all locations is set to zero at each MCMC iteration, and a separate intercept term should be included in the BUGS model. Note that centering during MCMC as implemented in NIMBLE follows the ad hoc approach of WinBUGS and does not sample under the constraint that the mean is zero as discussed on p. 36 of Rue and Held (2005). See details.
logical; if TRUE, probability density is returned on the log scale.
number of observations.
dcar_normal
gives the density, and rcar_normal
returns the current process values, since this distribution is improper.
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 generated a sample from the distribution, though 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.
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.
Distributions for other standard distributions
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab