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

213,748

Version

8.23.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

June 20th, 2024

Functions in forecast (8.23.0)

auto.arima

Fit best ARIMA model to univariate time series
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
autolayer

Create a ggplot layer appropriate to a particular data type
autolayer.mts

Automatically create a ggplot for time series objects
fitted.ARFIMA

h-step in-sample forecasts for time series models.
findfrequency

Find dominant frequency of a time series
autoplot.decomposed.ts

Plot time series decomposition components using ggplot
forecast.fracdiff

Forecasting using ARIMA or ARFIMA models
forecast.mlm

Forecast a multiple linear model with possible time series components
gas

Australian monthly gas production
croston

Forecasts for intermittent demand using Croston's method
gold

Daily morning gold prices
dshw

Double-Seasonal Holt-Winters Forecasting
forecast.stl

Forecasting using stl objects
forecast.StructTS

Forecasting using Structural Time Series models
forecast.modelAR

Forecasting using user-defined model
forecast.baggedModel

Forecasting using a bagged model
forecast.mts

Forecasting time series
ets

Exponential smoothing state space model
forecast.lm

Forecast a linear model with possible time series components
forecast.nnetar

Forecasting using neural network models
easter

Easter holidays in each season
forecast.bats

Forecasting using BATS and TBATS models
dm.test

Diebold-Mariano test for predictive accuracy
is.constant

Is an object constant?
getResponse

Get response variable from time series model.
monthdays

Number of days in each season
is.forecast

Is an object a particular forecast type?
gghistogram

Histogram with optional normal and kernel density functions
ma

Moving-average smoothing
forecast.HoltWinters

Forecasting using Holt-Winters objects
forecast-package

forecast: Forecasting Functions for Time Series and Linear Models
is.acf

Is an object a particular model type?
ggmonthplot

Create a seasonal subseries ggplot
mstl

Multiple seasonal decomposition
gglagplot

Time series lag ggplots
residuals.forecast

Residuals for various time series models
plot.bats

Plot components from BATS model
forecast.ets

Forecasting using ETS models
reexports

Objects exported from other packages
forecast.ts

Forecasting time series
modelAR

Time Series Forecasts with a user-defined model
sindexf

Forecast seasonal index
plot.ets

Plot components from ETS model
modeldf

Compute model degrees of freedom
tslm

Fit a linear model with time series components
meanf

Mean Forecast
nnetar

Neural Network Time Series Forecasts
StatForecast

Forecast plot
nsdiffs

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

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

Exponential smoothing forecasts
fourier

Fourier terms for modelling seasonality
seasonaldummy

Seasonal dummy variables
ndiffs

Number of differences required for a stationary series
msts

Multi-Seasonal Time Series
rwf

Naive and Random Walk Forecasts
autoplot.mforecast

Multivariate forecast plot
na.interp

Interpolate missing values in a time series
seasadj

Seasonal adjustment
plot.forecast

Forecast plot
plot.Arima

Plot characteristic roots from ARIMA model
tbats

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

Extract components of a TBATS model
taylor

Half-hourly electricity demand
subset.ts

Subsetting a time series
ggseasonplot

Seasonal plot
simulate.ets

Simulation from a time series model
wineind

Australian total wine sales
seasonal

Extract components from a time series decomposition
splinef

Cubic Spline Forecast
ggtsdisplay

Time series display
thetaf

Theta method forecast
tsCV

Time series cross-validation
woolyrnq

Quarterly production of woollen yarn in Australia
tsoutliers

Identify and replace outliers in a time series
tsclean

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

Box Cox Transformation
Arima

Fit ARIMA model to univariate time series
bats

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

Fit a fractionally differenced ARFIMA model
arima.errors

Errors from a regression model with ARIMA errors
accuracy.default

Accuracy measures for a forecast model
bizdays

Number of trading days in each season
arimaorder

Return the order of an ARIMA or ARFIMA model
baggedModel

Forecasting using a bagged model
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
CVar

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

Cross-validation statistic
bld.mbb.bootstrap

Box-Cox and Loess-based decomposition bootstrap.
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation