Skip to contents

Package

Forecast package

forecast-package
forecast: Forecasting Functions for Time Series and Linear Models

Time series analysis

Functions for working with time series

bizdays()
Number of trading days in each season
bld.mbb.bootstrap()
Box-Cox and Loess-based decomposition bootstrap.
BoxCox() InvBoxCox()
Box Cox Transformation
BoxCox.lambda()
Automatic selection of Box Cox transformation parameter
easter()
Easter holidays in each season
findfrequency()
Find dominant frequency of a time series
fourier() fourierf()
Fourier terms for modelling seasonality
is.constant()
Is an object constant?
monthdays()
Number of days in each season
msts()
Multi-Seasonal Time Series
na.interp()
Interpolate missing values in a time series
ndiffs()
Number of differences required for a stationary series
nsdiffs()
Number of differences required for a seasonally stationary series
ocsb.test()
Osborn, Chui, Smith, and Birchenhall Test for Seasonal Unit Roots
seasonaldummy() seasonaldummyf()
Seasonal dummy variables
subset(<ts>) subset(<msts>)
Subsetting a time series
tsclean()
Identify and replace outliers and missing values in a time series
tsoutliers()
Identify and replace outliers in a time series

Seasonal decomposition

Functions used in seasonal decomposition

ma()
Moving-average smoothing
mstl()
Multiple seasonal decomposition
seasonal() trendcycle() remainder()
Extract components from a time series decomposition
seasadj()
Seasonal adjustment

Modelling

Functions for estimating time series models

arfima()
Fit a fractionally differenced ARFIMA model
Arima()
Fit ARIMA model to univariate time series
auto.arima()
Fit best ARIMA model to univariate time series
baggedModel() baggedETS()
Forecasting using a bagged model
bats()
BATS model (Exponential smoothing state space model with Box-Cox transformation, ARMA errors, Trend and Seasonal components)
croston_model()
Croston forecast model
ets()
Exponential smoothing state space model
mean_model()
Mean Forecast Model
nnetar()
Neural Network Time Series Forecasts
rw_model()
Random walk model
forecast(<stl>) stlm() forecast(<stlm>) stlf()
Forecasting using stl objects
tbats()
TBATS model (Exponential smoothing state space model with Box-Cox transformation, ARMA errors, Trend and Seasonal components)
tslm()
Fit a linear model with time series components

Forecasting

Functions for producing forecasts

forecast(<croston_model>) croston()
Forecasts for intermittent demand using Croston's method
dshw()
Double-Seasonal Holt-Winters Forecasting
ses() holt() hw()
Exponential smoothing forecasts
forecast(<mean_model>) meanf()
Mean Forecast
modelAR()
Time Series Forecasts with a user-defined model
forecast(<rw_model>) rwf() naive() snaive()
Naive and Random Walk Forecasts
sindexf()
Forecast seasonal index
splinef()
Cubic Spline Forecast
forecast(<stl>) stlm() forecast(<stlm>) stlf()
Forecasting using stl objects
thetaf()
Theta method forecast
forecast(<fracdiff>) forecast(<Arima>) forecast(<ar>)
Forecasting using ARIMA or ARFIMA models
forecast(<baggedModel>)
Forecasting using a bagged model
forecast(<bats>) forecast(<tbats>)
Forecasting using BATS and TBATS models
forecast(<ets>)
Forecasting using ETS models
forecast(<HoltWinters>)
Forecasting using Holt-Winters objects
forecast(<lm>)
Forecast a linear model with possible time series components
forecast(<mlm>)
Forecast a multiple linear model with possible time series components
forecast(<modelAR>)
Forecasting using user-defined model
forecast(<mts>)
Forecasting time series
forecast(<nnetar>)
Forecasting using neural network models
forecast(<StructTS>)
Forecasting using Structural Time Series models
forecast(<ts>) forecast(<default>) print(<forecast>)
Forecasting time series
is.forecast() is.mforecast() is.splineforecast()
Is an object a particular forecast type?

