| spCF-predict | R Documentation |
Predicts at new sites from a cf_lm or cf_glm fit.
The fitted object keeps, for every selected scale, the local estimates at
the knots of that scale; prediction only spreads these to the new sites, so
its cost does not depend on the size of the training data, and the training
data are not needed. The result is identical to fitting the model with the
same sites given as coords0 (and x0, offset0).
## S3 method for class 'cf_lm'
predict(object, x0 = NULL, coords0 = NULL, probs = NULL, se_type = NULL, ...)
## S3 method for class 'cf_glm'
predict(
object,
x0 = NULL,
coords0 = NULL,
offset0 = NULL,
probs = NULL,
se_type = NULL,
...
)
## S3 method for class 'cf_dglm'
predict(
object,
x0 = NULL,
coords0 = NULL,
time0 = NULL,
offset0 = NULL,
probs = NULL,
se_type = NULL,
...
)
object |
A fitted model from |
x0 |
Covariates at the prediction sites, with the same columns as
|
coords0 |
Coordinates of the prediction sites (matrix or data.frame with
two columns). If |
probs |
Probability levels of the predictive quantiles. Defaults to the
levels of |
se_type |
|
... |
Not used. |
offset0 |
Offset at the prediction sites ( |
time0 |
Time points of the prediction sites ( |
With an additional learner (add_learn in
cf_lm_hv), the learner's model is kept in the fit and the
quantiles of the combined predictive are simulated, as in
cf_lm; they then vary slightly from call to call.
A data.frame with one row per site: the predictive mean
(pred), the predictive standard deviation (pred_sd) and the
predictive quantiles (q<level>, e.g. q0.025), on the response
scale.
set.seed(1)
n <- 300
coords <- cbind(px = runif(n), py = runif(n))
x <- data.frame(x1 = rnorm(n))
y <- 0.5 * x$x1 + sin(4 * coords[, 1]) + rnorm(n, sd = 0.3)
hv <- cf_lm_hv(y = y, x = x, coords = coords)
mod <- cf_lm(y = y, x = x, coords = coords, mod_hv = hv)
coords0 <- cbind(px = runif(5), py = runif(5))
x0 <- data.frame(x1 = rnorm(5))
predict(mod, x0 = x0, coords0 = coords0, probs = c(0.025, 0.975))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.