Comparing Spatial Regression to Random Forests for Large Environmental Data Sets

Environmental data may be"large"due to number of records, number of covariates, or both. Random forests has a reputation for good predictive performance when using many covariates with nonlinear relationships, whereas spatial regression, when using reduced rank methods, has a reputation for good predictive performance when using many records that are spatially autocorrelated. In this study, we compare these two techniques using a data set containing the macroinvertebrate multimetric index (MMI) at 1859 stream sites with over 200 landscape covariates. A primary application is mapping MMI predictions and prediction errors at 1.1 million perennial stream reaches across the conterminous United States. For the spatial regression model, we develop a novel transformation procedure that estimates Box-Cox transformations to linearize covariate relationships and handles possibly zero-inflated covariates. We find that the spatial regression model with transformations, and a subsequent selection of significant covariates, has cross-validation performance slightly better than random forests. We also find that prediction interval coverage is close to nominal for each method, but that spatial regression prediction intervals tend to be narrower and have less variability than quantile regression forest prediction intervals. A simulation study is used to generalize results and clarify advantages of each modeling approach.


Introduction
As we enter the age of "big data" (McAfee et al., 2012;Lohr, 2012), innovative statistical methods are required for insights from massive data sets (Gandomi and Haider, 2015). While big data is an abstract concept (Chen et al., 2014), data for a statistical analysis are generally prepared as tables, with records down the rows, and variables across the columns (Hand, 1999). While we immediately recognize big data problems for large numbers of records, there are also issues when there are large numbers of columns (Tukey, 1991). We are interested in a spatial data set in the United States of national importance based on an aquatic health index, where there are thousands of rows and hundreds of columns. Two leading candidates for analyzing such data are random forests (Breiman, 2001), because it handles large numbers of covariates with nonlinear relationships, and spatial regression (Ver Hoef et al., 2001), because it accounts for possible spatial autocorrelation.
The ultimate goal of the analysis is to predict the aquatic health index at over one million watersheds throughout the country, while also gaining some understanding of which covariates are important.
The goal of this article is to use best practices for analyzing the data with spatial regression and random forests, and then compare the methods.

