gfSsa | R Documentation |
This function applies singular spectrum analysis (SSA) in order to impute
missing values in a data set based on time-series forecasting. Note that the
SSA method requires sufficiently long series of continuous measurements, i.e.
with no data gaps at all. Therefore, gfLinInt
and
gfJulendat
should be used to fill smaller and medium-sized gaps
before applying gfSsa
.
gfSsa(data, prm = "TEMP", reversed_forecast = FALSE, ...)
data |
Object of class 'ki.data' or a filepath that can be coerced to
|
prm |
Character, default is "TEMP". Parameter(s) to fill. |
reversed_forecast |
Logical, default is FALSE. If TRUE, the supplied measurement series is reversed prior to forecasting, i.e. values are predicted into the past rather than into the future. |
... |
Additional arguments passed to |
An object of class ki.data
.
Florian Detsch
gfLinInt
, gfJulendat
## Not run:
gar <- subset(gsodstations, `STATION NAME` == "GARISSA")
gsod_gar <- dlGsodStations(usaf = gar$USAF,
start_year = 1990, end_year = 1995,
dsn = tempdir(),
unzip = TRUE)
# Conversion to KiLi SP1 `ki.data` object
ki_gar <- gsod2ki(data = gsod_gar,
prm_col = c("TEMP", "MIN", "MAX"),
df2ki = TRUE)
# Fill small gaps (n <= 5) with linear interpolation
ki_gar_linint <- gfLinInt(data = ki_gar,
prm = c("TEMP", "MIN", "MAX"))
# Fill remaining gaps based on SSA
ki_gar_ssa <- gfSsa(data = ki_gar_linint,
prm = c("TEMP", "MIN", "MAX"),
reversed_forecast = FALSE,
digits = 2)
plot(methods::slot(ki_gar_ssa, "Parameter")[["TEMP"]], type = "l", col = "red")
lines(methods::slot(ki_gar_linint, "Parameter")[["TEMP"]], col = "green")
lines(methods::slot(ki_gar, "Parameter")[["TEMP"]])
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.