Forward and reverse pass filter to correct phase shift introduced by one-pass filter. Uses signal::filter to do each filtering pass. Closely based on signal::filtfilt – see the documentation there for further discussion. Two main differences with that implementation: 1) We impute internal missing values for the purposes of filtering, then replace them with NAs again after filtering 2) We pad the end of the time series with the last observed value instead of zeros. Based on very informal plotting, this seems to give better values at the end of the time series, which will be important for prediction
1 | two_pass_signal_filter(filt, x, impute_fn)
|
x |
vector of data to be filtered |
filter |
vector of filter coefficients for a FIR filter |
method |
method for a call to stats::filter – see the documentation at stats::filter |
sides |
sides for a call to stats::filter – see the documentation at stats::filter |
circular |
circular for a call to stats::filter – see the documentation at stats::filter |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.