Learn R Programming

Functions for time series exploration, modelling and forecasting for R: tsutils package

Development repository for the tsutils package for R. Stable version can be found at: https://cran.r-project.org/package=tsutils

Installing

To install the development version use:

if (!require("devtools")){install.packages("devtools")}
devtools::install_github("trnnick/tsutils")

Otherwise, install the stable version from CRAN:

install.packages("tsutils")

Functionality

The tsutils package provides functions to support various aspects of time series and forecasting modelling. In particular this package includes: (i) tests and visualisations that can help the modeller explore time series components and perform decomposition; (ii) modelling shortcuts, such as functions to construct lagmatrices and seasonal dummy variables of various forms; (iii) an implementation of the Theta method; (iv) tools to facilitate the design of the forecasting process, such as ABC-XYZ analyses; and (v) "quality of life" tools, such as treating time series for trailing and leading values.

Time series exploration:

  • cmav: centred moving average.
  • coxstuart: Cox-Stuart test for location/dispersion.
  • decomp: classical time series decomposition.
  • seasplot: construct seasonal plots.
  • trendtest: test a time series for trend.

Time series modelling:

  • getOptK: optimal temporal aggregation level for AR(1), MA(1), ARMA(1,1).
  • lagmatrix: create leads/lags of variable.
  • residout: construct control chart of residuals.
  • seasdummy: create seasonal dummies.
  • theta: Theta method.

Hierarchical time series:

  • Sthief: temporal hierarchy S matrix.
  • plotSthief: plot temporal hierarchy S matrix.

Forecasting process modelling:

  • abc: ABC analysis.
  • xyz: XYZ analysis.
  • abcxyz: ABC-XYZ analyses visualisation.

Quality of life:

  • geomean: geometric mean.
  • lambdaseq: generate sequence of lambda for LASSO regression.
  • leadtrail: remove leading/training zeros/NAs.
  • wins: winsorisation, including vectorised versions colWins and rowWins.

Time series data:

  • referrals: A&E monthly referrals.

Authors & contributors

References

References are provided where necessary at the help file of each function. The overall modelling philosophy is reflected in:

Ord K., Fildes R., Kourentzes N. (2017) Principles of Business Forecasting, 2e. Wessex Press Publishing Co.

License

This project is licensed under the GPL3 License

Happy forecasting!

Copy Link

Version

Install

install.packages('tsutils')

Monthly Downloads

2,081

Version

0.9.4

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Nikolaos Kourentzes

Last Published

November 15th, 2023

Functions in tsutils (0.9.4)

nemenyi

Nonparametric multiple comparisons (Nemenyi test)
plotSthief

Plot temporal hierarchy
xyz

XYZ analysis
seasdummy

Create seasonal dummy variables.
seasplot

Seasonal plots with simplistic trend/season tests
mseastest

Multiplicative seasonality test
wins

Winsorise
theta

Theta method
tsutils-package

tsutils: Time Series Exploration, Modelling and Forecasting
residout

Residuals control chart
cmav

Centred moving average
tsutils

tsutils: Time Series Exploration, Modelling and Forecasting
trendtest

Test a time series for trend
lagmatrix

Create lead/lags of a variable
geomean

Geometric mean
leadtrail

Remove leading/training zeros/NAs
Sthief

Temporal hierarchy S matrix
abcxyz

ABC-XYZ visualisation
coxstuart

Cox-Stuart test
abc

ABC analysis
getOptK

Optimal temporal aggregation level for AR(1), MA(1), ARMA(1,1)
decomp

Classical time series decomposition
lambdaseq

Generate sequence of lambda for LASSO regression
referrals

NHS A&E Referrals