Skip to contents

Simple, lightweight R package for fitting, visualising, and predicting time-series data using Gaussian processes.

Installation

You can install the development version of tsgp from GitHub using the following:

devtools::install_github("hendersontrent/tsgp")

Premise

tsgp implements the functionality presented in a recent tutorial for modelling time-series data with Gaussian processes. Currently, only the univariate setting is supported. tsgp works on a structural time series perspective. That is, by decomposing a time series into its constituent statistical parts (e.g., trend, seasonality, noise), one can model each component independently before combining them to form the complete picture of temporal dynamics. This is not only intuitive, but it is also highly transparent—meaning that intelligent and justifiable modelling decisions must be made in order to appropriately capture the data generating process.

tsgp is extremely lightweight in both its dependencies and computational approach. If you are seeking a more rigorous or flexible approach to using GPs for time-series analysis, please look into Stan, GPy, GauPro, Tensorflow Probability, or GaussianProcesses.jl.

Functionality

Currently, tsgp supports the following covariance functions (kernels):

  • Exponentiated quadratic (squared exponential)
  • Rational quadratic
  • Periodic
  • Linear

tsgp flexibly enables composite kernels (either through addition or multiplication) to be constructed and is actively encouraged to appropriately model complex temporal dynamics.

tsgp also includes functions for computing and visualising draws from Gaussian process priors and posteriors, visualising covariance matrices, and plotting predictions.

Performance

tsgp is extremely fast at what it does. Well, as fast as it can be given the computation time involved in computing a GP posterior. tsgp implements well-known methods for efficiency and stability, such as using the Cholesky factorisation instead of computing a matrix inverse directly. A full model with trend, seasonality, and noise can be calculated on a time series of T = 1000 time points in a few seconds. This makes it an ideal tool for iterative model building and principled time-series exploration.