esmooth: Exponential smoothing

Description Usage Arguments Examples

Description

Exponential smoothing of (possibly non-equidistant) time series.

Usage

1
2
3
4
5
ses(yvar, tvar = NULL, alpha = NULL, init = NULL, fit = TRUE,
  n.ahead = 1, filter. = NULL)

des(yvar, tvar = NULL, alpha = NULL, init = NULL, fit = TRUE,
  n.ahead = 1, filter. = NULL)

Arguments

yvar

Time series, a numeric vector.

tvar

Time variable, a numeric vector. Defaults to 1, 2, ...

alpha

Smoothing parameter; if NULL, alpha will be estimated by minimizing a prediction error.

init

Intial value for the first smoothed value; defaults to the average of the first three observations.

fit

Should smoothing parameter be fitted to data?

filter.

Experimental feature, please do not use.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
yvar <- aggregate(co2)
tvar <- seq_along(yvar)
f1 <- ses(yvar, tvar)
f2 <- des(yvar, tvar)

at <- 1 + seq(0, 35, by=5)

par(mfrow=c(2,1))
plot(f1)
forecast_lines(f1, at=at, ahead=0:5, col='red', lwd=3)
forecast_lines(f2, at=at, ahead=0:5, col='blue', lwd=3)

## Add more noise
yvar2 <- yvar + rnorm(length(yvar), sd=40)
f1 <- ses(yvar2, tvar)
f2 <- des(yvar2, tvar)

plot(f1)
at <- 1 + seq(0, 35, by=5)
forecast_lines(f1, at=at, ahead=0:5, col='red', lwd=3)
forecast_lines(f2, at=at, ahead=0:5, col='blue', lwd=3)

hojsgaard/dataIrony documentation built on May 17, 2019, 7:06 p.m.