Predicted values and intervals based on a fitted model object.

# S3 method for class 'splm'
predict(
  object,
  newdata,
  se.fit = FALSE,
  scale = NULL,
  df = Inf,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  type = c("response", "terms", "weight"),
  block = FALSE,
  local,
  terms = NULL,
  na.action = na.fail,
  ...
)

# S3 method for class 'spautor'
predict(
  object,
  newdata,
  se.fit = FALSE,
  scale = NULL,
  df = Inf,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  type = c("response", "terms", "weight"),
  local,
  terms = NULL,
  na.action = na.fail,
  ...
)

# S3 method for class 'splm_list'
predict(
  object,
  newdata,
  se.fit = FALSE,
  scale = NULL,
  df = Inf,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  type = c("response", "terms"),
  local,
  terms = NULL,
  na.action = na.fail,
  ...
)

# S3 method for class 'spautor_list'
predict(
  object,
  newdata,
  se.fit = FALSE,
  scale = NULL,
  df = Inf,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  type = c("response", "terms"),
  local,
  terms = NULL,
  na.action = na.fail,
  ...
)

# S3 method for class 'splmRF'
predict(object, newdata, local, ...)

# S3 method for class 'spautorRF'
predict(object, newdata, local, ...)

# S3 method for class 'splmRF_list'
predict(object, newdata, local, ...)

# S3 method for class 'spautorRF_list'
predict(object, newdata, local, ...)

# S3 method for class 'spglm'
predict(
  object,
  newdata,
  type = c("link", "response", "terms", "weight"),
  se.fit = FALSE,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  dispersion = NULL,
  terms = NULL,
  local,
  var_correct = TRUE,
  delta = FALSE,
  newdata_size,
  na.action = na.fail,
  ...
)

# S3 method for class 'spgautor'
predict(
  object,
  newdata,
  type = c("link", "response", "terms", "weight"),
  se.fit = FALSE,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  dispersion = NULL,
  terms = NULL,
  local,
  var_correct = TRUE,
  delta = FALSE,
  newdata_size,
  na.action = na.fail,
  ...
)

# S3 method for class 'spglm_list'
predict(
  object,
  newdata,
  type = c("link", "response", "terms"),
  se.fit = FALSE,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  dispersion = NULL,
  terms = NULL,
  local,
  var_correct = TRUE,
  newdata_size,
  na.action = na.fail,
  ...
)

# S3 method for class 'spgautor_list'
predict(
  object,
  newdata,
  type = c("link", "response", "terms"),
  se.fit = FALSE,
  interval = c("none", "confidence", "prediction"),
  level = 0.95,
  dispersion = NULL,
  terms = NULL,
  local,
  var_correct = TRUE,
  newdata_size,
  na.action = na.fail,
  ...
)

# S3 method for class 'decorrelate'
predict(object, newdata, local, ...)

# S3 method for class 'decorrelate_list'
predict(object, newdata, local, ...)

Arguments

object

A fitted model object.

newdata

A data frame or sf object in which to look for variables with which to predict. If a data frame, newdata must contain all variables used by formula(object) and all variables representing coordinates. If an sf object, newdata must contain all variables used by formula(object) and coordinates are obtained from the geometry of newdata. If omitted, missing data from the fitted model object are used.

se.fit

A logical indicating if standard errors are returned. The default is FALSE.

scale

A numeric constant by which to scale the regular standard errors and intervals. Similar to but slightly different than scale for stats::predict.lm(), because predictions form a spatial model may have different residual variances for each observation in newdata. The default is NULL, which returns the regular standard errors and intervals.

df

Degrees of freedom to use for confidence or prediction intervals (ignored if scale is not specified). The default is Inf.

interval

Type of interval calculation. The default is "none". Other options are "confidence" (for confidence intervals) and "prediction" (for prediction intervals). When interval is "none" or "prediction", predictions are returned (and when requested, their corresponding uncertainties). When interval is "confidence", mean estimates are returned (and when requested, their corresponding uncertainties). This "none" behavior differs from that of lm(), as lm() returns confidence uncertainties (in .$se.fit).

level

