krige.mcgf_rs {mcgf}R Documentation

Obtain kriging forecasts for an mcgf_rs object.

Description

Obtain kriging forecasts for an mcgf_rs object.

Usage

## S3 method for class 'mcgf_rs'
krige(
  x,
  newdata = NULL,
  newlabel = NULL,
  soft = FALSE,
  prob,
  model = c("all", "base", "empirical"),
  interval = FALSE,
  level = 0.95,
  ...
)

Arguments

x

An mcgf_rs object.

newdata

A data.frame with the same column names as x. If newdata is missing the forecasts at the original data points are returned.

newlabel

A vector of new regime labels.

soft

Logical; if true, soft forecasts (and bounds) are produced.

prob

Matrix with simplex rows. Number of columns must be the same as unique labels in x.

model

Which model to use. One of all, base, or empirical.

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 interval = TRUE

...

Additional arguments. Give lag and horizon if they are not defined in x for the empirical model.

Details

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 soft = TRUE, prob will be used to compute the soft forecasts (weighted forecasts). The number of columns must match the number of unique levels in x. The column order must be the same as the order of regimes as in levels(attr(x, "label", exact = TRUE)). If not all regimes are seen in newlabel, then only relevant columns in prob are used.

When interval = TRUE, confidence interval for each forecasts and each horizon is given. Note that it does not compute confidence regions.

Value

A list of kriging forecasts (and prediction intervals).

See Also

Other functions on fitting an mcgf_rs: add_base.mcgf_rs(), add_lagr.mcgf_rs(), fit_base.mcgf_rs(), fit_lagr.mcgf_rs(), krige_new.mcgf_rs()

Examples

data(sim2)
sim2_mcgf <- mcgf_rs(sim2$data, dists = sim2$dists, label = sim2$label)
sim2_mcgf <- add_acfs(sim2_mcgf, lag_max = 5)
sim2_mcgf <- add_ccfs(sim2_mcgf, lag_max = 5)

# Fit a regime-switching separable model
fit_sep <- fit_base(
    sim2_mcgf,
    lag_ls = 5,
    model_ls = "sep",
    par_init_ls = list(list(
        c = 0.00005,
        gamma = 0.5,
        a = 0.5,
        alpha = 0.5
    )),
    par_fixed_ls = list(c(nugget = 0))
)

# Store the fitted separable models to 'sim2_mcgf'
sim2_mcgf <- add_base(sim2_mcgf, fit_base_ls = fit_sep)

# Calculate the simple kriging predictions and intervals
sim2_krige <- krige(sim2_mcgf, model = "base", interval = TRUE)

# Calculate RMSE for each location
rmse <- sqrt(colMeans((sim2_mcgf - sim2_krige$fit)^2, na.rm = TRUE))
rmse

# Calculate MAE for each location
mae <- colMeans(abs(sim2_mcgf - sim2_krige$fit), na.rm = TRUE)
mae

# Calculate POPI for each location
popi <- colMeans(
    sim2_mcgf < sim2_krige$lower | sim2_mcgf > sim2_krige$upper,
    na.rm = TRUE
)
popi

[Package mcgf version 1.1.1 Index]