theta: Theta method

View source: R/theta.R

thetaR Documentation

Theta method

Description

Estimate Theta method.

Forecast with fitted Theta method.

Produce a plot of the fitted Theta method.

Usage

theta(
  y,
  m = NULL,
  sign.level = 0.05,
  cost0 = c("MSE", "MdSE", "MAE", "MdAE"),
  cost2 = c("MSE", "MdSE", "MAE", "MdAE"),
  costs = c("MSE", "MdSE", "MAE", "MdAE"),
  multiplicative = c("multiplicative", "additive", "auto"),
  cma = NULL,
  outliers = NULL
)

## S3 method for class 'theta'
forecast(object, h = NULL, ...)

## S3 method for class 'theta'
plot(x, thetalines = c(TRUE, FALSE), ...)

theta.thief(y, h = NULL, ...)

Arguments

y

input time series. Can be ts object.

m

seasonal period. If y is a ts object then the default is its frequency.

sign.level

significance level for trend and seasonality tests.

cost0

cost function of theta0 line. Can be:

  • "MSE": mean squared error.

  • "MdSE": median squared error.

  • "MAE": mean absolute error.

  • "MdAE": median absolute error.

cost2

cost function of theta2 line. Same options as cost0.

costs

cost function of seasonal element. Same options as cost0.

multiplicative

type of seasonal decomposition. This can be "multiplicative", "additive" or "auto". If y contains non-positive values then this is forced to "additive".

cma

input precalculated level/trend for the analysis. Use NULL to estimate internally.

outliers

provide vector of location of observations that are considered outliers (see residout). These will be considered in the estimation of theta0. For no outliers use NULL.

object

object of class theta.

h

forecast horizon. If h is NULL, then the horizon is set equal to the the seasonal frequency.

...

additional arguments passed to functions.

x

object of class theta.

thetalines

if TRUE, then theta lines are included in the plot.

Details

This implementation of the Theta method tests automatically for seasonality and trend. Seasonal decomposition can be done either additively or multiplicatively and the seasonality is treated as a pure seasonal model. The various Theta components can be optimised using different cost functions. The originally proposed Theta method always assumed multiplicative seasonality and presence of trend, while all theta lines were optimised using MSE and seasonality was estimated using classical decomposition.

Value

An object of class theta, containing:

  • "method": "Theta".

  • "y": the input time series.

  • "m": seasonal periods.

  • "exist": Statistical testing results, exist[1] is the result for trend, exist[2] is for season.

  • "multiplicative": If TRUE, then seasonality is modelled multiplicatively.

  • "theta0": fitted theta0 line values.

  • "theta2": fitted theta2 line values.

  • "season": fitted season values.

  • "x.out": modelled outliers.

  • "cost": cost functions for theta0, theta2 and season components.

  • "a": SES parameters of theta2.

  • "b": regression parameters of theta0.

  • "p": coefficients of outliers from theta0 and theta2 estimation.

  • "g": pure seasonal exponential smoothing parameters.

  • "fitted": fitted values.

  • "residuals": in-sample residuals.

  • "MSE": in-sample Mean Squared Error.

Functions

  • theta.thief(): Wrapper function to use Theta with thief.

Author(s)

Nikolaos Kourentzes, nikolaos@kourentzes.com.

References

  • The original Theta method was proposed by: Assimakopoulos, V., & Nikolopoulos, K. (2000). The theta model: a decomposition approach to forecasting. International journal of forecasting, 16(4), 521-530. See details in how the implementation here differs.

  • The THieF forecasting methodology used for theta.thief is proposed by: Athanasopoulos, G., Hyndman, R. J., Kourentzes, N., & Petropoulos, F. (2017). Forecasting with temporal hierarchies. European Journal of Operational Research, 262(1), 60-74.

Examples

fit <- theta(referrals)
plot(fit)

forecast.theta(fit,h=12) # Or simply use forecast(fit)

## Not run: 
library(thief)
thief(referrals,forecastfunction=theta.thief)

## End(Not run)


tsutils documentation built on Nov. 15, 2023, 1:08 a.m.