decaverage {pastecs} | R Documentation

## Time series decomposition using a moving average

### Description

Decompose a single regular time series with a moving average filtering. Return a 'tsd' object. To decompose several time series at once, use `tsd()` with the argument `method="average"`

### Usage

    decaverage(x, type="additive", order=1, times=1, sides=2, ends="fill",
            weights=NULL)

### Arguments

`x` | a regular time series ('rts' under S+ and 'ts' under R)
`type` | the type of model, either `type="additive"` (by default), or `type="multiplicative"`
`order` | the order of the moving average (the window of the average being 2*order+1), centered around the current observation or at left of this observation depending upon the value of the `sides` argument. Weights are the same for all observations within the window. However, if the argument `weights` is provided, it supersedes `order`. One can also use `order="periodic"`. In this case, a deseasoning filter is calculated according to the value of `frequency`
`times` | The number of times to apply the method (by default, once)
`sides` | If 2 (by default), the window is centered around the current observation. If 1, the window is at left of the current observation (including it)
`ends` | either "NAs" (fill first and last values that are not calculable with NAs), or "fill" (fill them with the average of observations before applying the filter, by default), or "circular" (use last values for estimating first ones and vice versa), or "periodic" (use entire periods of contiguous cycles, deseasoning)
`weights` | a vector indicating weight to give to all observations in the window. This argument has the priority over `order`

### Details

This function is a wrapper around the `filter()` function and returns a 'tsd' object. However, it offers more methods to handle ends.

### Value

A 'tsd' object

### Author(s)

Frédéric Ibanez (ibanez@obs-vlfr.fr), Philippe Grosjean (phgrosjean@sciviews.org)

### References

Kendall, M., 1976. Time-series. Charles Griffin & Co Ltd. 197 pp.

Laloire, J.C., 1972. Méthodes du traitement des chroniques. Dunod, Paris, 194 pp.

Malinvaud, E., 1978. Méthodes statistiques de l'économétrie. Dunod, Paris. 846 pp.

Philips, L. & R. Blomme, 1973. Analyse chronologique. Université Catholique de Louvain. Vander ed. 339 pp.

### See Also

`tsd`, `tseries`, `deccensus`, `decdiff`, `decmedian`, `decevf`, `decreg`, `decloess`

### Examples

    data(marbio)
    ClausoB.ts <- ts(log(marbio$ClausocalanusB + 1))
    ClausoB.dec <- decaverage(ClausoB.ts, order=2, times=10, sides=2, ends="fill")
    plot(ClausoB.dec, col=c(1, 3, 2), xlab="stations")
    # A stacked graph is more representative in this case
    plot(ClausoB.dec, col=c(1, 3), xlab="stations", stack=FALSE, resid=FALSE,
            lpos=c(53, 4.3))

[Package pastecs version 1.3-4 Index]