Cardiff University

This code implements the test for heteroscedasticity, which can be applied to VARs and simultaneous equation models, as described by Doornik (1996). In the case of a VECM (p) with r cointegrating relationships:

The matrix of the regressors becomes which is a matrix.

Download the file testing_multi_hetero.m


function f=testing_multi_hetero(residuals,regressors);
%%     This function  evaluates the LM statistic    %%
%%      for investigating Heteroscedasticity in  a  %%
%%  mutlivariate framework, as it is described by   %%
%%          Doornik (1996) and Kelejian (1982)      %%
%%   (http://www.doornik.com/research/vectest.pdf)  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                    ATTENTION                     %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% IT IS ONLY FOR SQUARES AND NOT CROSS PRODUCTS OF %%
%%                 THE REGRESSORS                   %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                    INPUTS                        %%
%%  The residuals and the regressors are (nxT) and  %%
%%  (kxT) matrices respectively where n and k are   %%
%%   the numbers of the dependent and independent   %%
%%   variables respectively and T is the number of  %%
%%  the observations. The matrix of the regressors  %%
%%  does not contain a possible constant that could %% 
%%  be included in the initial regression equation  %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                    OUTPUTS                       %%
%% [chi^2 statistic, degrees of freedom, p_value]   %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%                   For  a VECM(p)                 %%
%%  dy(t)=con+a*b'*y(t-1)+c1*dy(t-1)+...+cp*dy(t-p) %%
%%       the matrix of the regressors is now        %%
%%  [b'*y(t-1);dy(t-1);...;dy(t-p)] a ((r+pn)xT)    %%
%%  where r is the rank of b' or the cointeration   %%
%%          relations in the system.                %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%   This function provides identical results with  %%
%%       these obtained by Eviews  5.1              %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This version:           October  26, 2004        %%
%%  Written by:                P.Minford and        %%
%%                            K.A.Theodoridis       %%              
%%                      TheodoridisK2@cardiff.ac.uk %%
%%                       Cardiff Business School    %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[nr kr]=size(residuals);
[nx kx]=size(regressors);
g=(1/2)*nr*(nr+1);
kataloipa=zeros(g,kr);
a=nr;
for i=1:nr;
    for j=1:nr;
        if i==j;
            kataloipa(i,:)=residuals(i,:).*residuals(j,:);
        elseif i<j;
            a=a+1;
            kataloipa(a,:)=residuals(i,:).*residuals(j,:);
        end;
    end;
end;
monada=ones(1,kx);
aneksartites=[monada;regressors;regressors.^2];
ektimites=kataloipa*aneksartites'*(inv(aneksartites*aneksartites'));
horis_per_kat=kataloipa-ektimites*aneksartites;
statheres=kataloipa*monada'*(inv(monada*monada'));
me_per_kat=kataloipa-statheres*monada;
Rm=1-(1/g)*trace((horis_per_kat*horis_per_kat')*inv(me_per_kat*me_per_kat'));
[nane kane]=size(aneksartites);
vathmoi_eleutherias=g*(nx)*2;
kritirio=kx*g*Rm;
timi_pithanotitas=1-chi2cdf(kritirio,vathmoi_eleutherias);
f=[kritirio vathmoi_eleutherias timi_pithanotitas];

Return to top