CRAN Task View: Time Series Analysis

Maintainer:

Rob J. Hyndman

Contact:

Rob.Hyndman at monash.edu

Version:

2014-12-23

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
Econometrics
and
Finance
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.

Basics

Infrastructure
: Base R contains substantial infrastructure for representing and analyzing
time series data. The fundamental class is
"ts"
that can
represent regularly spaced time series (using numeric time stamps).
Hence, it is particularly well-suited for annual, monthly, quarterly
data, etc.

Graphics
: Time series plots are obtained with
plot()
applied
to
ts
objects. (Partial) autocorrelation
functions plots are implemented in
acf()
and
pacf(). Alternative
versions are provided by
Acf()
and
Pacf()
in
forecast,
along with a combination display using
tsdisplay().
SDD
provides more general serial dependence diagrams.
Seasonal displays are obtained using
monthplot()
in stats and
seasonplot
in
forecast.

Times and Dates

Class
"ts"
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)
,
29-32.

Classes
"yearmon"
and
"yearqtr"
from
zoo
allow for more convenient computation with monthly
and quarterly observations, respectively.

Class
"Date"
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.

The
chron
package provides classes for
dates(),
hours()
and date/time (intra-day) in
chron(). There is no
support for time zones and daylight savings time. Internally,
"chron"
objects are (fractional) days since 1970-01-01.

Classes
"POSIXct"
and
"POSIXlt"
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. Internally,
"POSIXct"
objects are the number of seconds since 1970-01-01 00:00:00 GMT.
Package
lubridate
provides functions that facilitate
certain POSIX-based computations.

Class
"timeDate"
is provided in the
timeDate
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
"POSIXct"
and does
all computations in GMT only. Calendar functionality, e.g., including
information about weekends and holidays for various stock exchanges,
is also included.

The
"mondate"
class from the
mondate
package
facilitates computing with dates in terms of months.

The
tempdisagg
package includes methods for temporal disaggregation and interpolation of a low frequency time series to a higher frequency series.

TimeProjection
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,
"ts"
is the basic class for
regularly spaced time series using numeric time stamps.

The
zoo
package 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
"ts".
Coercion from and to
"zoo"
is available for all other
classes mentioned in this section.

The package
xts
is based on
zoo
and provides
uniform handling of R's different time-based data classes.

Various packages implement irregular time series based on
"POSIXct"
time stamps, intended especially for financial applications. These include
"its"
from
its,
"irts"
from
tseries, and
"fts"
from
fts.

The class
"timeSeries"
in
timeSeries
(previously: fSeries)
implements time series with
"timeDate"
time stamps.

The package
tframe
contains infrastructure for setting
time frames in different formats.

Forecasting and Univariate Modeling

The
forecast
package
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.

Exponential smoothing
:
HoltWinters()
in stats
provides some basic models with partial optimization,
ets()
from the
forecast
package provides a larger set of
models and facilities with full optimization. The
MAPA
package combines exponential smoothing models at different
levels of temporal aggregation to improve forecast accuracy.

Structural models
are implemented in
StructTS()
in stats, and in
stsm
and
stsm.class.
KFKSDS
provides a naive implementation of the Kalman filter and smoothers for univariate state space models. Bayesian structural time series models are implemented in
bsts.

Non-Gaussian time series can be handled with GLARMA state space models via the
glarma
package.

ARIMA models
:
arima()
in stats is the basic
function for ARIMA, SARIMA, ARIMAX, and subset ARIMA models.
It is enhanced in the
forecast
package via the function
Arima()
along with
auto.arima()
for automatic
order selection.
arma()
in the
tseries
package provides different algorithms for ARMA and subset ARMA
models.
FitARMA
implements a fast MLE algorithm for ARMA models.
Package
gsarima
contains functionality for Generalized SARIMA time series
simulation. The
mar1s
package handles multiplicative AR(1) with seasonal processes.
TSTutorial
provides an interactive tutorial for Box-Jenkins modelling.

Periodic ARMA models
:
pear
and
partsm
for periodic autoregressive time series models, and
perARMA
for periodic ARMA modelling and other procedures for periodic time series analysis.

ARFIMA models
: Some facilities for fractional differenced ARFIMA
models are provided in the
fracdiff
package. The
arfima
package
has more advanced and general facilities for ARFIMA and ARIMA models, including dynamic
regression (transfer function) models.
armaFit()
from the
fArma
package
is an interface for ARIMA and ARFIMA models. Fractional Gaussian noise and simple models for
hyperbolic decay time series are handled in the
FGN
package.

Transfer function
models are provided by the
arimax
function in the
TSA
package, and the
arfima
function in the
arfima
package.

Outlier detection following the Chen-Liu approach is provided by
tsoutliers.

Stochastic volatility
models are handled by
stochvol
in a Bayesian framework.

tsintermittent
implements various models for analysing and forecasting intermittent demand time series.

Miscellaneous
:
ltsa
contains methods for
linear time series analysis,
timsac
for time
series analysis and control, and
tsbugs
for time series BUGS models.

Frequency analysis

Spectral density estimation
is provided by
spectrum()
in the stats package, including the periodogram, smoothed periodogram and AR estimates. Bayesian spectral inference is provided by
bspec.
quantspec
includes methods to compute and plot Laplace periodograms for univariate time series. The Lomb-Scargle
periodogram for unevenly sampled time series is computed by
lomb.
psd
produces adaptive, sine-multitaper spectral density estimates.
kza
provides Kolmogorov-Zurbenko Adaptive Filters including break detection, spectral analysis,
wavelets and KZ Fourier Transforms.

