Skip to contents

SpatialGlmmFit: maximises the Laplace approximation of the GLMM marginal likelihood (Newton for the latent mode, L-BFGS-B for \(\beta\), \(\log\sigma\) and \(\log\) range) with iid group intercepts (as lme4::glmer with nAGQ = 1) or a spatial field (Exp, Gau, Sph); returns the Gaussian approximation of the latent posterior (mode, sd, covariance). SpatialGlmmPredict: kriging of the latent mode and variance, response mean by the lognormal formula (Poisson) or 20-point Gauss-Hermite (binomial). GlmmResiduals: Pearson, deviance and randomised quantile residuals. CrpsGaussian, CrpsPoisson, CrpsSample: continuous ranked probability scores. Identical to the Python arm morie.fn.sglmm.

Usage

SpatialGlmmFit(
  y,
  X,
  family = "poisson",
  coords = NULL,
  groups = NULL,
  model = "Exp",
  trials = NULL,
  start = NULL
)

SpatialGlmmPredict(fit, X0, coords0)

GlmmResiduals(y, mu, family = "poisson", trials = 1, size = NULL, seed = 1)

CrpsGaussian(y, mu, sigma)

CrpsPoisson(y, lam)

CrpsSample(y, samples)

Arguments

y

Responses.

X

Design matrix.

family

"poisson" or "binomial" (residuals also "negbin").

coords, groups

Spatial coordinates or grouping factor.

model

Spatial correlation model.

trials

Binomial trials.

start

Starting parameters.

fit

A SpatialGlmmFit result with coords.

X0, coords0

Prediction design and coordinates.

mu

Fitted means (probabilities for binomial).

size

Negative binomial size.

seed

Philox seed.

sigma, lam, samples

Predictive parameters or samples.

Value

List or numeric vector.

References

Breslow, N. E. and Clayton, D. G. (1993). Approximate inference in generalized linear mixed models. JASA 88, 9-25.

Dunn, P. K. and Smyth, G. K. (1996). Randomized quantile residuals. JCGS 5, 236-244.

Gneiting, T. and Raftery, A. E. (2007). Strictly proper scoring rules, prediction, and estimation. JASA 102, 359-378.

Examples

CrpsGaussian(0, 0, 1)
#> [1] 0.233695
GlmmResiduals(c(2, 0), c(2, 1))$pearson
#> [1]  0 -1