Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

expsmooth

Simple Exponential Smoothing


Description

Performs a simple exponential smoothing for univariate time series with no trend or seasonal pattern.

Usage

expsmooth(x, trend = 1, alpha = 0.2, beta = 0.10557, gamma = 0.07168,
  lead = 0, plot = TRUE)

Arguments

x

a numeric vector or univariate time series.

trend

the type of trend. See details.

alpha

the smoothing parameter for constant component. The default is 0.2.

beta

the smoothing parameter for linear component. The default is 0.10557.

gamma

the smoothing parameter for quadratic component. The default is 0.07168.

lead

the number of steps ahead for which prediction is required. The default is 0.

plot

a logical value indicating to print the plot of original data v.s smoothed data. The default is TRUE.

Details

Simple exponential smoothing is a weighted average between the most recent observation and the most recent forecasting, with weights α and 1 - α, respectively. To be precise, the smoothing equation of single exponential smoothing (constant model, trend = 1) is given by

level[t] = α *x[t] + (1 - α)*level[t-1],

and the forecasting equation is

hat{x}[t+1|t] = level[t],

for t = 1,...,n. The initial value level[0] = x[1]. For example, hat{x}[1|0] = level[0], hat{x}[2|1] = level[1],..., etc.

Let x1[t] be the smoothed values of single exponential smoothing. The double exponential smoothing (trend = 2, a linear model) is to apply a single exponential smoothing again to the smoothed sequence x1[t], with a new smoothing parameter beta. Similarly, we denote the smoothed values of double exponential smoothing to be x2[t]. The triple exponential smoothing (trend = 3, a quadratic model) is to apply the single exponential smoothing to the smoothed sequence x2[t] with a new smoothing parameter gamma. The default smoothing parameters (weights) alpha, beta, gamma are taken from the equation 1 - 0.8^{1/trend} respectively, which is similar to the FORECAST procedure in SAS.

Value

A list with class "es" containing the following components:

estimate

the smoothed values.

pred

the predicted values when lead > 0.

accurate

the accurate measurements.

Note

Missing values are removed before the analysis.

Author(s)

Debin Qiu

See Also

Examples

x <- rnorm(100)
es <- expsmooth(x) # trend = 1: a constant model
plot(x,type = "l")
lines(es$estimate,col = 2)
expsmooth(x,trend = 2) # trend = 2: a linear model
expsmooth(x,trend = 3) # trend = 3: a quadratic model

aTSA

Alternative Time Series Analysis

v3.1.2
GPL-2 | GPL-3
Authors
Debin Qiu
Initial release
2015-06-19

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.