Learn R Programming

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("pak")
pak::pak("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 = -0.4, d = 0.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

428,345

Version

9.0.1

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Rob Hyndman

Last Published

February 14th, 2026

Functions in forecast (9.0.1)

findfrequency

Find dominant frequency of a time series
bats

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

forecast: Forecasting Functions for Time Series and Linear Models
dm.test

Diebold-Mariano test for predictive accuracy
forecast.fracdiff

Forecasting using ARIMA or ARFIMA models
dshw

Double-Seasonal Holt-Winters Forecasting
easter

Easter holidays in each season
forecast.nnetar

Forecasting using neural network models
forecast.ets

Forecasting using ETS models
ets

Exponential smoothing state space model
forecast.mts

Forecasting time series
forecast.croston_model

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

Forecasting using Holt-Winters objects
forecast.modelAR

Forecasting using user-defined model
forecast.StructTS

Forecasting using Structural Time Series models
forecast.mlm

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

Mean Forecast
forecast.lm

Forecast a linear model with possible time series components
gas

Australian monthly gas production
fitted.ARFIMA

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

Forecasting using BATS and TBATS models
forecast.baggedModel

Forecasting using a bagged model
forecast.ts

Forecasting time series
gghistogram

Histogram with optional normal and kernel density functions
fourier

Fourier terms for modelling seasonality
getResponse

Get response variable from time series model.
forecast.stl

Forecasting using stl objects
modeldf

Compute model degrees of freedom
ma

Moving-average smoothing
modelAR

Time Series Forecasts with a user-defined model
forecast.theta_model

Theta method forecasts.
mean_model

Mean Forecast Model
gglagplot

Time series lag ggplots
ggmonthplot

Create a seasonal subseries ggplot
nnetar

Neural Network Time Series Forecasts
ndiffs

Number of differences required for a stationary series
plot.bats

Plot components from BATS model
plot.Arima

Plot characteristic roots from ARIMA model
is.forecast

Is an object a particular forecast type?
is.acf

Is an object a particular model type?
na.interp

Interpolate missing values in a time series
StatForecast

Forecast plot
msts

Multi-Seasonal Time Series
autoplot.mforecast

Multivariate forecast plot
mstl

Multiple seasonal decomposition
monthdays

Number of days in each season
ggseasonplot

Seasonal plot
seasonaldummy

Seasonal dummy variables
is.constant

Is an object constant?
forecast.rw_model

Naive and Random Walk Forecasts
gold

Daily morning gold prices
forecast.spline_model

Returns local linear forecasts and prediction intervals using cubic smoothing splines estimated with spline_model().
rw_model

Random walk model
sindexf

Forecast seasonal index
stlm

Forecasting model using STL with a generative time series model
residuals.forecast

Residuals for various time series models
reexports

Objects exported from other packages
plot.ets

Plot components from ETS model
plot.forecast

Forecast plot
nsdiffs

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

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

Time series display
tslm

Fit a linear model with time series components
spline_model

Cubic spline stochastic model
seasadj

Seasonal adjustment
tsoutliers

Identify and replace outliers in a time series
subset.ts

Subsetting a time series
theta_model

Theta model
tbats

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

Time series cross-validation
tbats.components

Extract components of a TBATS model
simulate.ets

Simulation from a time series model
tsclean

Identify and replace outliers and missing values in a time series
ses

Exponential smoothing forecasts
taylor

Half-hourly electricity demand
wineind

Australian total wine sales
woolyrnq

Quarterly production of woollen yarn in Australia
seasonal

Extract components from a time series decomposition
CV

Cross-validation statistic
accuracy.forecast

Accuracy measures for a forecast model
Arima

Fit ARIMA model to univariate time series
arima.errors

Errors from a regression model with ARIMA errors
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation
arfima

Fit a fractionally differenced ARFIMA model
CVar

k-fold Cross-Validation applied to an autoregressive model
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
arimaorder

Return the order of an ARIMA or ARFIMA model
checkresiduals

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

Plot time series decomposition components using ggplot
autolayer.mts

Automatically create a ggplot for time series objects
autoplot.acf

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

Box Cox Transformation
bizdays

Number of trading days in each season
auto.arima

Fit best ARIMA model to univariate time series
baggedModel

Forecasting using a bagged model
croston_model

Croston forecast model
bld.mbb.bootstrap

Box-Cox and Loess-based decomposition bootstrap.