bwfilter {mFilter} | R Documentation |
Butterworth filter of a time series
Description
Filters a time series using the Butterworth square-wave highpass filter described in Pollock (2000).
Usage
bwfilter(x,freq=NULL,nfix=NULL,drift=FALSE)
Arguments
x |
a regular time series |
nfix |
sets the order of the filter. The default is
|
freq |
integer, the cut-off frequency of the Butterworth
filter. The default is |
drift |
logical, |
Details
Almost all filters in this package can be put into the
following framework. Given a time series we are
interested in isolating component of
, denoted
with
period of oscillations between
and
, where
.
Consider the following decomposition of the time series
The component is assumed to have power only in the frequencies
in the interval
.
and
are related to
and
by
If infinite amount of data is available, then we can use the ideal bandpass filter
where the filter, , is given in terms of the lag operator
and defined as
The ideal bandpass filter weights are given by
The digital version of the Butterworth highpass filter is described by the rational polynomial expression (the filter's z-transform)
The time domain version can be obtained by substituting for the
lag operator
.
Pollock derives a specialized finite-sample version of the Butterworth
filter on the basis of signal extraction theory. Let be the
trend and
cyclical component of
, then these
components are extracted as
where and
.
If drift=TRUE
the drift adjusted series is obtained as
where is the undrifted series.
Value
A "mFilter
" object (see mFilter
).
Author(s)
Mehmet Balcilar, mehmet@mbalcilar.net
References
M. Baxter and R.G. King. Measuring business cycles: Approximate bandpass filters. The Review of Economics and Statistics, 81(4):575-93, 1999.
L. Christiano and T.J. Fitzgerald. The bandpass filter. International Economic Review, 44(2):435-65, 2003.
J. D. Hamilton. Time series analysis. Princeton, 1994.
R.J. Hodrick and E.C. Prescott. Postwar US business cycles: an empirical investigation. Journal of Money, Credit, and Banking, 29(1):1-16, 1997.
R.G. King and S.T. Rebelo. Low frequency filtering and real business cycles. Journal of Economic Dynamics and Control, 17(1-2):207-31, 1993.
D.S.G. Pollock. Trend estimation and de-trending via rational square-wave filters. Journal of Econometrics, 99:317-334, 2000.
See Also
mFilter
, hpfilter
, cffilter
,
bkfilter
, trfilter
Examples
## library(mFilter)
data(unemp)
opar <- par(no.readonly=TRUE)
unemp.bw <- bwfilter(unemp)
plot(unemp.bw)
unemp.bw1 <- bwfilter(unemp, drift=TRUE)
unemp.bw2 <- bwfilter(unemp, freq=8,drift=TRUE)
unemp.bw3 <- bwfilter(unemp, freq=10, nfix=3, drift=TRUE)
unemp.bw4 <- bwfilter(unemp, freq=10, nfix=4, drift=TRUE)
par(mfrow=c(2,1),mar=c(3,3,2,1),cex=.8)
plot(unemp.bw1$x,
main="Butterworth filter of unemployment: Trend,
drift=TRUE",col=1, ylab="")
lines(unemp.bw1$trend,col=2)
lines(unemp.bw2$trend,col=3)
lines(unemp.bw3$trend,col=4)
lines(unemp.bw4$trend,col=5)
legend("topleft",legend=c("series", "freq=10, nfix=2",
"freq=8, nfix=2", "freq=10, nfix=3", "freq=10, nfix=4"),
col=1:5, lty=rep(1,5), ncol=1)
plot(unemp.bw1$cycle,
main="Butterworth filter of unemployment: Cycle,drift=TRUE",
col=2, ylab="", ylim=range(unemp.bw3$cycle,na.rm=TRUE))
lines(unemp.bw2$cycle,col=3)
lines(unemp.bw3$cycle,col=4)
lines(unemp.bw4$cycle,col=5)
## legend("topleft",legend=c("series", "freq=10, nfix=2", "freq=8,
## nfix=2", "freq## =10, nfix=3", "freq=10, nfix=4"), col=1:5,
## lty=rep(1,5), ncol=1)
par(opar)