block_lnlp: Perform generalized forecasting using simplex projection or...

View source: R/LegacyInterface.R

block_lnlpR Documentation

Perform generalized forecasting using simplex projection or s-map

Description

block_lnlp uses multiple time series given as input to generate an attractor reconstruction, and then applies the simplex projection or s-map algorithm to make forecasts. This method generalizes the simplex and s_map routines, and allows for "mixed" embeddings, where multiple time series can be used as different dimensions of an attractor reconstruction.

Usage

block_lnlp(block, lib = NULL, pred = NULL, norm = 2, method = c("simplex",
  "s-map"), tp = 1, num_neighbors = switch(match.arg(method), 
  simplex = "e+1", `s-map` = 0), columns = NULL, target_column = 1, 
  stats_only = TRUE, first_column_time = FALSE, exclusion_radius = NULL, 
  epsilon = NULL, theta = NULL, silent = TRUE, save_smap_coefficients = FALSE)

Arguments

block

either a vector to be used as the time series, or a data.frame or matrix where each column is a time series

lib

a 2-column matrix, data.frame, 2-element vector or string of row indice pairs, where each pair specifies the first and last *rows* of the time series to create the library. If not specified, all available rows are used

pred

(same format as lib), but specifying the sections of the time series to forecast. If not specified, set equal to lib

norm

the distance measure to use. see 'Details'

method

the prediction method to use. see 'Details'

tp

the prediction horizon (how far ahead to forecast)

num_neighbors

the number of nearest neighbors to use. Note that the default value will change depending on the method selected. (any of "e+1", "E+1", "e + 1", "E + 1" will set this parameter to E+1 for each run.)

columns

either a vector with the columns to use (indices or names), or a list of such columns

target_column

the index (or name) of the column to forecast

stats_only

specify whether to output just the forecast statistics or to include the raw predictions for each run

first_column_time

indicates whether the first column of the given block is a time column (and therefore excluded when building the library)

exclusion_radius

excludes vectors from the search space of nearest neighbors if their *time index* is within exclusion_radius (NULL turns this option off)

epsilon

Not implemented

theta

the nonlinear tuning parameter (theta is only relevant if method == "s-map")

silent

prevents warning messages from being printed to the R console

save_smap_coefficients

specifies whether to include the s_map coefficients with the output

Details

The default parameters are set so that passing a vector as the only argument will use that vector to predict itself one time step ahead. If a matrix or data.frame is given as the only argument, the first column will be predicted (one time step ahead), using the remaining columns as the embedding. If the first column is not a time vector, 1:NROW will be used as time values.

norm = 2 (only option currently available) uses the "L2 norm", Euclidean distance:

distance(a,b) := \sqrt{\sum_i{(a_i - b_i)^2}}

method "simplex" (default) uses the simplex projection forecasting algorithm

method "s-map" uses the s-map forecasting algorithm

Value

A data.frame with components for the parameters and forecast statistics:

cols embedding
tp prediction horizon
nn number of neighbors
num_pred number of predictions
rho correlation coefficient between observations and predictions
mae mean absolute error
rmse root mean square error
perc percent correct sign
p_val p-value that rho is significantly greater than 0 using Fisher's z-transformation
const_pred_rho same as rho, but for the constant predictor
const_pred_mae same as mae, but for the constant predictor
const_pred_rmse same as rmse, but for the constant predictor
const_pred_perc same as perc, but for the constant predictor
const_p_val same as p_val, but for the constant predictor
model_output data.frame with columns for the time index, observations, predictions, and estimated prediction variance (if stats_only == FALSE)

If "s-map" is the method, then the same, but with additional columns:

theta the nonlinear tuning parameter
smap_coefficients data.frame with columns for the s-map coefficients (if save_smap_coefficients == TRUE)
smap_coefficient_covariances list of covariance matrices for the s-map coefficients (if save_smap_coefficients == TRUE)

Examples

block <- block_3sp
block_lnlp(block[,2:4])

block <- block_3sp
block_lnlp(block[,1:4], first_column_time = TRUE)

block <- block_3sp
block_lnlp(block, target_column = "x_t", columns = c("y_t", "z_t"), first_column_time = TRUE)

block <- block_3sp
x_t_pred = block_lnlp(block, columns = c("x_t", "y_t"), first_column_time = TRUE,
stats_only = FALSE)

block <- block_3sp
x_t_pred = block_lnlp(block, method = "s-map", theta = 3, columns =
c("x_t", "y_t"), first_column_time = TRUE, stats_only = FALSE, save_smap_coefficients = TRUE)

rEDM documentation built on July 9, 2023, 5:11 p.m.