carvar is the CAR covariance sigma2 (I - rho W)^-1 diag(m), carjac
the log-likelihood Jacobian term 0.5 log|I - rho W|, carsim draws
x = L'^-1 z from the precision (I - rho W)/sigma2 = L L' with Philox
normals (stream k of seed for draw k), cargmm the moment
(conditional least squares) estimator e'We / e'W^2 e of rho,
caricar the intrinsic CAR log-density with the generalised determinant
of D - W, carres Moran's I of CAR residuals (randomisation moments),
and carbym the REML variance components of the Gaussian
Besag-York-Mollie model y = mu + u + v (ICAR u, iid v), solved by
bisection on the profile score of the spatial share phi.
Usage
carvar(W, rho, sigma2, m = NULL)
carjac(W, rho)
carsim(W, rho, sigma2, nsim = 9, seed = 0)
cargmm(y, W, X = NULL)
caricar(phi, W, tau = 1, tol = 1e-09)
carres(resid, W, alternative = "greater")
carbym(y, W, tol = 1e-09)Arguments
- W
Spatial weights (symmetric adjacency for
carsim,caricar,carbym).- rho
CAR autocorrelation parameter.
- sigma2
Conditional variance scale.
- m
Optional vector of conditional variance multipliers.
- nsim
Number of simulated fields.
- seed
Philox seed.
- y
Numeric response.
- X
Optional regressor matrix (intercept only when NULL).
- phi
Field values for the ICAR density.
- tau
ICAR precision.
- tol
Relative eigenvalue threshold for the null space.
- resid
Residual vector.
- alternative
Alternative hypothesis for the Moran test.
Value
carvar a list with covariance, marginal_variance and
mean_marginal_variance; carjac, cargmm, caricar and carres
lists with statistic; carsim a list with the draws matrix (one
row per draw); carbym a list with sigma2_spatial,
sigma2_unstructured, phi, mu and reml_loglik.
References
Besag, J. (1974). Spatial interaction and the statistical analysis of lattice systems. Journal of the Royal Statistical Society B 36, 192-236. Besag, J., York, J. and Mollie, A. (1991). Bayesian image restoration, with two applications in spatial statistics. Annals of the Institute of Statistical Mathematics 43, 1-20. Rue, H. and Held, L. (2005). Gaussian Markov Random Fields. Chapman and Hall/CRC. Haining, R. (1990). Spatial Data Analysis in the Social and Environmental Sciences. Cambridge University Press.
Examples
W <- rbind(c(0, 1, 0), c(1, 0, 1), c(0, 1, 0))
carvar(W, 0.4, 2)$covariance
#> [,1] [,2] [,3]
#> [1,] 2.4705882 1.176471 0.4705882
#> [2,] 1.1764706 2.941176 1.1764706
#> [3,] 0.4705882 1.176471 2.4705882
carjac(W, 0.4)$statistic
#> [1] -0.1928312
caricar(c(0.5, -0.2, -0.3), W)$statistic
#> [1] -1.538571
