|
KalenderCategories |
Mittwoch, 11. August 2010Controlling the Transfer Function in the Analytic DFA: an Alternative Weighting ApproachIn my last Blog entry I emphasized that
Let me propose an alternative here which is appealing/efficient and tractable analytically but slightly less flexible because it emphasizes the transfer function i.e. the time-shift as well as the amplitude. 1. Introduction In order to illustrate the topic I'll rely on the structure of a practically important estimation problem, namely the real-time estimation of the business-cycle. For that purpose I'll assume that a series is filtered by a bandpass filter with bandpass [1,8] years, see the following R-code analytical_dfa_bp_restriction.r (newest version from 13.08.2010). Note that I apply this filter to a random-walk process in the R-code which is unlikely to be very appealing to economists but this is a toy example and I'm treating a statistical estimation problem here. Economists often complain that real-time estimates of cycles aren't in time. I'll propose a filter design which extracts a particular component `exactly': the amplitude function equals one and the time-shift vanishes. Moreover, the quality of this approximation in the vicinity of the targetted frequency can be arbitrarily improved (at costs of poorer performances in the stop band). Finally, I'll show that the optimization is still quadratic i.e. the problem is tractable analytically. 2. The Criterion The minimum revision error criterion can be seen in expression 5 in Wildi10:
Now assume that we add a weighting function W(omega_k):
If this weighting function is growing unboundedly towards a prespecified frequency omega_0 different from zero, then we expect that :
Assuming that the periodogram doesn't vanish in omega_0 (otherwise the component would not exist and the whole extraction operation would be meaningless, of course). But since Gamma(omega_0) is a real number, \hat{\Gamma}(omega_0) must be real too and therefore
Note that from a philosophical perspective I prefer the following additive weighting scheme which is implemented in my R-code (but you could straightforwardly the above multiplicative scheme):
i.e. the weighting supplied by the user is additive. This manner the user, through his particular weighting, acts like an independent process whose spectral density - W(omega) - adds to the original spectrum of the process as measured by the periodogram, I_{NX}(omega_k). I like this idea of the `independent parallel' user much more than the `serial' user and it seems much more natural, voilà. 3 The Weighting Function: ZPC-Filters In order to obtain the intended perfect fit in omega_0 we need a weighting function which behaves like the pseudo-spectral density of an I(1)-process with unit-root in frequency omega_0, see chapter 6 in Wildi2008. The corresponding operator would look like this
where P=1. But there is a much smarter way to proceed by adjoining a MA(1) in the numerator to obtain
with P=1 and Z>=P real numbers. For Z=P an identity is obtained and for Z>P a unit-root weighting results. This kind of filters, called ZPC-filter is used in the traditional DFA and it is described at length in section 3.2 in Wildi2008. The trick is that the real number Z>=1 controls for the width of the `spectral peak' in the weighting function W(omega) and therefore the local match of Gamma by \hat{Gamma} around omega_0 can be controlled. The following graph illustrates the `tightening' effect obtained by varying Z for omega_0=pi/24 (amplitude is truncated above 10...). Please note that 1000 corresponds to pi and 500 to pi/2 i.e. x-axis are frequencies. Added 13.08.2010: Before proceeding further it is useful to account for undesirable nuisances by normalizing this weighting function:
Thus W'''(pi)=1. Finally, in an additive setting (my preferred) one I'm using
i.e. W(omega) is scaled and satisfies W(pi)=0. The following graph is generated in my code: We have now the essential ingredients to control amplitude and time-shift of the real-time filter towards omega_0 through a very flexible weighting function W relying on a zpc-filter design. 4. Examples 4.1 Varying P The example at the end of my code entitled "# Example: P is varied" proposes a bandpass filter whose weighting function gradually converges to a unit-root with frequency pi/24 i.e. P converges towards 1 (it's not equal to one due tu numerical issues...). The following graph illustrates how amplitude and time-shift gradually converge towards 1 and 0 respectively as P approaches 1 (up-dated 13.08.2010): One can see that the amplitude function is approaching 1 in pi/24. And here we got the detail around pi/24 (which corresponds to the x-value 3) up-dated 13.08.2010: The convergence of both amplitude and time shift in pi/24 as P approaches 1 (the pole approaches the unit circle) are clearly visible. Interesting effects could be obtained by varying the filter length L but I'll let you experiment with the code (imposing constraints requires sufficiently flexible designs i.e. a `large' L). 4.2 Varying Z: First Order Restriction The following is based on the example called "# Example : first order restriction, Z is varied" in my code. P is now fixed to 1 (unit-root weighting: for numerical reasons I'm using P slightly larger than one...) and Z is varied. Let me just briefly reemphasize what I would like to do here:
For my purpose I selected an MA of length 300 (overfitting will be unavoidable but that's not my point here). The following graph plots amplitude and time-shift functions when Z is varied according to my code (click on the graph to magnify) up-dated 13.08.2010. The `outlier' (red line in the graph) corresponds to Z=P i.e. W=1: no emphasize of frequency omega_0. All other filters satisfy A(pi/24)=1 and Phi(pi/24)=0 - up to rounding errors which are due to the fact that P is not exactly one - but the quality of this approximation depends on Z. The following graph magnifies the above plot around pi/24 (which corresponds to x=3 on the abscissa) up-dated 13.08.2010: (I removed the Z=P filter, red line in the previous graph) One can see that the slope of the time-shift (recall that the time shift is the phase divided by the frequency) in the lower graph decreases such that the shift is closer to 0 in a wider range of frequencies around pi/24 for increasing Z. Similarly, the amplitude is closer to one in wider intervall around pi/24. Interestingly, the better/wider approximation around pi/24 translates into poorer stopband properties as can be seen in the previous graph: the amplitude is increasing towards pi which means that more noise will alter the output signal (no free lunch!). You can run my code and try this example and you could try smaller filter orders too:
4.3 Varying Z: Second Order Restriction (This section was added 13.08.2010 ) The following is based on the example called "# Example : second order restriction, Z is varied" in my code. The main difference when compared to 4.2 is that the weighting function is squared i.e. I'm using W(omega)^2 instead of W(omega). This simulates a second order unit-root in pi/24. Here are the graphs generated by my code: Note there are severe numerical issues at hand which are not solved in my R-code: therefore I couldn't generate as much plots as I'd have liked to. Nevertheless, one can see that the approximation in the vicinity of pi/24 becomes now much flatter (less ripples when compared to the same graph in the previous section). Also, noise-elimination in the stop-band gets affected negatively (the effect would be more pronounced but I couldn't generate corresponding graphs due to numerical issues: this could be tackled, in principle, but I don't have time to do so). A detailed-view now: (I removed the Z=P filter: red line in the previous graph) We see that the effect of Z is much stronger on the flattening of both the amplitude and the time-shift functions towards pi/24 (x=3 in the graph). The quality of the approximation can be controlled better towards pi/24 (losses in the stop band will be larger, however). 5. Time-Shift Restrictions: Interpretation So far we have seen three possible ways of controlling real-time filter characteristics:
A Side-note: controlling the time-shift in frequency omega_0=zero is slightly more complicated because
where a and b are scaling and centering constants (see above). Another side-note: In my R-code you'll find a weighting function which assigns an isolated weight to omega_0 only i.e. W(omega) is zero for omega different from omega_0 (in the additive setting). In this framework, the user presents himself - through W - to the optimization criterion in the form of a deterministic sinusoid instead of a unit root (intriguing, isn't it?). If the isolated weight is sufficiently large, then the above amplitude and phase constraints will be satisfied arbitrarily well. But one should be careful here:
Summary:
|
LinksBlog subscription |






It's time to introduce a short nomenclature for the DFA:T-DFA (T: Traditional) makes reference to Wildi2010 and the references therein: it is a long-time research project started before the first publication in 1998. The method has been used in a wide ran
Aufgenommen: Aug 12, 13:31
The entry on W-DFA has been up-dated today (13.08.2010):I provide slightly improved R-code (the weighting function has been adjusted for nuisances).New graphs generated by the improved code (nothing fundamental changed: only details).New example based on
Aufgenommen: Aug 13, 11:54