Table of Contents


File

hac_regression.m

Name

hac_regression

Synopsis

hac_regression - calculates the regression coefficients and the HAC heteroskedasticity and autocorrelation consistent estimator.

Introduction

NOTE: PART OF A SET OF 8 RELATED FILES:

To investigate the dynamic propagation of systemic risk, the authors measure the direction of the relationship between institutions using Granger causality. Specifically, the authors analyze the pairwise Granger causalities between the t and t + 1 monthly returns of the 4 indexes; they say that X Granger-causes Y if c1 has a p-value of less than 5%; similarly, they say that Y Granger-causes X if the p-value of b1 is less than 5%. They adjust for autocorrelation and heteroskedasticity in computing the p-value.

License

=============================================================================

Copyright 2011, Dimitrios Bisias, Andrew W. Lo, and Stavros Valavanis

COPYRIGHT STATUS: This work was funded in whole or in part by the Office of Financial Research under U.S. Government contract TOSOFR-11-C-0001, and is, therefore, subject to the following license: The Government is granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable, worldwide license to reproduce, prepare derivative works, distribute copies to the public, perform and display the work.
All other rights are reserved by the copyright owner.

THIS SOFTWARE IS PROVIDED "AS IS". YOU ARE USING THIS SOFTWARE AT YOUR OWN RISK. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS, CONTRIBUTORS, OR THE UNITED STATES GOVERNMENT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=============================================================================

Inputs

y
Name:
y
Description:

The response or dependent variable, i.e. second institution passed by calling function linear_granger_causality.m.

Type:
float
Range:
(-inf,+inf)
Dimensions:

Tx1 matrix

  1. Rows represent dates.

X
Name:
X
Description:

The regressors equivalent to lagged returns of the first and second institution, passed by calling function linear_granger_causality.m.

Type:
float
Range:
(-inf,+inf)
Dimensions:

TxK matrix

  1. Rows represent dates.
  2. Columns represent lagged returns for two institutions being compared.

truncation_lag_to_observations_ratio
Name:
truncation_lag_to_observations_ratio
Description:

The truncation lag to number of observations ratio used to construct the HAC estimator.

Type:
float
Range:
(0,1)
Dimensions:

scalar


Outputs

betas
Name:
betas
Description:

The regression coefficients

Type:
float
Range:
(-inf,+inf)
Dimensions:

Kx1 matrix

  1. Rows represent independent variables (institutions).

V_hat
Name:
V_hat
Description:

The HAC estimator.

Type:
float
Range:
(-inf,inf)
Dimensions:

KxK matrix (This is a covariance matrix.)

  1. Rows represent institutions.
  2. Columns represent institutions.

Code

% Run warning message
warning('OFRwp0001:UntestedCode', ...
    ['This version of the source code is very preliminary, ' ...
     'and has not been thoroughly tested. Users should not rely on ' ...
     'these calculations.']);



n = length(y);
% Regress y on X
betas = regress(y,X);
% Calculate the residuals
residuals = y - X*betas;


Q_hat = X'*X/n;

% Newey West estimator
L = round(truncation_lag_to_observations_ratio*n); 
H = diag(residuals)*X;
omega_hat = H'*H/n;  
for k = 1:L-1
    omega_temp = 0;
    for i = 1:n-k
        omega_temp = omega_temp + H(i,:)'*H(i+k,:);
    end
    omega_temp = omega_temp/(n-k);
    new_term = (L - k)/L *(omega_temp + omega_temp');
    omega_hat = omega_hat + new_term;
end

V_hat = inv(Q_hat)*omega_hat*inv(Q_hat);

Examples

NOTE: Numbers used in the examples are arbitrary valid values.
They do not necessarily represent a realistic or plausible scenario.

 y = [32, 31, 12, 69, 53]';

 X = ...
 [1,5,6; ... 
  3,7,3; ... 
  1,2,1; ... 
  8,9,2; ... 
  3,8,9];

 truncation_lag_to_observations_ratio = 0.5;

 [betas, V_hat] = hac_regression(y, X, ...
 truncation_lag_to_observations_ratio);

References

Billio et al. (2010). Econometric measures of systemic risk in the finance and insurance sectors (No. w16223). National Bureau of Economic Research.

Bisias et al. (2012). A survey of systemic risk analytics (Working paper #0001). Washington, DC: Office of Financial Research, 65-69.