November 8

Linear Filters
A linear lter takes input
yt =
xt
into output yt:
1
X
r=
1
ar xt r
for coecients ar ; 1 < r < 1.
If the input is a unit impulse at t = 0,
8
<
1 t=0
0 t 6= 0;
the output is yt = at, so the coecients are called the impulse
response function of the lter.
xt = :
1
For example, with
otherwise:
a1
= 1; a2 = 0:5; a3 = 0:2 and
par(mfrow = c(2, 1))
x = ts(rep(0, 20), start =
x[time(x) == 0] = 1
plot(x, type = "b")
abline(h = 0, col = "red",
y = filter(x, c(0, 1, 0.5,
plot(y, type = "b")
abline(h = 0, col = "red",
ar
=0
-5)
lty = 2)
-0.2), sides = 1)
lty = 2)
If, as here, ar = 0 for r < 0, the lter is real-time, or causal,
or realizable.
2
If the input is a (complex) cosine wave,
xt = Rei(2!t+);
the output is
yt =
1
X
r=
= xt
where
ar Rei[2!(t r)+]
1
1
X
r=
1
ar e
2i!r
= x t A (! );
A(! ) =
1
X
r=
1
ar e
2i!r
is called the frequency response function of the lter.
3
Same example:
# filter() does not work for complex input:
filter.complex = function(x, ...) {
complex(real = filter(Re(x), ...),
imag = filter(Im(x), ...))
}
R = 2
omega = 0.2
phi = 1
x = R * exp(1i * (2 * pi * omega * time(x) + phi))
y = filter.complex(x, c(0, 1, 0.5, -0.2), sides = 1)
y / x
So A(0:2) = 0:066312 1:362506i.
4
Backshift Operator
The lter can be written
yt =
where
1
X
r=
1
ar xt r
=
= a(B )xt;
a (B ) =
1
X
r=
1
1
X
r=
1
ar B r xt
ar B r :
The frequency response function is
A(! ) = a e
2i!
:
5
Gain and Phase
The frequency response function in polar coordinates:
A(! ) = jA(! )j expf i(! )g:
jA(!)j is the gain function (or amplitude).
(!) is the phase function.
E.g. delay:
yt = Axt D ; A > 0; ) A(! ) = Ae
2iD!
{
gain = A, constant,
{
phase = 2D!, linear in ! with slope 2D.
, so
6
Types of Filter
If
yt =
m
X
r=0
a r xt r
the lter is a Finite Impulse Response (FIR) lter.
If m = 1 it is an Innite Impulse Response (IIR) lter.
Some IIR lters are recursive :
yt = a0xt +
m
X
r=1
br yt r :
7
ARMA models
If xt is white noise and the lter is FIR, yt is MA(m).
If xt is white noise and the lter is recursive, yt is AR(m).
General ARMA is the output of a combined lter applied to
white noise, with an FIR lter followed by a recursive lter.
8
Output Spectrum
If the input is any stationary process with autocovariances
xx(h),
the covariances of the output are
cov
yt+h; yt
X
= cov
=
XX
=
XX
r
s
r
s
r
ar xt+h r ;
X
s
!
asxt s
ar ascov xt+h r ; xt s
ar asxx(h
r + s):
This does not depend on t, so fytg is weakly stationary with
yy (h) =
XX
r
s
ar asxx(h
r + s):
9
So the power spectral density of fytg is
fyy (! ) =
=
=
X
h
yy (h)e
XXX
h r
X
r
s
ar e
2i!h
ar asxx(h
2i!r
!
s
2
X
4
h
xx(h
X
r + s)e
ase+2i!s
r + s)e
2i!h
!
3
2i! (h
r+s)5
= jA(!)j2fxx(!):
In words,
output spectrum = input spectrum squared gain:
10
We can also compute the cross covariance xy (h):
cov
xt+h; yt
= cov
=
X
=
X
s
s
xt+h;
X
s
!
a s xt s
ascov xt+h; xt s
asxx(h + s):
This too does not depend on t, so fxtg and fytg are jointly
stationary with
xy (h) =
X
s
asxx(h + s):
11
So the cross spectral density is
fxy (! ) =
=
=
X
h
xy (h)e
XX
h s
"
X
s
2i!h
asxx(h + s)e
2i!s
#
ase
= A(!)fxx(!):
2i!h
3
2
X
4
h
xx(h + s)e
2i! (h+s) 5
Similarly, fyx(!) = A(!)fxx(!), or in words,
cross spectrum = input spectrumfrequency response function:
12
Note that the squared coherency is
j
fyx(! )j2
2
(! ) =
y:x
=
for every frequency !.
fxx(! )fyy (! )
jA(!)fxx(!)j2
fxx(! )jA(! )j2fxx(! )
=1
That is, if one series is a ltered version of another, their
squared coherency is 1 at all frequencies.
The converse is also true.
13
Examples
First dierence:
ar
{
{
= 0 otherwise.
yt
=
xt
xt
1
, so
a0
The frequency response function is
A(! ) = 1 e 2i! = e i! ei! e
= 1; a1 = 1, and
i!
=e
i!
2i sin(!):
For 0 ! 1=2, the gain function is 2 sin(!):
par(mfrow = c(2, 1));
plot(function(x) sin(pi * x), from = 0, to = 0.5)
abline(h = 0, lty = 2)
plot(function(x) sin(pi * x)^2, from = 0, to = 0.5)
abline(h = 0, lty = 2)
{
For 0 ! 1=2, the phase function is !
=2.
14
Centered moving average:
m
1
x
yt =
2m + 1 r = m t
X
{
r:
The frequency response function is
m
1
e2i!m e 2i!(m+1)
2i!r
e
=
2m + 1 r= m
(2m + 1) 1 e 2i!
= sin[(2m + 1)!] :
(2m + 1) sin(!)
0
@
1
X
A
15
Gain function:
par(mfrow = c(2,
plot(function(x)
from = 0, to =
plot(function(x)
from = 0, to =
plot(function(x)
from = 0, to =
1));
sin(13 * pi * x) / (13 * sin(pi * x)),
0.5, col = "blue"); abline(h = 0, lty = 2)
abs(sin(13 * pi * x) / (13 * sin(pi * x))),
0.5, add = TRUE); abline(h = 0, lty = 2)
(sin(13 * pi * x) / (13 * sin(pi * x)))^2,
0.5); abline(h = 0, lty = 2)
Phase function alternates between 0 and .
16
ARMA Spectrum
ARMA(p; q) model:
(B )xt = (B )wt = yt;
yt
say.
is ltered versions of both xt and wt, so
2i! 2
fyy (! ) = e
fxx(! )
= e 2i! 2 fww (!):
Solve for fxx(!):
fxx(! ) = fww (! ) e
e
2i!
2
2i!
2
= w
2
e
e
2i!
2
2i!
2
:
17
Pre-whitening
Recall: the spectrum of the output of a lter is
fyy (! ) = jA(! )j2fxx(! ):
If we choose the lter so that
jA(!)j2 = f k(!) ;
xx
then fyy (!) is constant.
That is, the output of the lter is white noise. It is called a
pre-whitening lter for the input fxtg.
18
One way to nd a pre-whitening lter is to t an AR model
to the input data, because the model equation (B )xt = wt
denes such a lter.
Even
approximate pre-whitening can be helpful, because a
nearly constant
variable fxx(!).
fyy (! )
is easier to estimate than a highly
The resulting estimate of fxx(!) is then
f^yy (! )
jA (! )j2 :
19