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.
-
Modeling
: Methods for analyzing and modeling time series include ARIMA models in
arima(), AR(p) and VAR(p) models in
ar(),
structural models in
StructTS(),
visualization via
plot(), (partial) autocorrelation
functions in
acf()
and
pacf(), classical
decomposition in
decompose(), STL decomposition
in
stl(), moving average and autoregressive linear
filters in
filter(), and basic Holt-Winters forecasting in
HoltWinters().
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.
-
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
tis
package provides the
"ti"
class for
time/date information.
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 class
"tis"
in
tis
implements
time series with
"ti"
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.
-
Autoregressive models
:
ar()
in stats (with
model selection),
FitAR
for subset AR models, and
pear
for periodic autoregressive time series models.
-
ARIMA models
:
arima()
in stats is the basic
function for ARIMA, SARIMA, ARIMAX, and subset ARIMA models.
It is enhanced in the
forecast
package
along with
auto.arima()
for automatic
order selection.
arma()
in the
tseries
package provides different algorithms for ARMA and subset ARMA
models. Extensive facilities for fractional differenced ARFIMA
models are provided in the
fracdiff
package.
armaFit()
from the
fArma
package is an
interface for ARIMA and ARFIMA models. Package
gsarima
contains functionality for generalized
SARIMA time series simulation. The
mar1s
package handles multiplicative AR(1) with seasonal processes/
-
GARCH models
:
garch()
from
tseries
fits basic GARCH models,
garchFit()
from
fGarch
implements ARIMA models with a wide class of GARCH innovations.
bayesGARCH
estimates a Bayesian
GARCH(1,1) model with t innovations.
gogarch
implements Generalized Orthogonal GARCH (GO-GARCH) models.
-
Miscellaneous
:
ltsa
contains methods for
linear time series analysis,
dlm
for Bayesian
analysis of dynamic linear models,
timsac
for time
series analysis and control,
BootPR
for
bias-corrected forecasting and bootstrap prediction intervals
for autoregressive time series
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.
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.
-
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. Further wavelet methods can be found in
the packages
brainwaver,
rwt,
waveslim, and
wavethresh.
-
Miscellaneous
:
ArDec
implements autoregressive-based decomposition
of a time series.
signalextraction
for real-time signal extraction
(direct filter approach).
bspec
for Bayesian inference on the discrete power
spectrum of time series.
kza
provides Kolmogorov-Zurbenko Adaptive Filters including break detection, spectral analysis,
wavelets and KZ Fourier Transforms.
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.
-
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.
Nonlinear Time Series Analysis
-
Nonlinear autoregression
: Various forms of nonlinear
autoregression are available in
tsDyn
including
additive AR, neural nets, SETAR and LSTAR models.
bentcableAR
implements Bent-Cable autoregression.
BAYSTAR
provides Bayesian analysis of threshold
autoregressive models.
-
The
TISEAN
project
provided algorithms for time series analysis from
nonlinear dynamical systems theory.
RTisean
provides
an R interface to the algorithms and
tseriesChaos
provides an R implementation of the algorithms.
-
Tests
: Various tests for nonlinearity are provided in
fNonlinear.
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).
-
Time-varying parameter
models can be fitted using the
tpr
package.
-
Distributed lag non-linear models
are handled via the
dlnm
package.
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. 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,
estVARXls()
in
dse
and a Bayesian approach is available in
MSBVAR.
-
Markov-switching VAR
models are available in
MSVAR.
-
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
and
vars
packages, including versions with structural
constraints.
-
Time series factor analysis
is provided in
tsfa.
-
Multivariate state space models
are implemented in the
FKF
(Fast Kalman Filter) package.
This provides relatively flexible state space models via the
fkf()
comment: 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.
Both packages assume uncorrelated error terms.
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 the M-competition and M3-competition are provided in the
Mcomp
package.
-
Data from Tsay (2005)
Analysis of financial
time series
are in the
FinTS
package, along with some functions and
script files required to work some of the examples.
-
Data from Cryer and Chan (2008)
Time series analysis with applications in R
are in the
TSA
package.
-
TSdbi
provides a common interface to time series databases.
-
fame
provides an interface for FAME time series databases
-
VhayuR
provides an interface to he Vhayu Velocity time series database
-
fEcofin
Economic and Financial Data Sets
-
AER
and
Ecdat
both contain many data sets (including time series data)
from many econometrics text books
Miscellaneous
-
cts: Continuous time autoregressive models.
-
dtw: Dynamic time warping algorithms for computing and plotting pairwise alignments between time series.
-
ensembleBMA: Bayesian Model Averaging to create probabilistic forecasts from ensemble forecasts and weather observations.
-
fractal: Fractal time series modeling and analysis.
-
fractalrock: Generate fractal time series with non-normal returns distribution.
-
GeneCycle
and
GeneNet: Microarray time series and network analysis.
-
hydrosanity: Graphical user interface for exploring hydrological time series.
-
paleoTS: Modeling evolution in paleontological time series.
-
pastecs: Regulation, decomposition and analysis of space-time series.
-
ptw: Parametric time warping.
-
RSEIS: Seismic time series analysis tools.
-
sde: Simulation and inference for stochastic differential equations.
-
tiger: Temporally resolved groups of typical differences (errors) between two time series are determined and visualized.
-
tsModel: Time series modeling for air pollution and health.