# Chapter 10 Statistical modelling of spatial data

Spatial data almost always (and everywhere) has the property that it is spatially structured: observations done closeby in space tend to be more similar than observations done at larger distance from each other. This phenomenon, in the geography domain attributed to Waldo Tobler (as in “Waldo Tobler’s first law of geography”) was already noted by (Fisher and others 1937) and was a motivation for developing randomized block design in agricultural experiments: allocating treatments randomly to blocks avoids that spatial structure gets mixed up (or: confounds) with a signal caused by the treatment.

The often heard argument that spatially structured data *means*
that the data is spatially correlated, which would *exclude*
estimation methods that assume independent observations is false.
Correlation is a property of two random variables, and there are
different ways in which spatial data can be approached with random
variables: either the observation locations are random (leading to
design-based inference) or the observed values are random (leading
to model-based inference). The next section points out the difference
between these two.

## 10.1 Design-based and model-based inference

Statistical inference means the action of estimating parameters about a population from sample data. Suppose we denote the variable of interest with \(z(s)\), where \(z\) is the attribute value measured at location \(s\), and we are interested in estimating the mean value of \(z(s)\) over a domain \(D\), \[z(s)=\frac{1}{|D|} \int_{ u \in D} z(u)du,\] with \(|D|\) the area of \(D\), from sample data \(z(s_1),...,z(s_n)\).

Then, there are two possibilities to proceed: model-based, or design-based. A model-based approach considers \(z(s)\) to be a realisation of a superpopulation \(Z(s)\) (using capital letters to indicate random variables), and could for instance postulate a model for its spatial variability in the form of \[Z(s) = m + e(s), \ \ \mbox{E}(e(s)) = 0, \ \ \mbox{Cov(e(s))} = \Sigma(\theta)\] which would require choosing the covariance function \(\Sigma()\) and estimating its parameters \(\theta\) form \(z(s)\), and then computing a block kriging prediction \(\hat{Z}(D)\) (section 12.5). This approach makes no assumptions about the sample \(z(s)\), but of course it should allow for choosing the covariance function and estimating its parameters; inference is conditional to the validity of the postulated model.

Rather than assuming a superpopulation model, the design-based
approach (De Gruijter and Ter Braak 1990; D. J. Brus 2021a; Breidt, Opsomer, and others 2017) assumes
randomness in the locations, which is justified (only) when using
random sampling. It *requires* that the sample data were obtained
by probability sampling, meaning that some form of spatial random
sampling was used where all elements of \(z(s)\) had a known and
positive probability of being included in the sample obtained. The
random process is that of sampling: \(z(s_1)\) is a realisation of
the random process \(z(S_1)\), the first observation taken *over
repeated random sampling*. Design-based estimaters only need
these inclusion probabilities to estimate mean values with standard
errors. This means that for instance given a simple random sample,
the unweighted sample mean is used to estimate the population mean,
and no model parameters need to be fit.

The misconception here, as explained in [brus2021], is that this is
only the case when working under model-based approaches: \(Z(s_1)\)
and \(Z(s_2)\) may well be correlated (“model-dependent”), but although
in a particular random sampling (realisation) \(z(s_1)\) and \(z(s_2)\)
*may* be close in space, the corresponding random variables \(z(S_1)\)
and \(z(S_2)\) considered over repeated random sampling are not close
together, and are design-independent. Both situations can co-exist
without contradiction, and are a consequence of choosing to work
under one inference framework or the other.

The choice whether to work under a design-based or model-based framework depends on the purpose of the study and the data collection process. The model-based framework lends itself best for cases * where predictions are required for individual locations, or for areas too small to be sampled * when the available data were not collected using a known random sampling scheme (i.e., the inclusion probabilities are unknown, or are zero over particular areas or/and times) Design-based approaches are most suitable when * observations were collected using a spatial random sampling process * aggregated properties of the entire sample region (or sub-region) are needed. * estimates are required that are not sensitive to potential model misspecification, e.g. when needed for regulatory purposes.

