**************************************************************************************************************
**                                             USAGE OF THE EXCEL ADD-IN FILTER.XLA                        **
**************************************************************************************************************

**************************************************************************************************************
DISCLAIMER:

THE USER USES THE ADDIN "FILTER.XLA" AT HER OR HIS OWN RISK.
NEITHER THE AUTHOR OF THE EXCEL ADDIN "FILTER.XLA" NOR THE ECB WILL BE RESPONSIBLE FOR ANY DAMAGE
TO DATA, SOFTWARE, HARDWARE OR ANYTHING ELSE CAUSED BY USE OR ISNTALLATION OF THE ADDIN "FILTER.XLA".
**************************************************************************************************************

**************************************************************************************************************
I N S T A L L A T I O N
The Excel-Addin "FILTER.XLA" provides the HP filter, the Extended Exponential Smoothing (Toedter 2003) 
and the TCS filter (M. Mohr 2005).
In order to use the file in Excel,
    1) save FILTER.XLA in any directory (for instance, as: d:\mystuff\filter.xla)
    2) start Excel, select "Tools -- Add-Ins" and search and select the filter.xls using "Browse"
    3) mark the entry "Filter" in the list of Add-Ins.
    4) O.K.
This provides the filter toolbar with the buttons "HP Filter | EES | TCS". 
Furthermore, the matrix function hpf, ees, tc and tcs are available in excel formulas, in the same way as 
Excel matrix formulas (see Excel help for usage of matrix functions). 
Note that the TC and the TCS filter in Excel work slowly for long series with more than 72 entries.

**************************************************************************************************************
U S A G E   O F   M A T R I X     F O R M U L A S

Matrix formulas have the advantage of updating themselves whenever a value in the input range or in any cell 
containing filter parameters is being changed. 

