lp {onlineforecast} | R Documentation |
First-order low-pass filtering
Description
First-order low-pass filtering of time series.
Usage
lp(X, a1, usestate = TRUE)
Arguments
X |
Dataframe or matrix (or list of them) of forecasts in columns to be low-pass filtered. |
a1 |
The low-pass filter coefficient. |
usestate |
logical: Use the state kept in the model$input? if |
Details
This function applies a first order unity gain low-pass filter to the columns of X
.
The low-pass filter is applied to each column seperately. The stationary gain of the filter i one.
If a list of dataframes (or matrices) is given, then the low-pass filtering is recursively applied on each.
Value
The low-pass filtered dataframe (as a matrix)
Examples
# Make a dataframe for the examples
X <- data.frame(k1=rep(c(0,1),each=5))
X$k2 <- X$k1
Xf <- lp(X, 0.5, usestate=FALSE)
Xf
# See the input and the low-pass filtered result
plot(X$k1)
lines(Xf[ ,"k1"])
# Slower response with higher a1 value
lines(lp(X, 0.8, usestate=FALSE)[ ,"k1"])
# If a list of dataframes is given, then lp() is recursively applied on each
lp(list(X,X), 0.5, usestate=FALSE)
[Package onlineforecast version 1.0.2 Index]