Matlab program to measure
comovement with VAR forecast errors and frequency domain filters




These programs were written by Steve Sumner with support of NSF grant 9708587.


Introduction:

The set of programs on this website present two methods that can be used to obtain a concise set of descriptive results about the comovement of variables. The first method calculates the correlations of VAR forecast errors for two time-series at various forecast horizons. The second method calculates correlations of two filtered time-series at different frequencies using high-pass filters from the frequency domain (proposed by Baxter and King (1994)).

What will I need to calculate the comovements of two time-series?

The complete set of MATLAB programs/functions that are necessary to perform the above-described calculations include:
These files will need to be downloaded from this website. In addition to these programs the user will also need to provide a data file. This file is assumed to contain two columns of data (one column for each time-series) and cannot accommodate larger files with more than two time-series.
NOTE: Any transformations to the data should be performed prior to using the programs, i.e. if a user wishes to transform the data using logs, this should be done prior to creating the data file.

Using the Programs:

The program that controls the flow of execution is calccorr.m. This program MUST BE EDITED for each individual use of the programs. It contains a set of user-defined variables that are instrumental in the program's execution. Depending on the method that is used to calculate the comovements, some of these user-defined inputs will be ignored. These variables and the method they are associated with are listed below:
VAR Forecast Error Method and High-Pass Filter Method High-Pass Filter Method VAR Forecast Error Method
NOTE: Other programs on this website should not need to be edited and should be executed as is.

Algorithms:

Method 1 (VAR Forecast errors):
Given the user-defined variables and the data (stored in the file named infile ), the program estimates several VARs and chooses the best fitting model using the user-specified model selection criterion (infocrit). Before VAR estimation the data is differenced if the variable unitroot has been set to equal one. If this is the case then one observation is lost. In the estimation of the VAR, the program always includes a constant and imposes that the number of lags in each variable (equation) must be the same. When the estimation is performed in levels of the variables (unitroot=0), in addition to the specification with only a constant, alternative specifications with a linear trend and a quadratic trend are considered. For the VARs where the data has been differenced (unitroot=1), only the linear trend alternative specification is considered. Finally, the variable nlags defines how many lags will be allowed in the various VAR specifications. For example, if nlags=5, and unitroot=0, then a total of 15 VARs would be estimated. Three VARs would be estimated for each possible number of lags, one to five. For each number of lags, the three specifications would be a constant, a constant and linear trend, and a constant, linear trend and quadratic trend.

After selecting the 'best' model using either the aic or bic model selection criterion (as defined by infocrit), the estimated coefficients and the variance-covariance matrix of the error terms are used to calculate the correlations of the VAR forecast errors at various forecast horizons. The forecast horizons are obtained from the user input forecastrange, which is a vector of numbers indicating the forecast horizons for which the correlations should be calculated.

Finally, should the user so choose (ciyes=1), then confidence intervals will be calculated for the estimated correlations using a bootstrapping technique (see Hamilton, Time-Series Analysis, pgs. 337-338). This technique creates simulated economies (the number of economies is defined by numreplic) from the fitted residuals and the estimated VAR system and then re-calculates the statistics of interest. Confidence intervals can then be inferred from these results.

Method 2 (High-Pass Filter):
Given the user-defined variables truncparam and forecastrange, and the data (stored in the file named infile), the program filters the data to take out the portion of the time-series associated with a periodicity greater than the forecastrange for each value of forecastrange. The correlation of the two filtered time-series is then calculated (see den Haan, NBER working paper #5553, 1996 for a more detailed explanation of the filter).

Testing Program Execution:

To ensure that the programs have been downloaded and installed properly, a data file ( testdat.txt) has been included on the website. This data can be used along with the user inputs specified in the documentation section of calccorr.m to test the execution of the program. Results when using this data file are provided in the documentation section of calccorr.m.