**4. Generalized linear spatial models**

Generalized linear models (GLM) [36, 37] are very useful when the response variable does not follow a normal distribution. The assumptions of GLMs are


The *Yi* follow a common distributional family, indexed by their expectations *μi*, and possibly by additional parameters common to all *n* responses.

An important extension of this basic class of models is the generalized linear mixed model (GLMM) [38], in which *Y*1, … , *Yn* are mutually independent conditional on the realized values of a set latent random variables (random effects) *U*1, … , *Un* and the

conditional expectations are given by *g μ<sup>i</sup>* ð Þ¼ *Ui* þ *x*<sup>0</sup> *i β*. A generalized linear spatial model is a GLMM in which the *U*1, … , *Un* are derived from spatial process. Diggle and Ribeiro in 2007 [1], refers to these models as generalized linear geostatistical model (GLGM). In accordance with Diggle et al. [39], the assumptions of the generalized linear spatial models are as follows


Then *Mi* <sup>¼</sup> *<sup>g</sup>*�<sup>1</sup> **<sup>x</sup>**<sup>0</sup> *i β* þ *W s*ð Þ*<sup>i</sup>* , where the linear predictor would be given by *<sup>η</sup><sup>i</sup>* <sup>¼</sup> **x**0 *i β* þ *W s*ð Þ*<sup>i</sup>* .

Taking Diggle and Tawn as a precedent (1998) [39]; Jing and De Oliveira in 2015 [40] state the GLSM as follows

$$Y\_i|W\_i \sim p(\cdot|\mu\_i). \tag{13}$$

where

$$\mathbf{W} \sim \mathcal{N} \mathcal{M}(\mathbf{X}\boldsymbol{\beta}, \sigma^2 \mathbf{R}) \tag{14}$$

**R** is of the same form as the Gaussian process (2)


Since *<sup>g</sup>* is the link function then *<sup>g</sup> <sup>μ</sup><sup>i</sup>* ð Þ¼ *<sup>η</sup><sup>i</sup>* and *<sup>μ</sup><sup>i</sup>* <sup>¼</sup> *<sup>g</sup>*�<sup>1</sup> *<sup>η</sup><sup>i</sup>* ð Þ, *<sup>i</sup>* <sup>¼</sup> 1, … , *<sup>n</sup>*, where the linear predictor is given by *<sup>η</sup><sup>i</sup>* <sup>¼</sup> *Wi*, then *<sup>μ</sup><sup>i</sup>* <sup>¼</sup> *<sup>g</sup>*�<sup>1</sup>ð Þ *Wi* . The unknown parameters in GLSM are *β*, *σ*<sup>2</sup> and *ϕ*.

The two most widely used GLSM for spatial count data are the Poisson and Binomial spatial models [39, 41].

The *geoCount* [40] package implements the GLSM; the function *runMCMC* is used to generate posterior samples of the Gaussian process and the GLSM parameters, with which the parameter estimates and their credibility intervals can be obtained.

In the package *geoRglm* [42, 43], the functions *glsm.krige*, *pois.krige* and *binom.krige* implement the GLSMs, in this case, parameter estimation is performed under the frequentist approach. While the functions *krige.bayes*, *pois.krige.bayes* and *binom.krige.*

*bayes*, which also implement the GLSMs, estimate the parameters under the Bayesian approach. These functions report estimates of *β*, *σ*<sup>2</sup> and *ϕ*.

The *glmmfields* package implements the Gamma, Poisson, Negative Binomial, Binomial and Lognormal models using the function *glmmfields* [34], parameter estimation is performed under the Bayesian approach. The function *glmmfields* reports the parameter estimates using the posterior median with their respective 95% percentile credible intervals; it also reports the Gelman and Rubin diagnostic values.
