Type: | Package |
Title: | Forecasting of Univariate Time Series Using the Pattern Sequence-Based Forecasting (PSF) Algorithm |
Version: | 0.5 |
Date: | 2022-04-30 |
Author: | Neeraj Bokde, Gualberto Asencio-Cortes and Francisco Martinez-Alvarez |
Maintainer: | Neeraj Bokde <neerajdhanraj@gmail.com> |
Description: | Pattern Sequence Based Forecasting (PSF) takes univariate time series data as input and assist to forecast its future values. This algorithm forecasts the behavior of time series based on similarity of pattern sequences. Initially, clustering is done with the labeling of samples from database. The labels associated with samples are then used for forecasting the future behaviour of time series data. The further technical details and references regarding PSF are discussed in Vignette. |
BugReports: | https://github.com/neerajdhanraj/PSF/issues |
URL: | https://www.neerajbokde.in/viggnette/2021-10-13-PSF/ |
License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] |
Imports: | data.table, cluster |
VignetteBuilder: | knitr |
RoxygenNote: | 7.1.2 |
NeedsCompilation: | no |
Encoding: | UTF-8 |
Packaged: | 2022-04-30 17:29:00 UTC; mayur |
Repository: | CRAN |
Date/Publication: | 2022-05-01 14:20:10 UTC |
Suggests: | knitr, rmarkdown, forecast |
Plot actual and forecasted values of an univariate time series
Description
Takes an univariate time series and a vector with forecasted values.
Usage
## S3 method for class 'psf'
plot(x, predictions = c(), cycle = 24, ...)
Arguments
x |
The trained PSF model generated by psf() function. |
predictions |
A vector with previously computed forecasted values. |
cycle |
The number of values that conform a cycle in the time series (e.g. 24 hours per day, 12 month per year, and so on). Only used when input data is not in time series (ts) format. |
... |
Additional graphical parameters given to plot function. |
Examples
## Train a PSF model from the univariate time series 'nottem' (package:datasets).
p <- psf(nottem)
## Forecast the next 12 values of such time series.
pred <- predict(p, n.ahead = 12)
## Plot forecasted values.
plot(p, pred)
Forecasting of univariate time series using a trained PSF model
Description
Takes a trained PSF model and the prediction horizon as inputs.
Usage
## S3 method for class 'psf'
predict(object, n.ahead = 1, ...)
Arguments
object |
The trained PSF model generated by psf() function. |
n.ahead |
The number of predicted values to be obtained. |
... |
Other parameters will be ignored. |
Value
Vector with the resulting predictions
Examples
## Train a PSF model from the univariate time series 'nottem' (package:datasets).
p <- psf(nottem)
## Forecast the next 12 values of such time series.
pred <- predict(p, n.ahead = 12)
Train a PSF model from an univariate time series using the PSF algorithm
Description
Takes an univariate time series as input. Optionally, specific internal parameters of the PSF algorithm can be also specified.
Usage
psf(data, k = seq(2, 10), w = seq(1, 10), cycle = 24)
Arguments
data |
Input univariate time series, in any format (time series (ts), vector, matrix, list, data frame). |
k |
The number of clusters, or a vector of candidate values to search for the optimum automatically. |
w |
The window size, or a vector of candidate values to search for the optimum automatically. |
cycle |
The number of values that conform a cycle in the time series (e.g. 24 hours per day). Only used when input data is not in time series format. |
Value
An object of class 'psf' with 7 elements:
original_series |
Original time series stored to be used internally to build further plots. |
train_data |
Adapted and normalized internal time series used to train the PSF model. |
k |
Number of clusters used |
w |
Window size used |
cycle |
Determined cycle for the input time series. |
dmin |
Minimum value of the input time series (used to denormalize internally further predictions). |
dmax |
Maximum value of the input time series (used to denormalize internally further predictions). |
Examples
## Train a PSF model from the univariate time series 'nottem' (package:datasets).
p <- psf(nottem)
## Train a PSF model from the univariate time series 'sunspots' (package:datasets).
p <- psf(sunspots)