ss.filter: Smoothing Spline Filter.

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

uses smoothing spline to estimate the trend, and also estimate the seasonal component if necessary.

Usage

1
ss.filter(x, seasonal = FALSE, period = NULL, plot = TRUE, ...)

Arguments

x

a numeric vector or univariate time series.

seasonal

a logical value indicating to estimate the seasonal component. The default is FALSE.

period

seasonal period. Only valid for seasonal = TRUE. The default is FALSE.

plot

a logical value indicating to make the plots. The default is TRUE.

...

optional arguments to smooth.spline.

Details

For univariate time seties x[t], the additive seasonal model is assumed to be

x[t] = m[t] + S[t] + R[t],

where m[t], S[t], R[t] are trend, seasonal and irregular components, respectively. The trend m[t] is estimated by cubic (default) smoothing spline using function smooth.spline. The estimated trend is denoted to be mhat[t]. If seasonal component is present (seasonal = TRUE), the seasonal indices Shat[t] can be estimated by averaging the sequence x[t] - mhat[t] for each of 1:period, defined as Shat[t]. For example, the seasonal component in January can be estimated by the average of all of the observations made in January after removing the trend component. To ensure the identifiability of m[t] and S[t], we have to assume

S[i + j*period] = S[i], ∑ S[i] = 0,

where i = 1,...,period; j = floor(n/period). The irregularity or residuals are computed by Rhat[t] = x[t] - mhat[t] - Shat[t].

For the multiplicative seasonal model

x[t] = m[t] * S[t] * R[t],

it can be transformed to an additive seasonal model by taking a logarithm on both sides if x[t] > 0, i.e.,

log(x[t]) = log(m[t]) + log(S[t]) + log(R[t]),

and then use the refined moving average filter for the components decomposition as the same in the additive seasonal model.

Plots of original data v.s fitted data, fitted trend, seasonal indices (if seasonal = TRUE) and residuals will be drawn if plot = TRUE.

Value

A matrix containing the following columns:

data

original data x.

trend

fitted trend.

season

seasonal indices if seasonal = TRUE.

residual

irregularity or residuals.

Author(s)

Debin Qiu

References

Green, P. J. and Silverman, B. W. (1994) Nonparametric Regression and Generalized Linear Models: A Roughness Penalty Approach. Chapman and Hall.

Hastie, T. J. and Tibshirani, R. J. (1990) Generalized Additive Models. Chapman and Hall.

J. Fan and Q. Yao, Nonlinear Time Series: Nonparametric and Parametric Methods, first ed., Springer, New York, 2003.

See Also

ma.filter

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## decompose the trend for the first difference of annual global air temperature from 1880-1985
data(globtemp)
decomp1 <- ss.filter(globtemp)

## decompose the trend and seasonality for CO2 data with monthly and additive seasonality
decomp2 <- ss.filter(co2, seasonal = TRUE, period = 12)

## decompose the trend and seasonality for monthly airline passenger numbers from 1949-1960
decomp3 <- ss.filter(AirPassengers, seasonal = TRUE, period = 12)

## simulation data: oracally efficient estimation for AR(p) coefficients
d <- 12
n <- d*100
x <- (1:n)/n
y <- 1 + 2*x + 0.3*x^2 + sin(pi*x/6) + arima.sim(n = n,list(ar = 0.2), sd = 1)
fit <- ss.filter(y, seasonal = TRUE,period = 12, plot = FALSE)
ar(fit[,4], aic = FALSE, order.max = 1)$ar

debinqiu/rmaf documentation built on May 15, 2019, 1:54 a.m.