Added the possibility of computing hp-filtered simulated moments.
parent
fb97797405
commit
dcf49d606f
|
@ -23,10 +23,6 @@ global M_ options_ oo_
|
|||
warning_old_state = warning;
|
||||
warning off
|
||||
|
||||
if options_.hp_filter
|
||||
error('STOCH_SIMUL: HP filter is not yet implemented for empirical moments')
|
||||
end
|
||||
|
||||
if size(var_list,1) == 0
|
||||
var_list = M_.endo_names(1:M_.orig_endo_nbr, :);
|
||||
end
|
||||
|
@ -45,7 +41,13 @@ end
|
|||
y = y(ivar,options_.drop+M_.maximum_lag+1:end)';
|
||||
|
||||
m = mean(y);
|
||||
y = y - repmat(m,size(y,1),1);
|
||||
|
||||
if options_.hp_filter
|
||||
[hptrend,y] = sample_hp_filter(y,options_.hp_filter);
|
||||
else
|
||||
y = bsxfun(@minus, y, m);
|
||||
end
|
||||
|
||||
s2 = mean(y.*y);
|
||||
s = sqrt(s2);
|
||||
oo_.mean = transpose(m);
|
||||
|
@ -54,8 +56,7 @@ oo_.var = y'*y/size(y,1);
|
|||
labels = deblank(M_.endo_names(ivar,:));
|
||||
|
||||
if options_.nomoments == 0
|
||||
z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
|
||||
|
||||
z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
|
||||
title='MOMENTS OF SIMULATED VARIABLES';
|
||||
if options_.hp_filter
|
||||
title = [title ' (HP filter, lambda = ' ...
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
function [hptrend,hpcycle] = sample_hp_filter(y,s)
|
||||
% HP filters a collection of time series.
|
||||
%
|
||||
% INPUTS
|
||||
% y [double] T*n matrix of data (n is the number of variables)
|
||||
% s [integer] scalar, smoothing parameter.
|
||||
%
|
||||
% OUTPUTS
|
||||
% hptrend [double] T*n matrix, trend component of y.
|
||||
% hpcycle [double] T*n matrix, cycle component of y.
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
%
|
||||
|
||||
% Copyright (C) 2010 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
% Dynare is free software: you can redistribute it and/or modify
|
||||
% it under the terms of the GNU General Public License as published by
|
||||
% the Free Software Foundation, either version 3 of the License, or
|
||||
% (at your option) any later version.
|
||||
%
|
||||
% Dynare is distributed in the hope that it will be useful,
|
||||
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
% GNU General Public License for more details.
|
||||
%
|
||||
% You should have received a copy of the GNU General Public License
|
||||
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
[T,n] = size(y);
|
||||
|
||||
if nargin<2
|
||||
s = 1600;
|
||||
end
|
||||
|
||||
D = spdiags(repmat([s, -4.0*s, (1 + 6.0*s), -4.0*s, s], T, 1), -2:2, T, T);% Sparse matrix.
|
||||
D(1,1) = 1.0+s; D(T,T) = D(1,1);
|
||||
D(1,2) = -2.0*s; D(2,1) = D(1,2); D(T-1,T) = D(1,2); D(T,T-1) = D(1,2);
|
||||
D(2,2) = 1.0+5.0*s; D(T-1,T-1) = D(2,2);
|
||||
|
||||
hptrend = D\y;
|
||||
hpcycle = y-hptrend;
|
Loading…
Reference in New Issue