Get Started

Simple exponential smoothing

The ses() function produces forecasts obtained using simple exponential smoothing (SES). The parameters are estimated using least squares estimation. All you need to specify is the time series and the forecast horizon; the default forecast time is h = 10 years.

> args(ses)
function (y, h = 10, ...)

> fc <- ses(oildata, h = 5)
> summary(fc)

You will also use summary() and fitted(), along with autolayer() for the first time, which is like autoplot() but it adds a "layer" to a plot rather than creating a new plot.

Here, you will apply these functions to marathon, the annual winning times in the Boston marathon from 1897-2016. The data are available in your workspace.

This is a part of the course

“Forecasting in R”

View Course

Exercise instructions

  • Use the ses() function to forecast the next 10 years of winning times.
  • Use the summary() function to see the model parameters and other information.
  • Use the autoplot() function to plot the forecasts.
  • Add the one-step forecasts for the training data, or fitted values, to the plot using fitted() and autolayer().

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Use ses() to forecast the next 10 years of winning times
fc <- ___(___, h = ___)

# Use summary() to see the model parameters
___

# Use autoplot() to plot the forecasts
___

# Add the one-step forecasts for the training data to the plot
autoplot(___) + autolayer(fitted(___))
Edit and Run Code