Plotting

Functions for plotting time series and forecasts

Acf() Pacf() Ccf() taperedacf() taperedpacf()
(Partial) Autocorrelation and Cross-Correlation Function Estimation
checkresiduals()
Check that residuals from a time series model look like white noise
autoplot(<acf>) ggAcf() ggPacf() ggCcf() autoplot(<mpacf>) ggtaperedacf() ggtaperedpacf()
ggplot (Partial) Autocorrelation and Cross-Correlation Function Estimation and Plotting
gghistogram()
Histogram with optional normal and kernel density functions
gglagplot() gglagchull()
Time series lag ggplots
ggseasonplot() seasonplot()
Seasonal plot
ggmonthplot() ggsubseriesplot()
Create a seasonal subseries ggplot
is.acf() is.Arima() is.baggedModel() is.bats() is.ets() is.modelAR() is.stlm() is.nnetar() is.nnetarmodels()
Is an object a particular model type?
autolayer()
Create a ggplot layer appropriate to a particular data type
autolayer(<mts>) autolayer(<msts>) autolayer(<ts>) autoplot(<ts>) autoplot(<mts>) autoplot(<msts>) fortify(<ts>)
Automatically create a ggplot for time series objects
plot(<forecast>) autoplot(<forecast>) autoplot(<splineforecast>) autolayer(<forecast>) plot(<splineforecast>)
Forecast plot
autoplot(<mforecast>) autolayer(<mforecast>) plot(<mforecast>)
Multivariate forecast plot
autoplot(<decomposed.ts>) autoplot(<stl>) autoplot(<StructTS>) autoplot(<seas>) autoplot(<mstl>)
Plot time series decomposition components using ggplot
plot(<Arima>) plot(<ar>) autoplot(<Arima>) autoplot(<ar>)
Plot characteristic roots from ARIMA model
plot(<bats>) autoplot(<tbats>) autoplot(<bats>) plot(<tbats>)
Plot components from BATS model
plot(<ets>) autoplot(<ets>)
Plot components from ETS model
ggtsdisplay() tsdisplay()
Time series display
StatForecast GeomForecast geom_forecast()
Forecast plot

Model analysis

Functions for analysing time series models

arima.errors()
Errors from a regression model with ARIMA errors
arimaorder()
Return the order of an ARIMA or ARFIMA model
checkresiduals()
Check that residuals from a time series model look like white noise
getResponse()
Get response variable from time series model.
modeldf()
Compute model degrees of freedom
fitted(<ARFIMA>) fitted(<Arima>) fitted(<ar>) fitted(<bats>) fitted(<ets>) fitted(<modelAR>) fitted(<nnetar>) fitted(<tbats>)
h-step in-sample forecasts for time series models.
residuals(<forecast>) residuals(<ar>) residuals(<Arima>) residuals(<bats>) residuals(<tbats>) residuals(<ets>) residuals(<ARFIMA>) residuals(<nnetar>) residuals(<stlm>) residuals(<tslm>)
Residuals for various time series models
simulate(<ets>) simulate(<Arima>) simulate(<ar>) simulate(<rw_model>) simulate(<fracdiff>) simulate(<nnetar>) simulate(<modelAR>) simulate(<tbats>)
Simulation from a time series model
tbats.components()
Extract components of a TBATS model

Forecast evaluation

Functions used for evaluating forecasts

accuracy(<default>)
Accuracy measures for a forecast model
CV()
Cross-validation statistic
CVar()
k-fold Cross-Validation applied to an autoregressive model
dm.test()
Diebold-Mariano test for predictive accuracy
tsCV()
Time series cross-validation

Data

Data sets included in the package

gas
Australian monthly gas production
gold
Daily morning gold prices
taylor
Half-hourly electricity demand
wineind
Australian total wine sales
woolyrnq
Quarterly production of woollen yarn in Australia