In case a sampling procedure is to be planned (De Gruijter et al. 2006), some form of spatial random sampling is definitely worth considering since it opens up the possibility of following both inference frameworks.

## 10.2 Predictive models with coordinates

In data science projects, coordinates may be seen as features in a larger set of predictors (or features, or covariates) and treated accordingly. There are some catches with doing so.

As usual when working with predictors, it is good to choose predictive methods that are not sensitive to shifts in origin or shifts in unit (scale). Assuming a two-dimensional problem, predictive models should also not be sensitive to arbitrary rotations of the x- and y- or latitude and longitude axes. For projected (2D, Cartesian) coordinates this can be assured e.g. by using polynomials of order \(n\) as \((x+y)^n\), rather than \((x)^n + (y)^n\); for a second order polynomial this involves including the term \(xy\), so that an ellipsoidal-shape trend surface does not have to be aligned with the \(x-\) or \(y-\)axis. For a GAM model with spline components, one would use a spline in two dimensions rather than two independent splines in \(x\) and \(y\). An exception to this “rule” is when e.g. a pure latitude effect is desired, for instance to account for solar energy influx.

When the area covered by the data is large, the difference between using ellipsoidal coordinates and projected coordinates will automatically become larger, and hence choosing one of both will have an effect on predictive modelling. For very large extents, e.g. global models, polynomials or splines in latitude and longitude will not make sense as they ignore the circular nature of longitude and the coordinate singularities at the poles. Here, spherical harmonics, base functions that are continuous on the sphere with increasing spatial frequencies can replace polynomials or be used as spline base functions.

In many cases, the spatial coordinates over which samples were
collected also define the space over which predictions are made,
setting them apart from other features. Many simple predictive
approaches, including most machine learning methods, assume
sample data to be independent. When samples are collected by
spatially random sampling over the spatial target area, this
assumption may be justified when working under a design-based context
(D. J. Brus 2021b). This context however treats the coordinate space as
the variable over which we randomize, which affords predicting
values for a new *randomly chosen* location but rules out making
predictions for fixed locations; this implies that averages over
areas over which samples were collected can be obtained, but not
spatial interpolations. In case predictions for fixed locations
are required, or in case data were not collected by spatial
random sampling, a model-based approach (as taken in chapter
12) is needed and typically some form of spatial
and/or temporal autocorrelation of residuals must be assumed.

A common case is where sample data are collected opportunistically (“whatever could be found”), and are then used in a predictive framework that does not weigh them. This has a consequence that the resulting model may be biased towards over-represented areas (in predictor space and/or in spatial coordinates space), and that simple (random) cross validation statistics may be over-optimistic when taken as performance measures for spatial prediction (Meyer and Pebesma 2020). Adaptive cross validation measures, e.g. spatial cross validation may help getting more relevant measures for predictive performance.

## 10.3 Model-based inference

Wikle/Zambione/Cressie: (Wikle, Zammit-Mangion, and Cressie 2019)

Geostatistics: (Gräler, Pebesma, and Heuvelink 2016) scalable method comparison: (Heaton et al. 2018)

Point patterns: (Stoyan et al. 2017) (Gabriel, Rowlingson, and Diggle 2013)

Spatstat book: (Baddeley, Rubak, and Turner 2015)

R-INLA: (Blangiardo et al. 2013), (Blangiardo and Cameletti 2015) (Gómez-Rubio 2020)

R-INLA-SPDF: Advanced Spatial Modeling with Stochastic Partial Differential Equations Using R and INLA: (Krainski et al. 2018)

Possibly: M. Cameletti: Stem: Spatio-temporal models in R Estimation of the parameters of a spatio-temporal model using the EM algorithm, estimation of the parameter standard errors using a spatio-temporal parametric bootstrap, spatial mapping.

Stcos: https://onlinelibrary.wiley.com/doi/abs/10.1002/sta4.94 , CRAN, https://arxiv.org/abs/1904.12092 (Raim et al. 2020)

### References

Baddeley, Adrian, Ege Rubak, and Rolf Turner. 2015. *Spatial Point Patterns: Methodology and Applications with R*. Chapman; Hall/CRC.

