expsmooth {aTSA} | R Documentation |
Performs a simple exponential smoothing for univariate time series with no trend or seasonal pattern.
expsmooth(x, trend = 1, alpha = 0.2, beta = 0.10557, gamma = 0.07168,
lead = 0, plot = TRUE)
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 |
beta |
the smoothing parameter for linear component. The default is |
gamma |
the smoothing parameter for quadratic component. The default is |
lead |
the number of steps ahead for which prediction is required.
The default is |
plot |
a logical value indicating to print the plot of original data v.s smoothed
data. The default is |
Simple exponential smoothing is a weighted average between the most recent
observation and the most recent forecasting, with weights \alpha
and
1 - \alpha
, respectively. To be precise, the smoothing equation of single exponential
smoothing (constant model, trend = 1
) is given by
level[t] = \alpha *x[t] + (1 - \alpha)*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.
A list with class "es"
containing the following components:
estimate |
the smoothed values. |
pred |
the predicted values when |
accurate |
the accurate measurements. |
Missing values are removed before the analysis.
Debin Qiu
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