TSGFphenopix {greenbrown} R Documentation

Temporal smoothing and gap filling using phenopix

Description

Time series smoothing and gap filling using fitting methods as provided in the `greenProcess` function of the `phenopix` package. Function fits are performed for each year separately for which `PhenopixMY` is used.

Usage

`TSGFphenopix(Yt, interpolate = FALSE, fit = "spline", ...)`

Arguments

 `Yt` univariate time series of class `ts`. `interpolate` Should the smoothed and gap filled time series be interpolated to daily values? `fit` fitting function to be applied, available options are: spline, beck, elmore, klosterman, gu (see `greenProcess`) `...` further arguments (currently not used)

Value

The function returns a gap-filled and smoothed version of the time series.

Author(s)

Matthias Forkel <matthias.forkel@geo.tuwien.ac.at> [aut, cre]

`PhenopixMY`, `TsPP`

Examples

```# load a time series of NDVI (normalized difference vegetation index)
data(ndvi)
plot(ndvi)

# introduce random gaps
gaps <- ndvi
gaps[runif(100, 1, length(ndvi))] <- NA
plot(gaps)

# do smoothing and gap filling
tsgf <- TSGFphenopix(gaps, fit="spline")
plot(gaps)
lines(tsgf, col="red")

# compare original data with gap-filled data
plot(ndvi[is.na(gaps)], tsgf[is.na(gaps)], xlab="original", ylab="gap filled")
abline(0,1)
r <- cor(ndvi[is.na(gaps)], tsgf[is.na(gaps)])
legend("topleft", paste("Cor =", round(r, 3)))

# compare spline from phenopix with TSGFspline
spl <- TSGFspline(gaps)
plot(gaps)
lines(tsgf, col="red")
lines(spl, col="blue")
legend("topleft", c("TSGFphenopix.spline", "TSGFspline"), text.col=c("red", "blue"))
# Note that the differences originate from the fact that TSGFspline is applied on
# the full time series whereas spline within phenopix is applied for each year
# separetely. Yearly fits for TSGFphenopix.spline are afterwards combined to a full
# time series. This can cause jumps or peaks between two years. Thus, TSGFspline is
# the better choice for multi-year time series. This is also seen in cross-validation:
plot(ndvi[is.na(gaps)], tsgf[is.na(gaps)], xlab="original", ylab="gap filled", col="red")
points(ndvi[is.na(gaps)], spl[is.na(gaps)], col="blue")
abline(0,1)
r <- cor(cbind(ndvi[is.na(gaps)], tsgf[is.na(gaps)], spl[is.na(gaps)]))
lgd <- paste(c("TSGFphenopix.spline", "TSGFspline"), "Cor =", round(r[1,2:3], 3))
legend("topleft", lgd, text.col=c("red", "blue"))

# Other fits wihtin phenopix might be usefull but are rather computationally expensive:
tsgf <- TSGFphenopix(gaps, fit="klosterman")
plot(gaps)
lines(tsgf, col="red")

```

[Package greenbrown version 2.4.3 Index]