Tolerance/confidence level. The default is 0.95.

type

The prediction type, either on the response scale, link scale (only for spglm() or spgautor() model objects), terms scale, or prediction (i.e., Kriging) weight scale.

block

A logical indicating whether a block prediction over the entire region in newdata should be returned. When block is TRUE, newdata should be a dense grid of prediction locations that span the entire region. The default is FALSE, which returns point predictions for each location on newdata.

local

A optional logical or list controlling the big data approximation. If omitted, local is set to TRUE or FALSE based on the observed data sample size (i.e., sample size of the fitted model object) – if the sample size exceeds 10,000, local is set to TRUE, otherwise it is set to FALSE. This default behavior occurs because for point prediction the main computational burden of the big data approximation depends almost exclusively on the observed data sample size, not the number of predictions desired (which we feel is not intuitive at first glance). For block prediction (block = TRUE) the density of the prediction grid also matters, so local is additionally set to approximate the theoretical solution when nrow(newdata) exceeds 10,000 (see below). If local is FALSE, no big data approximation is implemented. If a list is provided, the following arguments detail the big data approximation:

  • method: The big data approximation method. If method = "all", all observations are used and size is ignored. If method = "distance", the size data observations closest (in terms of Euclidean distance) to the observation requiring prediction are used. If method = "covariance", the size data observations with the highest covariance with the observation requiring prediction are used. If random effects and partition factors are not used in estimation and the spatial covariance function is monotone decreasing, "distance" and "covariance" are equivalent. The default is "covariance". Only used with models fit using splm() or spglm().

  • size: The number of data observations to use when method is "distance" or "covariance". The default is 100. Only used with models fit using splm() or spglm().

  • parallel: If TRUE, parallel processing via the parallel package is automatically used. This can significantly speed up computations even when method = "all" (i.e., no big data approximation is used), as predictions are spread out over multiple cores. The default is FALSE.

  • ncores: If parallel = TRUE, the number of cores to parallelize over. The default is the number of available cores on your machine.

  • byrow_threshold: Only relevant when a random effect or partition factor is used and method is "distance" or "covariance". In this scenario, when the observed sample size times the number of predictions is less than byrow_threshold, computations are performed once for all predictions simultaneously (which is generally faster but uses more memory). Otherwise, computations are performed separately for each prediction, one row at a time (which is generally slower but uses less memory). The default is 10000^2. Only used with models fit using splm() or spglm().

When local is a list, at least one list element must be provided to initialize default arguments for the other list elements. If local is TRUE, defaults for local are chosen such that local is transformed into list(size = 100, method = "covariance", parallel = FALSE).

If block is TRUE, local controls two separate big data approximations, one for the observed data and one for the prediction grid (newdata):

  • method and size act on the observed data exactly as when block is FALSE (method takes "all", "covariance", or "distance"); the default method is "covariance" with size 4000. This default size is much larger than when block is FALSE because block prediction averages covariances and explanatory variables before prediction.

  • method_new controls the big data prediction grid density. method_new = "basis" (the default) approximates the block variance using a basis of size_new well-spread grid nodes. method_new = "subset" approximates the block mean and variance by subsampling newdata so that its size is only size_new. The default size_new is 4000.

  • ordering chooses the size_new nodes from newdata and takes the same values as the ordering argument of sprnorm()/conditional() under approximation = "vecchia" ("maxmin", "grts", "random", "none", "middleout", "outsidein", "coordinate"). The default is "grts".

  • parallel and ncores parallelize the variance calculation when method_new = "basis".

When local is a list, at least one list element must be provided to initialize default arguments for the other list elements. If local is TRUE, defaults for local are chosen such that local is transformed into list(method = "covariance", size = 4000, method_new = "basis", size_new = 4000, ordering = "grts").

terms

If type is "terms", the type of terms to be returned, specified via either numeric position or name. The default is all terms are included.

na.action

Missing (NA) values in newdata will return an error and should be removed before proceeding.

...

Other arguments. Only used for models fit using splmRF() or spautorRF() where ... indicates other arguments to ranger::predict.ranger().

dispersion

