Why Put Spatial or Temporal Effects in a GLMM?
In a non-Gaussian GLMM, observations can be conditionally independent yet associated after latent effects are integrated out. That distinction is useful when outcomes such as disease indicators or event counts are measured at nearby locations or repeatedly over time. A Gaussian latent effect can represent the remaining structured variation in the linear predictor, while the response distribution describes variation in the outcomes conditional on that predictor.
The crucial specification is not merely “add a random effect.” It is to say which observations share or relate to which latent effects, and what covariance those effects have. A single independent random intercept for a group, for example, gives observations in that group a common source of variation. A spatial or temporal latent effect instead allows effects indexed by different locations or times to be correlated. This tutorial focuses on specifying that conditional model and interpreting the distinction; the precise families of spatial covariance structures are separate topics.
Conditional Model and Assumptions
For a spatial-only model, write \(w(s_r)\); for a temporal-only model, write \(w(t_r)\). A joint spatial-temporal model can use \(w(s_r,t_r)\), or it can include distinct spatial and temporal components, such as \(u(s_r)+v(t_r)\). Those are different modeling choices: one joint effect can express covariance over pairs of space-time indices, whereas separate components assign variation to distinct sources. The specification must state whether those components are independent or have some other joint distribution.
The standard conditional assumptions are as follows. First, conditional on the latent effects and covariates, each response follows the declared family and mean-link relationship. Second, responses are conditionally independent unless the model explicitly gives them additional conditional dependence. Third, the latent vector is jointly Gaussian with mean zero and the stated covariance matrix. If additional random effects are included, their distribution and their dependence or independence from the spatial-temporal effect must also be stated. The covariance must be mathematically admissible; selecting and checking particular covariance structures is a separate step.
“Conditional” matters. In a Bernoulli model, for instance, \(Y_r\mid\mathbf{w}\) has Bernoulli variance \(\mu_r(1-\mu_r)\). That response-level variation is part of the conditional outcome distribution. It is not an extra Gaussian effect, and it does not represent covariance between latent effects at different indices.
From Latent Covariance to Marginal Dependence
Suppose two observations are conditionally independent given the latent effects. Their conditional covariance is then zero, but this does not generally imply zero covariance after averaging over the latent effects. If both responses depend on correlated latent values, their conditional means vary together. The resulting marginal association is one of the main reasons to include a spatial or temporal effect.
For a Poisson model with a log link, this relationship can be shown directly. Let \(Y_r\mid w_r\sim\operatorname{Poisson}(\exp(a_r+w_r))\), where \(a_r\) is the fixed part of the predictor and \((w_r,w_q)\) is jointly Gaussian with mean zero. Conditional independence gives \(E(Y_rY_q\mid w_r,w_q)=E(Y_r\mid w_r)E(Y_q\mid w_q)\) for distinct observations. The moment-generating function of a mean-zero Gaussian vector then gives the marginal covariance formula below.
Thus positive latent covariance produces positive marginal covariance in this Poisson log-link case, even though the counts are conditionally independent. This result depends on the stated log-link Poisson model; it is not a universal formula for every response family or link.
Worked Example: Correlated Latent Effects and Poisson Counts
Consider two hypothetical counts at different locations. Conditional on their latent effects, let \(Y_1\) and \(Y_2\) be independent Poisson variables with means \(\exp(\log 2+w_1)\) and \(\exp(\log 2+w_2)\). Suppose the Gaussian effects have variances \(0.25\) each and covariance \(0.10\). Find the marginal mean of each count and their marginal covariance.
The assumptions are a Poisson response conditional on the latent effects, a log link, and a jointly Gaussian latent pair with the stated covariance. By the Gaussian moment formula,
The marginal covariance is
The counts therefore have positive marginal covariance, although they are independent conditional on \(w_1,w_2\). The covariance arises from the shared pattern in the latent effects, not from a claim that the Poisson responses are conditionally dependent.
Worked Specifications
Worked Example: A Spatial Logistic GLMM
Suppose a hypothetical survey records a binary outcome \(Y_r\) at locations \(s_r\), along with a binary covariate \(x_r\). Specify a spatial logistic GLMM and calculate the conditional event probability for an observation with \(x_r=1\) and latent effect \(w(s_r)=0.40\), given \(\beta_0=-1.00\) and \(\beta_1=0.60\).
A suitable specification is
The conditional model assumes Bernoulli responses are independent given the latent vector and covariates. The latent effect has mean zero and a covariance matrix whose entries depend on the locations and parameters \(\theta\). For the stated observation,
Conditional on the specified latent value, the modeled event probability is \(0.500\). This is not the probability averaged over the latent-effect distribution. To obtain that marginal probability, one would integrate the inverse-logit mean over the distribution of \(w(s_r)\); in general, applying the inverse link to the mean linear predictor does not perform that integration.
Worked Example: A Spatiotemporal Count Model With Exposure
Imagine hypothetical event counts \(Y_{st}\) observed at location \(s\) and time \(t\), with known exposure \(E_{st}\). Specify a Poisson model with a spatial effect, a temporal effect, and a covariate \(x_{st}\). Then compute the conditional mean and probability of zero for one observation with \(E_{st}=2\), \(x_{st}=2\), \(\beta_0=-1.00\), \(\beta_1=0.30\), \(u(s)=0.20\), and \(v(t)=-0.10\).
One specification is
For this example, assume the spatial vector \(\mathbf{u}\) and temporal vector \(\mathbf{v}\) are each mean-zero Gaussian, are independent of each other, and have their own stated covariance matrices. Responses are conditionally independent given both vectors. The offset \(\log(E_{st})\) accounts for exposure under the model’s proportional-rate specification. Substitution gives
For a Poisson variable, \(P(Y_{st}=0\mid\mathbf{u},\mathbf{v})=\exp(-\mu_{st})\). Thus the conditional probability of zero is \(\exp(-1.482)\approx 0.227\). This is a conditional calculation at the given spatial and temporal effects, not a probability averaged over their Gaussian distributions.
Worked Example: Separating Structured Covariance From Independent Noise
Consider two hypothetical observations with linear predictors \(\eta_1=a_1+w_1+\epsilon_1\) and \(\eta_2=a_2+w_2+\epsilon_2\). Suppose \(\operatorname{Var}(w_1)=\operatorname{Var}(w_2)=0.64\), \(\operatorname{Cov}(w_1,w_2)=0.32\), and the independent Gaussian terms \(\epsilon_1,\epsilon_2\) each have variance \(0.25\), with all \(\epsilon\) terms independent of the \(w\) terms. Find the predictor covariance and variance for each observation.
The \(w\) terms encode the structured covariance associated with their indices. The \(\epsilon\) terms represent additional independent observation-level noise on the predictor scale. Independence means \(\operatorname{Cov}(\epsilon_1,\epsilon_2)=0\) and \(\operatorname{Cov}(w_r,\epsilon_q)=0\). Therefore,
The same variance calculation gives \(\operatorname{Var}(\eta_2)=0.89\). Independent noise increases each predictor’s marginal variance but does not create covariance between the two observations. In a non-Gaussian model, adding such a term is a distinct modeling decision: it is not the same as specifying the response-family variation or the covariance of the indexed latent effect.
Specification Checks and Common Failure Modes
A useful specification makes the response model, indices, and dependence assumptions explicit. Before interpreting or fitting it, check the following:
- Response family and link: State the conditional distribution and how its mean is linked to the predictor. A binary response with a logit link and a count response with a log link are different models.
- Index mapping: State which location or time belongs to each observation. If several observations share the same location-time pair, say whether they use the same latent value.
- Random-effect assumptions: Give the latent effects’ mean and covariance, and state whether spatial, temporal, and grouped effects are independent of one another.
- Conditional independence: Say whether observations are independent after conditioning on every latent effect in the model. If not, the remaining conditional dependence needs its own specification.
- Variation and identifiability: Consider whether the data contain replication or covariate information capable of distinguishing fixed effects, group-level variation, indexed latent variation, and any independent predictor noise. If these sources produce similar patterns, their separate magnitudes may be difficult to estimate.
Residual patterns can also signal a mismatch. For example, systematic clustering of unexplained outcomes by location or time may indicate that an independent-effects model has left structured dependence unmodeled. Conversely, adding a flexible correlated effect does not guarantee improvement: an estimated latent pattern that is weakly informed by the observations, unstable across specifications, or redundant with other effects calls for caution. These checks identify concerns; they do not by themselves prove which covariance model is correct.
A frequent mistake is to say, “The observations are conditionally independent, so there is no dependence to model.” Conditional independence only applies after conditioning on the latent effects. If the effects are correlated, integrating them out can induce marginal dependence, as the Poisson derivation showed. The correction is to state both levels: conditional independence of responses given the latent vector, and covariance among the latent values.
Another mistake is to treat all unexplained variability as interchangeable “noise.” In a non-Gaussian GLMM, the conditional response distribution already contributes observation-level variation. An indexed Gaussian effect changes the predictor and can induce dependence between observations. Independent Gaussian predictor noise, if included, adds a separate source of variability and does not create cross-observation covariance. Their roles and scales are different.
How This Specification Compares With Alternatives
| Approach | Dependence represented | Key distinction |
|---|---|---|
| Independent grouped random intercept | Observations in the same group share a random effect; effects for different groups are independent under the model. | Provides group-level clustering but does not, by itself, represent covariance that varies with location or time separation. |
| Spatial or temporal latent-effect GLMM | Latent predictor values indexed by locations or times can have covariance across distinct indices. | Defines a conditional response model and represents structured latent dependence; marginal response dependence follows after integrating over the effects. |
| Independent observation-level predictor noise | Each observation receives its own independent additional predictor perturbation. | Changes individual predictor variation without creating covariance between distinct observations. |
| Marginal model for correlated responses | Specifies relationships among response means and a response-level association structure. | Directly targets marginal relationships rather than defining dependence through a conditional Gaussian latent predictor. |
These alternatives answer different questions and need not be interchangeable. A spatial or temporal GLMM is useful when a conditional mean model and a latent Gaussian representation are scientifically and statistically appropriate. Its limitations include reliance on the chosen covariance specification, computational cost for large latent vectors, and possible difficulty separating sources of variation. It also does not make causal effects identifiable: coefficients describe modeled associations conditional on the included terms and assumptions.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- In a Bernoulli GLMM, what does conditional independence mean, and why can responses still be marginally associated?
- A Poisson log-link model has \(\operatorname{Cov}(w_1,w_2)=0\) for two distinct observations. According to the derived formula, what is their marginal covariance under its assumptions?
- For a spatial logistic model with \(\eta=-0.70+0.50x+w(s)\), calculate the conditional event probability when \(x=1\) and \(w(s)=0.20\).
- What is the difference between adding independent Gaussian noise to each linear predictor and using correlated location-indexed latent effects?
- Name two assumptions that should be stated when specifying a joint spatial-temporal GLMM.
Solutions. (1) Conditional independence means the responses are independent given the covariates and all latent effects. They may still be marginally associated because correlated latent effects make their conditional means vary together. (2) The formula gives \(E(Y_1)E(Y_2)\{\exp(0)-1\}=0\), so their marginal covariance is zero under the stated Poisson log-link and Gaussian-latent assumptions. (3) The predictor is \(-0.70+0.50(1)+0.20=0\), so the conditional probability is \(\exp(0)/(1+\exp(0))=0.500\). (4) Independent noise increases predictor variation observation by observation but creates no covariance between distinct noise terms; correlated indexed effects allow predictor values at different locations to covary. (5) Examples include the conditional response family and link, the Gaussian latent-effect mean and covariance, whether spatial and temporal components are independent, and whether responses are conditionally independent given all effects.