Learn R Programming

dbnR (version 0.7.1)

forecast_ts: Performs forecasting with the GDBN over a data set

Description

Given a dbn.fit object, the size of the net and a folded data.set, performs a forecast over the initial evidence taken from the data set.

Usage

forecast_ts(
  dt,
  fit,
  size,
  obj_vars,
  ini = 1,
  len = dim(dt)[1] - ini,
  rep = 1,
  num_p = 50,
  print_res = TRUE,
  plot_res = TRUE,
  mode = "exact",
  prov_ev = NULL
)

Arguments

dt

data.table object with the TS data

fit

dbn.fit object

size

number of time slices of the net

obj_vars

variables to be predicted

ini

starting point in the data set to forecast.

len

length of the forecast

rep

number of times to repeat the approximate forecasting

num_p

number of particles in the approximate forecasting

print_res

if TRUE prints the mae and sd metrics of the forecast

plot_res

if TRUE plots the results of the forecast

mode

"exact" for exact inference, "approx" for approximate

prov_ev

variables to be provided as evidence in each forecasting step

Value

the results of the forecast

Examples

Run this code
# NOT RUN {
size = 3
data(motor)
dt_train <- motor[200:2500]
dt_val <- motor[2501:3000]
obj <- c("pm_t_0")
net <- learn_dbn_struc(dt_train, size)
f_dt_train <- fold_dt(dt_train, size)
f_dt_val <- fold_dt(dt_val, size)
fit <- fit_dbn_params(net, f_dt_train, method = "mle")
res <- suppressWarnings(forecast_ts(f_dt_val, fit, size, 
        obj_vars = obj, print_res = FALSE, plot_res = FALSE))
# }

Run the code above in your browser using DataLab