block_lnlp {rEDM} | R Documentation |
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_type = c("L2 norm", "L1 norm", "P norm"), P = 0.5, 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, short_output = FALSE)
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 specifes 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_type |
the distance function to use. see 'Details' |
P |
the exponent for the P norm |
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 the full output as if stats_only were set to FALSE) |
short_output |
specifies whether to return a truncated output data.frame whose rows only include the predictions made and not the whole input block |
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_type "L2 norm" (default) uses the typical Euclidean distance:
distance(a, b) := √(∑(a_i - b_i)^2)
norm_type "L1 norm" uses the Manhattan distance:
distance(a, b) := ∑|a_i - b_i|
norm type "P norm" uses the P norm, generalizing the L1 and L2 norm to use $p$ as the exponent:
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
If stats_only, then 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 |
Otherwise, a list where the number of elements is equal to the number of runs (unique parameter combinations). Each element is a list with the following components:
params | data.frame of parameters (embedding, tp, nn) |
model_output | data.frame with columns for the time index, observations, and predictions |
stats | data.frame of forecast statistics |
data("two_species_model") block <- two_species_model[1:200,] block_lnlp(block, columns = c("x", "y"), first_column_time = TRUE)