smoothFFT: smooth time series with FFT

Description Usage Arguments Value Author(s) See Also Examples

View source: R/smoothFFT.R

Description

smooth time series with FFT

Usage

1
smoothFFT(x, sd, keepNA = TRUE, quiet = FALSE, ...)

Arguments

x

Numerical vector

sd

Standard deviation. Determines degree of smoothing. Use negative value to return original x.

keepNA

Logical: keep NA values? For computation, NAs will be interpolated with berryFunctions::approx2. If keepNA=TRUE, the result will again have NAs. If keepNA=FALSE, they will remain interpolated. DEFAULT: TRUE

quiet

Logical. Suppress warnings about all-NA vectors? DEFAULT: FALSE

...

Further arguments passed to fftw::IFFT

Value

Smoothed vector

Author(s)

Berry Boessenkool, berry-b@gmx.de, Aug 2017

See Also

qdoyVis

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
x <- cumsum(rnorm(200))
plot(x, type="l")
lines(smoothFFT(x, sd=1), col=4)
lines(smoothFFT(x, sd=4), col=2)

x[105:111] <- NA
plot(x, type="l")
lines(smoothFFT(x, sd=3), col=4, lwd=2)
lines(smoothFFT(x, sd=3, keepNA=FALSE), col=2, lty=3)

x <- seas$Koeln["gev","RP.50",,3]
plot(x, type="l")
lines(smoothFFT(x, sd=4), col=4)
lines(smooth.spline(x,spar=0.45), col=2)

x <- x[1:100]
plot(x, type="l")
lines(smoothFFT(x, sd=3), col=4)    # works better for seasonal data, I guess
lines(smooth.spline(x,spar=0.45), col=2)

smoothFFT(c(42,NA,NA,NA,NA)[-1], 2)

stopifnot(all(x == smoothFFT(x, -1)))

ERottler/rfs documentation built on May 20, 2019, 3:04 p.m.