ComeçarComece de graça

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.

Este exercício faz parte do curso

Forecasting in R

Ver curso

Instruções do exercício

  • 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().

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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(___))
Editar e executar o código