gapfillSSA(amnt.artgaps = c(0.05, 0.05), DetBestIter = ".getBestIteration", debugging = FALSE, amnt.iters = c(10, 10), amnt.iters.start = c(1, 1), fill.margins = FALSE, first.guess = c(), GroupEigTrpls = "grouping.auto", groupingMethod = "wcor", kind = c("auto", "1d-ssa", "2d-ssa")[1], M = floor(length(series)/3), matrix.best.iter = "perf.all.gaps", MeasPerf = "RMSE", n.comp = 2 * amnt.iters[1], open.plot = TRUE, plot.results = FALSE, plot.progress = FALSE, pad.series = c(0, 0), print.stat = TRUE, remove.infinite = FALSE, scale.recstr = TRUE, series, seed = integer(), size.biggap = 20, SSA.methods = c("nutrlan", "propack", "eigen", "svd"), tresh.convergence = 0.01, tresh.min.length = 5, z.trans.series = TRUE)
Iteration performance measure: The DetBestIter function should take any of the RMSE matrices (small/big/all gaps) as an input and return i.best with best inner loops for each outer loop and h.best as the outer loop until which should be iterated. Use the default function as a reference.
Visualize results: If plot.per == TRUE an image plot is produced visualizing the RMSE between the artificial gaps and the reconstruction for each iteration. A red dot indicates the iteration chosen for the final reconstruction.
Padding: For padding the series should start and end exactly at the start and end of a major oscillation (e.g. a yearly cycle and the length to use for padding should be a integer multiple of this length. The padding is solved internally by adding the indicated part of the series at the start and at the end of the series. This padded series is only used internally and only the part of the series with original data is returned in the results. Padding is not (yet) possible for two dimensional SSA.
Multidimensional SSA: 1d or 2d SSA is possible. If a vector is given, one dimensional SSA is computed. In case of a matrix as input, two dimensional SSA is performed. For the two dimensional case two embedding should be given (one in the direction of each dimension). If 'big gaps' are set to be used for the cross validation, quadratic blocks of gaps with the size 'size.biggap'*'size.biggap' are inserted.
ssa
## create series with gaps
series.ex <- sin(2 * pi * 1:1000 / 100) + 0.7 * sin(2 * pi * 1:1000 / 10) +
rnorm(n = 1000, sd = 0.4)
series.ex[sample(c(1:1000), 30)] <- NA
series.ex[c(seq(from = sample(c(1:1000), 1), length.out = 20),
seq(from = sample(c(1:1000), 1), length.out = 20))]<-NA
indices.gaps <- is.na(series.ex)
## prepare graphics
layout(matrix(c(1:5, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7), ncol = 5, byrow = TRUE),
widths = c(1, 1, 1, 0.1, 0.1))
par(mar = c(2, 0, 0, 0.2), oma = c(0, 3, 2, 0.2), tcl = 0.2, mgp = c(0, 0, 100),
las = 1)
## perform gap filling
data.filled <- gapfillSSA(series = series.ex, plot.results = TRUE, open.plot = FALSE)
## plot series and filled series
plot(series.ex, xlab = '', pch = 16)
plot(data.filled$filled.series, col = indices.gaps+1, xlab = '', pch = 16)
points(data.filled$reconstr, type = 'l', col = 'blue')
mtext(side = 1, 'Index', line = 2)
legend(x = 'topright', merge = TRUE, pch = c(16, 16, NA), lty = c(NA, NA, 1),
col = c('black', 'red', 'blue'),
legend = c('original values', 'gap filled values', 'reconstruction'))
Run the code above in your browser using DataLab