Last chance! 50% off unlimited learning
Sale ends in
For forecasting, it is not possible in general to preserve the
attributes of the input objects. However, Rssa
knows about some
common time series classes (e.g. 'ts') and tries to infer the time
scales for forecasted objects as well.
The input formats are as follows: 1d SSA and Toeplitz SSA Input is assumed to be a simple vector, or vector-like object (e.g. univariare 'ts' or 'zooreg' object). Everything else is coerced to vector.
2d SSA
Input assumed to be a matrix. If there are any NA
's then the
shaped variant of 2d SSA will be used. All non-NA
elements
will be used as a mask.
nd SSA
Input assumed to be an array of arbitrary dimension. If there are any
NA
's then the shaped variant will be used.
MSSA While the representation of a one dimensional time series in R is pretty obvious, there are multiple possible ways of defining the multivariate time series. Let us outline some common choices.
Also, the time scales of the individual time series can be
normalized via head or tail padding with NA
(for example, as
a result of the ts.union
call), or specified via time series
attributes. Or, everything can be mixed all together.
The ssa
routine with 'kind = mssa' allows one to provide any
of the outlined multivariate series formats. As usual, all the
attributes, names of the series, NA padding, etc. is carefully
preserved.
CSSA Complex vectors are assumed at the input.
ssa
s <- ssa(co2) # Perform the decomposition using the default window length
r <- reconstruct(s, groups = list(Trend = c(1, 4),
Seasonality = c(2, 3))) # Reconstruct into 2 series
class(r$Trend) # Result is 'ts' object
# Simultaneous trend extraction using MSSA
s <- ssa(EuStockMarkets, kind = "mssa")
r <- reconstruct(s, groups = list(Trend = c(1,2)))
class(r$Trend) # Result is 'mts' object
# Trend forecast
f <- rforecast(s, groups = list(Trend = c(1, 2)), len = 50, only.new = FALSE)
class(f) # For 'ts' objects the time scales are inferred automatically
# Artificial image for 2dSSA
mx <- outer(1:50, 1:50,
function(i, j) sin(2*pi * i/17) * cos(2*pi * j/7) + exp(i/25 - j/20)) +
rnorm(50^2, sd = 0.1)
# Decompose 'mx' with circular window
s <- ssa(mx, kind = "2d-ssa", wmask = circle(5), neig = 10)
# Reconstruct
r <- reconstruct(s, groups = list(1, 2:5))
# Plot components, original image and residuals
plot(r)
# 3D-SSA example (2D-MSSA)
data(Barbara)
ss <- ssa(Barbara, L = c(50, 50, 1))
plot(ss)
Run the code above in your browser using DataLab