simplex
uses time delay embedding on a single time
series to generate an attractor reconstruction, and then applies the
simplex projection algorithm to make forecasts.
s_map
is similar to simplex
, but uses the S-map
algorithm to make forecasts.
simplex(time_series, lib = c(1, NROW(time_series)), pred = lib,
norm = 2, E = 1:10, tau = 1, tp = 1, num_neighbors = "e+1",
stats_only = TRUE, exclusion_radius = NULL, epsilon = NULL,
silent = FALSE)s_map(time_series, lib = c(1, NROW(time_series)), pred = lib,
norm = 2, E = 1, tau = 1, tp = 1, num_neighbors = 0,
theta = c(0, 1e-04, 3e-04, 0.001, 0.003, 0.01, 0.03, 0.1, 0.3, 0.5,
0.75, 1, 1.5, 2, 3, 4, 6, 8), stats_only = TRUE,
exclusion_radius = NULL, epsilon = NULL, silent = FALSE,
save_smap_coefficients = FALSE)
either a vector to be used as the time series, or a data.frame or matrix with at least 2 columns (in which case the first column will be used as the time index, and the second column as the 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 embedding dimensions to use for time delay embedding
the lag to use for time delay embedding
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.)
specify whether to output just the forecast statistics or the raw predictions for each run
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)
prevents warning messages from being printed to the R console
the nonlinear tuning parameter (theta is only relevant if method == "s-map")
specifies whether to include the s_map coefficients with the output (and forces stats_only = FALSE, as well)
For simplex
, a data.frame with components for the
parameters and forecast statistics:
E |
embedding dimension |
tau |
time lag |
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 ) |
For s_map
, the same as for simplex
, 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 ) |
simplex
is typically applied, and the embedding dimension
varied, to find an optimal embedding dimension for the data. Thus, the
default parameters are set so that passing a time series as the only
argument will run over E = 1:10 (embedding dimension), using leave-one-out
cross-validation over the whole time series, and returning just the forecast
statistics.
s_map
is typically applied, with fixed embedding dimension, and theta
varied, to test for nonlinear dynamics in the data. Thus, the default
parameters are set so that passing a time series as the only argument will
run over a default list of thetas (0, 0.0001, 0.0003, 0.001, 0.003, 0.01,
0.03, 0.1, 0.3, 0.5, 0.75, 1.0, 1.5, 2, 3, 4, 6, and 8), using E = 1,
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}
$$
# NOT RUN {
data("two_species_model")
ts <- two_species_model$x[1:200]
simplex(ts, lib = c(1, 100), pred = c(101, 200))
data("two_species_model")
ts <- two_species_model$x[1:200]
simplex(ts, stats_only = FALSE)
data("two_species_model")
ts <- two_species_model$x[1:200]
s_map(ts, E = 2)
data("two_species_model")
ts <- two_species_model$x[1:200]
s_map(ts, E = 2, theta = 1, save_smap_coefficients = TRUE)
# }
Run the code above in your browser using DataLab