The tk_stl_diagnostics()
function generates a Seasonal-Trend-Loess decomposition.
The function is "tidy" in the sense that it works
on data frames and is designed to work with dplyr
groups.
STL method:
The STL method implements time series decomposition using
the underlying stats::stl()
. The decomposition separates the
"season" and "trend" components from
the "observed" values leaving the "remainder".
Frequency & Trend Selection
The user can control two parameters: .frequency
and .trend
.
The .frequency
parameter adjusts the "season" component that is removed
from the "observed" values.
The .trend
parameter adjusts the
trend window (t.window
parameter from stl()
) that is used.
The user may supply both .frequency
and .trend
as time-based durations (e.g. "6 weeks") or numeric values
(e.g. 180) or "auto", which automatically selects the frequency and/or trend
based on the scale of the time series.