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.

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)

Value

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

colsembedding
tpprediction horizon
nnnumber of neighbors
num_prednumber of predictions
rhocorrelation coefficient between observations and predictions
maemean absolute error
rmseroot mean square error
percpercent correct sign
p_valp-value that rho is significantly greater than 0 using Fisher's z-transformation
const_pred_rhosame as rho, but for the constant predictor
const_pred_maesame as mae, but for the constant predictor
const_pred_rmsesame as rmse, but for the constant predictor
const_pred_percsame as perc, but for the constant predictor
const_p_valsame as p_val, but for the constant predictor
model_outputdata.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:

thetathe nonlinear tuning parameter
smap_coefficientsdata.frame with columns for the s-map coefficients (if save_smap_coefficients == TRUE)
smap_coefficient_covarianceslist of covariance matrices for the s-map coefficients (if save_smap_coefficients == TRUE)

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) := \sqrt{\sum_i{(a_i - b_i)^2}} $$ norm = 1 uses the "L1 norm", Manhattan distance: $$distance(a,b) := \sum_i{|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) := \sum_i{(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

Examples

data("two_species_model") block <- two_species_model[1:200,] block_lnlp(block, columns = c("x", "y"), first_column_time = TRUE)
#> Warning: Found overlap between lib and pred. Enabling cross-validation with exclusion radius = 0.
#> embedding tp nn num_pred rho mae rmse perc p_val #> 1 1, 2 1 3 199 0.992695 0.009281957 0.02326201 1 0 #> const_pred_num_pred const_pred_rho const_pred_mae const_pred_rmse #> 1 199 -0.9503299 0.3763936 0.3805352 #> const_pred_perc const_p_val #> 1 1 1