Blangiardo, Marta, and Michela Cameletti. 2015. *Spatial and Spatio-Temporal Bayesian Models with R-Inla*. John Wiley & Sons.

Blangiardo, Marta, Michela Cameletti, Gianluca Baio, and Håvard Rue. 2013. “Spatial and Spatio-Temporal Models with R-Inla.” *Spatial and Spatio-Temporal Epidemiology* 4: 33–49. https://doi.org/https://doi.org/10.1016/j.sste.2012.12.001.

Breidt, F Jay, Jean D Opsomer, and others. 2017. “Model-Assisted Survey Estimation with Modern Prediction Techniques.” *Statistical Science* 32 (2): 190–205.

Brus, Dick J. 2021a. “Statistical Approaches for Spatial Sample Survey: Persistent Misconceptions and New Developments.” *European Journal of Soil Science* 72 (2): 686–703. https://doi.org/https://doi.org/10.1111/ejss.12988.

Brus, Dick J. 2021b. “Statistical Approaches for Spatial Sample Survey: Persistent Misconceptions and New Developments.” *European Journal of Soil Science* 72 (2): 686–703. https://doi.org/https://doi.org/10.1111/ejss.12988.

De Gruijter, Jaap, Dick J Brus, Marc FP Bierkens, and Martin Knotters. 2006. *Sampling for Natural Resource Monitoring*. Springer Science & Business Media.

De Gruijter, JJ, and CJF Ter Braak. 1990. “Model-Free Estimation from Spatial Samples: A Reappraisal of Classical Sampling Theory.” *Mathematical Geology* 22 (4): 407–15.

Fisher, Ronald Aylmer, and others. 1937. “The Design of Experiments.” *The Design of Experiments.*, no. 2nd Ed.

Gabriel, Edith, Barry Rowlingson, and Peter Diggle. 2013. “Stpp: An R Package for Plotting, Simulating and Analyzing Spatio-Temporal Point Patterns.” *Journal of Statistical Software, Articles* 53 (2): 1–29. https://doi.org/10.18637/jss.v053.i02.

Gómez-Rubio, Virgilio. 2020. *Bayesian Inference with Inla*. CRC Press.

Gräler, Benedikt, Edzer Pebesma, and Gerard Heuvelink. 2016. “Spatio-Temporal Interpolation using gstat.” *The R Journal* 8 (1): 204–18. https://doi.org/10.32614/RJ-2016-014.

Heaton, Matthew J., Abhirup Datta, Andrew O. Finley, Reinhard Furrer, Joseph Guinness, Rajarshi Guhaniyogi, Florian Gerber, et al. 2018. “A Case Study Competition Among Methods for Analyzing Large Spatial Data.” *Journal of Agricultural, Biological and Environmental Statistics*, December. https://doi.org/10.1007/s13253-018-00348-w.

Krainski, Elias T, Virgilio Gómez-Rubio, Haakon Bakka, Amanda Lenzi, Daniela Castro-Camilo, Daniel Simpson, Finn Lindgren, and Håvard Rue. 2018. *Advanced Spatial Modeling with Stochastic Partial Differential Equations Using R and Inla*. CRC Press.

Meyer, Hanna, and Edzer Pebesma. 2020. “Predicting into Unknown Space? Estimating the Area of Applicability of Spatial Prediction Models.” https://arxiv.org/abs/2005.07939.

Raim, Andrew M., Scott H. Holan, Jonathan R. Bradley, and Christopher K. Wikle. 2020. *Stcos: Space-Time Change of Support*. https://github.com/holans/ST-COS.

Stoyan, Dietrich, Francisco J. Rodríguez-Cortés, Jorge Mateu, and Wilfried Gille. 2017. “Mark Variograms for Spatio-Temporal Point Processes.” *Spatial Statistics* 20: 125–47. https://doi.org/https://doi.org/10.1016/j.spasta.2017.02.006.

Wikle, Christopher K, Andrew Zammit-Mangion, and Noel Cressie. 2019. *Spatio-Temporal Statistics with R*. CRC Press.