Learn R Programming

Rssa (version 0.13-1)

gapfill: Perform SSA gapfilling via forecast

Description

Perform SSA gapfilling of the series.

Usage

"gapfill"(x, groups, base = c("original", "reconstructed"), method = c("sequential", "simultaneous"), alpha = 0.5, ..., drop = TRUE, drop.attributes = FALSE, cache = TRUE) "gapfill"(x, groups, base = c("original", "reconstructed"), alpha = 0.5, ..., drop = TRUE, drop.attributes = FALSE, cache = TRUE) "gapfill"(x, groups, base = c("original", "reconstructed"), method = c("sequential", "simultaneous"), alpha = 0.5, ..., drop = TRUE, drop.attributes = FALSE, cache = TRUE) "gapfill"(x, groups, base = c("original", "reconstructed"), method = c("sequential", "simultaneous"), alpha = 0.5, ..., drop = TRUE, drop.attributes = FALSE, cache = TRUE)

Arguments

x
Shaped SSA object holding the decomposition
groups
list, the grouping of eigentriples to be used in the forecast
base
series used as a 'seed' for gapfilling: original or reconstructed according to the value of groups argument
method
method used for gapfilling, "sequential" means to filling by a recurrent forecast from complete parts; "simultaneous" tries to build a projections onto the signal subspace. See 'References' for more info.
alpha
weight used for combining forecasts from left and right when method = "sequential"; 0.5 means that the forecasts are averaged, 0 (1) means that only forecast from the left (right correspondingly) is used
...
additional arguments passed to reconstruct routines
drop
logical, if 'TRUE' then the result is coerced to series itself, when possible (length of 'groups' is one)
drop.attributes
logical, if 'TRUE' then the attributes of the input series are not copied to the reconstructed ones.
cache
logical, if 'TRUE' then intermediate results will be cached in the SSA object.

Value

List of objects with gaps filled in. Elements of the list have the same names as elements of groups. If group is unnamed, corresponding component gets name `Fn', where `n' is its index in groups list.Or, the forecasted object itself, if length of groups is one and 'drop = TRUE'.

Details

The function fills in the missed entries in the series. Both methods described in (Golyandina, Osipov, 2007) are implemented:
  • method = "sequential" performs forecast from complete chunks onto incomplete. For internal gaps forecast is performed from both sides of the gap and average is taken in order to reduce the forecast error. For gaps in the beginning or end of the series the method coincides with ordinary recurrent forecast;
  • method = "simultaneous" performs gap filling via projections onto signal subspace. The method may fail if insufficient complete observations are provided.

References

N. Golyandina, E. Osipov (2007): The "Caterpillar"-SSA method for analysis of time series with missing values. Journal of Statistical Planning and Inference, Vol. 137, No. 8, Pp 2642--2653 http://www.gistatgroup.com/cat/mvssa1en.pdf

See Also

Rssa for an overview of the package, as well as, rforecast, igapfill,

Examples

Run this code
# Produce series with gaps
F <- co2; F[100:200] <- NA
# Perform shaped SSA
s <- ssa(F, L = 72)
# Fill in gaps using the trend and 2 periodicty components
g <- gapfill(s, groups = list(1:6))
# Compare the result
plot(g)
lines(co2, col = "red")

Run the code above in your browser using DataLab