seasonal.ave {mar1s}R Documentation

Averaged Seasonal Component of Time Series

Description

Extracts seasonal component of time series by averaging observations on the same position in the cycle.

Usage

seasonal.ave(x, ave.FUN = mean, ...)

Arguments

x

A univariate time series.

ave.FUN

Averaging function.

...

Additional arguments passed to ave.FUN.

Value

A time series object with times from 0 to 1 and the same frequency as x.

See Also

ave, seasonal.smooth for alternative seasonal extraction method.

Examples

set.seed(19860306)

## Artificial example
x <- ts(sin(2*pi*(3:97)/10) + 0.5*rnorm(length(3:97)),
	start = c(0, 3), frequency = 10)

plot.default(time(x)%%1, x, xlab = "Phase")
lines(seasonal.ave(x), col = "blue")
lines(seasonal.ave(x, median), col = "green")
legend("bottomleft",
       legend = c("Mean averaging",
		  "Median averaging"),
       col = c("blue", "green"),
       lty = "solid")

## Realistic example
data(nesterov.index, package = "mar1s")
x <- log(nesterov.index[, "mean"])
x[x < -10] <- -Inf

plot.default(time(x)%%1, x, xlab = "Phase", pch = ".")
lines(seasonal.ave(x), col = "blue")
lines(seasonal.ave(x, median), col = "green")
legend("topleft",
       legend = c("Mean averaging",
		  "Median averaging"),
       col = c("blue", "green"),
       lty = "solid")

[Package mar1s version 2.1.1 Index]