Smoothing time series
Time series decomposition allows us to extract distinct components from time series data. The smoothing technique enables us to forecast the future values of time series data. In this recipe, we introduce how to use the HoltWinters
function to smooth time series data.
Getting ready
Ensure you have completed the previous recipe by generating a time series object and storing it in two variables: m
and m_ts
.
How to do it…
Please perform the following steps to smooth time series data:
- First, use
HoltWinters
to perform Winters exponential smoothing:> m.pre <- HoltWinters(m) > m.pre Holt-Winters exponential smoothing with trend and additive seasonal component. Call: HoltWinters(x = m) Smoothing parameters: alpha: 0.8223689 beta : ...
Get R for Data Science Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.