Learn R Programming

tsforecast (version 1.3.0)

tsesm: Exponential Smoothing Forecasts

Description

The `tsesm` function forecasts future values of a univariate time series using exponential smoothing.

Usage

tsesm(
  x,
  order = c("simple", "holt", "holt-winters"),
  damped = FALSE,
  initial = c("optimal", "simple"),
  type = c("additive", "multiplicative"),
  alpha = NULL,
  beta = NULL,
  gamma = NULL,
  lambda = NULL,
  phi = NULL,
  biasadj = FALSE,
  exp.trend = FALSE,
  seasonal.period = NULL,
  train.prop = 1
)

# S3 method for tsesm print(x, ...)

# S3 method for tsesm summary(object, ...)

Value

A list of class "tsesm" with components:

coef

a vector of smoothing parameters.

m

number of seasons in the series, usually equivalent to the series' frequency obtained by tsfreq.

components

values used for fitting exponential smoothing model.

states

estimated values of all smoothing parameter for each observation.

initstate

initial values of the smoothing parameters.

sigma2

residual variance.

loglik

the maximized log-likelihood, or the approximation to it used.

aic, aicc, bic

the AIC, AICc, and BIC values corresponding to the log-likelihood. Only valid for method = "ML" fits.

x

original series data or a `tsesm` object.

x.time

list of time in which the series values were observed.

x.timegap

time gap between the series and forecasted values.

x.name

name of the time series for which forecasts was requested.

fitted

a vector of fitted series values.

residuals

a vector of the series residuals.

damped

logical value indicating whether damped trend was used or not.

initial

method used for selecting initial state values.

type

indicator of an additive or multiplicative time series.

exp.trend

indicator of the use of exponential trend.

lambda

parameter value of the Box-Cox transformation.

biasadj

indicator of the use of adjusted back-transformed mean for Box-Cox transformations.

series

series name x in match call.

call

the matched call.

error

a list of prediction error estimators, including $ME for mean error, $RMSE for root mean squared error, $MAE for mean absolute error, $MPE for mean percentage error, $MAPE for mean absolute percentage error, $MASE for mean absolute scaled error, $MASE.S for seasonal mean absolute scaled error, and $ACF1 for lag 1 autocorrelation.

model.test

a list of information regarding the prediction of the testing data including `x.test` (part of `x` used for testing), `fitted.test` (predicted values of the testing data), `residuals.test` (prediction error of the testing data), and `error.test` (prediction error measurements based on the testing data). Only available if train.prop is smaller than 1.

Arguments

x

a univariate time series or a `tsesm` object.

order

a specification of the exponential smoothing method. The available options are "simple", "holt", "holt-winters".

damped

logical. If TRUE, a damped trend is used. Default is FALSE.

initial

method used for selecting initial state values. Available options are `optimal` and `simple`. If `optimal`, the initial values are optimised along with the smoothing parameters using `ets`. If `simple`, the initial values are set to values obtained using simple calculations on the first few observations.

type

specify whether the time series is `additive` or `multiplicative`.

alpha

value of smoothing parameter for the level. If NULL, it will be estimated.

beta

value of smoothing parameter for the trend. If NULL, it will be estimated.

gamma

value of smoothing parameter for the seasonal component If NULL, it will be estimated.

lambda

parameter of the Box-Cox transformation. If lambda = "auto", a transformation is automatically selected using `BoxCox.lambda`. The transformation is ignored if NULL. Otherwise, data transformed before model is estimated.

phi

value of damping parameter if damped = TRUE. If NULL, it will be estimated.

biasadj

use adjusted back-transformed mean for Box-Cox transformations. If transformed data is used to produce forecasts and fitted values, a regular back transformation will result in median forecasts. If biasadj == TRUE, an adjustment will be made to produce mean forecasts and fitted values.

exp.trend

logical. If TRUE, an exponential trend is fitted. Otherwise, the trend is (locally) linear. Default is FALSE.

