Learn R Programming

⚠️There's a newer version (8.24.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

191,858

Version

7.1

License

GPL (>= 2)

Issues

Pull Requests

Stars

Forks

Maintainer

Rob Hyndman

Last Published

April 14th, 2016

Functions in forecast (7.1)

arfima

Fit a fractionally differenced ARFIMA model
CV

Cross-validation statistic
gold

Daily morning gold prices
nnetar

Neural Network Time Series Forecasts
forecast

Forecasting time series
fitted.Arima

One-step in-sample forecasts using ARIMA models
tslm

Fit a linear model with time series components
dshw

Double-Seasonal Holt-Winters Forecasting
splinef

Cubic Spline Forecast
tbats.components

Extract components of a TBATS model
subset.ts

Subsetting a time series
logLik.ets

Log-Likelihood of an ets object
arima.errors

ARIMA errors
msts

Multi-Seasonal Time Series
Arima

Fit ARIMA model to univariate time series
woolyrnq

Quarterly production of woollen yarn in Australia
thetaf

Theta method forecast
tsdisplay

Time series display
is.forecast

Is an object a particular forecast type?
forecast.Arima

Forecasting using ARIMA or ARFIMA models
fortify.forecast

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

Multivariate forecast plot
plot.ets

Plot components from ETS model
naive

Naive forecasts
na.interp

Interpolate missing values in a time series
rwf

Random Walk Forecast
arimaorder

Return the order of an ARIMA or ARFIMA model
is.ets

Is an object a particular model type?
plot.Arima

Plot characteristic roots from ARIMA model
seasonplot

Seasonal plot
seasadj

Seasonal adjustment
seasonaldummy

Seasonal dummy variables
plot.forecast

Forecast plot
forecast.HoltWinters

Forecasting using Holt-Winters objects
forecast.lm

Forecast a linear model with possible time series components
tbats

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

Number of differences required for a stationary series
ets

Exponential smoothing state space model
taylor

Half-hourly electricity demand
autoplot.stl

ggplot STL object
gas

Australian monthly gas production
croston

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

Simulation from a time series model
BoxCox

Box Cox Transformation
plot.bats

Plot components from BATS model
geom_forecast

Forecast plot
sindexf

Forecast seasonal index
bizdays

Number of trading days in each season
easter

Easter holidays in each season
ggmonthplot

Create a seasonal subseries ggplot
Acf

(Partial) Autocorrelation and Cross-Correlation Function Estimation
mforecast

Forecasting time series
autoplot.decomposed.ts

ggplot of a decomposed time series object
forecast.ets

Forecasting using ETS models
monthdays

Number of days in each season
auto.arima

Fit best ARIMA model to univariate time series
tsoutliers

Identify and replace outliers in a time series
is.constant

Is an object constant?
getResponse

Get response variable from time series model.
forecast.bats

Forecasting using BATS and TBATS models
forecast.StructTS

Forecasting using Structural Time Series models
forecast.stl

Forecasting using stl objects
bats

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

Australian total wine sales
autoplot.acf

ggplot (Partial) Autocorrelation and Cross-Correlation Function Estimation
tsclean

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

Accuracy measures for forecast model
ma

Moving-average smoothing
autoplot.ts

Automatically create a ggplot for time series objects
findfrequency

Find dominant frequency of a time series
BoxCox.lambda

Automatic selection of Box Cox transformation parameter
meanf

Mean Forecast
ses

Exponential smoothing forecasts
forecast.mlm

Forecast a multiple linear model with possible time series components
dm.test

Diebold-Mariano test for predictive accuracy