View source: R/ts_fil_seas_adj.R
| ts_fil_seas_adj | R Documentation |
Remove the seasonal component from a time series while preserving level and trend, using STL decomposition.
ts_fil_seas_adj(frequency = NULL)
frequency |
Frequency of the time series. It is an optional parameter. It can be configured when the frequency of the time series is known. |
A ts_fil_seas_adj object.
R. B. Cleveland, W. S. Cleveland, J. E. McRae, and I. Terpenning (1990). STL: A seasonal-trend decomposition procedure based on loess. Journal of Official Statistics, 6(1), 3–73.
# Seasonal adjustment using STL at known frequency
# Load package and build a seasonal signal
library(daltoolbox)
library(tspredit)
x <- seq_len(120)
y <- x / 100 + sin(2 * pi * x / 12) + rnorm(120, sd = 0.05)
# Fit seasonal adjustment (set frequency if known) and transform
filter <- ts_fil_seas_adj(frequency = 12)
filter <- fit(filter, y)
yhat <- transform(filter, y)
# Plot original vs seasonally adjusted series
plot_ts_pred(y = y, yadj = yhat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.