cma: Centered Moving Average

View source: R/cma.R

cmaR Documentation

Centered Moving Average

Description

Function constructs centered moving average based on state space SMA

Usage

cma(y, order = NULL, silent = TRUE, ...)

Arguments

y

Vector or ts object, containing data needed to be smoothed.

order

Order of centered moving average. If NULL, then the function will try to select order of SMA based on information criteria. See sma for details.

silent

If TRUE, then plot is not produced. Otherwise, there is a plot...

...

Nothing. Needed only for the transition to the new name of variables.

Details

If the order is odd, then the function constructs SMA(order) and shifts it back in time. Otherwise an AR(order+1) model is constructed with the preset parameters:

phi_i = {0.5,1,1,...,0.5} / order

This then corresponds to the centered MA with 0.5 weight for the first observation and 0.5 weight for an additional one. e.g. if this is monthly data and we use order=12, then half of the first January and half of the new one is taken.

This is not a forecasting tool. This is supposed to smooth the time series in order to find trend. So don't expect any forecasts from this function!

Value

Object of class "smooth" is returned. It contains the list of the following values:

  • model - the name of the estimated model.

  • timeElapsed - time elapsed for the construction of the model.

  • order - order of the moving average.

  • nParam - table with the number of estimated / provided parameters. If a previous model was reused, then its initials are reused and the number of provided parameters will take this into account.

  • fitted - the fitted values, shifted in time.

  • forecast - NAs, because this function does not produce forecasts.

  • residuals - the residuals of the SMA / AR model.

  • s2 - variance of the residuals (taking degrees of freedom into account) of the SMA / AR model.

  • y - the original data.

  • ICs - values of information criteria from the respective SMA or AR model. Includes AIC, AICc, BIC and BICc.

  • logLik - log-likelihood of the SMA / AR model.

  • lossValue - Cost function value (for the SMA / AR model).

  • loss - Type of loss function used in the estimation.

Author(s)

Ivan Svetunkov, ivan@svetunkov.ru

References

  • Svetunkov I. (2023) Smooth forecasting with the smooth package in R. arXiv:2301.01790. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.48550/arXiv.2301.01790")}.

  • Svetunkov I. (2015 - Inf) "smooth" package for R - series of posts about the underlying models and how to use them: https://openforecast.org/category/r-en/smooth/.

See Also

es, ssarima

Examples


# CMA of specific order
ourModel <- cma(rnorm(118,100,3),order=12)

# CMA of arbitrary order
ourModel <- cma(rnorm(118,100,3))

summary(ourModel)


smooth documentation built on Oct. 1, 2024, 5:07 p.m.