Home > matlab > long_run_variance.m

long_run_variance

PURPOSE ^

Returns the long run variance of data, a T*m matrix.

SYNOPSIS ^

function sigma = long_run_variance(data,band)

DESCRIPTION ^

 Returns the long run variance of data, a T*m matrix.

 INPUTS
    data      [double]  T*m matrix, where T is the number of observations and m the number of variables.
    band      [double]  scalar, the bandwidth parameter.

 OUTPUTS
    sigma     [double]  m*m matrix.

 SPECIAL REQUIREMENTS
    none

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function sigma = long_run_variance(data,band)
0002 % Returns the long run variance of data, a T*m matrix.
0003 %
0004 % INPUTS
0005 %    data      [double]  T*m matrix, where T is the number of observations and m the number of variables.
0006 %    band      [double]  scalar, the bandwidth parameter.
0007 %
0008 % OUTPUTS
0009 %    sigma     [double]  m*m matrix.
0010 %
0011 % SPECIAL REQUIREMENTS
0012 %    none
0013 
0014 % Copyright (C) 2009-2010 Dynare Team
0015 %
0016 % This file is part of Dynare.
0017 %
0018 % Dynare is free software: you can redistribute it and/or modify
0019 % it under the terms of the GNU General Public License as published by
0020 % the Free Software Foundation, either version 3 of the License, or
0021 % (at your option) any later version.
0022 %
0023 % Dynare is distributed in the hope that it will be useful,
0024 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0025 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0026 % GNU General Public License for more details.
0027 %
0028 % You should have received a copy of the GNU General Public License
0029 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0030 
0031 verbose = 1;
0032 
0033 if nargin<2
0034     [T,m] = size(data);
0035     band = ceil(T^(1/4));
0036     if verbose
0037         disp(['Bandwidth parameter is equal to ' num2str(band) '.'])
0038     end
0039 end
0040 
0041 gamma = multivariate_sample_autocovariance(data,band);
0042 sigma = gamma(:,:,1);
0043 for i=1:band
0044     sigma = sigma + bartlett(i,band)*(gamma(:,:,i+1)+transpose(gamma(:,:,i+1)));
0045 end
0046 
0047 function w = bartlett(i,n)
0048 w = 1 - i / (n+1);

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005