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

Description Usage Arguments Details Value Examples

View source: R/block_lnlp_interface.R

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

1
2
3
4
5
6
block_lnlp(block, lib = c(1, NROW(block)), pred = lib, 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 = FALSE, 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 (or 2-element vector) where each row specifies the first and last *rows* of the time series to use for attractor reconstruction

pred

(same format as lib), but specifying the sections of the time series to forecast.

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 peg this parameter to E+1 for each run, any value < 1 will use all possible neighbors.)

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 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 indexing)

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

excludes vectors from the search space of nearest neighbors if their *distance* is farther away than epsilon (NULL turns this option off)

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 (and forces stats_only = FALSE, as well)

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. Rownames will be converted to numeric if possible to be used as the time index, otherwise 1:NROW will be used instead. The default lib and pred are for leave-one-out cross-validation over the whole time series, and returning just the forecast statistics.

norm = 2 (default) uses the "L2 norm", Euclidean distance:

distance(a, b) := √(∑(a_i - b_i)^2)

norm = 1 uses the "L1 norm", Manhattan distance:

distance(a, b) := ∑|a_i - b_i|

Other values generalize the L1 and L2 norm to use the given argument as the exponent, P, as:

distance(a, b) := (∑(a_i - b_i)^P)^(1/P)

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

1
2
3
data("two_species_model")
block <- two_species_model[1:200,]
block_lnlp(block, columns = c("x", "y"), first_column_time = TRUE)

ha0ye/rEDM documentation built on March 30, 2021, 11:21 p.m.