Robust STR decomposition
Robust Seasonal-Trend decomposition of time series data using Regression (robust version of STRmodel
).
RSTRmodel(data, predictors = NULL, strDesign = NULL, lambdas = NULL, confidence = NULL, nMCIter = 100, control = list(nnzlmax = 1e+06, nsubmax = 3e+05, tmpmax = 50000), reportDimensionsOnly = FALSE, trace = FALSE)
data |
Time series or a vector of length L. |
predictors |
List of predictors.
|
strDesign |
An optional parameter used to create the design matrix. It is used internally in the library to improve performance when the design matrix does not require full recalculation. |
lambdas |
An optional parameter. A structure which replaces lambda parameters provided with predictors. It is used as either a starting point for the optimisation of parameters or as the exact model parameters. |
confidence |
A vector of percentiles giving the coverage of confidence intervals.
It must be greater than 0 and less than 1.
If |
nMCIter |
Number of Monte Carlo iterations used to estimate confidence intervals for Robust STR decomposition. |
control |
Passed directly to |
reportDimensionsOnly |
A boolean parameter. When TRUE the method constructs the design matrix and reports its dimensions without proceeding further. It is mostly used for debugging. |
trace |
When |
A structure containing input and output data.
It is an S3 class STR
, which is a list with the following components:
output – contains decomposed data. It is a list of three components:
predictors – a list of components where each component corresponds to the input predictor. Every such component is a list containing the following:
data – fit/forecast for the corresponding predictor (trend, seasonal component, flexible or seasonal predictor).
beta – beta coefficients of the fit of the coresponding predictor.
lower – optional (if requested) matrix of lower bounds of confidence intervals.
upper – optional (if requested) matrix of upper bounds of confidence intervals.
random – a list with one component data, which contains residuals of the model fit.
forecast – a list with two components:
data – fit/forecast for the model.
beta – beta coefficients of the fit.
lower – optional (if requested) matrix of lower bounds of confidence intervals.
upper – optional (if requested) matrix of upper bounds of confidence intervals.
input – input parameters and lambdas used for final calculations.
data – input data.
predictors - input predictors.
lambdas – smoothing parameters used for final calculations (same as input lambdas for STR method).
method – always contains string "RSTRmodel"
for this function.
Alexander Dokumentov
Dokumentov, A., and Hyndman, R.J. (2016) STR: A Seasonal-Trend Decomposition Procedure Based on Regression www.monash.edu/business/econometrics-and-business-statistics/research/publications/ebs/wp13-15.pdf
n <- 70 trendSeasonalStructure <- list(segments = list(c(0,1)), sKnots = list(c(1,0))) ns <- 5 seasonalStructure <- list(segments = list(c(0,ns)), sKnots = c(as.list(1:(ns-1)),list(c(ns,0)))) seasons <- (0:(n-1))%%ns + 1 trendSeasons <- rep(1, length(seasons)) times <- seq_along(seasons) data <- seasons + times/4 set.seed(1234567890) data <- data + rnorm(length(data), 0, 0.2) data[20] <- data[20] + 3 data[50] <- data[50] - 5 plot(times, data, type = "l") timeKnots <- times trendData <- rep(1, n) seasonData <- rep(1, n) trend <- list(data = trendData, times = times, seasons = trendSeasons, timeKnots = timeKnots, seasonalStructure = trendSeasonalStructure, lambdas = c(1,0,0)) season <- list(data = seasonData, times = times, seasons = seasons, timeKnots = timeKnots, seasonalStructure = seasonalStructure, lambdas = c(1,0,1)) predictors <- list(trend, season) rstr <- RSTRmodel(data, predictors, confidence = 0.8) plot(rstr)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.