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.

Installation

You can install the stable version from CRAN.

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

You can install the development version from Github

# install.packages("devtools")
devtools::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.7

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

April 29th, 2019

Functions in forecast (8.7)

ets

Exponential smoothing state space model
autoplot.decomposed.ts

Plot time series decomposition components using ggplot
gghistogram

Histogram with optional normal and kernel density functions
autoplot.acf

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

Number of trading days in each season
dm.test

Diebold-Mariano test for predictive accuracy
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation
Arima

Fit ARIMA model to univariate time series
getResponse

Get response variable from time series model.
croston

Forecasts for intermittent demand using Croston's method
modelAR

Time Series Forecasts with a user-defined model
monthdays

Number of days in each season
autoplot.mforecast

Multivariate forecast plot
reexports

Objects exported from other packages
BoxCox

Box Cox Transformation
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
findfrequency

Find dominant frequency of a time series
bld.mbb.bootstrap

Box-Cox and Loess-based decomposition bootstrap.
dshw

Double-Seasonal Holt-Winters Forecasting
simulate.ets

Simulation from a time series model
checkresiduals

Check that residuals from a time series model look like white noise
sindexf

Forecast seasonal index
forecast

Forecasting time series
easter

Easter holidays in each season
ggtsdisplay

Time series display
tslm

Fit a linear model with time series components
forecast.ets

Forecasting using ETS models
forecast.mts

Forecasting time series
fitted.fracdiff

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

Forecasting Functions for Time Series and Linear Models
forecast.nnetar

Forecasting using neural network models
forecast.lm

Forecast a linear model with possible time series components
woolyrnq

Quarterly production of woollen yarn in Australia
gas

Australian monthly gas production
na.interp

Interpolate missing values in a time series
rwf

Naive and Random Walk Forecasts
forecast.StructTS

Forecasting using Structural Time Series models
CV

Cross-validation statistic
StatForecast

Forecast plot
mstl

Multiple seasonal decomposition
forecast.mlm

Forecast a multiple linear model with possible time series components
gglagplot

Time series lag ggplots
msts

Multi-Seasonal Time Series
CVar

k-fold Cross-Validation applied to an autoregressive model
forecast.modelAR

Forecasting using user-defined model
autolayer

Create a ggplot layer appropriate to a particular data type
auto.arima

Fit best ARIMA model to univariate time series
ggmonthplot

Create a seasonal subseries ggplot
is.acf

Is an object a particular model type?
ndiffs

Number of differences required for a stationary series
nnetar

Neural Network Time Series Forecasts
ggseasonplot

Seasonal plot
ses

Exponential smoothing forecasts
forecast.stl

Forecasting using stl objects
nsdiffs

Number of differences required for a seasonally stationary series
tsoutliers

Identify and replace outliers in a time series
fourier

Fourier terms for modelling seasonality
is.forecast

Is an object a particular forecast type?
plot.Arima

Plot characteristic roots from ARIMA model
forecast.fracdiff

Forecasting using ARIMA or ARFIMA models
ma

Moving-average smoothing
meanf

Mean Forecast
plot.bats

Plot components from BATS model
seasonal

Extract components from a time series decomposition
splinef

Cubic Spline Forecast
wineind

Australian total wine sales
ocsb.test

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

Seasonal dummy variables
residuals.forecast

Residuals for various time series models
taylor

Half-hourly electricity demand
subset.ts

Subsetting a time series
forecast.HoltWinters

Forecasting using Holt-Winters objects
seasadj

Seasonal adjustment
tsCV

Time series cross-validation
tbats

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

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

Forecasting using a bagged model
forecast.bats

Forecasting using BATS and TBATS models
gold

Daily morning gold prices
is.constant

Is an object constant?
plot.ets

Plot components from ETS model
plot.forecast

Forecast plot
tbats.components

Extract components of a TBATS model
thetaf

Theta method forecast
arima.errors

Errors from a regression model with ARIMA errors
arimaorder

Return the order of an ARIMA or ARFIMA model
bats

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

Accuracy measures for a forecast model
arfima

Fit a fractionally differenced ARFIMA model
autolayer.mts

Automatically create a ggplot for time series objects
baggedModel

Forecasting using a bagged model