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”
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()
andautolayer()
.
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(___))
This exercise is part of the course
Forecasting in R
Learn how to make predictions about the future using time series forecasting in R including ARIMA models and exponential smoothing methods.
Forecasts produced using exponential smoothing methods are weighted averages of past observations, with the weights decaying exponentially as the observations get older. In other words, the more recent the observation, the higher the associated weight. This framework generates reliable forecasts quickly and for a wide range of time series, which is a great advantage and of major importance to applications in business.
Exercise 1: Exponentially weighted forecastsExercise 2: Simple exponential smoothingExercise 3: SES vs naiveExercise 4: Exponential smoothing methods with trendExercise 5: Holt's trend methodsExercise 6: Exponential smoothing methods with trend and seasonalityExercise 7: Holt-Winters with monthly dataExercise 8: Holt-Winters method with daily dataExercise 9: State space models for exponential smoothingExercise 10: Automatic forecasting with exponential smoothingExercise 11: ETS vs seasonal naiveExercise 12: Match the models to the time seriesExercise 13: When does ETS fail?What is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.