Skip to contents

CarPrecision: proper CAR precision \(\tau (D - \rho W)\). SarCovariance: SAR covariance \(\sigma^2 [(I - \rho W)'(I - \rho W)]^{-1}\). GmrfSimulate: GMRF samples by \(L' x = e\) for \(Q = L L'\) (Rue and Held 2005). SpatialGlmmSimulate: responses given a latent field for Gaussian, Poisson, binomial, negative binomial (NB2) and gamma families, drawn by inversion of Philox uniforms with exact pmf recurrences. Identical to the Python arm morie.fn.sglmm.

Usage

CarPrecision(W, rho, tau = 1)

SarCovariance(W, rho, sigma2 = 1)

GmrfSimulate(Q, nsim = 1L, seed = 1)

SpatialGlmmSimulate(
  X,
  beta,
  latent,
  family = "poisson",
  trials = 1,
  size = NULL,
  shape = NULL,
  sigma = 1,
  seed = 1
)

Arguments

W

Adjacency matrix.

rho

Spatial dependence.

tau

Precision scale.

sigma2

Innovation variance.

Q

Precision matrix.

nsim

Number of samples.

seed

Philox seed.

X

Design matrix.

beta

Coefficients.

latent

Latent field values.

family

Response family.

trials

Binomial trials.

size

Negative binomial size.

shape

Gamma shape.

sigma

Gaussian noise standard deviation.

Value

Matrix or list.

References

Besag, J. (1974). Spatial interaction and the statistical analysis of lattice systems. JRSS B 36, 192-236.

Rue, H. and Held, L. (2005). Gaussian Markov Random Fields: Theory and Applications. Chapman and Hall/CRC.

Diggle, P. J., Tawn, J. A. and Moyeed, R. A. (1998). Model-based geostatistics. Applied Statistics 47, 299-350.

Examples

CarPrecision(rbind(c(0, 1), c(1, 0)), 0.5, 2)
#>      [,1] [,2]
#> [1,]    2   -1
#> [2,]   -1    2
SpatialGlmmSimulate(matrix(1, 2, 1), 0, c(0, 0), family = "binomial")$mu
#> [1] 0.5 0.5