Description Usage Arguments Details Value Author(s) References See Also Examples
uses smoothing spline to estimate the trend, and also estimate the seasonal component if necessary.
1 |
x |
a numeric vector or univariate time series. |
seasonal |
a logical value indicating to estimate the seasonal component. The default is
|
period |
seasonal period. Only valid for |
plot |
a logical value indicating to make the plots. The default is |
... |
optional arguments to |
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
.
A matrix containing the following columns:
data |
original data |
trend |
fitted trend. |
season |
seasonal indices if |
residual |
irregularity or residuals. |
Debin Qiu
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.
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
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.