Motivating Data Set
For this study, we use a data set containing the biological condition of n = 1859 sites from the US Environmental Protection Agency's 2008/09 National Rivers and Streams Assessment (NRSA; USEPA, 2016a). The NRSA used a generalized random-tessellation design (Stevens Jr and Olsen, 2004) to collect a spatially-balanced and representative sample of stream sites across the conterminous US (CONUS). The target population for the design consisted of all rivers and streams within the CONUS that had flowing water during the study period, which extended between April to September of 2008/09. Benthic macroinverabrates (e.g., aquatic insects, crustaceans, and worms) were sampled to determine the biological condition of stream sites. A multimetric index (MMI) was developed for the NRSA to summarize several measures of the condition of macroinvertebrate assemblages (e.g., taxonomic composition, diversity, tolerance to disturbance, etc.) into a combined index. The reported MMI values were calculated by summing six individual measures, or 'metrics', and then normalized to a 0-100 scale (USEPA, 2016b). The individual metrics used for the MMI were selected separately for each of the nine ecoregions (Omernik, 1987) to account for some of the natural variation in climate, geology, hydrology and soils among stream sites. The ecoregion boundaries and locations of the 2008/09 NRSA stream sites are shown in Figure 1. A comprehensive description of the MMI developed for the NRSA was provided by Stoddard et al. (2008), USEPA (2016b), and Hill et al. (2017).
For modeling the MMI we use a large suite of p = 209 covariates from the Stream-Catchment (StreamCat) data set (Hill et al., 2016; publicly available at https://www.epa.gov/nationalaquatic-resource-surveys/streamcat). StreamCat contains upstream landscape features (e.g., topograpy, precipitation, landscape imperviousness, urban and agricultural land use) for 2.6 million stream reaches across the CONUS and allows for spatially explicit prediction. The variables in StreamCat can be linked to the National Hydrography Dataset Plus Version 2 (NHDPlusV2; McKay et al., 2012) and are available at two spatial scales: local catchment and full contributing watershed. Hill et al. (2016) defines a "catchment" as the local drainage area for an individual NHDPlusV2 stream segement, excluding upstream drainage area; and a "watershed" as the set of hydrologically connected catchments that contribute flow to a given catchment (i.e., catchment plus upstream catchments). Note that we only make MMI predictions for the 1.1 million perennial stream reaches (as designated in NHDPlusV2) since the sample frame for the NRSA is limited to these types of streams. Descriptions of StreamCat covariates used in this study are provided in the Supplement.

Literature Review
There have been surprisingly few attempts to compare random forests and spatial regression. Most found random forests superior to various forms of linear regression with autocorrelated errors (Li et al., 2011a,b;Appelhans et al., 2015;Hengl et al., 2015;Fayad et al., 2016), although Parmentier et al. (2011), and Temesgen and Ver Hoef (2014 found spatial regression outperformed random forests. All comparisons used either root-mean-squared prediction error (RMSPE) or mean absolute prediction error (MAPE) on some form of n-fold cross-validation, and only Temesgen and Ver Hoef (2014) evaluated the estimated prediction errors to examine whether prediction intervals contained the true values with the correct proportion. None of the papers simulated spatially autocorrelated data to evaluate and compare the different modeling approaches.
The comparisons in our review used random forests and spatial regression mostly as black box methods. By black box methods, we mean that data are used without much examination, and methods that rely on default values and little user interaction. Generally, random forests seems to outperform spatial regression, but only as a black box method. Can practitioners with more experience make each of these methods work better, and then how will they compare? It will be (or should be) rare that data, collected at great expense, are subjected to black box methods. The history of regression has taught statisticians to use best practices for their data analyses, including exploring data, making transformations, checking residuals, using model diagnostics, and then possibly refitting models. We suggest that the results given in the previously mentioned literature are not necessarily reflective of a considered approach to many data analyses. In contrast, we will confine ourselves to a single data set, and a single response variable, but we take considerable effort to make each method work as well as possible, and discuss the ramifications after the analyses. We will also use simulations to investigate properties not seen in the real data.
Our objectives are to compare random forest and spatial regression modeling approaches for predicting and mapping the MMI for all 1.1 million perennial stream reaches across the CONUS.
In a related study, Hill et al. (2017) used random forest modeling to predict the binary "good" and "poor" MMI condition classes with StreamCat predictor variables. The random forest models developed in Hill et al. (2017) were used to map the predicted probability of good stream condition for all perennial CONUS stream reaches. In this article we instead model the MMI scores directly, and include both random forests and spatial regression. We also evaluate each method's ability to quantify the uncertainty of the MMI predictions. Previous studies have produced maps of random forest model uncertainties by interpolating the residuals (Oliveira et al., 2012;Appelhans et al., 2015), or taking the standard deviations of the predictions made by each tree in the ensemble (Freeman et al., 2015). In this article we take a different approach, and formally construct random forest prediction intervals using the method of quantile regression forests (Meinshausen, 2006), which has been studied primarily in the context of non-spatial data. We also consider a hybrid random forest regression-kriging approach, in which a simple-kriging model is estimated for the random forest residuals, and simple-kriging predictions of residuals are added to random forest predictions. Although we focus on a particular data set, we generalize the concepts through simulations, and our overall goal is application to other large environmental data sets.

Spatial Regression Model
Here, we introduce the spatial regression model, likelihood-based estimation methods, and kriging prediction and variance equations that we apply to the MMI and StreamCat data. The reduced rank method, and covariate transformation and selection procedures will be discussed in subsequent sections. A thorough review of the geostatistical modeling approach discussed in this study is provided in Cressie (1993) and Cressie and Wikle (2011).
Suppose that Y = (Y (s 1 ), · · · , Y (s n )) is a response vector that is spatially referenced at locations s i ∈ D ⊂ R 2 . The spatial regression model can be written as where X is an n × p design matrix for the covariates, β is a p × 1 vector of unknown regression coefficients, z is an n × 1 vector of spatially autocorrelated random variables, and is an n × 1 vector of independent random errors. The n × n covariance matrix for the model can be expressed as Σ = var(Y ) = var(z) + var( ) = R + σ 2 I.
To simplify estimation of (2), we assume a stationary covariance function that depends on Euclidean distance and takes an exponential form. That is, the (i, j) entry of R is given by where · denotes the Euclidean distance metric, and σ 2 z and α are parameters to be estimated.
In the geostatistical literature, the parameters σ 2 z , α, and σ 2 are, respectively, called the partial sill, range, and nugget. The nugget parameter models residual variation in the response when the separating distance is zero.
Model (1) is also commonly referred to as the spatial linear model (SLM), and as the universalkriging model when used for spatial prediction, with the ordinary-kriging model being the special case when X is a n × 1 column vector of 1's. While numerous types of covariance functions have been proposed for the SLM (e.g., Chiles and Delfiner, 1999, pp. 80-93), we only consider the exponential form in (3) since estimation of the SLM is computationally demanding with large data sets. Moreover, for modeling MMI, we focus instead on estimating covariate transformations in X, which are discussed subsequently in Section 2.2. Regionally varying intercept terms are also included in X to account for differences in MMI development in the nine ecoregions.
The parameters of a spatial regression model for a particular data set can be estimated using maximum likelihood (ML; Cressie, 1993, p. 92) or restricted maximum likelihood (REML; Patterson and Thompson, 1971;Harville, 1974) estimation. The negative log-likelihood can be expressed as where, for ML, c = 0, and for REML, c = −p log(2π) + log |X Σ(θ) −1 X|; the covariance matrix, Σ(θ), is written here to emphasize dependence on the unknown covariance parameters θ (i.e., nugget, partial sill, and range). Minimizing (4) with respect to β giveŝ The ML or REML estimators of the covariance parameters,θ, are obtained by substitutingβ(θ) into (4) and minimizing with respect to θ; estimators of the regression coefficients are consequently found by substitution ofθ back into (5), i.e.,β(θ). In practice, we obtain ML or REML estimates of θ numerically using the general purpose optimization function optim() provided in the statistical software package R (R Core Team, 2016). Note that REML estimators tend to have less bias and better performance (in terms of mean squared error) than ML estimators, especially when p is large relative to n (Harville, 1977;Cressie, 1993, p. 93).
Once the parameters are estimated for the spatial regression model, we use universal kriging to make predictions and construct prediction intervals (Cressie, 1993, pp. 151-155;Cressie and Wikle, 2011, pp. 145-148). The universal-kriging prediction and variance equations for the response at a new location s 0 are given bŷ where t( , and x(s 0 ) is the covariate vector at s 0 . Note that the covariance function is defined here as C(u, v) = σ 2 z exp(||u − v||/α) + I(u = v)σ 2 for all locations u, v ∈ D. Also, note that (6) is derived as the homogeneously linear combination of the data, λ Y where λ ∈ R n , that minimizes the mean-squared- x(s 0 ) β; and (7) is the minimized mean-square-prediction error, often referred to as the kriging variance.

Reduced Rank Methods
For data sets with a large number of records, inverting the covariance matrix when optimizing the log-likelihood function (4) can be computationally burdensome. For example, the motivating 2008/09 NRSA data set contains nearly 2000 records; thus there is a computational cost when estimating a spatial regression model for this data set. To accelerate parameter estimation for the SLM we consider reduced rank methods (Cressie and Johannesson, 2008;Banerjee et al., 2008). In this section we specify the reduced rank method used in the study; Section 2.3 will subsequently discuss the application of this method to a computationally efficient covariate selection routine.
Consider a set of r knot locations {k i : i = 1, · · · , r}, distributed over the same domain as the observed data, such that r << n. Instead of modeling the covariance matrix for Y in terms of the Euclidean distances between the observed locations, we can alternatively model the covariance matrix in terms of the knot locations as and σ 2 z , α, and σ 2 are parameters to be estimated. An advantage of the specification in (8) is that application of the well-known Sherman-Morrison-Woodbury formula (see Henderson and Searle (1981) for a review) yields the following decomposition: Since (9) only involves inverting an r × r matrix computation speed is greatly improved.
Note that (8) can be viewed as the covariance matrix for Y in the spatial mixed effects model where γ is an r × 1 vector of random effects such that var(γ) = K −1 . Also, one property of the covariance matrix specified in (8) is that if the knots are the observed data locations {s i }, then S = K = R, and consequently (8) is equivalent to the full rank covariance matrix defined in (2).

Covariate Transformations
Many of the covariates in the StreamCat data set have nonlinear relationships with MMI. For example, Figure 2(a,c) shows highly skewed relationships between MMI and two StreamCat covariates: watershed area in square km (WsAreaSqKm); and the percent of watershed area classified as developed, medium intensity land use within a 100-m buffer of a stream reach (PctUrbMd2006WsRp100).
The log-transformation helps linearize the relationship between MMI and PctUrbMd2006WsRp100 ( Figure 2d), and also reveals a quadratic relationship between MMI and WsAreaSqKm ( Figure 2b).
While not shown here, many of the other StreamCat covariates exhibit similar types of nonlineari-ties, and further motivate considering covariate transformations.
To linearize relationships between the covariates and response variable, we estimate Box-Cox transformations (Box and Cox, 1964) for the covariates. Specifically, we estimate transformations of the form where x > −λ 2 . Note that Box-Cox transformations were first proposed as a way to transform the response variable (Box and Cox, 1964), however, these types of power transformations have also been applied to the independent variables in regression modeling (Fox, 2008, pp. 50-63).
Figure 2 suggests that StreamCat covariates can be zero-inflated (e.g., PctUrbMd2006WsRp100), or have quadratic relationships with the response (e.g., log-transformed WsAreaSqKm). Different types of transformation effects are considered depending on whether or not the StreamCat covariate is zero-inflated. To estimate transformations for the zero-inflated covariates, we estimate the following linear models for varying values of λ 1 and λ 2 : Here y is MMI, x i is the i th StreamCat covariate, is the error term, and I(a) is the indicator function, equal to one if the argument a is true, and zero otherwise. For each zero-inflated covariate, we use the Aikaike Information Criterion (AIC; Akaike, 1974) to select optimal (λ 1 , λ 2 ) and the type of transformation: zero/nonzero indicator (11), interaction between the indicator and transformed covariate (12), or both (13). That is, out of several candidate values for (λ 1 , λ 2 ), we select the Box-Cox parameter values and type of transformation effect that corresponds to the linear model (11, 12, or 13) with the lowest AIC. To estimate transformations for the other covariates (not zero-inflated), we estimate the following linear models for varying values of λ 1 and λ 2 : For each covariate that is not zero-inflated, we again use the AIC to select optimal (λ 1 , λ 2 ) and the type of transformation: linear (14) or quadratic (15) polynomial. In practice, we vary the values of the exponent parameter λ 1 between 0 and 3, and try several shifting parameters λ 2 to ensure that (10) is well defined. We also define a covariate x i as being zero-inflated if the proportions of zeros is greater than 2%. Note that the transformations are estimated separately for each covariate, and that spatial autocorrelation is ignored while estimating transformations because otherwise the procedure would be too slow computationally.
Once transformations have been selected, a new design matrix containing the transformations for each StreamCat covariate can be used to fit either a multiple regression or spatial regression model. Since we include indicator variables for zero-inflated covariates and quadratic polynomial effects, the transformed design matrix is larger than the design matrix without transformations. In the next section, we discuss a covariate selection approach for reducing the number of parameters in a spatial regression model.

Covariate Selection
Covariate selection for the spatial regression model is implemented in two phases. For the first phase, we fit a multiple linear regression model (LM) with the full set of covariates from the StreamCat data set. Dummy variables for the ecoregions (Figure 1) are also included as additional covariates in the LM to account for regional variations in MMI development. Variables are then selected using a backwards stepwise algorithm (i.e., the step() function from R Core Team (2016)). Note, we start by selecting variables for an LM rather than an SLM since the LM can be rapidly estimated, and software is readily available for variable selection.
For the second phase, we estimate an SLM with the variables selected for the LM. We then conduct further variable selection for the SLM since some covariates may no longer be significant once spatial autocorrelation is taken into account (Ver Hoef et al., 2001;Hoeting et al., 2006).
Specifically, we repeatedly remove the covariate with the largest absolute t-statistic and re-fit the SLM until the model's AIC score starts to increase. To speed up ML estimation of the SLM during this procedure we use the reduced rank method (Section 2.1). Once all variables are selected for the SLM, REML with the full rank covariance matrix is used to estimate the final model. A step-by-step description of the covariate selection procedure is provided in the Supplement (Section S1).

Random Forest Model
Random forest (RF) modeling has become a popular technique for regression and classification with complex environmental data sets (Prasad et al., 2006;Cutler et al., 2007;Carlisle et al., 2009;Evans et al., 2011;Hill et al., 2013;Freeman et al., 2015). In contrast to multiple regression, RF is an entirely nonparametric and algorithmic procedure which makes no a priori assumptions about the relationship between the predictor variables and the response. RF has a reputation for good predictive performance when the data contain a large number predictor variables, and when there are complex nonlinearities and interaction effects in the relationship between the predictors and response variable (Cutler et al., 2007;Strobl et al., 2009;Biau, 2012). In addition, RF provides several measures of variable importance that allow for interpretation of the fitted model (Hastie et al., 2009, p. 593).
An RF model can be defined as a collection of regression trees {T b : b = 1, · · · , B} each built from a bootstrap sample of the data set {Y , X}. When growing each tree T b , at each parent node a subset of m of the p predictor variables are randomly selected, and the best split-point is found among those m variables to form two daughter nodes. The trees in the RF ensemble are grown deep with no pruning. Bagging trees (Breiman, 1996) are the special case when m = p (i.e., all predictor variables are used as candidates for splitting at each node). An RF prediction at a new site with predictor values x = (x 1 , · · · , x p ) is found by averaging the predictions made by each tree in the ensemble:f RF is also commonly used for classification, in which case T b (x) takes on discrete values (e.g., 0/1 for binary classification) and the RF prediction can be defined as the majority vote from the collection of class predictions {T b (x)}. However, in this study we only consider RF for regression. Note that the RF algorithm produces individual tree estimators with high variance. That is, a regression tree fit to different portions of the data can yield very different predictions at an unsampled site.
The main idea behind RF is that averaging over many tree models is a way to reduce variance, and thereby improve predictive performance relative to a single tree model (Breiman, 1996(Breiman, , 2001 We implement RF using the R package randomForest (Liaw and Wiener, 2002). There are two tuning parameters when estimating an RF model with this package: the number of trees B, and the number of predictor variables m randomly selected at each node. However, RF is generally insensitive to choice of tuning parameters, and the defaults perform adequately for most data sets (Liaw and Wiener, 2002;Cutler et al., 2007;Freeman et al., 2015). In practice, we use B = 1000 trees and the default m = p/3. We use more trees than the default value (500) since this is recommended for data sets that have a large number of predictors (Liaw and Wiener, 2002). For the RF model of MMI, we also use the full set of StreamCat predictor variables, as well as an additional categorical predictor for the ecoregions. We do not perform additional subset selection since the RF algorithm is robust to handling large sets of predictor variables (Breiman, 2001;Strobl et al., 2009;Biau, 2012).

Quantile Prediction Intervals
Prediction intervals for RF can be computed using quantile regression forests (QRF; Meinshausen, 2006). Here Q α (x) defines the α-quantile, that is, the value of the random response variable Y such that the probability Y is less than Q α (x), for given x, is exactly equal to α;Q α (x) denotes the QRF estimator of this quantity. A main distinction between the RF and QRF algorithms is that RF only keeps track of the mean value of the response data at each leaf (terminal node) of each tree. QRF, on the other hand, keeps track of all the response data at each leaf of each tree and approximates the full conditional distribution with this additional information. In practice, we implement the QRF method using the R package quantregForest (Meinshausen, 2016), which builds on the randomForest package also used in this study.

Random Forest Regression Kriging
Random forest regression kriging (RFRK) has been proposed in a number of studies as a way to account for spatial autocorrelation in RF modeling (e.g, Li et al., 2011b;Hengl et al., 2015;Fayad et al., 2016). For RFRK, a prediction at a new site is given by summing the RF prediction and the kriging prediction of the RF residual. Formally, an RFRK prediction of Y (s 0 ), at a new site s 0 , is given byŶ wheref RF is the RF prediction with covariates x(s 0 ), andê(s 0 ) is the kriging prediction of the residual. In practice, we use ML to estimate a simple-kriging model for the RF residuals that assumes a zero mean (i.e, E(e(s)) = 0) and exponential model for the covariance matrix. Ad-ditionally, we use the simple-kriging variances for the residuals to construct prediction intervals.
Computational details are provided in the Supplement (Section S2).

Performance Measures
We assess the performance of different models for MMI using 10-fold cross validation. Seven models of MMI are considered for the comparison: (1) an ordinary-kriging model, i.e., an SLM with no covariates and a single intercept term (X is a n × 1 column vector of 1's); (2) an LM with no transformations; (3) an SLM with no transformations; (4) an LM with transformations; (5) an SLM with transformations; (6) an RF model; and (7) an RFRK model.
The root-mean-square prediction error (RMSPE) and coverage of the prediction intervals are used to evaluate the cross-validation performance of the different models. Let Y i denote the i th observed value andŶ i the 10-fold cross-validation prediction. The RMSPE is computed as the square root of the mean of (Y i −Ŷ i ) 2 and coverage of the 90% prediction intervals is computed as the mean of ) for all i in 1, · · · , n, where I is the indicator function and se(Ŷ i ) is the prediction standard error. Since we estimate quantile prediction intervals for RF, the coverage of the 90% prediction intervals is computed as the mean of I(Q 0.05 (x i ) < Y i <Q 0.95 (x i )) for all i in 1, · · · , n, where x i are the predictor variables at the i th site andQ α (x i ) is the 10-fold cross-validation prediction of the α-quantile defined in Section 3.1.

Results
The 10-fold cross-validation performance measures for modeling MMI are presented in in a more parsimonious model than the LM. The RFRK model also performed better than the RF model, although the difference was not substantial (Pearson correlation between RF and RFRK cross-validation predictions was greater than 0.98).
The coverages of the 90% and 95% prediction intervals were close to nominal for all models in Table 1. That is, for each method, the prediction intervals computed during cross-validation contained the true observed MMI values with approximately the correct proportion. However, even though the coverages were similar, there were considerable differences between the lengths of the prediction intervals from the different methods ( Figure 3). For instance, there was much greater variability in the lengths of the RF quantile prediction intervals than the SLM and RFRK prediction intervals. The lengths of the prediction intervals for the SLM also showed a positive skew ( Figure 3); this can be explained by the universal-kriging variances getting larger for sites which fall away from than bulk of the data in the covariate space (Hengl et al., 2004). The distribution of the prediction interval lengths for RFRK was more symmetric, in comparison, since the simple-kriging variances only account for the uncertainty due to relative geographic distances between points, and not possible quantitative extrapolation in the covariates.
Scatter plots of predicted versus observed values are presented in Figure 4. The scatter plots reveal that the predictions from the different models tend towards the mean of the observed MMIs (36.9). This effect was most pronounced for the ordinary-kriging, RF, and RFRK models; in comparison, the LM and SLM had wider distributions of predicted values. While most of the predictions from the LM and SLM (with and without transformations) were within the defined range of the MMI (0-100), Figure 4 shows that a small percentage (< 0.5%) of predictions were negative. The predictions from the RF and RFRK models, on the other hand, were contained within the observed MMI range. Note that, by definition, RF models cannot predict outside the range of the observed data since each tree model within the forest makes predictions by taking the mean of the response data falling within a given leaf (terminal) node.
Covariance parameter estimates (nugget, partial sill, and range) for the spatial regression models are presented in Table 2. The ordinary kriging model has a larger estimated nugget parameter,σ 2 , and smaller nugget-to-sill ratio,σ 2 /(σ 2 z +σ 2 ), than the SLM. This is expected since the covariates in the SLM explain additional variation in MMI not accounted for by ordinary kriging. Moreover, the spatially-referenced StreamCat covariates in the SLM account for some spatial autocorrelation in MMI. To further assist interpretation, Table 2 also presents the effective range, −α log[0.01 * (σ 2 z + σ 2 )/σ 2 z ], which is defined here as the distance beyond which spatial autocorrelation is less than 0.01 (i.e., the distance h found by solving ρ(h) = C(h)/C(0) = 0.01; Irvine et al., 2007). The effective ranges for ordinary-kriging and the SLM reveal that spatial autocorrelation in the data is close to zero for distances beyond 480-580km. Additionally, for the RFRK model, both the effective range (160km) and nugget-to-sill ratio (0.951) indicate little, perhaps negligible, spatial autocorrelation in the RF residuals. Note that, for the effective range calculations we use 0.01 instead of 0.05, which is more common, since the nugget-to-sill ratio for RFRK is greater that 0.95.
Maps of the RF and SLM predictions of MMI are presented in Figure 5 (a,b). The maps show MMI predictions for 1.1 million perennial stream reaches within the CONUS. Again, predictions were made only for perennial stream reaches since the sampling frame for the 2008/09 NRSA is limited to these types of streams. Overall, the maps show similar spatial patterns in the MMI predictions from the two models. As expected, regions dominated by urban or agricultural land tend to have lower MMI predictions than more remote regions. The most noticeable difference between the prediction maps is that the SLM shows a wider distribution of predicted values than RF, with sharper differences between regions with low and high MMI predictions (e.g., Willamette Valley versus Cascades in Oregon; Piedmont versus Blue Ridge Mountains in Georgia, S. and N. Carolina, and Virginia). Also note that the RF predictions never reach zero, while about 1.2% of the SLM predictions are negative and set to zero in Figure 5 since MMI is defined between 0-100.
In contrast to the prediction maps, the maps of the RF and SLM prediction errors (lengths of 90% prediction intervals) are strikingly different (Figure 5c,d). There is much greater variability in the lengths of prediction intervals in the map for the RF model than the SLM (note, this is consistent with the cross-validation results in Figure 3). Moreover, the SLM prediction intervals show greater precision in regions that are more densely sampled (e.g., Mississippi Basin). Contrastingly, the precision of the RF quantile prediction intervals do not apparently scale with the density of sampling locations.
Lastly, both the SLM and RF models provide measures of variable importance. For the SLM, covariates can be ranked in terms of the absolute t-statistics for the coefficients. For RF, covariates can be ranked in terms of a permutation-based measure (i.e., the average increase in mean-square error when each covariate is permuted in the out-of-bag data; Hastie et al., 2009, p. 593

Simulation
Modeling the MMI data indicated that the SLM, with appropriate transformations of the covariates to obtain near linear relationships between response and covariates, performed slightly better than RF. However, this is but a single data set with apparently little autocorrelation in the residuals.
We explore the affect of nonlinear relationships between response and covariates, R 2 , and varying amounts of autocorrelation, through simulations.
Data for this simulation study are generated from the following model: Here δ(s) = z(s) + is a spatially autocorrelated error term such that cov(z(s), z(s + h)) = σ 2 z exp(− h /α) and var( ) = σ 2 is the nugget effect. The parameter c governs the proportion of variance in y explained by the covariates in the systematic component of the model f . The parameter a governs amount of nonlinearity in f , which is decomposed into a nonlinear term g and linear term h. Note that the sine function, with multiplicative interaction between x 1 and x 2 , in (16) was chosen since it is difficult to recover with a linear model, and so RF is expected to have advantages if the data are generated from this type of nonlinear function.
The following characteristics of the simulated data are varied by adjusting the values of the parameters in (16): • The amount of spatial autocorrelation in the error term δ(s). We set σ 2 z = 1 and σ 2 = 9 for a low amount of autocorrelation, and σ 2 z = 9 and σ 2 = 1 for a high amount of autocorrelation.
The range parameter is always α = 0.5.
• The empirical R 2 , i.e., the proportion of variation in y explained by f . The value of parameter c is adjusted in each simulation run to give an empirical R 2 which is either high (0.9) or low (0.1).
• Whether the linear or nonlinear term dominates. The value of parameter a is adjusted in each simulation run so that the proportion of variance in f explained by the nonlinear term g is either high (0.9) or low (0.1).
This gives a total of 2 3 = 8 cases since there are 2 levels (high/low) for each characteristic (spatial autocorrelation, empirical R 2 , and amount of nonlinearity). The 8 cases are summarized in Table 3.
For each simulation case, we generated 20 data sets [y; x 1 , · · · , x 4 ] of 1500 points with locations randomly generated over the unit square. For each data set, 500 points were used for training, and the other 1000 as a test set. Values for the covariates x i were drawn from Unif[0,1]. Data from the spatially autocorrelated error term δ(s) in (16) were generated using the Cholesky decomposition method (Cressie, 1993, pp. 201-202). Values of parameters c and a were selected to fix the empirical R 2 and amount of nonlinearity in the simulated data sets generated for each case. Since values of c and a varied, Table 3 presents the averaged values.
The LM, SLM, RF, and RFRK models are compared in the simulations. The SLM is fit using REML with the full rank covariance matrix, and no covariate transformations are considered.
Model performance measures (RMSPE and prediction interval coverage) are averaged over the 20 simulated data sets generated for each case. The simulation code is provided in an R package available at https://github.com/ericwfox/slmrf.

Simulation Results
Simulation results are presented in Table 3. When there was a high amount of autocorrelation in the error term and R 2 = 0.1 (case 2,6), SLM and RFRK performed substantially better than LM and RF. When R 2 = 0.9 and the nonlinear component dominated (case 3,4), RF and RFRK performed substantially better than LM and SLM; RFRK also performed better than RF when there was a high amount of autocorrelation in the error term (case 4). When R 2 = 0.9 and the linear component dominated (case 7,8), the SLM had the best performance among all methods; RFRK also performed better than LM when there was a high amount of autocorrelation in the error term (case 8). When the nugget effect dominated (case 1,5), all models performed similarly in terms of RMSPE, and the SLM had slightly better performance than other methods. For all cases, SLM performed better than LM, and RFRK performed at least as well as RF. However, this is reasonable since there was some amount of autocorrelation in the data generated for each case.
Moreover, when there was only a small amount of autocorrelation in the error term and R 2 = 0.9 (case 3,7), the spatial models performed approximately as well as the non-spatial models (i.e., RF performed as well as RFRK in case 3, and LM performed approximately as well as SLM in case 7).
The coverages of the 90% prediction intervals for LM, SLM, and RFRK were close to nominal for all simulation cases. The quantile prediction intervals for RF showed over-coverage when the linear term dominated and R 2 = 0.9 (case 7,8), but were otherwise reasonable, although not as precise as the other methods.

Discussion and Conclusions
In this article we compared spatial regression and RF methods for modeling stream condition (MMI) with over 200 potential covariates. We used the models for prediction and uncertainty quantification of MMI at 1.1 million perennial stream reaches across the CONUS. Initial exploratory analysis revealed highly nonlinear relationships between StreamCat covariates and MMI scores, which motived the application of Box-Cox transformations for the covariates. We found that the SLM with transformations and RF model performed comparably well in terms of cross-validated RMSPE. However, the SLM without transformations did not perform nearly as well as RF. Thus, the estimation of transformations to account for nonlinearities in the data was an important step for constructing a suitable spatial regression model. The maps of the SLM and RF predictions showed similar spatial trends in stream condition, although the RF predictions were smoother and had greater tendency to concentrate around the mean. Many of the top predictors identified by each method were also similar.
A novel contribution of this study was the assessment and comparison of prediction intervals for the spatial regression and RF methods. The construction of prediction intervals is not yet common practice in RF modeling. In contrast to geostatistics, there is no consensus in the RF literature on best practices for uncertainty quantification. We investigated two ways to construct prediction intervals for RF models: first, by using the quantile regression forest method of Meinshausen (2006); and second, by fitting the RFRK model and using the simple-kriging variances for the RF residuals to form intervals. We found that coverages of the prediction intervals for the SLM, RF, and RFRK models of stream condition were close to nominal (Table 1). However, the lengths of the RF prediction intervals, computed using quantile regression forests, had much greater variability than the SLM and RFRK prediction intervals. One explanation for these differences is that the kriging variances are optimized by minimizing the mean-square-prediction error, whereas the RF quantile prediction intervals are not found by directly minimizing a loss function. The large amount of variability in the prediction interval lengths for quantile regression forests was also acknowledged in Meinshausen (2006) in applications to a variety of data sets.
The results of this study indicate that there are several trade-offs when deciding between an RF or spatial regression approach to modeling a large environmental data set. We summarize these below: • Predictions from RF will always be within the range of the observed data, whereas spatial regression can extrapolate outside this range. In the context of modeling MMI, this was an advantage of the RF approach since the MMI is bounded between 0-100; the SLM also generated some negative MMI predictions that needed to be set to zero in the prediction map ( Figure 5). However, in applications to other data sets, predicting within the range of sampled values is not, in general, an advantage. For instance, for an unbounded normally distributed response variable, if only 1% of the data were sampled, then we would expect that, in the other 99% unsampled sites, there will be values both greater and less than the values in the sample.
• The SLM stands out as a better descriptive model for ecological processes than RF. The initial exploratory analysis and transformation procedure provided insights into the functional relationships between the covariates and MMI response variable. In contrast, the ways in which RF deals with nonlinearities and interactions are hidden in the ensemble of trees and difficult to interpret.
• RF has a slight computational edge over the SLM. The RF algorithm is easy to implement using the randomForest package, and RF models are generally insensitive to values of the tuning parameters. However, computational considerations for fitting an SLM are also not overly-demanding with modern approaches such as REML and reduced rank methods.
• The results from the data analysis (Section 5) suggest advantages to the spatial regression approach for uncertainty quantification. The SLM prediction intervals were narrower, on average, than the RF quantile prediction intervals. Moreover, the prediction intervals for the SLM are more suitable for spatial data since they scale with sampling density.
Generally, in applications to similar types of large environmental data sets, RF has considerable advantages over the SLM only when treating each approach as a black box method, as we discussed in Section 1.2. We recommend the SLM if the practitioner takes a more careful approach to modeling by exploring the data, estimating covariate transformations to account for nonlinearities, and implementing model diagnostics. While RF is easier to implement, the SLM has advantages for inferential tasks such as constructing prediction intervals and assessing covariate significance.
The simulations demonstrated that no single type of model performs best under all conditions, and that each method is designed for specific purposes. For data sets with a high amount of nonlinearity in the covariates, and transformations to linearity are difficult or impossible, RF or RFRK are superior methods that can uncover patterns and interactions that are difficult to recover with an LM or SLM. However, for data sets with a high amount of spatial autocorrelation and linear structure in the covariates, the SLM is the superior method. Also, if the data have a small amount spatial autocorrelation, then it may not be worth the computational effort to fit a spatial model, and either RF or LM are sufficient. The simulation results also indicate that the SLM prediction intervals generally have better coverage than the RF quantile prediction intervals.
Going back to our introductory paragraph, environmental data may be large in n (rows) or p (columns). For spatial models, research for large n is very active, including the reduced rank approaches, among others. Less attention is given to large p, although many proven techniques can be combined into an overall strategy. We suggest that modelers of spatial data carefully consider transformations to linearity and subsequent removal of covariates to obtain a parsimonious set of (transformed) covariates, including possible interactions. We provided one such example, creating indicator variables for covariates with excessive zeros, using Box-Cox transformations on nonzero covariate values, and creating their interaction. Model selection was possible for large p in the presence of large n using reduced rank methods. We stress that this is not the only strategy, but rather an example of how to proceed for both large n and p, which has received little attention.
Given such a strategy, we created an SLM model that slightly outperformed RF, which requires less interaction with the data. Conclusively, there is no correct way to statistically analyze and model large environmental data sets. The results of this study suggest that a variety of modeling approaches can be considered, and that each approach can lead to different insights into the data set and applied problem. By comparing spatial regression to RF we ultimately found ways to improve both techniques.

Acknowledgments
We

Supplementary Material
Supplementary material related to this manuscript can be accessed at the following GitHub repository: https://github.com/ericwfox/slmrf. The repository contains an R package with the code for the simulation study in Section 6. The repository also contains a supplementary PDF with (1) a step-by-step description of the covariate selection procedure; (2) computation details of the random forest regression kriging computations; and (3) additional tables and figures.  The effective range is the distance (km) beyond which spatial autocorrelation is less than 0.01, and the nugget-to-sill ratio is given byσ 2 /(σ 2 z +σ 2 ).    Table 1 and the text. Figure 5: Maps of MMI predictions and lengths of 90% prediction intervals for RF (a,c) and SLM with transformations (b,d). The prediction sites are the 1.1 million perennial stream reaches (catchments) in the NRSA sampling frame. Note the different scales in the maps of prediction interval lengths (c,d). Also note that SLM predictions (b) were truncated at the 0.005 and 0.995 quantiles, and negative predictions (< 1.3% of sites) were set to zero since MMI is defined between 0-100.