| predict.spmodel {spmodel} | R Documentation |
Model predictions (Kriging)
Description
Predicted values and intervals based on a fitted model object.
Usage
## S3 method for class 'splm'
predict(
object,
newdata,
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
level = 0.95,
local,
...
)
## S3 method for class 'spautor'
predict(
object,
newdata,
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
level = 0.95,
local,
...
)
## S3 method for class 'splm_list'
predict(
object,
newdata,
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
level = 0.95,
local,
...
)
## S3 method for class 'spautor_list'
predict(
object,
newdata,
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
level = 0.95,
local,
...
)
## 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"),
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
newdata_size,
level = 0.95,
local,
var_correct = TRUE,
...
)
## S3 method for class 'spgautor'
predict(
object,
newdata,
type = c("link", "response"),
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
newdata_size,
level = 0.95,
local,
var_correct = TRUE,
...
)
## S3 method for class 'spglm_list'
predict(
object,
newdata,
type = c("link", "response"),
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
newdata_size,
level = 0.95,
local,
var_correct = TRUE,
...
)
## S3 method for class 'spgautor_list'
predict(
object,
newdata,
type = c("link", "response"),
se.fit = FALSE,
interval = c("none", "confidence", "prediction"),
newdata_size,
level = 0.95,
local,
var_correct = TRUE,
...
)
Arguments
object |
A fitted model object. |
newdata |
A data frame or |
se.fit |
A logical indicating if standard errors are returned.
The default is |
interval |
Type of interval calculation. The default is |
level |
Tolerance/confidence level. The default is |
local |
A optional logical or list controlling the big data approximation. If omitted,
When |
... |
Other arguments. Only used for models fit using |
type |
The scale ( |
newdata_size |
The |
var_correct |
A logical indicating whether to return the corrected prediction
variances when predicting via models fit using |
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. Fox et al. (2020)
call this approach random forest regression Kriging. For splmRF_list
or spautorRF objects,
predictions are returned for each list element.
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.
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", xcoord = x, ycoord = y
)
predict(spmod, sulfate_preds)
predict(spmod, sulfate_preds, interval = "prediction")
augment(spmod, newdata = sulfate_preds, interval = "prediction")
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)