The dispersion of assumed when computing the prediction standard errors for spglm() or spgautor() model objects when family is "nbinomial", "beta", "Gamma", or "inverse.gaussian". If omitted, the model object dispersion parameter is used.

var_correct

A logical indicating whether to return the corrected prediction variances when predicting via models fit using spglm() or spgautor(). The default is TRUE.

delta

A logical indicating whether to return delta method standard errors on the response scale when se.fit = TRUE and type = "response". The default is FALSE.

newdata_size

The size value for each observation in newdata used when predicting for the binomial family, with a default value of 1.

Value

For splm or spautor objects, if se.fit is FALSE, predict() returns a vector of predictions or a matrix of predictions with column names fit, lwr, and upr if interval is "confidence" or "prediction". If se.fit is TRUE, a list with the following components is returned:

  • fit: vector or matrix as above

  • se.fit: standard error of each fit

For splm_list or spautor_list objects, a list that contains relevant quantities for each list element.

For splmRF or spautorRF objects, a vector of predictions. For splmRF_list or spautorRF_list objects, a list that contains relevant quantities for each list element.

For decorrelate objects, a vector of predictions. For decorrelate_list objects, a list that contains relevant quantities for each list element.

Details

For splm and spautor objects, the (empirical) best linear unbiased predictions (i.e., Kriging predictions) at each site are returned when interval is "none" or "prediction" alongside standard errors. Prediction intervals are also returned if interval is "prediction". When interval is "confidence", the estimated mean is returned alongside standard errors and confidence intervals for the mean. For splm_list and spautor_list objects, predictions and associated intervals and standard errors are returned for each list element.

For splmRF or spautorRF objects, random forest spatial residual model predictions are computed by combining the random forest prediction with the (empirical) best linear unbiased prediction for the residual. This approach is called random forest regression Kriging. For splmRF_list or spautorRF objects, predictions are returned for each list element.

For decorrelate objects, the spatial decorrelation transformation predictions recorrelated to the original scale. For decorrelate_list objects, predictions are returned for each list element.

References

Fox, E.W., Ver Hoef, J. M., & Olsen, A. R. (2020). Comparing spatial regression to random forests for large environmental data sets. PloS one, 15(3), e0229509.

Examples

