Decomposes a time series represented by an inz_ts object into its seasonal, trend, and remainder components using the specified smoothing method.

decomp(
  x,
  var = NULL,
  sm_model = c("stl"),
  mult_fit = FALSE,
  model_range = NULL,
  ...
)

# S3 method for inz_dcmp
plot(
  x,
  recompose.progress = c(0, 0),
  recompose = any(recompose.progress > 0),
  ylab = NULL,
  title = NULL,
  colour = c("#1B9E46", "#45a8ff", "orangered"),
  ...
)

Arguments

x

An `inz_dcmp` object representing the decomposed time series.

var

A character vector of length one, or NULL.

sm_model

The smoothing method to be used. Currently on "stl" is available.

mult_fit

If TRUE, a multiplicative model is used; otherwise, an additive model is used by default.

model_range

The range of data to be decomposed by the model. It can be specified as dates or years. If part of model_range lies outside the range of the data, the exceeding proportion is ignored.

...

Additional arguments (ignored).

recompose.progress

A numeric vector of length 2, controlling the display of recomposition progress when `recompose` is `TRUE`. The first component shows the progress for the seasonal component (0 to 1), and the second component tracks the number of observations recomposed so far.

recompose

Logical indicating whether the recomposition should be displayed or not.

ylab

The label for the y-axis of the plot.

title

The title for the plot.

colour

A vector of three colors specifying the colors for the trend, seasonal, and residuals components, respectively.

Value

An inz_dcmp object, which is a sub-class of dable, representing the decomposed components of the time series.

References

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, 3iV73.

See also

Examples

ts <- inzightts(visitorsQ)
d <- decomp(ts)
#> Decomp variable not specified, automatically selected `var = "Australia"`

if (FALSE) {
plot(d)
}