Apply running means or medians, `lowess`

or Savitzky-Golay
filtering to smooth functional data. This does nothing for `tfb`

-objects,
which should be smoothed by using a smaller basis / stronger penalty.

tf_smooth(x, ...)
# S3 method for tfb
tf_smooth(x, ...)
# S3 method for tfd
tf_smooth(x, method = c("lowess", "rollmean", "rollmedian", "savgol"), ...)

## Arguments

## Value

a smoothed version of the input. For some methods/options, the
smoothed functions may be shorter than the original ones (at both ends).

## Details

`tf_smooth.tfd`

overrides/automatically sets some defaults of the used
methods:

`lowess`

uses a span parameter of `f`

= .15 (instead of .75)
by default.

`rollmean`

/`median`

use a window size of `k`

= $<$number of
grid points$>$/20 (i.e., the nearest odd integer to that) and sets `fill= "extend"`

(i.e., constant extrapolation to replace missing values at the
extremes of the domain) by default. Use `fill= NA`

for `zoo`

's default
behavior of shortening the smoothed series.

`savgol`

uses a window size of `k`

= $<$number of
grid points$>$/10 (i.e., the nearest odd integer to that).

## Examples

#>
#> Attaching package: ‘zoo’

#> The following objects are masked from ‘package:base’:
#>
#> as.Date, as.Date.numeric

#>
#> Attaching package: ‘pracma’

#> The following object is masked from ‘package:purrr’:
#>
#> cross

#> using f = 0.15 as smoother span for lowess

# these methods ignore the distances between arg-values:
f_mean <- tf_smooth(f, "rollmean")

#> Warning: non-equidistant arg-values in ‘f’ ignored by rollmean.

#> using k = 5 observations for rolling data window.

#> setting fill = 'extend' for start/end values.

f_median <- tf_smooth(f, "rollmean", k = 31)

#> Warning: non-equidistant arg-values in ‘f’ ignored by rollmean.

#> setting fill = 'extend' for start/end values.

f_sg <- tf_smooth(f, "savgol", fl = 31)

#> Warning: non-equidistant arg-values in ‘f’ ignored by savgol.