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 on R 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)

# ETS forecasts
fit <- ets(USAccDeaths)
plot(forecast(fit))

# Automatic ARIMA forecasts
fit <- auto.arima(WWWusage)
plot(forecast(fit, h=20))

# ARFIMA forecasts
library(fracdiff)
x <- fracdiff.sim( 100, ma=-.4, d=.3)$series
fit <- arfima(x)
plot(forecast(fit, h=30))

# Forecasting with STL
tsmod <- stlm(USAccDeaths, modelfunction=ar)
plot(forecast(tsmod, h=36))

plot(stlf(AirPassengers, lambda=0))

decomp <- stl(USAccDeaths,s.window="periodic")
plot(forecast(decomp))

# TBATS forecasts
fit <- tbats(USAccDeaths)
plot(forecast(fit))

taylor.fit <- tbats(taylor)
plot(forecast(taylor.fit))

License

This package is free and open source software, licensed under GPL (>= 2).

Copy Link

Version

Install

install.packages('forecast')

Monthly Downloads

213,748

Version

7.3

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

October 13th, 2016

Functions in forecast (7.3)

autoplot.decomposed.ts

ggplot of a decomposed time series object
arima.errors

ARIMA errors
autoplot.acf

ggplot (Partial) Autocorrelation and Cross-Correlation Function Estimation
auto.arima

Fit best ARIMA model to univariate time series
accuracy

Accuracy measures for forecast model
arimaorder

Return the order of an ARIMA or ARFIMA model
arfima

Fit a fractionally differenced ARFIMA model
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation
Arima

Fit ARIMA model to univariate time series
autoplot.stl

ggplot STL object
CV

Cross-validation statistic
dm.test

Diebold-Mariano test for predictive accuracy
bizdays

Number of trading days in each season
dshw

Double-Seasonal Holt-Winters Forecasting
BoxCox

Box Cox Transformation
autoplot.ts

Automatically create a ggplot for time series objects
easter

Easter holidays in each season
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
bats

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

Forecasts for intermittent demand using Croston's method
fitted.tbats

h-step in-sample forecasts using tbats models
fitted.Arima

h-step in-sample forecasts using ARIMA models
ets

Exponential smoothing state space model
forecast.ets

Forecasting using ETS models
fitted.bats

h-step in-sample forecasts using bats models
findfrequency

Find dominant frequency of a time series
forecast.bats

Forecasting using BATS and TBATS models
fitted.ets

h-step in-sample forecasts using ets models
forecast.Arima

Forecasting using ARIMA or ARFIMA models
fitted.nnetar

h-step in-sample forecasts using nnetar models
forecast.StructTS

Forecasting using Structural Time Series models
forecast.mlm

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

Forecasting using Holt-Winters objects
forecast.lm

Forecast a linear model with possible time series components
gas

Australian monthly gas production
forecast.stl

Forecasting using stl objects
forecast.nnetar

Forecasting using neural network models
fortify.forecast

Fortify a forecast object to data.frame for ggplot
plot.forecast

Forecast plot
forecast

Forecasting time series
ggmonthplot

Create a seasonal subseries ggplot
gglagplot

Time series lag ggplots
geom_forecast

Forecast plot
is.constant

Is an object constant?
gold

Daily morning gold prices
is.ets

Is an object a particular model type?
na.interp

Interpolate missing values in a time series
naive

Naive and Random Walk Forecasts
is.forecast

Is an object a particular forecast type?
getResponse

Get response variable from time series model.
ma

Moving-average smoothing
logLik.ets

Log-Likelihood of an ets object
plot.Arima

Plot characteristic roots from ARIMA model
wineind

Australian total wine sales
seasonaldummy

Seasonal dummy variables
plot.bats

Plot components from BATS model
seasadj

Seasonal adjustment
woolyrnq

Quarterly production of woollen yarn in Australia
sindexf

Forecast seasonal index
simulate.ets

Simulation from a time series model
taylor

Half-hourly electricity demand
tbats.components

Extract components of a TBATS model
plot.ets

Plot components from ETS model
plot.mforecast

Multivariate forecast plot
tsoutliers

Identify and replace outliers in a time series
monthdays

Number of days in each season
tslm

Fit a linear model with time series components
msts

Multi-Seasonal Time Series
subset.ts

Subsetting a time series
splinef

Cubic Spline Forecast
tbats

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

Theta method forecast
tsclean

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

Number of differences required for a stationary series
tsdisplay

Time series display
nnetar

Neural Network Time Series Forecasts
mforecast

Forecasting time series
seasonplot

Seasonal plot
meanf

Mean Forecast
ses

Exponential smoothing forecasts