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)
time_series | 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) |
---|---|
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' |
E | the embedding dimensions to use for time delay embedding |
tau | the lag to use for time delay embedding |
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.) |
stats_only | specify whether to output just the forecast statistics or the raw predictions for each run |
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) |
silent | prevents warning messages from being printed to the R console |
theta | the nonlinear tuning parameter (theta is only relevant if method == "s-map") |
save_smap_coefficients | 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}
$$
data("two_species_model") ts <- two_species_model$x[1:200] simplex(ts, lib = c(1, 100), pred = c(101, 200))#> E tau tp nn num_pred rho mae rmse perc p_val #> 1 1 1 1 2 99 0.9977065 0.008357515 0.013002536 1 1.744958e-241 #> 2 2 1 1 3 98 0.9989009 0.005136110 0.009018716 1 3.100170e-293 #> 3 3 1 1 4 97 0.9990626 0.004970217 0.008331537 1 1.637664e-302 #> 4 4 1 1 5 96 0.9971511 0.008104056 0.014523326 1 2.152115e-219 #> 5 5 1 1 6 95 0.9965447 0.009534573 0.015990520 1 1.387630e-204 #> 6 6 1 1 7 94 0.9948537 0.012735600 0.019566559 1 4.606555e-178 #> 7 7 1 1 8 93 0.9943411 0.013903466 0.020459728 1 1.264351e-170 #> 8 8 1 1 9 92 0.9928574 0.016085801 0.023026414 1 9.197431e-156 #> 9 9 1 1 10 91 0.9927218 0.016557143 0.023240397 1 5.043687e-153 #> 10 10 1 1 11 90 0.9921240 0.017697481 0.024493244 1 3.913787e-147 #> const_pred_num_pred const_pred_rho const_pred_mae const_pred_rmse #> 1 99 -0.9696726 0.3771995 0.3811690 #> 2 98 -0.9694899 0.3776359 0.3816164 #> 3 97 -0.9693895 0.3779297 0.3819369 #> 4 96 -0.9692005 0.3781315 0.3821729 #> 5 95 -0.9690482 0.3782716 0.3823513 #> 6 94 -0.9687106 0.3779132 0.3820240 #> 7 93 -0.9684948 0.3777218 0.3818742 #> 8 92 -0.9682642 0.3780649 0.3822440 #> 9 91 -0.9680677 0.3783219 0.3825359 #> 10 90 -0.9679411 0.3786576 0.3829010 #> const_pred_perc const_p_val #> 1 1 1 #> 2 1 1 #> 3 1 1 #> 4 1 1 #> 5 1 1 #> 6 1 1 #> 7 1 1 #> 8 1 1 #> 9 1 1 #> 10 1 1#> Warning: Found overlap between lib and pred. Enabling cross-validation with exclusion radius = 0.#> E tau tp nn num_pred rho mae rmse perc p_val #> 1 1 1 1 2 199 0.9935132 0.010898960 0.02190263 1 0.000000e+00 #> 2 2 1 1 3 198 0.9941356 0.006718955 0.02076716 1 0.000000e+00 #> 3 3 1 1 4 197 0.9920315 0.007295780 0.02431598 1 0.000000e+00 #> 4 4 1 1 5 196 0.9906450 0.008829094 0.02631030 1 9.682911e-304 #> 5 5 1 1 6 195 0.9962264 0.008826986 0.01670992 1 0.000000e+00 #> 6 6 1 1 7 194 0.9958433 0.011211758 0.01750450 1 0.000000e+00 #> 7 7 1 1 8 193 0.9955036 0.011909085 0.01821520 1 0.000000e+00 #> 8 8 1 1 9 192 0.9937719 0.014373767 0.02148182 1 0.000000e+00 #> 9 9 1 1 10 191 0.9934040 0.015176019 0.02210354 1 0.000000e+00 #> 10 10 1 1 11 190 0.9923382 0.016699364 0.02398609 1 0.000000e+00 #> const_pred_num_pred const_pred_rho const_pred_mae const_pred_rmse #> 1 199 -0.9503299 0.3763936 0.3805352 #> 2 198 -0.9684038 0.3765168 0.3806739 #> 3 197 -0.9688821 0.3770916 0.3811776 #> 4 196 -0.9688946 0.3774204 0.3814957 #> 5 195 -0.9690341 0.3776509 0.3817309 #> 6 194 -0.9688659 0.3775119 0.3816094 #> 7 193 -0.9687451 0.3774507 0.3815690 #> 8 192 -0.9686880 0.3776819 0.3818055 #> 9 191 -0.9686819 0.3778536 0.3819894 #> 10 190 -0.9685374 0.3778696 0.3820268 #> const_pred_perc const_p_val model_output #> 1 1 1 c(2, 3, .... #> 2 1 1 c(2, 3, .... #> 3 1 1 c(2, 3, .... #> 4 1 1 c(2, 3, .... #> 5 1 1 c(2, 3, .... #> 6 1 1 c(2, 3, .... #> 7 1 1 c(2, 3, .... #> 8 1 1 c(2, 3, .... #> 9 1 1 c(2, 3, .... #> 10 1 1 c(2, 3, ....#> Warning: Found overlap between lib and pred. Enabling cross-validation with exclusion radius = 0.#> E tau tp nn theta num_pred rho mae rmse perc #> 1 2 1 1 0 0.0000 198 0.9657371 0.039812393 0.04982476 1 #> 2 2 1 1 0 0.0001 198 0.9657415 0.039810163 0.04982157 1 #> 3 2 1 1 0 0.0003 198 0.9657504 0.039805703 0.04981520 1 #> 4 2 1 1 0 0.0010 198 0.9657817 0.039790090 0.04979291 1 #> 5 2 1 1 0 0.0030 198 0.9658708 0.039745464 0.04972923 1 #> 6 2 1 1 0 0.0100 198 0.9661814 0.039589064 0.04950655 1 #> 7 2 1 1 0 0.0300 198 0.9670588 0.039142497 0.04887196 1 #> 8 2 1 1 0 0.1000 198 0.9700165 0.037573331 0.04666727 1 #> 9 2 1 1 0 0.3000 198 0.9775100 0.033059289 0.04052216 1 #> 10 2 1 1 0 0.5000 198 0.9833757 0.028643565 0.03492574 1 #> 11 2 1 1 0 0.7500 198 0.9880897 0.023991575 0.02962951 1 #> 12 2 1 1 0 1.0000 198 0.9904746 0.020860058 0.02651966 1 #> 13 2 1 1 0 1.5000 198 0.9925683 0.018068919 0.02342138 1 #> 14 2 1 1 0 2.0000 198 0.9946577 0.015367977 0.01987157 1 #> 15 2 1 1 0 3.0000 198 0.9974683 0.010502762 0.01370791 1 #> 16 2 1 1 0 4.0000 198 0.9973697 0.009755731 0.01395530 1 #> 17 2 1 1 0 6.0000 198 0.9951959 0.009410954 0.01894897 1 #> 18 2 1 1 0 8.0000 198 0.9907575 0.009328022 0.02649087 1 #> p_val const_pred_num_pred const_pred_rho const_pred_mae #> 1 3.557737e-176 198 -0.9684038 0.3765168 #> 2 3.465763e-176 198 -0.9684038 0.3765168 #> 3 3.288867e-176 198 -0.9684038 0.3765168 #> 4 2.737698e-176 198 -0.9684038 0.3765168 #> 5 1.620137e-176 198 -0.9684038 0.3765168 #> 6 2.566921e-177 198 -0.9684038 0.3765168 #> 7 1.257304e-179 198 -0.9684038 0.3765168 #> 8 5.214022e-188 198 -0.9684038 0.3765168 #> 9 9.363677e-215 198 -0.9684038 0.3765168 #> 10 1.081861e-244 198 -0.9684038 0.3765168 #> 11 6.481307e-280 198 -0.9684038 0.3765168 #> 12 8.307358e-305 198 -0.9684038 0.3765168 #> 13 0.000000e+00 198 -0.9684038 0.3765168 #> 14 0.000000e+00 198 -0.9684038 0.3765168 #> 15 0.000000e+00 198 -0.9684038 0.3765168 #> 16 0.000000e+00 198 -0.9684038 0.3765168 #> 17 0.000000e+00 198 -0.9684038 0.3765168 #> 18 3.033391e-308 198 -0.9684038 0.3765168 #> const_pred_rmse const_pred_perc const_p_val #> 1 0.3806739 1 1 #> 2 0.3806739 1 1 #> 3 0.3806739 1 1 #> 4 0.3806739 1 1 #> 5 0.3806739 1 1 #> 6 0.3806739 1 1 #> 7 0.3806739 1 1 #> 8 0.3806739 1 1 #> 9 0.3806739 1 1 #> 10 0.3806739 1 1 #> 11 0.3806739 1 1 #> 12 0.3806739 1 1 #> 13 0.3806739 1 1 #> 14 0.3806739 1 1 #> 15 0.3806739 1 1 #> 16 0.3806739 1 1 #> 17 0.3806739 1 1 #> 18 0.3806739 1 1data("two_species_model") ts <- two_species_model$x[1:200] s_map(ts, E = 2, theta = 1, save_smap_coefficients = TRUE)#> Warning: Found overlap between lib and pred. Enabling cross-validation with exclusion radius = 0.#> E tau tp nn theta num_pred rho mae rmse perc p_val #> 1 2 1 1 0 1 198 0.9904746 0.02086006 0.02651966 1 8.307358e-305 #> const_pred_num_pred const_pred_rho const_pred_mae const_pred_rmse #> 1 198 -0.9684038 0.3765168 0.3806739 #> const_pred_perc const_p_val model_output smap_coefficients #> 1 1 1 c(2, 3, .... c(NaN, -.... #> smap_coefficient_covariances #> 1 NULL, c(....