## 3 Methods
### Random Forest for Spatial Data
Complete benchmarking of the prediction efficiency is documented in R code and is available via the GitHub repository at [[https://github.com/thengl/GeoMLA](https://github.com/thengl/GeoMLA)]([https://github.com/thengl/GeoMLA](https://github.com/thengl/GeoMLA)), accessed on 30 August 2023. A fundamental concept of much of the work on geospatial statistics is a **Gaussian process**. These are assignments of Gaussian random variables \(X_{\ell}\) (which can be multi-dimensional) to locations \(\ell\) with a covariance structure, typically describing how \(X_{\ell}\) relates to \(X_{\ell^{\prime}}\) for \(\ell^{\prime}\) a neighbour of \(\ell\)[39, 46]. In more complicated situations the \"neighbouring locations\" can be ascribed by a graph, as in the case of SPAM trees [47]. **Kriging** is a technique to utilize knowledge about spatial autocorrelation in modeling and prediction [48]. Kriging [39] uses the Gaussian process model to estimate \"missing data\" at locations where there are no measurements from locations using the covariance structure. If measurements of a random variable \(Z_{\ell}\) are known at locations \(\ell_{1},\ell_{2},\ldots,\ell_{m}\), then the missing data at a location \(\ell\) can be inferred from these by a formula like  
\[\hat{Z}_{\ell}=\sum_{k=1}^{m}w(\ell,\ell_{k})Z_{\ell+k}, \tag{2}\]  
where \(w(\ell,\ell_{k})\) is a weight obtained from the covariance matrices connecting \(\ell\) with \(\ell_{k}\). Kriging requires a rigid statistical structure for this \"interpolation\" of missing data. The Random Forest spatial prediction method of [PERSON] et al. [27], however, provides an alternative that avoids such rigid assumptions. We also refer the reader to Fixed Rank Kriging (FrK) [49, 50]. Fixed Rank Kriging is kriging with the class of non-stationary covariance functions, which is a relaxation of the assumptions of Ordinary Kriging. Implementation of Generalization of RFsp to Spatial-Temporal Data  
In the previous section, we showed the generic equation of an RFsp (Equation (1)), and we use this to formulate the model in this study. Following from Equation (1), the RFsp model is  
\[Z_{\ell}=f(X_{G_{\ell}},A_{\ell},T_{\ell}), \tag{3}\]where \(\ell\) is now extended to a spatiotemporal domain, by adding a time dimension, \(\ell\in\mathbb{R}^{2}\times\left[0,\infty\right)\). We define \(A_{\ell}\) as the aerosol value at the spatiotemporal location \(\ell\),\(T_{\ell}\) is the time covariate, namely, the cumulative number of days since 1 January 1970 (cdate) and day of the year (doy) over the dates of the study time period. \(X_{G_{\ell}}\) denotes the distance matrix; the distances between all pairs of locations \(\ell\) within the defined study area; that is, the \(ij\) entry is the distance between the \(i\)th and \(j\)th locations. We follow the steps below in order to calculate the distances for all pairs of grid cells, and then the resultant _design matrix_ is used in the RFsp algorithm (implemented in the ranger package). Procedural steps via the ranger package using Equations (1)-(3):  
1. Create an \(n\times n\) matrix where \(n\) is the number of cells in the grid and each row of the matrix corresponds to an individual cell. Each cell is dependent, not only spatially with respect to surrounding cells, but also dependent on the amount of aerosols contained in the cells. 2. For each row of the matrix, all of those aerosol values from each cell are included. This step adds \(n\) columns to the design matrix. 3. Next, we repeat the above process for each day of the study period. 4. Also included in the model are cdate and doy for the number of days of observation, which we denote by \(r\). 5. As there are \(n\) cells of data for each day, all cdate and doy values are repeated \(n\) times, then all together we have a \((r\times n)\times(2n+2)\) matrix. These steps create a large matrix, which is the design matrix. Quantile prediction intervals are used as a measure of the prediction error in the ozone predictions obtained from the application of RFsp.