Learn R Programming

dbnR (version 0.7.8)

smooth_ts: Performs smoothing with the GDBN over a dataset

Description

Given a dbn.fit object, the size of the net and a folded dataset, performs a smoothing of a trajectory. Smoothing is the opposite of forecasting: given a starting point, predict backwards in time to obtain the time series that generated that point.

Usage

smooth_ts(
  dt,
  fit,
  size = NULL,
  obj_vars,
  ini = dim(dt)[1],
  len = ini - 1,
  print_res = TRUE,
  plot_res = TRUE,
  prov_ev = NULL
)

Value

a list with the original values and the results of the smoothing

Arguments

dt

data.table object with the TS data

fit

dbn.fit object

size

number of time slices of the net. Deprecated, will be removed in the future

obj_vars

variables to be predicted. Should be in the oldest time step

ini

starting point in the dataset to smooth

len

length of the smoothing

print_res

if TRUE prints the mae and sd metrics of the smoothing

plot_res

if TRUE plots the results of the smoothing

prov_ev

variables to be provided as evidence in each smoothing step. Should be in the oldest time step

Examples

Run this code
size = 3
data(motor)
dt_train <- motor[200:900]
dt_val <- motor[901:1000]
obj <- c("pm_t_2")
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-g")
res <- suppressWarnings(smooth_ts(f_dt_val, fit, 
        obj_vars = obj, len = 10, print_res = FALSE, plot_res = FALSE))

Run the code above in your browser using DataLab