Description Usage Arguments Details Value Author(s) References See Also Examples
Filters a time series using the Butterworth squarewave highpass filter described in Pollock (2000).
1 
x 
a regular time series 
nfix 
sets the order of the filter. The default is

freq 
integer, the cutoff frequency of the Butterworth
filter. The default is 
drift 
logical, 
Almost all filters in this package can be put into the following framework. Given a time series \{x_t\}^T_{t=1} we are interested in isolating component of x_t, denoted y_t with period of oscillations between p_l and p_u, where 2 ≤ p_l < p_u < ∞.
Consider the following decomposition of the time series
x_t = y_t + \bar{x}_t
The component y_t is assumed to have power only in the frequencies in the interval \{(a,b) \cup (a,b)\} \in (π, π). a and b are related to p_l and p_u by
a=\frac{2 π}{p_u}\ \ \ \ \ {b=\frac{2 π}{p_l}}
If infinite amount of data is available, then we can use the ideal bandpass filter
y_t = B(L)x_t
where the filter, B(L), is given in terms of the lag operator L and defined as
B(L) = ∑^∞_{j=∞} B_j L^j, \ \ \ L^k x_t = x_{tk}
The ideal bandpass filter weights are given by
B_j = \frac{\sin(jb)\sin(ja)}{π j}
B_0=\frac{ba}{π}
The digital version of the Butterworth highpass filter is described by the rational polynomial expression (the filter's ztransform)
\frac{λ(1z)^n(1z^{1})^n}{(1+z)^n(1+z^{1})^n+λ(1z)^n(1z^{1})^n}
The time domain version can be obtained by substituting z for the lag operator L.
Pollock derives a specialized finitesample version of the Butterworth filter on the basis of signal extraction theory. Let s_t be the trend and c_t cyclical component of y_t, then these components are extracted as
y_t=s_t+c_t=\frac{(1+L)^n}{(1L)^d}ν_t+(1L)^{nd}\varepsilon_t
where ν_t \sim N(0,σ_ν^2) and \varepsilon_t \sim N(0,σ_\varepsilon^2).
If drift=TRUE
the drift adjusted series is obtained as
\tilde{x}_{t}=x_tt≤ft(\frac{x_{T}x_{1}}{T1}\right), \ \ t=0,1,…,T1
where \tilde{x}_{t} is the undrifted series.
A "mFilter
" object (see mFilter
).
Mehmet Balcilar, [email protected]
M. Baxter and R.G. King. Measuring business cycles: Approximate bandpass filters. The Review of Economics and Statistics, 81(4):57593, 1999.
L. Christiano and T.J. Fitzgerald. The bandpass filter. International Economic Review, 44(2):43565, 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):116, 1997.
R.G. King and S.T. Rebelo. Low frequency filtering and real business cycles. Journal of Economic Dynamics and Control, 17(12):20731, 1993.
D.S.G. Pollock. Trend estimation and detrending via rational squarewave filters. Journal of Econometrics, 99:317334, 2000.
mFilter
, hpfilter
, cffilter
,
bkfilter
, trfilter
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36  ## 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)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.