Decomposition
Misc
- Also see EDA, Time Series >> Seasonality
- Presents details about Daily Seasonal Adjustment (DSA)
- Packages
- {genlasso} - Trend filtering of any given polynomial order
- {dsp} (paper) - MCMC implementation for Bayesian trend filtering (BTF) with dynamic horseshoe processes as the prior (penalty)
- Dynamic Shrinkage Processes (DSPs) extend popular global-local shrinkage priors, such as the horseshoe prior for sparse signals, to the time series setting by allowing the shrinkage behavior to depend on the history of the shrinkage process.
- DSPs are used as the prior on the 1st/2nd differences, which produces curve estimates and credible bands that are highly adaptive to both rapidly- and slowly-changing features
- Implementations for the (static) horseshoe (HS) prior and a Normal-Inverse-Gamma (NIG) prior
- {TrendLSW} (Vignette) - Wavelet Methods for Analyzing Nonstationary Time Series
- Allows users to simulate time series with first and second order nonstationarity, as well as estimate relevant quantities of interest, such as the trend and wavelet spectrum associated to time series. (i.e. smoothing for trends and spectral estimation)
- Notes from on the vignette and wavelets, in general, are in
scrapsheet.qmd
in the repo.
- There are two approaches to noise reduction: filtering algorithms and smoothing algorithms. In filtering algorithms, signal points are fed sequentially, therefore only the current and the previous points are used to get rid of noise at the current point. Smoothing algorithms assume that the entire signal has been received, and all signal points, both previous and subsequent, are used to get rid of noise at the current point.
- Low Pass FIlter
- High Pass FIlter
- Matching Filter
Seasonal Adjusted Forecasting
The seasonality is extracted from the time series using STL. The extracted seasonal time series and the seasonally adjusted time series are forecast separately. Both forecasts are then added back together to produce the final forecast.
- A seasonal naive method is commonly used to forecast the seasonal component.
- Not sure how you would combine the uncertainty (i.e PIs)
Example
from statsmodels.tsa.api import STL from sktime.forecasting.naive import NaiveForecaster # fitting the seasonal decomposition method = STL(yt, period=period).fit() series_decomp # adjusting the data = yt - series_decomp.seasonal seas_adj # forecasting the non-seasonal part = make_reduction(estimator=RidgeCV(), forecaster ='recursive', strategy=3) window_length forecaster.fit(seas_adj) = forecaster.predict(fh=list(range(1, 13))) seas_adj_pred # forecasting the seasonal part = NaiveForecaster(strategy='last', sp=12) seas_forecaster seas_forecaster.fit(series_decomp.seasonal)= seas_forecaster.predict(fh=list(range(1, 13))) seas_preds # combining the forecasts = seas_adj_pred + seas_preds preds
Seasonal Trend Decomposition using LOESS (STL)
- Time series get decomposed into trend-cycle (T), seasonal (S), and remainder (R) components
- Yt = Tt + St + Rt, where t = 1,2,…,N
- LOESS smoothes a time series by:
- Weights are applied to the neighborhood of each point which depend on the distance from the point
- A polynomial regression is fit at each data point with points in the neighborhood as explanatory variables
- Components are additive
- Entails two recursive procedures: inner loop and outer loop
- Each iteration updates the trend-cycle and seasonal components
- Inner Loop is iterated until there’s a robust estimate of the trend and seasonal component
- The outer loop is only iterated if outliers exist among the data points
- Inner Loop Procedure
- Detrending
- Initially occurs by subtracting an initial trend component (?) from the original series
- Subseries smoothing
- 12 monthly subseries are separated and collected
- Each is smoothed with LOESS
- Re-combined to create the initial seasonal component
- Low-Pass filtering of smoothed seasonal component
- Seasonal component passed through a 3x12x12 moving average.
- Result is again smoothed by LOESS (length = 13) in order to detect any trend-cycle in it.
- Detrending of smoothed subseries
- Result of low-pass filtering is subtracted from seasonal component in step 2 to get the final seasonal component
- De-seasonalization
- Final seasonal component is subtracted from the original series
- Trend smoothing
- LOESS is applied to deseasonalized series to get the final trend component
- Detrending
- Outer Loop procedure
- Final trend and seasonal components are subtracted from the original series to get the remainder/residual series
- The final trend and seasonal components are tested for outlier points
- A weight is calculated and used in the next iteration of the Inner Loop to down-weight the outlier points.