The CAR-Proper Distribution
Density function and random generation for the proper Gaussian conditional autoregressive (CAR) distribution.
dcar_proper(x, mu, C = CAR_calcC(adj, num), adj, num, M = CAR_calcM(num), tau, gamma, evs = CAR_calcEVs3(C, adj, num), log = FALSE) rcar_proper(n = 1, mu, C = CAR_calcC(adj, num), adj, num, M = CAR_calcM(num), tau, gamma, evs = CAR_calcEVs3(C, adj, num))
x |
vector of values. |
mu |
vector of the same length as |
C |
vector of the same length as |
adj |
vector of indices of the adjacent locations (neighbors) of each spatial location. This is a sparse representation of the full adjacency matrix. |
num |
vector giving the number of neighboring locations of each spatial location, with length equal to the number of locations. |
M |
vector giving the diagonal elements of the conditional variance matrix, with length equal to the number of locations. See ‘Details’. |
tau |
scalar precision of the Gaussian CAR prior. |
gamma |
scalar representing the overall degree of spatial dependence. See ‘Details’. |
evs |
vector of eigenvalues of the adjacency matrix implied by |
log |
logical; if |
n |
number of observations. |
If both C
and M
are omitted, then all weights are taken as one, and corresponding values of C
and M
are generated.
The C
and M
parameters must jointly satisfy a symmetry constraint: that M^(-1) %*% C
is symmetric, where M
is a diagonal matrix and C
is the full weight matrix that is sparsely represented by the parameter vector C
.
For a proper CAR model, the value of gamma
must lie within the inverse minimum and maximum eigenvalues of M^(-0.5) %*% C %*% M^(0.5)
, where M
is a diagonal matrix and C
is the full weight matrix. These bounds can be calculated using the deterministic functions carMinBound(C, adj, num, M)
and carMaxBound(C, adj, num, M)
, or simultaneously using carBounds(C, adj, num, M)
. In the case where C
and M
are omitted (all weights equal to one), the bounds on gamma are necessarily (-1, 1).
dcar_proper
gives the density, and rcar_proper
generates random deviates.
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.
CAR-Normal, Distributions for other standard distributions
x <- c(1, 3, 3, 4) mu <- rep(3, 4) adj <- c(2, 1,3, 2,4, 3) num <- c(1, 2, 2, 1) ## omitting C and M uses all weights = 1 dcar_proper(x, mu, adj = adj, num = num, tau = 1, gamma = 0.95) ## equivalent to above: specifying all weights = 1, ## then using as.carCM to generate C and M arguments weights <- rep(1, 6) CM <- as.carCM(adj, weights, num) C <- CM$C M <- CM$M dcar_proper(x, mu, C, adj, num, M, tau = 1, gamma = 0.95) ## now using non-unit weights weights <- c(2, 2, 3, 3, 4, 4) CM2 <- as.carCM(adj, weights, num) C2 <- CM2$C M2 <- CM2$M dcar_proper(x, mu, C2, adj, num, M2, tau = 1, gamma = 0.95)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.