seasonal.period

number of seasons within a seasonal cycle. If NULL, the value of frequency(x) will be taken. Default is NULL.

train.prop

a numerical value specifying the proportion of training data in the series. The value must be between 0 and 1. Default is 1.

...

other printing parameters

object

a `tsesm` object to summarise.

Author

Ka Yui Karl Wu

Details

The `tsesm` function uses the same mechanism for exponential smoothing like `forecast::ses`, `forecast::holt`, and `forecast::hw`. Instead of using three different functions, all of them are integrated in tsesm, and user can choose the method by specifying the value of the order parameter.

The option `simple` is the lowest exponential smoothing order, or the first exponential smoothing order (that's why the parameter is called `order` and not `method`). It can be used to forecast series with only level \((\ell)\) component. The corresponding forecasting formula is given by:

$$\tilde{x}_{t+h|t} = \ell_t = \alpha x_{t-1} + (1-\alpha)\ell_{t-1},$$

where \(\alpha\) is the smoothing parameter for the level component, and \(h\) is the number of periods ahead for forecasting.

With the `holt` option, the second exponential smoothing order can be chosen. It is suitable for the forecasting of series with level \((\ell)\) and trend \((b)\) components.

$$\ell_t = \alpha x_{t} + (1-\alpha)(\ell_{t-1} + b_{t-1})$$

$$b_t = \beta(\ell_{t}-\ell_{t-1}) + (1-\beta)b_{t-1}$$

$$\tilde{x}_{t+h|t} = \ell_{t}+hb_{t}$$

where \(\alpha\) and \(\beta\) are the smoothing parameters for the level and trend components, respectively, \(h\) is the number of periods ahead for forecasting.

The third exponential smoothing order can be specified by the `holt-winters` option. It can be used to forecast time series with level \((\ell)\), trend \((b)\), and seasonal \((s)\) components.

$$\ell_t = \alpha (x_{t} - s_{t-m}) + (1-\alpha)(\ell_{t-1} + b_{t-1})$$

$$b_t = \beta(\ell_{t}-\ell_{t-1}) + (1-\beta)b_{t-1}$$

$$s_t = \gamma(x_{t}-\ell_{t-1}-b_{t-1}) + (1-\gamma)s_{t-m}$$

$$\tilde{x}_{t+h|t} = \ell_{t}+hb_{t}+s_{t+h-m(k+1)}$$

where \(\alpha\), \(\beta\), and \(\gamma\) are the smoothing parameters for the level, trend, and seasonal components, respectively, \(h\) is the number of periods ahead for forecasting, \(m\) is the number of periods within a seasonal cycle, and \(k\) is the integer part of \((h-1)/m\), which ensures that the estimates of the seasonal indices used for forecasting come from the final period of the series.

If train.prop is smaller than 1, the function will only treat the training part of the series as past data. When applying `tsforecast` or `predict`, the forecast will start after the end of the training part of the original series.

References

Box, G. E. P., & Jenkins, G. M. (1970). Time series analysis: Forecasting and control. Holden-Day.

Hyndman, R. J., Athanasopoulos, G. (2021). Forecasting: Principles and practice (3rd ed.). OTexts.
https://otexts.com/fpp3/

Hyndman, R. J., Athanasopoulos, G., Bergmeir, C., Caceres, G., Chhay, L., O'Hara-Wild, M., Petropoulos, F., Razbash, S., Wang, E., Yasmeen, F. (2025).
forecast: Forecasting functions for time series and linear models. R package version 8.24.0,
https://pkg.robjhyndman.com/forecast/.

Hyndman, R. J., Khandakar, Y. (2008). Automatic time series forecasting: the forecast package for R. Journal of Statistical Software, 27(3), 1-22.

Examples

Run this code
tsesm(airport$Travellers, order = "simple")
tsesm(airport$Travellers, order = "holt")
tsesm(airport$Travellers, order = "holt-winters")

Run the code above in your browser using DataLab