CRAN Task View: Time Series Analysis
|Maintainer:||Rob J Hyndman|
|Contact:||Rob.Hyndman at monash.edu|
Base R ships with a lot of functionality useful for time series, in particular in the stats package. This is complemented by many packages on CRAN, which are briefly summarized below. There is also a considerable overlap between the tools for time series and those in the
task views. The packages in this view can be roughly structured into the following topics. If you think that some package is missing from the list, please let us know.
Base R contains substantial infrastructure for representing and analyzing time series data. The fundamental class is
that can represent regularly spaced time series (using numeric time stamps). Hence, it is particularly well-suited for annual, monthly, quarterly data, etc.
Moving averages are computed by
zoo. The latter also provides a general function
rollapply, along with other specific rolling statistics functions.
provides parallel functions for computing rolling statistics.
Time series plots are obtained with
(Partial) autocorrelation functions plots are implemented in
pacf(). Alternative versions are provided by
forecast, along with a combination display using
provides more general serial dependence diagrams, while
computes and plots the distance covariance and correlation functions of time series.
Seasonal displays are obtained using
in stats and
implements wrap-around time series graphics.
provides ggplot2 graphics for seasonally adjusted series and rolling statistics.
provides an interface to the Dygraphs interactive time series charting library.
plots forecast objects from the
package using dygraphs.
Basic fan plots of forecast distributions are provided by
vars. More flexible fan plots of any sequential distributions are implemented in
Times and Dates
can only deal with numeric time stamps, but many more classes are available for storing time/date information and computing with it.
For an overview see
R Help Desk: Date and Time Classes in R
by Gabor Grothendieck and Thomas Petzoldt in
R News 4(1)
allow for more convenient computation with monthly and quarterly observations, respectively.
from the base package is the basic class for dealing with dates in daily data. The dates are internally stored as the number of days since 1970-01-01.
provides classes for
and date/time (intra-day) in
There is no support for time zones and daylight savings time.
objects are (fractional) days since 1970-01-01.
implement the POSIX standard for date/time (intra-day) information and also support time zones and daylight savings time.
However, the time zone computations require some care and might be system-dependent.
objects are the number of seconds since 1970-01-01 00:00:00 GMT.
provides functions that facilitate certain POSIX-based computations.
is provided in the
package (previously: fCalendar).
It is aimed at financial time/date information and deals with time zones and daylight savings times via a new concept of "financial centers".
Internally, it stores all information in
and does all computations in GMT only.
Calendar functionality, e.g., including information about weekends and holidays for various stock exchanges, is also included.
class for time/date information.
package facilitates computing with dates in terms of months.
includes methods for temporal disaggregation and interpolation of a low frequency time series to a higher frequency series.
extracts useful time components of a date object, such as day of week, weekend, holiday, day of month, etc, and put it in a data frame.
Time Series Classes
As mentioned above,
is the basic class for regularly spaced time series using numeric time stamps.
provides infrastructure for regularly and irregularly spaced time series using arbitrary classes for the time stamps (i.e., allowing all classes from the previous section).
It is designed to be as consistent as possible with
Coercion from and to
is available for all other classes mentioned in this section.
is based on
and provides uniform handling of R's different time-based data classes.
Various packages implement irregular time series
time stamps, intended especially for financial applications. These include
(previously: fSeries) implements time series with
implements time series with
contains infrastructure for setting time frames in different formats.
Forecasting and Univariate Modeling
provides a class and methods for univariate time series forecasts, and provides many functions implementing different forecasting models including all those in the stats package.
in stats provides some basic models with partial optimization,
package provides a larger set of models and facilities with full optimization.
package combines exponential smoothing models at different levels of temporal aggregation to improve forecast accuracy.
The theta method
is implemented in the
function from the
An alternative and extended implementation is provided in
in stats (with model selection) and
for subset AR models.
in stats is the basic function for ARIMA, SARIMA, ARIMAX, and subset ARIMA models.
It is enhanced in the
package via the function
for automatic order selection.
package provides different algorithms for ARMA and subset ARMA models.
implements a fast MLE algorithm for ARMA models.
contains functionality for Generalized SARIMA time series simulation.
package handles multiplicative AR(1) with seasonal processes.
provides an interactive tutorial for Box-Jenkins modelling.
Improved prediction intervals for ARIMA and structural time series models are provided by
Periodic ARMA models
for periodic autoregressive time series models, and
for periodic ARMA modelling and other procedures for periodic time series analysis.
Some facilities for fractional differenced ARFIMA models are provided in the
package has more advanced and general facilities for ARFIMA and ARIMA models, including dynamic regression (transfer function) models.
package is an interface for ARIMA and ARFIMA models.
Fractional Gaussian noise and simple models for hyperbolic decay time series are handled in the
are provided by the
function in the
package, and the
function in the
following the Chen-Liu approach is provided by
are implemented in
in stats, and in
provides a naive implementation of the Kalman filter and smoothers for univariate state space models.
Bayesian structural time series models are implemented in
Non-Gaussian time series
can be handled with GLARMA state space models via
glarma, and using Generalized Autoregressive Score models in the
Conditional Auto-Regression models using Monte Carlo Likelihood methods are implemented in
fits basic GARCH models.
Many variations on GARCH models are provided by
Other univariate GARCH packages include
which implements ARIMA models with a wide class of GARCH innovations.
There are many more GARCH packages described in the
are handled by
in a Bayesian framework.
Count time series
are handled in the
provides for Zero-Inflated Models for count time series.
implements various models for analysing and forecasting intermittent demand time series.
Censored time series
can be modelled using
are provided via
in the stats package.
Additional tests are given by
Change point detection
is provided in
(using linear regression models),
(using nonparametric tests),
(using wild binary segmentation).
package provides many popular changepoint methods,
does nonparametric changepoint detection for univariate and multivariate series.
Time series imputation
is provided by the
Some more limited facilities are available using
Forecasts can be combined
which supports the most frequently used methods to combine forecasts.
provides functions for ensemble forecasts, combining approaches from the
has facilities for online predictions based on combinations of forecasts provided by the user.
is provided in the
Distributional forecast evaluation using scoring rules is available in
contains methods for linear time series analysis,
for time series analysis and control,
for time series BUGS models.
Spectral density estimation
is provided by
in the stats package, including the periodogram, smoothed periodogram and AR estimates.
Bayesian spectral inference is provided by
includes methods to compute and plot Laplace periodograms for univariate time series.
The Lomb-Scargle periodogram for unevenly sampled time series is computed by
produces adaptive, sine-multitaper spectral density estimates.
provides Kolmogorov-Zurbenko Adaptive Filters including break detection, spectral analysis, wavelets and KZ Fourier Transforms.
also provides some multitaper spectral analysis tools.
package includes computing wavelet filters, wavelet transforms and multiresolution analyses.
Wavelet methods for time series analysis based on Percival and Walden (2000) are given in
can be used to plot and compute the wavelet spectra, cross-wavelet spectra, and wavelet coherence of non-stationary time series. It also includes functions to cluster time series based on the (dis)similarities in their spectrum.
Tests of white noise using wavelets are provided by
Further wavelet methods can be found in the packages
using Fourier terms is implemented in
package also provides some simple harmonic regression facilities via the
Decomposition and Filtering
Filters and smoothing
in stats provides autoregressive and moving average linear filtering of multiple univariate time series.
package provides several robust time series filters,
includes miscellaneous time series filters useful for smoothing and extracting trend and cyclical components.
from the stats package computes Tukey's running median smoothers, 3RS3R, 3RSS, 3R, etc.
computes the 4253H twice smoothing method.
Classical (seasonal/trend) decomposition is provided via
more advanced and flexible decomposition is available using
stl(), both from the basic stats package.
Autoregressive-based decomposition is provided by
uses a refined moving average filter for decomposition.
Singular Spectrum Analysis
is implemented in
Empirical Mode Decomposition
and Hilbert spectral analysis is provided by
Additional tools, including ensemble EMD, are available in
An alternative implementation of ensemble EMD and its complete variant are available in
the stats package provides classical decomposition in
and STL decomposition in
Enhanced STL decomposition is available in
provides a wrapper for the
which must be installed first.
provides a graphical user interface for
X-13-ARIMA-SEATS binaries are provided in the
providing an R interface.
Analysis of seasonality
package provides methods for detecting and characterizing abrupt changes within the trend and seasonal components obtained from a decomposition.
provides a generalization of Hewitt's seasonality test.
Seasonal analysis of health data including regression models, time-stratified case-crossover, plotting functions and residual checks.
Seasonal analysis and graphics, especially for climatology.
Optimal deseasonalization for geophysical time series using AR fitting.
Stationarity, Unit Roots, and Cointegration
Stationarity and unit roots
provides various stationarity and unit root tests including Augmented Dickey-Fuller, Phillips-Perron, and KPSS.
Alternative implementations of the ADF and KPSS tests are in the
package, which also includes further methods such as Elliott-Rothenberg-Stock, Schmidt-Phillips and Zivot-Andrews tests.
package also provides the MacKinnon test,
provides seasonal unit root tests.
provides implementations of both the standard ADF and a covariate-augmented ADF (CADF) test.
provides a test of local stationarity and computes the localized autocovariance.
Time series costationarity determination is provided by
has functions for locally stationary time series analysis.
Locally stationary wavelet models for nonstationary time series are implemented in
(including estimation, plotting, and simulation functionality for time-varying spectrums).
The Engle-Granger two-step method with the Phillips-Ouliaris cointegration test is implemented in
urca. The latter additionally contains functionality for the Johansen trace and lambda-max tests.
provides Johansen's test and AIC/BIC simultaneous rank-lag selection.
provides tools to extract and plot common trends from a cointegration system.
Parameter estimation and inference in a cointegrating regression are implemented in
Nonlinear Time Series Analysis
Various forms of nonlinear autoregression are available in
including additive AR, neural nets, SETAR and LSTAR models, threshold VAR and VECM. Neural network autoregression is also provided in
implements Bent-Cable autoregression.
provides Bayesian analysis of threshold autoregressive models.
provides an R implementation of the algorithms from the
Autoregression Markov switching models
are provided in
while dependent mixtures of latent Markov models are given in
for categorical and continuous time series.
Various tests for nonlinearity are provided in
tests for nonlinear serial dependence based on entropy metrics.
Additional functions for nonlinear time series
are available in
Fractal time series modeling and analysis
is provided by
generates fractal time series with non-normal returns distributions.
Dynamic Regression Models
Dynamic linear models
A convenient interface for fitting dynamic regression models via OLS is available in
an enhanced approach that also works with other regression functions and more time series classes is implemented in
More advanced dynamic system equations can be fitted using
Gaussian linear state space models can be fitted using
(via maximum likelihood, Kalman filtering/smoothing and Bayesian methods),
which uses MCMC.
Functions for distributed lag non-linear modelling are provided in
can be fitted using the
fits a sparse linear model with an order constraint on the coefficients in order to handle lagged regressors where the coefficients decay as the lag increases.
of various kinds is available in
including discrete and continuous time, linear and nonlinear models, and different types of latent variables.
Multivariate Time Series Models
Vector autoregressive (VAR) models
are provided via
in the basic stats package including order selection via the AIC. These models are restricted to be stationary.
is an all-purpose toolkit for analyzing multivariate time series including VAR, VARMA, seasonal VARMA, VAR models with exogenous variables, multivariate regression with time series errors, and much more.
Possibly non-stationary VAR models are fitted in the
package, which also allows VAR models in principal component space.
allows estimation of sparse VAR and VECM models,
estimates VAR and VARX models with structured lasso penalties.
Automated VAR models and networks are available in
More elaborate models are provided in package
dse, and a Bayesian approach is available in
Another implementation with bootstrapped prediction intervals is given in
provides multi-level vector autoregression.
provides routines for identifying structural shocks in VAR models using sign restrictions.
state space models
are provided in the
facilitates Monte Carlo experiments to evaluate the associated estimation methods.
Vector error correction models
are available via the
packages, including versions with structural constraints and thresholding.
Time series component analysis
Time series factor analysis is provided in
implements forecatable component analysis by searching for the best linear transformations that make a multivariate time series as forecastable as possible.
finds a linear transformation of a multivariate time series giving lower-dimensional subseries that are uncorrelated with each other.
Multivariate state space models
are implemented in the
(Fast Kalman Filter) package. This provides relatively flexible state space models via the
function: state-space parameters are allowed to be time-varying and intercepts are included in both equations.
An alternative implementation is provided by the
package which provides a fast multivariate Kalman filter, smoother, simulation smoother and forecasting.
Yet another implementation is given in the
package which also contains tools for converting other multivariate models into state space form.
provides a unified interface for
fits constrained and unconstrained multivariate autoregressive state-space models using an EM algorithm.
All of these packages assume the observational and state error terms are uncorrelated.
Partially-observed Markov processes
are a generalization of the usual linear multivariate state space models, allowing non-Gaussian and nonlinear models. These are implemented in the
Analysis of large groups of time series
Time series clustering
is implemented in
provides distance measures for time series data.
implements tools based on time series symbolic discretization for finding motifs in time series and facilitates interpretable time series classification.
Methods for plotting and forecasting collections of hierarchical and grouped time series
are provided by
An alternative approach to reconciling forecasts of hierarchical time series is provided by
Continuous time models
Continuous time autoregressive modelling
is provided in
simulates and models stochastic differential equations.
Simulation and inference for stochastic differential equations
is provided by
package provides function
for time series bootstrapping, including block bootstrap with several variants.
provides fast stationary and block bootstrapping.
Maximum entropy bootstrap for time series is available in
computes the bootstrap CI for the sample ACF and periodogram.
computes bias-corrected forecasting and boostrap prediction intervals for autoregressive time series.
Time Series Data
Data from Makridakis, Wheelwright and Hyndman (1998)
Forecasting: methods and applications
are provided in the
Data from Hyndman, Koehler, Ord and Snyder (2008)
Forecasting with exponential smoothing
are in the
Data from Hyndman and Athanasopoulos (2013)
Forecasting: principles and practice
are in the
Data from the M-competition and M3-competition
are provided in the
package. Data from the M4 competition are given in
provides facilities for downloading economic and financial time series from public sources.
Data from the Quandl online portal
to financial, economical and social datasets can be queried interactively using the
Data from the Datamarket online portal
can be fetched using the
Data from Cryer and Chan (2010)
are in the
Data from Shumway and Stoffer (2011)
are in the
Data from Tsay (2005)
Analysis of financial time series
are in the
package, along with some functions and script files required to work some of the examples.
provides a common interface to time series databases.
provides an interface for FAME time series databases
both contain many data sets (including time series data) from many econometrics text books
Dynamic time warping algorithms for computing and plotting pairwise alignments between time series.
Bayesian Model Averaging to create probabilistic forecasts from ensemble forecasts and weather observations.
Early warnings signals toolbox for detecting critical transitions in time series
turns machine-extracted event data into regular aggregated multivariate time series.
Analysis of fragmented time directionality to investigate feedback in time series.
aims to find "learned pattern similarity" for time series.
provides tools for preparing ecological community time series data for multivariate AR modeling.
routines for the estimation of sparse long run partial correlation networks for time series data.
Modeling evolution in paleontological time series.
Regulation, decomposition and analysis of space-time series.
Parametric time warping.
provides tools to generate vector time series.
is set of S3 and S4 functions for spatial multi-site stochastic generation of daily time-series of temperature and precipitation making use of VAR models. The package can be used in climatology and statistical hydrology.
Seismic time series analysis tools.
Raster time series analysis (e.g., time series of satellite images).
Time series models for small area estimation.
Spatio-temporal Bayesian modelling.
Temporal and spatio-temporal modeling and monitoring of epidemic phenomena.
Turbulence time series Event Detection and classification.
Functions to calculate characteristics of quasi periodic time series, e.g. observed estuarine water levels.
Temporally resolved groups of typical differences (errors) between two time series are determined and visualized.
Mining Univariate and Multivariate Motifs in Time-Series Data.
Time series modeling for air pollution and health.
Exploring water quality time series.