Learn R Programming

⚠️There's a newer version (8.23.0) of this package.Take me there.

forecast

The R package forecast provides methods and tools for displaying and analysing univariate time series forecasts including exponential smoothing via state space models and automatic ARIMA modelling.

This package is now retired in favour of the fable package. The forecast package will remain in its current state, and maintained with bug fixes only. For the latest features and development, we recommend forecasting with the fable package.

Installation

You can install the stable version from CRAN.

install.packages('forecast', dependencies = TRUE)

You can install the development version from Github

# install.packages("remotes")
remotes::install_github("robjhyndman/forecast")

Usage

library(forecast)
library(ggplot2)

# ETS forecasts
USAccDeaths %>%
  ets() %>%
  forecast() %>%
  autoplot()

# Automatic ARIMA forecasts
WWWusage %>%
  auto.arima() %>%
  forecast(h=20) %>%
  autoplot()

# ARFIMA forecasts
library(fracdiff)
x <- fracdiff.sim( 100, ma=-.4, d=.3)$series
arfima(x) %>%
  forecast(h=30) %>%
  autoplot()

# Forecasting with STL
USAccDeaths %>%
  stlm(modelfunction=ar) %>%
  forecast(h=36) %>%
  autoplot()

AirPassengers %>%
  stlf(lambda=0) %>%
  autoplot()

USAccDeaths %>%
  stl(s.window='periodic') %>%
  forecast() %>%
  autoplot()

# TBATS forecasts
USAccDeaths %>%
  tbats() %>%
  forecast() %>%
  autoplot()

taylor %>%
  tbats() %>%
  forecast() %>%
  autoplot()

For more information

License

This package is free and open source software, licensed under GPL-3.

Copy Link

Version

Install

install.packages('forecast')

Monthly Downloads

266,957

Version

8.16

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

January 10th, 2022

Functions in forecast (8.16)

BoxCox

Box Cox Transformation
accuracy

Accuracy measures for a forecast model
CV

Cross-validation statistic
arima.errors

Errors from a regression model with ARIMA errors
CVar

k-fold Cross-Validation applied to an autoregressive model
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation
arfima

Fit a fractionally differenced ARFIMA model
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
bats

BATS model (Exponential smoothing state space model with Box-Cox transformation, ARMA errors, Trend and Seasonal components)
Arima

Fit ARIMA model to univariate time series
arimaorder

Return the order of an ARIMA or ARFIMA model
autoplot.acf

ggplot (Partial) Autocorrelation and Cross-Correlation Function Estimation and Plotting
checkresiduals

Check that residuals from a time series model look like white noise
autoplot.decomposed.ts

Plot time series decomposition components using ggplot
forecast

Forecasting time series
fitted.ARFIMA

h-step in-sample forecasts for time series models.
bld.mbb.bootstrap

Box-Cox and Loess-based decomposition bootstrap.
autolayer.mts

Automatically create a ggplot for time series objects
croston

Forecasts for intermittent demand using Croston's method
baggedModel

Forecasting using a bagged model
dm.test

Diebold-Mariano test for predictive accuracy
forecast.baggedModel

Forecasting using a bagged model
forecast.bats

Forecasting using BATS and TBATS models
gghistogram

Histogram with optional normal and kernel density functions
getResponse

Get response variable from time series model.
splinef

Cubic Spline Forecast
subset.ts

Subsetting a time series
auto.arima

Fit best ARIMA model to univariate time series
ets

Exponential smoothing state space model
bizdays

Number of trading days in each season
forecast.mlm

Forecast a multiple linear model with possible time series components
forecast-package

Forecasting Functions for Time Series and Linear Models
forecast.modelAR

Forecasting using user-defined model
autolayer

Create a ggplot layer appropriate to a particular data type
forecast.fracdiff

Forecasting using ARIMA or ARFIMA models
forecast.HoltWinters

Forecasting using Holt-Winters objects
dshw

Double-Seasonal Holt-Winters Forecasting
is.acf

Is an object a particular model type?
findfrequency

Find dominant frequency of a time series
easter

Easter holidays in each season
forecast.StructTS

Forecasting using Structural Time Series models
ggtsdisplay

Time series display
gas

Australian monthly gas production
is.forecast

Is an object a particular forecast type?
gglagplot

Time series lag ggplots
ndiffs

Number of differences required for a stationary series
nnetar

Neural Network Time Series Forecasts
tslm

Fit a linear model with time series components
ggmonthplot

Create a seasonal subseries ggplot
residuals.forecast

Residuals for various time series models
na.interp

Interpolate missing values in a time series
forecast.ets

Forecasting using ETS models
thetaf

Theta method forecast
rwf

Naive and Random Walk Forecasts
seasadj

Seasonal adjustment
tbats.components

Extract components of a TBATS model
autoplot.mforecast

Multivariate forecast plot
StatForecast

Forecast plot
forecast.lm

Forecast a linear model with possible time series components
monthdays

Number of days in each season
forecast.stl

Forecasting using stl objects
modelAR

Time Series Forecasts with a user-defined model
nsdiffs

Number of differences required for a seasonally stationary series
ocsb.test

Osborn, Chui, Smith, and Birchenhall Test for Seasonal Unit Roots
reexports

Objects exported from other packages
simulate.ets

Simulation from a time series model
sindexf

Forecast seasonal index
forecast.mts

Forecasting time series
fourier

Fourier terms for modelling seasonality
tsclean

Identify and replace outliers and missing values in a time series
forecast.nnetar

Forecasting using neural network models
is.constant

Is an object constant?
mstl

Multiple seasonal decomposition
gold

Daily morning gold prices
seasonaldummy

Seasonal dummy variables
seasonal

Extract components from a time series decomposition
msts

Multi-Seasonal Time Series
tsCV

Time series cross-validation
meanf

Mean Forecast
ma

Moving-average smoothing
taylor

Half-hourly electricity demand
tbats

TBATS model (Exponential smoothing state space model with Box-Cox transformation, ARMA errors, Trend and Seasonal components)
plot.Arima

Plot characteristic roots from ARIMA model
plot.ets

Plot components from ETS model
plot.bats

Plot components from BATS model
ggseasonplot

Seasonal plot
ses

Exponential smoothing forecasts
plot.forecast

Forecast plot
tsoutliers

Identify and replace outliers in a time series
woolyrnq

Quarterly production of woollen yarn in Australia
wineind

Australian total wine sales