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

266,957

Version

8.8

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

August 2nd, 2019

Functions in forecast (8.8)

autoplot.acf

ggplot (Partial) Autocorrelation and Cross-Correlation Function Estimation and Plotting
autolayer.mts

Automatically create a ggplot for time series objects
Arima

Fit ARIMA model to univariate time series
baggedModel

Forecasting using a bagged model
checkresiduals

Check that residuals from a time series model look like white noise
bld.mbb.bootstrap

Box-Cox and Loess-based decomposition bootstrap.
dshw

Double-Seasonal Holt-Winters Forecasting
easter

Easter holidays in each season
autolayer

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

Fit best ARIMA model to univariate time series
autoplot.decomposed.ts

Plot time series decomposition components using ggplot
ets

Exponential smoothing state space model
forecast.baggedModel

Forecasting using a bagged model
findfrequency

Find dominant frequency of a time series
forecast.mts

Forecasting time series
forecast.nnetar

Forecasting using neural network models
fitted.fracdiff

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

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

Forecasting using BATS and TBATS models
bizdays

Number of trading days in each season
is.constant

Is an object constant?
gold

Daily morning gold prices
ma

Moving-average smoothing
forecast.stl

Forecasting using stl objects
meanf

Mean Forecast
fourier

Fourier terms for modelling seasonality
dm.test

Diebold-Mariano test for predictive accuracy
croston

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

Forecasting using ETS models
forecast-package

Forecasting Functions for Time Series and Linear Models
forecast

Forecasting time series
forecast.StructTS

Forecasting using Structural Time Series models
getResponse

Get response variable from time series model.
autoplot.mforecast

Multivariate forecast plot
gghistogram

Histogram with optional normal and kernel density functions
reexports

Objects exported from other packages
mstl

Multiple seasonal decomposition
ggmonthplot

Create a seasonal subseries ggplot
is.acf

Is an object a particular model type?
taylor

Half-hourly electricity demand
plot.Arima

Plot characteristic roots from ARIMA model
gglagplot

Time series lag ggplots
is.forecast

Is an object a particular forecast type?
forecast.fracdiff

Forecasting using ARIMA or ARFIMA models
tbats

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

Australian monthly gas production
forecast.mlm

Forecast a multiple linear model with possible time series components
nsdiffs

Number of differences required for a seasonally stationary series
na.interp

Interpolate missing values in a time series
forecast.modelAR

Forecasting using user-defined model
rwf

Naive and Random Walk Forecasts
StatForecast

Forecast plot
forecast.HoltWinters

Forecasting using Holt-Winters objects
plot.bats

Plot components from BATS model
forecast.lm

Forecast a linear model with possible time series components
ocsb.test

Osborn, Chui, Smith, and Birchenhall Test for Seasonal Unit Roots
plot.ets

Plot components from ETS model
modelAR

Time Series Forecasts with a user-defined model
monthdays

Number of days in each season
plot.forecast

Forecast plot
ggseasonplot

Seasonal plot
tbats.components

Extract components of a TBATS model
seasonal

Extract components from a time series decomposition
ses

Exponential smoothing forecasts
seasonaldummy

Seasonal dummy variables
msts

Multi-Seasonal Time Series
tsclean

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

Cubic Spline Forecast
ndiffs

Number of differences required for a stationary series
tsCV

Time series cross-validation
subset.ts

Subsetting a time series
simulate.ets

Simulation from a time series model
nnetar

Neural Network Time Series Forecasts
residuals.forecast

Residuals for various time series models
sindexf

Forecast seasonal index
ggtsdisplay

Time series display
thetaf

Theta method forecast
tslm

Fit a linear model with time series components
wineind

Australian total wine sales
tsoutliers

Identify and replace outliers in a time series
seasadj

Seasonal adjustment
woolyrnq

Quarterly production of woollen yarn in Australia
arimaorder

Return the order of an ARIMA or ARFIMA model
arfima

Fit a fractionally differenced ARFIMA model
arima.errors

Errors from a regression model with ARIMA errors
CV

Cross-validation statistic
CVar

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

Accuracy measures for a forecast model
BoxCox

Box Cox Transformation
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation