TSGFlinear: Temporal smoothing and gap filling using linear interpolation

Description Usage Arguments Value Author(s) See Also Examples

Description

This function fills gaps in a time series by using linear interpolation na.approx and smoothes the time series by using running median window of size 3 runmed

Usage

1
2
TSGFlinear(Yt, interpolate = FALSE, 
    ...)

Arguments

Yt

univariate time series of class ts.

interpolate

Should the smoothed and gap filled time series be interpolated to daily values by using approx?

...

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@tu-dresden.de> [aut, cre]

See Also

TsPP

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# introduce random gaps 
gaps <- ndvi
gaps[runif(100, 1, length(ndvi))] <- NA
plot(gaps)

# do smoothing and gap filling
tsgf <- TSGFlinear(gaps)
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)))

greenbrown documentation built on Dec. 18, 2020, 3:02 p.m.