Example: HP filter with lambda = 30.
 - Select the first cell of the range to which the trend should be written.
 - Extent the selection marking the whole range for output.
 - Write (without "): "=hpf(20,"
 - (Note: depending on the language of Excel version used the field separator may be ";" rather than ",".
    In this case you would have to write (without "): "=hpf(20;".)
 - mark the range of values to be filtered. In this way the address of the range appears as an argument 
    in the function hpf.
 - Put in ")" (again without ").
 - Press CRTL+SHIFT at the same time while you press the ENTER key.
 - The filtered values appear in the output range.
Instead of a constant value for lambda, a reference to a cell containing the value of lambda may be specified.
Only one time series can be given as input range, it is not possible to filter several time series at the same time.
The series in the input range can be given as row-or column vector. It may contain non-numerical values.
The function detects this and computes the trend of the sub-range consisting of the area between the first numerical 
cell and the last numerical cell before the first non-numerical cell of the input range. The function ees which 
provides the extended exponential smoothing works in the same way. 

The same applies to tc and tcs, providing the Trend-Cycle and the Trend-Cycle-Season filters. Note, however, that the 
output range should be large enough to provide give for the trend, the cyclical, and, in the case of the tcs, 
the seasonal component. Furthermore, note that the functions tc and tcs are more flexible and need more parameters.
Assuming that the Excel field separator is "," the general usage of tc or tcs is 
    tc(d,c,cycle,inrange,{dummyrange},{RangeForDummyComment}) for the TC filter and 
    tcs(d,c,cycle,season,inrange,{dummyrange},{RangeForDummyComment}) for the TCS filter
(Depending on the language of Excel version used the Excel field separator may be ";" rather than ",".
 Replace commas by by semicolons in this case )
d: order of the stochastic trend (usually in the range of 0 - 2); 
   d can be specified as a string to assume also seasonal random walks as "[d]s[seas]" (without brackets and ") where
               [d] is an integer value denoting the trend order and
               [seas] is a scalar denoting the seasonality in the stochastic trend (for instance: 1s4).
   The specification d = 0 is possible. It implies xt = 0 and makes sense only for non-trending time series.
c: order of stochastic cyclical process (usually in the range of 0 - 2). 
   c may be set equal to zero
cycle: average length of the stochastic cylce in periods . 
       If d<> 0, c=0 and cycle > 0, the HP or the EES follow. In this case, the value of 
       cycle specifies the value of the smoothing parameter lambda.
       c and cycle can be both set equal to zero. Together with d > 0 this gives a 1-component trend or 
       -- if s > 0 -- a 2-components trend-season filter.
season: the season: 4 for quarterly data, 12 for monthly data, etc
         s > 1, together with c = 0, critcycl = 0 and d = 0 gives a 1-component seasonal filter that can be used 
         to de-seasonalise a stationary series.
dummyrange: Optional, a range with at least one dummy vector specifying at least one structural break in the trend
    The dummy vector(s) must be literarily independent and should consist of 0's and 1's.
RangeForDummyComment: Optional, a cell address into which the value of structural breaks would be written as a comment
    Can only be specified if dummyrange is specified as well.

Any parameter value can be given as cell reference.

Examples: 
(Depending on the language of Excel version used the Excel field separator may be ";" rather than ",".
 Replace commas by by semicolons in this case )
tcs(1,2,28,4,B2:B31) -> tc filter with first order trend, 
    second order cycle and quarterly seasonal. The average length of the cycle is 28, 
tcs(1,2,28,4,B2:B31,C2:D31,J2) -> tc filter with season as before, but now with two dummy series. 
    TCS writes the size of the structural breaks in the comments of cell J2.
    indicating structural breaks. The size of the breaks is given as a comment in the second cell of the trend-output
tc(1,2,8,B2:B31) -> tc filter with average cycle length of 8 periods and no seasonal component
    This is equivalent to tcs(1,2,8,,B2:B31) or tcs(1,2,8,0,B2:B31) or tcs(1,2,8,1,B2:B31)
tc("1s4",2,28,B2:B31) -> tc filter with average cycle length of 28 periods and a quarterly unit root in the trend
tcs(2,0,0,4,B2:B31) -> tcs filter no cyclical component (since both, nc and cc =0) and a quarterly seasonal component; 
       the cyclical component would be set to zero in this case
tcs(0,2,28,4,B2"B31)-> tcs filter with no trend, second order cycle and quarterly seasonal. In this way, one could 
    filter a stationary series. The trend component would be set to zero
The tc filter programme contains the HP filter and the EES as special cases:
tc(2,0,100,B2:B31) -> tc filter with 2nd order trend and zero-order cycle: this is an HP filter with lambda=100
tc(2,0,100,B2:B31,C2:C31) as above, but now with a dummy series, indicating a structural break.
tc(1,0,7,B2:B31) -> tc filter with 1rst order trend and zero-order cycle: this is an EES filter with lambda=7
A particular interesting case is the HP filter or EES, combined with a simultaneous seasonal component:
tcs(2,0,1600,4,B2@:B31) -> this is an HP filter with Lambda=1600, combined with a seasonal filter to 
    filter out a quarterly seasonal component. In this way, the HP filter could be applied to seasonal 
    time series. The cyclical component is computed as a residual as actual series - trend component - seasonal component.
    Applying the HP filter without a simultaneous seasonal component on a  seasonal series  gives rise to 
    a significant start- and end-point bias as the trend would be affected by the seasonal impact  at the 
    beginning and at the end of the time series). 

**************************************************************************************************************
U S A G E   O F   T O O L B A R   B U T T O N S

The functions hpf, ees, and tcs may also be used via the respective buttons on the filter toolbar

Just select the range with the series to be filtered and the range to which the output should be written, whereby 
the first range selected is always regarded as input with the values to be filtered.
Then klick on the respective button ("HP Filter", "EES" or "TCS") in the filter toolbar with the mouse. 
When using the toolbar buttons, please note that ! THE CELLS IN THE OUTPUT RANGE ARE OVERWRITTEN WITHOUT WARNING !

Parameters may be provided in a comment in the first cell of the output range. 
For instance, with the HP filter the comment may contain (without "): "lambda=30;". If no comments 
are given, default values of the respective parameters are used.

It works as well with the tcs filter. Just make sure that the output range is large enough to gather the trend, 
the cyclical, and possibly the seasonal component. 
For instance with the tcs filter, the comment in the first cell of the output range may contain 
"d=1;c=2;cycle=28;season=4;" This would write the the trend, the cyclical, and he seasonal component of the input range 
into the output range, whereby the trend is specified as a first order random walk; a stochastic cycle of order 2 with 
an average cycle length of 28 periods and a quarterly seasonal component are assumed.

The comment "d=1;c=2;cycle=8;dummy=C2:D32;" specifies a tc filter with two structural breaks given by 0's and 1's in 
the range C2:D32.

The range of dummies can be specified in a different way: columns (or rows) only containing 0's or 1's immediately 
before or after the column (or row) with the values to be filtered are automatically regarded as dummies. If dummies are 
specified in both ways, i.e. within the selected input range and in the comment of the first cell of the output range,
the specification in the selected input range takes precedence over the specification in the cell comment. 

If dummies are present, the values of the structural breaks are automatically written as comments in the second cell of the 
trend output range. 


REFERENCES:
Mohr, M. (2005): A Trend cycle (season) filter, ECB Working paper 499, http://www.ecb.int/pub/pdf/scpwps/ecbwp499.pdf
Schlicht, E./ R. Pauly (1983): Descriptive seasonal adjustment by minimizing perturbations, Empirica 1, p. 15-28.
Toedter, K.-H. (2003): Exponential smoothing as an alternative to the Hodrick-Prescott filter? 
          In I. Klein and S. Mittnick (eds.): Contributions to modern Econometrics: 
          from data analysis to economic policy. In honor of Gerd Hansen, pp 223-237, Kluwer.