spmod <- splm(sulfate ~ 1, data = sulfate, spcov_type = "exponential")
predict(spmod, sulfate_preds)
#>         1         2         3         4         5         6         7         8 
#>  1.624009 24.395319  8.947418 16.446500  4.948606 26.762345  2.868187 14.255728 
#>         9        10        11        12        13        14        15        16 
#>  1.528476 14.300872  1.209497 17.122842  1.327888 20.181497 21.283600 11.235139 
#>        17        18        19        20        21        22        23        24 
#> 18.686876  9.668878  1.790990 23.619017  3.289241  2.346246  2.047833  2.006561 
#>        25        26        27        28        29        30        31        32 
#>  3.201769  1.495122 18.651578  7.835887 18.798495  5.149106  1.815728  4.066504 
#>        33        34        35        36        37        38        39        40 
#> 12.410924  3.148776  1.300986  6.967949 18.968441  7.314436 14.658665 15.508052 
#>        41        42        43        44        45        46        47        48 
#> 12.397846 24.894481 17.323940 26.836397  1.606072  8.556330  3.772526 14.958904 
#>        49        50        51        52        53        54        55        56 
#> 24.459497  1.970591 27.142423 13.601790  2.573685  1.910667  7.462880 17.171611 
#>        57        58        59        60        61        62        63        64 
#> 16.968042  1.342515 18.665014 12.684033 15.403922 23.536085  1.593403 16.992112 
#>        65        66        67        68        69        70        71        72 
#> 28.490473  1.299507  1.156972  6.169330  3.440658 10.783522  3.607576 17.824632 
#>        73        74        75        76        77        78        79        80 
#>  8.929036  7.283987  2.139187  1.661652 19.376280  1.298919 16.340008 15.290979 
#>        81        82        83        84        85        86        87        88 
#> 17.808855  3.667224  9.735831  1.840372  1.672515  7.801513  2.325218  1.613402 
#>        89        90        91        92        93        94        95        96 
#>  2.692172 19.410507  4.064770  7.960096 12.411138 25.909052 15.122960 16.655562 
#>        97        98        99       100 
#> 21.647230 20.829858 16.763191 16.680239 
predict(spmod, sulfate_preds, interval = "prediction")
#>           fit        lwr       upr
#> 1    1.624009 -6.4466253  9.694643
#> 2   24.395319 16.8500433 31.940594
#> 3    8.947418  1.0157736 16.879063
#> 4   16.446500  8.6266270 24.266372
#> 5    4.948606 -2.7766202 12.673832
#> 6   26.762345 19.2316689 34.293021
#> 7    2.868187 -5.0737681 10.810141
#> 8   14.255728  6.7472875 21.764168
#> 9    1.528476 -6.3392618  9.396215
#> 10  14.300872  6.6182651 21.983479
#> 11   1.209497 -6.7439161  9.162910
#> 12  17.122842  9.5860947 24.659589
#> 13   1.327888 -6.8424375  9.498214
#> 14  20.181497 12.7470639 27.615931
#> 15  21.283600 13.5900268 28.977173
#> 16  11.235139  3.2217759 19.248503
#> 17  18.686876 11.0819760 26.291776
#> 18   9.668878  1.7791074 17.558648
#> 19   1.790990 -6.1939399  9.775920
#> 20  23.619017 16.0402123 31.197822
#> 21   3.289241 -4.7270635 11.305545
#> 22   2.346246 -5.1441640  9.836655
#> 23   2.047833 -6.0421934 10.137859
#> 24   2.006561 -5.7808121  9.793935
#> 25   3.201769 -4.5420731 10.945611
#> 26   1.495122 -6.3572432  9.347486
#> 27  18.651578 11.1199184 26.183237
#> 28   7.835887 -0.3427818 16.014556
#> 29  18.798495 11.0246933 26.572298
#> 30   5.149106 -2.6926600 12.990872
#> 31   1.815728 -6.3378244  9.969280
#> 32   4.066504 -3.5882335 11.721242
#> 33  12.410924  4.6427937 20.179054
#> 34   3.148776 -4.4689556 10.766508
#> 35   1.300986 -6.8455656  9.447538
#> 36   6.967949 -0.9703506 14.906249
#> 37  18.968441 11.6361006 26.300782
#> 38   7.314436 -0.5212963 15.150168
#> 39  14.658665  6.7407623 22.576568
#> 40  15.508052  7.7668705 23.249234
#> 41  12.397846  4.4118062 20.383886
#> 42  24.894481 17.5367811 32.252180
#> 43  17.323940  9.6371219 25.010759
#> 44  26.836397 19.3745867 34.298208
#> 45   1.606072 -6.2119772  9.424122
#> 46   8.556330  0.4323397 16.680319
#> 47   3.772526 -3.6895226 11.234576
#> 48  14.958904  7.1674434 22.750364
#> 49  24.459497 16.8185776 32.100416
#> 50   1.970591 -6.0096614  9.950844
#> 51  27.142423 19.7265315 34.558314
#> 52  13.601790  6.0634533 21.140126
#> 53   2.573685 -5.1273026 10.274673
#> 54   1.910667 -6.3019052 10.123239
#> 55   7.462880 -0.4178286 15.343588
#> 56  17.171611  9.5011471 24.842075
#> 57  16.968042  9.1588390 24.777245
#> 58   1.342515 -6.4518144  9.136845
#> 59  18.665014 11.2593609 26.070668
#> 60  12.684033  4.7569074 20.611159
#> 61  15.403922  7.8559236 22.951920
#> 62  23.536085 16.0346775 31.037492
#> 63   1.593403 -6.2027601  9.389565
#> 64  16.992112  9.1653935 24.818831
#> 65  28.490473 20.9640417 36.016904
#> 66   1.299507 -6.8044341  9.403448
#> 67   1.156972 -6.9385809  9.252526
#> 68   6.169330 -1.7859469 14.124606
#> 69   3.440658 -4.6319002 11.513217
#> 70  10.783522  3.0358671 18.531178
#> 71   3.607576 -4.3529720 11.568125
#> 72  17.824632 10.4664428 25.182822
#> 73   8.929036  1.3721396 16.485933
#> 74   7.283987 -0.7459909 15.313965
#> 75   2.139187 -6.0790935 10.357467
#> 76   1.661652 -5.8870518  9.210357
#> 77  19.376280 11.6670193 27.085540
#> 78   1.298919 -6.5548708  9.152709
#> 79  16.340008  8.5776678 24.102348
#> 80  15.290979  7.3458497 23.236108
#> 81  17.808855 10.2202055 25.397504
#> 82   3.667224 -3.8337247 11.168173
#> 83   9.735831  1.9310480 17.540614
#> 84   1.840372 -5.9619665  9.642711
#> 85   1.672515 -6.0432434  9.388274
#> 86   7.801513 -0.3445465 15.947572
#> 87   2.325218 -5.6195151 10.269951
#> 88   1.613402 -6.0328549  9.259658
#> 89   2.692172 -4.9800331 10.364376
#> 90  19.410507 12.0255970 26.795417
#> 91   4.064770 -4.0069423 12.136483
#> 92   7.960096  0.1240763 15.796116
#> 93  12.411138  4.4675947 20.354681
#> 94  25.909052 18.3932818 33.424822
#> 95  15.122960  7.2165536 23.029367
#> 96  16.655562  9.0500159 24.261109
#> 97  21.647230 13.9120066 29.382453
#> 98  20.829858 13.5080438 28.151672
#> 99  16.763191  9.3107299 24.215653
#> 100 16.680239  8.6515429 24.708936
augment(spmod, newdata = sulfate_preds, interval = "prediction")
#> Simple feature collection with 100 features and 3 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -2283774 ymin: 582930.5 xmax: 1985906 ymax: 3037173
#> Projected CRS: NAD83 / Conus Albers
#> # A tibble: 100 × 4
#>    .fitted .lower .upper            geometry
#>  *   <dbl>  <dbl>  <dbl>         <POINT [m]>
#>  1    1.62  -6.45   9.69  (-1771413 1752976)
#>  2   24.4   16.9   31.9    (1018112 1867127)
#>  3    8.95   1.02  16.9  (-291256.8 1553212)
#>  4   16.4    8.63  24.3    (1274293 1267835)
#>  5    4.95  -2.78  12.7  (-547437.6 1638825)
#>  6   26.8   19.2   34.3    (1445080 1981278)
#>  7    2.87  -5.07  10.8   (-1629090 3037173)
#>  8   14.3    6.75  21.8    (1302757 1039534)
#>  9    1.53  -6.34   9.40  (-1429838 2523494)
#> 10   14.3    6.62  22.0    (1131970 1096609)
#> # ℹ 90 more rows
# \donttest{
sulfate$var <- rnorm(NROW(sulfate)) # add noise variable
sulfate_preds$var <- rnorm(NROW(sulfate_preds)) # add noise variable
sprfmod <- splmRF(sulfate ~ var, data = sulfate, spcov_type = "exponential")
predict(sprfmod, sulfate_preds)
#>          1          2          3          4          5          6          7 
#>  1.7823353 25.8810706  5.2787453 15.0268032 -0.7117014 29.6042425 -3.5421663 
#>          8          9         10         11         12         13         14 
#>  7.9530878  1.9733610 15.0594887 -2.4021564 25.0060505  7.0021687 14.4306906 
#>         15         16         17         18         19         20         21 
#> 37.0124456 18.1722202 20.9270048 12.5263451  3.9712374 13.9661026  6.6881290 
#>         22         23         24         25         26         27         28 
#>  0.1363860 -1.1043961 -4.5710559 -4.1057351  6.2260524 34.5817338  5.6249834 
#>         29         30         31         32         33         34         35 
#>  8.6803371  3.6954259  5.7731356  4.3402871  6.6875437  9.2895885 -5.1765572 
#>         36         37         38         39         40         41         42 
#> -0.1203448 24.1694369  6.0953712 11.0283148 13.0207042  9.1891926 24.5568042 
#>         43         44         45         46         47         48         49 
#> 13.2395306 17.5461106  2.7606002  0.4446351 -2.2207539 16.3114009 14.8712292 
#>         50         51         52         53         54         55         56 
#>  0.7417909 32.3351794 17.3266344 -7.0966206 16.6417364 -2.6892151  9.7718245 
#>         57         58         59         60         61         62         63 
#> 31.0669334 -1.2720197 23.3676491  7.3759085 14.8306074 17.7233703  5.0632900 
#>         64         65         66         67         68         69         70 
#> 11.5391305 33.2982976 -1.4179985  4.3821541  3.2358158 -2.9603106  6.1302282 
#>         71         72         73         74         75         76         77 
#> -1.2867297 19.9780121 19.1702489  1.3991735 -6.8842384 -2.1418508 17.2656861 
#>         78         79         80         81         82         83         84 
#>  5.3366869  9.4057646 16.0327656 13.8969452  4.3808326  0.7080030 -1.2758225 
#>         85         86         87         88         89         90         91 
#>  2.6364404 15.6945671  5.0402504  1.2073791 -4.0285902 14.4621739  7.5556811 
#>         92         93         94         95         96         97         98 
#>  6.6666080 11.5867487 32.6929507 17.4991648 17.6144458 23.4744117 19.0965946 
#>         99        100 
#>  9.3784015 10.0789220 
# }
# \donttest{
spgmod <- spglm(presence ~ elev * strat,
  family = "binomial",
  data = moose,
  spcov_type = "exponential"
)
predict(spgmod, moose_preds)
#>            1            2            3            4            5            6 
#>  0.090323080 -0.552960093 -2.263554802 -1.098562352  1.427164687 -3.017967563 
#>            7            8            9           10           11           12 
#> -3.378343360 -2.989825063 -1.033620274 -1.441968112 -0.002314762  1.959397916 
#>           13           14           15           16           17           18 
#> -0.308085881 -1.057872804 -0.557799825 -1.989177567 -1.249950216 -1.661631795 
#>           19           20           21           22           23           24 
#> -2.000709550 -1.456625541 -0.582727163 -1.687239087 -0.977090590 -0.642088369 
#>           25           26           27           28           29           30 
#> -0.839495518 -1.395255140  1.999524998 -3.397978145  0.189003651 -1.201831878 
#>           31           32           33           34           35           36 
#>  0.536783958 -2.138634396 -0.644580166 -1.361692092 -0.144114708 -1.467851126 
#>           37           38           39           40           41           42 
#> -0.346800922 -2.317198801 -1.280924322 -3.442672662  0.302866472 -3.463598244 
#>           43           44           45           46           47           48 
#> -1.801140509 -0.371938944 -3.343901550 -1.046988030 -1.439301045 -2.803217332 
#>           49           50           51           52           53           54 
#> -1.220321946 -1.303624872 -1.730942375 -1.097135426  1.479748809 -2.826025730 
#>           55           56           57           58           59           60 
#> -1.047065327 -1.115370554 -3.047487968 -1.316754680 -4.100116412 -0.550835841 
#>           61           62           63           64           65           66 
#> -1.200178935 -1.578204264 -0.754737616  0.503179666 -1.517542106 -2.955712683 
#>           67           68           69           70           71           72 
#> -1.634262908  0.835560993 -2.691593834 -1.412878667 -2.705366453 -1.755138400 
#>           73           74           75           76           77           78 
#> -0.578758438 -1.268122668 -3.250381458 -1.845400838 -2.912304526 -1.815351320 
#>           79           80           81           82           83           84 
#> -0.848378787  0.350555212 -2.216871794 -0.367789223 -3.035114500 -2.634776081 
#>           85           86           87           88           89           90 
#> -1.330907762 -0.725748040 -2.756902792 -3.111945678 -1.519457507 -4.202830087 
#>           91           92           93           94           95           96 
#> -1.689082635 -1.750628979 -0.218240096 -0.082030450 -0.358868745  0.885185571 
#>           97           98           99          100 
#>  0.493301699 -1.325530727 -0.845472209 -0.128197938 
predict(spgmod, moose_preds, interval = "prediction")
#>              fit        lwr         upr
#> 1    0.090323080 -2.2400274  2.42067358
#> 2   -0.552960093 -3.5760383  2.47011811
#> 3   -2.263554802 -5.1065692  0.57945963
#> 4   -1.098562352 -3.5733195  1.37619476
#> 5    1.427164687 -0.9476128  3.80194222
#> 6   -3.017967563 -5.9707642 -0.06517093
#> 7   -3.378343360 -6.2559399 -0.50074683
#> 8   -2.989825063 -5.7599085 -0.21974159
#> 9   -1.033620274 -4.2836130  2.21637245
#> 10  -1.441968112 -3.8740326  0.99009638
#> 11  -0.002314762 -2.3529778  2.34834832
#> 12   1.959397916 -0.9340603  4.85285614
#> 13  -0.308085881 -2.7074201  2.09124835
#> 14  -1.057872804 -3.4866078  1.37086219
#> 15  -0.557799825 -3.2716667  2.15606706
#> 16  -1.989177567 -4.2420743  0.26371914
#> 17  -1.249950216 -3.5879087  1.08800825
#> 18  -1.661631795 -5.2044339  1.88117035
#> 19  -2.000709550 -4.6186159  0.61719683
#> 20  -1.456625541 -4.1487612  1.23551016
#> 21  -0.582727163 -3.6355255  2.47007114
#> 22  -1.687239087 -4.0265541  0.65207589
#> 23  -0.977090590 -3.4191367  1.46495551
#> 24  -0.642088369 -3.1671354  1.88295863
#> 25  -0.839495518 -3.8187147  2.13972370
#> 26  -1.395255140 -4.5630959  1.77258563
#> 27   1.999524998 -0.3754789  4.37452891
#> 28  -3.397978145 -5.9641295 -0.83182675
#> 29   0.189003651 -2.6097048  2.98771210
#> 30  -1.201831878 -3.6485226  1.24485884
#> 31   0.536783958 -1.6984996  2.77206755
#> 32  -2.138634396 -5.0759938  0.79872501
#> 33  -0.644580166 -3.1010166  1.81185623
#> 34  -1.361692092 -3.9651577  1.24177352
#> 35  -0.144114708 -3.8676558  3.57942638
#> 36  -1.467851126 -3.9096974  0.97399518
#> 37  -0.346800922 -3.4332909  2.73968910
#> 38  -2.317198801 -4.7387214  0.10432385
#> 39  -1.280924322 -3.8644562  1.30260759
#> 40  -3.442672662 -6.3858881 -0.49945726
#> 41   0.302866472 -2.0572153  2.66294827
#> 42  -3.463598244 -6.0498949 -0.87730163
#> 43  -1.801140509 -4.9732758  1.37099479
#> 44  -0.371938944 -2.9451671  2.20128922
#> 45  -3.343901550 -6.2570423 -0.43076077
#> 46  -1.046988030 -3.4357470  1.34177092
#> 47  -1.439301045 -4.2317831  1.35318106
#> 48  -2.803217332 -6.6085221  1.00208745
#> 49  -1.220321946 -3.7772602  1.33661630
#> 50  -1.303624872 -4.2046029  1.59735319
#> 51  -1.730942375 -5.3921999  1.93031515
#> 52  -1.097135426 -3.5444835  1.35021267
#> 53   1.479748809 -1.8508224  4.81031999
#> 54  -2.826025730 -6.6539711  1.00191967
#> 55  -1.047065327 -3.3337684  1.23963779
#> 56  -1.115370554 -4.2947355  2.06399440
#> 57  -3.047487968 -6.1882474  0.09327150
#> 58  -1.316754680 -3.7958907  1.16238132
#> 59  -4.100116412 -7.9000530 -0.30017978
#> 60  -0.550835841 -3.0874092  1.98573751
#> 61  -1.200178935 -3.5405599  1.14020205
#> 62  -1.578204264 -5.8738878  2.71747932
#> 63  -0.754737616 -4.1598929  2.65041765
#> 64   0.503179666 -1.7675778  2.77393714
#> 65  -1.517542106 -4.2274054  1.19232123
#> 66  -2.955712683 -5.4929625 -0.41846284
#> 67  -1.634262908 -5.3679767  2.09945088
#> 68   0.835560993 -1.5834918  3.25461383
#> 69  -2.691593834 -5.2679320 -0.11525568
#> 70  -1.412878667 -3.9154079  1.08965060
#> 71  -2.705366453 -6.4070849  0.99635197
#> 72  -1.755138400 -4.3523935  0.84211673
#> 73  -0.578758438 -3.2234584  2.06594148
#> 74  -1.268122668 -4.7386422  2.20239690
#> 75  -3.250381458 -6.2829945 -0.21776845
#> 76  -1.845400838 -4.6865302  0.99572848
#> 77  -2.912304526 -5.7407648 -0.08384426
#> 78  -1.815351320 -4.6533709  1.02266823
#> 79  -0.848378787 -3.8795487  2.18279115
#> 80   0.350555212 -2.3321715  3.03328194
#> 81  -2.216871794 -5.0113648  0.57762120
#> 82  -0.367789223 -2.8336279  2.09804946
#> 83  -3.035114500 -6.2068891  0.13666011
#> 84  -2.634776081 -5.3117475  0.04219537
#> 85  -1.330907762 -3.9353724  1.27355690
#> 86  -0.725748040 -3.5014843  2.04998821
#> 87  -2.756902792 -6.2453885  0.73158293
#> 88  -3.111945678 -5.7584991 -0.46539230
#> 89  -1.519457507 -4.2475176  1.20860262
#> 90  -4.202830087 -8.3823718 -0.02328838
#> 91  -1.689082635 -5.6344878  2.25632255
#> 92  -1.750628979 -4.5912814  1.09002340
#> 93  -0.218240096 -2.8035116  2.36703137
#> 94  -0.082030450 -4.0467753  3.88271442
#> 95  -0.358868745 -3.4863205  2.76858300
#> 96   0.885185571 -1.6252513  3.39562242
#> 97   0.493301699 -2.1250673  3.11167071
#> 98  -1.325530727 -3.9859122  1.33485078
#> 99  -0.845472209 -3.1449524  1.45400797
#> 100 -0.128197938 -2.6003311  2.34393520
augment(spgmod, newdata = moose_preds, interval = "prediction")
#> Simple feature collection with 100 features and 5 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: 269386.2 ymin: 1418453 xmax: 419976.2 ymax: 1541763
#> Projected CRS: NAD83 / Alaska Albers
#> # A tibble: 100 × 6
#>     elev strat .fitted .lower  .upper           geometry
#>  * <dbl> <chr>   <dbl>  <dbl>   <dbl>        <POINT [m]>
#>  1  143. L      0.0903 -2.24   2.42   (401239.6 1436192)
#>  2  324. L     -0.553  -3.58   2.47   (352640.6 1490695)
#>  3  158. L     -2.26   -5.11   0.579  (360954.9 1491590)
#>  4  221. M     -1.10   -3.57   1.38   (291839.8 1466091)
#>  5  209. M      1.43   -0.948  3.80   (310991.9 1441630)
#>  6  218. L     -3.02   -5.97  -0.0652 (304473.8 1512103)
#>  7  127. L     -3.38   -6.26  -0.501  (339011.1 1459318)
#>  8  122. L     -2.99   -5.76  -0.220  (342827.3 1463452)
#>  9  191  L     -1.03   -4.28   2.22   (284453.8 1502837)
#> 10  105. L     -1.44   -3.87   0.990  (391343.9 1483791)
#> # ℹ 90 more rows
# }
decorr <- decorrelate(log_cond ~ temp, data = lake, spcov_type = "exponential")
predict(decorr, newdata = lake_preds)
#>        1        2        3        4        5        6        7        8 
#> 6.789344 6.943967 6.491117 5.251468 5.620144 4.782357 6.775321 4.566189 
#>        9       10 
#> 6.814480 4.304283