predict.spmodel | R Documentation |
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"),
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"),
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"),
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'
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 '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,
...
)
object |
A fitted model object. |
newdata |
A data frame or |
se.fit |
A logical indicating if standard errors are returned.
The default is |
scale |
A numeric constant by which to scale the regular standard errors and intervals.
Similar to but slightly different than |
df |
Degrees of freedom to use for confidence or prediction intervals
(ignored if |
interval |
Type of interval calculation. The default is |
level |
Tolerance/confidence level. The default is |
type |
The prediction type, either on the response scale, link scale (only for
|
local |
A optional logical or list controlling the big data approximation. If omitted,
When |
terms |
If |
na.action |
Missing ( |
... |
Other arguments. Only used for models fit using |
dispersion |
The dispersion of assumed when computing the prediction standard errors
for |
var_correct |
A logical indicating whether to return the corrected prediction
variances when predicting via models fit using |
newdata_size |
The |
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.
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.
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.
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)
spgmod <- spglm(presence ~ elev * strat,
family = "binomial",
data = moose,
spcov_type = "exponential"
)
predict(spgmod, moose_preds)
predict(spgmod, moose_preds, interval = "prediction")
augment(spgmod, newdata = moose_preds, interval = "prediction")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.