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.

A complementary forecasting package is the fable package, which implements many of the same models but in a tidyverse framework.

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

164,830

Version

8.22.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Rob Hyndman

Last Published

March 4th, 2024

Functions in forecast (8.22.0)

autoplot.decomposed.ts

Plot time series decomposition components using ggplot
bld.mbb.bootstrap

Box-Cox and Loess-based decomposition bootstrap.
bats

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

Number of trading days in each season
autolayer

Create a ggplot layer appropriate to a particular data type
checkresiduals

Check that residuals from a time series model look like white noise
forecast-package

forecast: Forecasting Functions for Time Series and Linear Models
fitted.ARFIMA

h-step in-sample forecasts for time series models.
forecast.bats

Forecasting using BATS and TBATS models
forecast.ets

Forecasting using ETS models
forecast.HoltWinters

Forecasting using Holt-Winters objects
forecast.fracdiff

Forecasting using ARIMA or ARFIMA models
is.acf

Is an object a particular model type?
is.forecast

Is an object a particular forecast type?
forecast.mts

Forecasting time series
dm.test

Diebold-Mariano test for predictive accuracy
forecast.modelAR

Forecasting using user-defined model
croston

Forecasts for intermittent demand using Croston's method
forecast.StructTS

Forecasting using Structural Time Series models
easter

Easter holidays in each season
dshw

Double-Seasonal Holt-Winters Forecasting
ggmonthplot

Create a seasonal subseries ggplot
gglagplot

Time series lag ggplots
StatForecast

Forecast plot
gas

Australian monthly gas production
forecast.baggedModel

Forecasting using a bagged model
ocsb.test

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

Mean Forecast
autolayer.mts

Automatically create a ggplot for time series objects
gold

Daily morning gold prices
ma

Moving-average smoothing
is.constant

Is an object constant?
baggedModel

Forecasting using a bagged model
ets

Exponential smoothing state space model
nnetar

Neural Network Time Series Forecasts
plot.Arima

Plot characteristic roots from ARIMA model
sindexf

Forecast seasonal index
tsclean

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

Forecasting using stl objects
reexports

Objects exported from other packages
forecast.nnetar

Forecasting using neural network models
residuals.forecast

Residuals for various time series models
nsdiffs

Number of differences required for a seasonally stationary series
splinef

Cubic Spline Forecast
woolyrnq

Quarterly production of woollen yarn in Australia
getResponse

Get response variable from time series model.
ggtsdisplay

Time series display
gghistogram

Histogram with optional normal and kernel density functions
wineind

Australian total wine sales
findfrequency

Find dominant frequency of a time series
mstl

Multiple seasonal decomposition
ndiffs

Number of differences required for a stationary series
rwf

Naive and Random Walk Forecasts
monthdays

Number of days in each season
forecast.mlm

Forecast a multiple linear model with possible time series components
forecast.lm

Forecast a linear model with possible time series components
msts

Multi-Seasonal Time Series
na.interp

Interpolate missing values in a time series
forecast.ts

Forecasting time series
fourier

Fourier terms for modelling seasonality
seasonaldummy

Seasonal dummy variables
taylor

Half-hourly electricity demand
subset.ts

Subsetting a time series
modelAR

Time Series Forecasts with a user-defined model
ggseasonplot

Seasonal plot
seasadj

Seasonal adjustment
tbats

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

Multivariate forecast plot
plot.forecast

Forecast plot
simulate.ets

Simulation from a time series model
tbats.components

Extract components of a TBATS model
ses

Exponential smoothing forecasts
seasonal

Extract components from a time series decomposition
modeldf

Compute model degrees of freedom
tslm

Fit a linear model with time series components
plot.bats

Plot components from BATS model
tsoutliers

Identify and replace outliers in a time series
plot.ets

Plot components from ETS model
thetaf

Theta method forecast
tsCV

Time series cross-validation
BoxCox

Box Cox Transformation
autoplot.acf

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

Fit a fractionally differenced ARFIMA model
arima.errors

Errors from a regression model with ARIMA errors
auto.arima

Fit best ARIMA model to univariate time series
CV

Cross-validation statistic
CVar

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

(Partial) Autocorrelation and Cross-Correlation Function Estimation
arimaorder

Return the order of an ARIMA or ARFIMA model
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
Arima

Fit ARIMA model to univariate time series
accuracy.default

Accuracy measures for a forecast model