Wavelet methods
: The
wavelets
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
wmtsa.
biwavelet
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.
Further wavelet methods can be found in the packages
brainwaver,
rwt,
waveslim,
wavethresh
and
mvcwt.

Decomposition and Filtering

Filters
:
filter()
in stats
provides autoregressive and moving average linear filtering of
multiple univariate time series. The
robfilter
package provides several robust time series filters, while
mFilter
includes miscellaneous time series filters
useful for smoothing and extracting trend and cyclical
components.

Decomposition
: Classical decomposition
is provided via
decompose(), more advanced and flexible
decomposition is available using
stl(), both from
the basic stats package.
Autoregressive-based decomposition is provided by
ArDec.
rmaf
uses a refined moving average filter for decomposition.

Analysis of seasonality
: the
bfast
package provides methods for detecting and characterizing abrupt changes within the trend and seasonal components obtained from a decomposition.
npst
provides a generalization of Hewitt's seasonality test.

deseasonalize: Optimal deseasonalization for geophysical time series using AR fitting.

Stationarity, Unit Roots, and Cointegration

Stationarity and unit roots
:
tseries
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
urca
package, which also includes further methods
such as Elliott-Rothenberg-Stock, Schmidt-Phillips and Zivot-Andrews
tests. The
fUnitRoots
package also provides the MacKinnon test.
CADFtest
provides implementations of both the standard ADF
and a covariate-augmented ADF (CADF) test.

Local stationarity
:
locits
provides a test of local stationarity and computes the localized autocovariance. Time series costationarity determination is provided by
costat.
Locally stationary wavelet models for nonstationary time series are implemented in
wavethresh
(including estimation, plotting, and simulation functionality for time-varying spectrums).

Cointegration
: The Engle-Granger two-step method with the Phillips-Ouliaris
cointegration test is implemented in
tseries
and
urca.
The latter additionally contains functionality for the Johansen trace
and lambda-max tests.
tsDyn
provides Johansen's test and AIC/BIC simultaneous rank-lag selection.
CommonTrend
provides tools to extract and plot common trends from a cointegration system.

Fractal time series modeling and analysis is provided by
fractal.
fractalrock
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
dynlm;
an enhanced approach that also works with other regression functions
and more time series classes is implemented in
dyn.
The
tslars
package applies a dynamic variable selection procedure using an extension of the LARS
algorithm. More advanced dynamic system equations can be fitted using
dse. Gaussian linear state
space models can be fitted using
dlm
(via maximum
likelihood, Kalman filtering/smoothing and Bayesian methods), or using
bsts
which uses MCMC.
Functions for distributed lag non-linear modelling are provided in
dlnm.

MIDAS regression
and other econometric methods for mixed frequency time series data analysis are provided by
midasr.

gets
provides GEneral-To-Specific (GETS) model selection for either ARX models with log-ARCH-X errors, or a log-ARCH-X model of the log variance.

orderedLasso
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.

Multivariate Time Series Models

Vector autoregressive (VAR) models
are provided via
ar()
in the basic stats package including order
selection via the AIC. These models are
restricted to be stationary.
MTS
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
mAr
package, which also allows
VAR models in principal component space. More elaborate models
are provided in package
vars,
tsDyn,
estVARXls()
in
dse, and a Bayesian approach is available in
MSBVAR. Another implementation with
bootstrapped prediction intervals is given in
VAR.etp.

VARIMA models
and
state space models
are provided
in the
dse
package.
EvalEst
facilitates Monte Carlo experiments to
evaluate the associated estimation methods.

Vector error correction models
are available via the
urca,
vars
and
tsDyn
packages, including versions with structural constraints and thresholding.

Multivariate GARCH models
including DCC, GO-GARCH and Copula-GARCH are available in
rmgarch.

Time series component analysis
: Time series factor analysis is provided in
tsfa.
ForeCA
implements forecatable component analysis by searching for the best linear transformations that make a multivariate time series as forecastable as possible.

Multivariate state space models
are implemented in the
FKF
(Fast Kalman Filter) package.
This provides relatively flexible state space models via the
fkf()
function: state-space
parameters are allowed to be time-varying and intercepts are included in both equations.
An alternative implementation is provided by the
KFAS
package which provides a
fast multivariate Kalman filter, smoother, simulation smoother and forecasting. Yet another implementation
is given in the
dlm
package which also contains tools for converting other multivariate models
into state space form.
dlmodeler
provides a unified interface for
dlm,
KFAS
and
FKF.
MARSS
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
pomp
package.

Simulation and inference for stochastic differential equations is provided by
sde
and
yuima.

Resampling

Bootstrapping
: The
boot
package provides
function
tsboot()
for time series bootstrapping,
including block bootstrap with several variants.
tsbootstrap()
from
tseries
provides
fast stationary and block bootstrapping.
Maximum entropy bootstrap for time series is available in
meboot.
timesboot
computes the bootstrap CI for the sample ACF and periodogram.
BootPR
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
fma
package.

Data from Hyndman, Koehler, Ord and Snyder (2008)
Forecasting
with exponential smoothing
are in the
expsmooth
package.

Data from Hyndman and Athanasopoulos (2013)
Forecasting: principles and practice
are in the
fpp
package.

Data from the M-competition and M3-competition are provided in the
Mcomp
package.

pdfetch
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
Quandl
package.

Data from the Datamarket online portal can be fetched using the
rdatamarket
package.

RMAWGEN
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.