Holt-Winters filtering
We can similarly remove the seasonal effects of a time-series by Holt-Winters filtering. Setting the beta
parameter of the HoltWinters
function to FALSE
will result in a model with exponential smoothing practically suppressing all the outliers; setting the gamma
argument to FALSE
will result in a non-seasonal model. A quick example:
> nts <- ts(daily$N, frequency = 7) > fit <- HoltWinters(nts, beta = FALSE, gamma = FALSE) > plot(fit)
The red line represents the filtered time-series. We can also fit a double or triple exponential model on the time-series by enabling the beta
and gamma
parameters, resulting in a far better fit: ...
Get Mastering Data Analysis with R 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.