Simplex performs time series forecasting based on
weighted nearest neighbors projection in the time series phase space as
described in Sugihara and May.
Simplex(dataFrame = NULL, columns, target, lib, pred, E = NULL, Tp = 1, knn = 0,
tau = -1, exclusionRadius = 0, embedded = FALSE,
validLib = logical(0), noTime = FALSE, ignoreNan = TRUE,
backend = "RANN", pathIn = "./", dataFile = "", pathOut = "./",
predictFile = "", parameterList = FALSE, includeState = FALSE,
verbose = FALSE, showPlot = FALSE, .tieBreak = TRUE)A data.frame with columns Time, Observations, Predictions and Pred_Variance.
If includeState = TRUE a named list "internal" is added.
A data.frame of input data. The first column is time
unless noTime = TRUE. The columns must be named.
Column name(s) to build the embedding: character vector string of whitespace separated column name(s), or vector of column names used to create the library. If individual column names contain whitespace place names in a vector, or, append ',' to the name.
Target column name to predict.
Library (training) index range as (start end) pairs. Mulitple row index pairs can be specified with each pair defining the first and last rows of time series observation segments used to create the library.
Prediction index range as (start end) pairs. A single contiguous range is supported.
Embedding dimension. Required (no default); must be a positive integer unless embedded = TRUE, in which case it is inferred as the number of columns.
Forecast interval (prediction horizon, number of time column rows).
Number of nearest neighbours. If knn=0 knn is set to E+1..
Embedding delay (negative selects past lags).
Temporal (Theiler) exclusion radius around each
prediction point excludes vectors from the search space of nearest
neighbors if their relative time index is within exclusionRadius.
If TRUE columns already form the embedding.
Logical vector marking admissible library rows (or length 0 for all).
If TRUE synthesise a 1..N time index instead of using column 1.
Remove rows with NaN in the embedding from the library and prediction sets.
Nearest-neighbour backend: "RANN" (default) or "brute".
File path for input dataFile.
Input dataFile, .csv format. The first column must be a time index or time values unless noTime is TRUE. The first row must be column names.
Output file path for predictFile
Output file name, .csv format.
Append named list of parameters/values to return.
If TRUE, also return an internal list of engine state: knn_neighbors, knn_distances, lib_i, pred_i, targetVec, embedding (1-based row indices; 0 = neighbour sentinel).
Emit diagnostic messages.
If TRUE draw a base-graphics plot of the result.
If TRUE implement nearest neighbor tie breaking.
If embedded is FALSE, the data column(s) are embedded to
dimension E with time lag tau. This embedding forms an
E-dimensional phase space for the Simplex projection.
If embedded is TRUE, the data are assumed to contain an
E-dimensional embedding with E equal to the number of columns.
Predictions are made using leave-one-out cross-validation, i.e.
observation vectors are excluded from the prediction simplex.
To assess an optimal embedding dimension EmbedDimension
can be applied. Accuracy statistics can be estimated by
ComputeError.
Sugihara G. and May R. 1990. Nonlinear forecasting as a way of distinguishing chaos from measurement error in time series. Nature, 344:734-741.
data( block_3sp )
smplx = Simplex(block_3sp, "x_t", "x_t", lib = c(1, 100), pred = c(101, 195), E = 3)
ComputeError( smplx $ Predictions, smplx $ Observations )
Run the code above in your browser using DataLab