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 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 (same format as lib), but specifying the sections of the time series to forecast. the distance measure to use. see 'Details' the prediction method to use. see 'Details' the prediction horizon (how far ahead to forecast) 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.) either a vector with the columns to use (indices or names), or a list of such columns the index (or name) of the column to forecast specify whether to output just the forecast statistics or the raw predictions for each run indicates whether the first column of the given block is a time column (and therefore excluded when indexing) excludes vectors from the search space of nearest neighbors if their *time index* is within exclusion_radius (NULL turns this option off) excludes vectors from the search space of nearest neighbors if their *distance* is farther away than epsilon (NULL turns this option off) the nonlinear tuning parameter (theta is only relevant if method == "s-map") prevents warning messages from being printed to the R console 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:

 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_rho same as rho , but for the constant predictor const_mae same as mae , but for the constant predictor const_rmse same as rmse , but for the constant predictor const_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 )

## 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