| Title: | STL with Extended Capabilities |
|---|---|
| Description: | Implements a Seasonal-Trend decomposition procedure based on LOESS (STL, developed by Cleveland, Cleveland, McRae, and Terpenning, 1990) in 'R' and 'C++'. The package supports missing values, fractional seasonal periods, multiplicative decompositions, and cross-validation based selection of the seasonal smoothing window. |
| Authors: | Daniel Ollech [aut, cre], Pavithra Purushothaman [ctb] |
| Maintainer: | Daniel Ollech <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.1.0 |
| Built: | 2026-11-07 17:49:19 UTC |
| Source: | https://github.com/cran/stlpro |
Plot an STL decomposition fitted by stlpro
Plot the reconstructed observed series and its seasonal, trend, and remainder components.
## S3 method for class 'stlpro' plot( x, plot_type = c("multiple", "single"), multiplicative = NULL, xlab = "", ylab = "data", main = NULL, labels = c("Unadjusted and adjusted series", "Seasonal component", "Trend component", "Remainder component"), col = c("#071108", "#D31B0D", "#d35e13", "#417246", "#2274A5"), lwd = 1, ... )## S3 method for class 'stlpro' plot( x, plot_type = c("multiple", "single"), multiplicative = NULL, xlab = "", ylab = "data", main = NULL, labels = c("Unadjusted and adjusted series", "Seasonal component", "Trend component", "Remainder component"), col = c("#071108", "#D31B0D", "#d35e13", "#417246", "#2274A5"), lwd = 1, ... )
x |
An object returned by |
plot_type |
Either |
multiplicative |
Logical. Is the decomposition multiplicative?
If |
xlab |
Label for the x-axis. |
ylab |
Label for the y-axis of the observed-data panel. |
main |
Optional overall plot title. |
labels |
Optional character vector of length four giving labels for the observed, seasonal, trend, and remainder panels. |
col |
Colours used for the observed, seasonally adjusted, seasonal, trend, and remainder series, respectively. |
lwd |
Line width. |
... |
Further graphical parameters passed to |
Invisibly returns x.
Pretty-prints an object of class "cv_results".
## S3 method for class 'cv_results' print(x, ...)## S3 method for class 'cv_results' print(x, ...)
x |
Object of class |
... |
Currently ignored. |
Invisibly returns the printed character string.
Daniel Ollech
Decompose a time series into seasonal, trend, and remainder components using STL, optionally with robust fitting. Compare to stats::stl it included cross-validation, multiplicative decompositions, allows non-integer seasonal periods and can handle missing values.
stl( y, period = NULL, multiplicative = FALSE, s_window = NULL, t_window = NULL, l_window = NULL, s_degree = 0, t_degree = 1, l_degree = 1, s_jump = NULL, t_jump = NULL, l_jump = NULL, inner = NULL, outer = 0, robust = NULL, s_window_candidates = c(7, 9, 13, 19, 37), error_metric = "RMSE" )stl( y, period = NULL, multiplicative = FALSE, s_window = NULL, t_window = NULL, l_window = NULL, s_degree = 0, t_degree = 1, l_degree = 1, s_jump = NULL, t_jump = NULL, l_jump = NULL, inner = NULL, outer = 0, robust = NULL, s_window_candidates = c(7, 9, 13, 19, 37), error_metric = "RMSE" )
y |
Numeric vector or time series. |
period |
Seasonal period, can be non-integer. If NULL and y is ts, uses frequency(y). |
multiplicative |
Logical. If TRUE a multiplicative decomposition is calculated, additive otherwise. |
s_window |
Seasonal window (odd integer >= 3). If NULL, is set using cross-validation. |
t_window |
Trend window (odd integer >= 3). If NULL, uses the default, namely nextodd(ceiling((1.5*period) / (1-(1.5/s_window)))). |
l_window |
Low-pass window (odd integer >= 3). If NULL, uses default. |
s_degree |
Degree of locally-fitted polynomial in seasonal smoothing (0 or 1). |
t_degree |
Degree of locally-fitted polynomial in trend smoothing (0 or 1). |
l_degree |
Degree of locally-fitted polynomial in low-pass smoothing (0 or 1). |
s_jump |
Seasonal jump (integer >= 1). If NULL, uses default. |
t_jump |
Trend jump (integer >= 1). If NULL, uses default. |
l_jump |
Low-pass jump (integer >= 1). If NULL, uses default. |
inner |
Number of inner iterations. If |
outer |
Number of outer robustifying iterations (default |
robust |
Logical scalar controlling the robustness iteration settings. If |
s_window_candidates |
Candidates for cross-validation based selection
of |
error_metric |
Error metric used for cross-validation: |
Values of period that are within 1e-8 of an integer are rounded to that
integer. Values must be finite scalars greater than 1.
A list with components: seasonal, trend, remainder, sa, weights, call, cv_results.
Daniel Ollech