| krige.mcgf | R Documentation |
mcgf object.Obtain kriging forecasts for an mcgf object.
## S3 method for class 'mcgf'
krige(
x,
newdata = NULL,
model = c("all", "base", "empirical"),
interval = FALSE,
level = 0.95,
...
)
x |
An |
newdata |
A data.frame with the same column names as |
model |
Which model to use. One of |
interval |
Logical; if TRUE, prediction intervals are computed. |
level |
A numeric scalar between 0 and 1 giving the confidence level for
the intervals (if any) to be calculated. Used when |
... |
Additional arguments. Give |
It produces simple kriging forecasts for a zero-mean mcgf. It supports
kriging for the empirical model, the base model, and the all model
which is the general stationary model with the base and Lagrangian model
from x.
When interval = TRUE, confidence interval for each forecasts and each
horizon is given. Note that it does not compute confidence regions.
A list of kriging forecasts (and prediction intervals).
Other functions on fitting an mcgf:
add_base.mcgf(),
add_lagr.mcgf(),
fit_base.mcgf(),
fit_lagr.mcgf(),
krige_new.mcgf()
data(sim1)
sim1_mcgf <- mcgf(sim1$data, dists = sim1$dists)
sim1_mcgf <- add_acfs(sim1_mcgf, lag_max = 5)
sim1_mcgf <- add_ccfs(sim1_mcgf, lag_max = 5)
# Fit a separable model and store it to 'sim1_mcgf'
fit_sep <- fit_base(
sim1_mcgf,
model = "sep",
lag = 5,
par_init = c(
c = 0.001,
gamma = 0.5,
a = 0.3,
alpha = 0.5
),
par_fixed = c(nugget = 0)
)
sim1_mcgf <- add_base(sim1_mcgf, fit_base = fit_sep)
# Fit a Lagrangian model
fit_lagr <- fit_lagr(
sim1_mcgf,
model = "lagr_tri",
par_init = c(v1 = 300, v2 = 300, lambda = 0.15),
par_fixed = c(k = 2)
)
# Store the fitted Lagrangian model to 'sim1_mcgf'
sim1_mcgf <- add_lagr(sim1_mcgf, fit_lagr = fit_lagr)
# Calculate the simple kriging predictions and intervals
sim1_krige <- krige(sim1_mcgf, interval = TRUE)
# Calculate RMSE for each location
rmse <- sqrt(colMeans((sim1_mcgf - sim1_krige$fit)^2, na.rm = TRUE))
rmse
# Calculate MAE for each location
mae <- colMeans(abs(sim1_mcgf - sim1_krige$fit), na.rm = TRUE)
mae
# Calculate POPI for each location
popi <- colMeans(
sim1_mcgf < sim1_krige$lower | sim1_mcgf > sim1_krige$upper,
na.rm = TRUE
)
popi
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.