Skip to content
Snippets Groups Projects
Commit 2c2dcaaa authored by stepan's avatar stepan
Browse files

4.0: Merged r2543:2544 changeset from trunk [Bug fix. The

DsgeSmoother was crashing when M_.exo_nbr=1. Added a new function that 
generalizes the matlab's squeeze function (the problem is that squeeze 
does not affect 2D arrays)]


git-svn-id: https://www.dynare.org/svn/dynare/branches/4.0@2545 ac1d8469-bf42-47a9-8791-bf33cf982152
parent 81b0ea39
No related branches found
Tags
No related merge requests found
......@@ -193,7 +193,7 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T,R,P,PK,d,
% -----------------------------------------------------------------------------
% 4. Kalman smoother
% -----------------------------------------------------------------------------
if any(any(H ~= 0)) % should be replaced by a flag
if any(any(H ~= 0)) % should be replaced by a flag
if kalman_algo == 1
[alphahat,epsilonhat,etahat,ahat,aK] = ...
DiffuseKalmanSmootherH1(T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
......@@ -288,17 +288,23 @@ function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK,T,R,P,PK,d,
alphahat = QT*alphahat;
ahat = QT*ahat;
nk = options_.nk;
% $$$ if M_.exo_nbr<2 % Fix the crash of Dynare when the estimated model has only one structural shock (problem with
% $$$ % the squeeze function, that does not affect 2D arrays).
% $$$ size_decomp = 0;
% $$$ else
% $$$ size_decomp = size(decomp,4);
% $$$ end
for jnk=1:nk
aK(jnk,:,:) = QT*squeeze(aK(jnk,:,:));
for i=1:size(PK,4)
PK(jnk,:,:,i) = QT*squeeze(PK(jnk,:,:,i))*QT';
PK(jnk,:,:,i) = QT*dynare_squeeze(PK(jnk,:,:,i))*QT';
end
for i=1:size(decomp,4)
decomp(jnk,:,:,i) = QT*squeeze(decomp(jnk,:,:,i));
decomp(jnk,:,:,i) = QT*dynare_squeeze(decomp(jnk,:,:,i));
end
end
for i=1:size(P,4)
P(:,:,i) = QT*squeeze(P(:,:,i))*QT';
P(:,:,i) = QT*dynare_squeeze(P(:,:,i))*QT';
end
end
end
function B = dynare_squeeze(A);
% Same as matlab's squeeze function except that it also affects 2D arrays.
% Copyright (C) 2009 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/>.
sizA = size(A);
dimA = length(sizA);
switch dimA
case 1
B = A;
case 2
if sizA(1)==1
B = transpose(A);
elseif sizA(2)==1
B = A(:,1);
else
B = A;
end
otherwise
B = squeeze(A);
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment