more short-circuit logicals in the place of element-wise logicals
parent
a153f81156
commit
c59133562c
|
@ -29,7 +29,7 @@ function [LIK, lik] = missing_observations_kalman_filter(T,R,Q,H,P,Y,start,mf,k
|
|||
% NOTES
|
||||
% The vector "lik" is used to evaluate the jacobian of the likelihood.
|
||||
|
||||
% Copyright (C) 2004-2010 Dynare Team
|
||||
% Copyright (C) 2004-2011 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -59,7 +59,7 @@ oldK = Inf;
|
|||
notsteady = 1; % Steady state flag.
|
||||
F_singular = 1;
|
||||
|
||||
while notsteady & t<smpl
|
||||
while notsteady && t<smpl
|
||||
t = t+1;
|
||||
d_index = data_index{t};
|
||||
if isempty(d_index)
|
||||
|
|
|
@ -29,7 +29,7 @@ function [LIK, llik] = univariate_diffuse_kalman_filter_corr(T,R,Q,H,Pinf,Pstar,
|
|||
% NOTES
|
||||
% The vector "lik" is used to evaluate the jacobian of the likelihood.
|
||||
|
||||
% Copyright (C) 2004-2010 Dynare Team
|
||||
% Copyright (C) 2004-2011 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -109,7 +109,7 @@ while newRank && (t<smpl)
|
|||
lik(t) = lik(t) + llik(t,i);
|
||||
if ~isempty(options_.diffuse_d)
|
||||
newRank = (icc<options_.diffuse_d);
|
||||
if newRank && (any(diag(Za*Pinf*Za')>kalman_tol)==0 & rank(Pinf,crit)==0);
|
||||
if newRank && (any(diag(Za*Pinf*Za')>kalman_tol)==0 && rank(Pinf,crit)==0);
|
||||
options_.diffuse_d = icc;
|
||||
newRank=0;
|
||||
disp('WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF')
|
||||
|
|
|
@ -27,7 +27,7 @@ function [alphahat,epsilonhat,etahat,atilde,P,aK,PK,decomp] = kalman_smoother(T,
|
|||
% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
|
||||
% Analysis, vol. 24(1), pp. 85-98).
|
||||
|
||||
% Copyright (C) 2004-2010 Dynare Team
|
||||
% Copyright (C) 2004-2011 Dynare Team
|
||||
%
|
||||
% This file is part of Dynare.
|
||||
%
|
||||
|
@ -87,7 +87,7 @@ P(:,:,1) = P0;
|
|||
t = 0;
|
||||
notsteady = 1;
|
||||
F_singular = 1;
|
||||
while notsteady & t<smpl
|
||||
while notsteady && t<smpl
|
||||
t = t+1;
|
||||
v(:,t) = Y(:,t)-a(mf,t);
|
||||
F = P(mf,mf,t) + H;
|
||||
|
|
|
@ -44,7 +44,7 @@ fhat=f0;
|
|||
g = g0;
|
||||
gnorm = norm(g);
|
||||
%
|
||||
if (gnorm < 1.e-12) & ~badg % put ~badg 8/4/94
|
||||
if (gnorm < 1.e-12) && ~badg % put ~badg 8/4/94
|
||||
retcode =1;
|
||||
dxnorm=0;
|
||||
% gradient convergence
|
||||
|
@ -126,14 +126,14 @@ else
|
|||
fcount=fcount+1;
|
||||
shrinkSignal = (~badg & (f0-f < max([-THETA*dfhat*lambda 0]))) | (badg & (f0-f) < 0) ;
|
||||
growSignal = ~badg & ( (lambda > 0) & (f0-f > -(1-THETA)*dfhat*lambda) );
|
||||
if shrinkSignal & ( (lambda>lambdaPeak) | (lambda<0) )
|
||||
if (lambda>0) & ((~shrink) | (lambda/factor <= lambdaPeak))
|
||||
if shrinkSignal && ( (lambda>lambdaPeak) || (lambda<0) )
|
||||
if (lambda>0) && ((~shrink) || (lambda/factor <= lambdaPeak))
|
||||
shrink=1;
|
||||
factor=factor^.6;
|
||||
while lambda/factor <= lambdaPeak
|
||||
factor=factor^.6;
|
||||
end
|
||||
%if (abs(lambda)*(factor-1)*dxnorm < MINDX) | (abs(lambda)*(factor-1) < MINLAMB)
|
||||
%if (abs(lambda)*(factor-1)*dxnorm < MINDX) || (abs(lambda)*(factor-1) < MINLAMB)
|
||||
if abs(factor-1)<MINDFAC
|
||||
if abs(lambda)<4
|
||||
retcode=2;
|
||||
|
@ -143,12 +143,12 @@ else
|
|||
done=1;
|
||||
end
|
||||
end
|
||||
if (lambda<lambdaMax) & (lambda>lambdaPeak)
|
||||
if (lambda<lambdaMax) && (lambda>lambdaPeak)
|
||||
lambdaMax=lambda;
|
||||
end
|
||||
lambda=lambda/factor;
|
||||
if abs(lambda) < MINLAMB
|
||||
if (lambda > 0) & (f0 <= fhat)
|
||||
if (lambda > 0) && (f0 <= fhat)
|
||||
% try going against gradient, which may be inaccurate
|
||||
if dispIndx, lambda = -lambda*factor^6, end
|
||||
else
|
||||
|
@ -160,11 +160,11 @@ else
|
|||
done = 1;
|
||||
end
|
||||
end
|
||||
elseif (growSignal & lambda>0) | (shrinkSignal & ((lambda <= lambdaPeak) & (lambda>0)))
|
||||
elseif (growSignal && lambda>0) || (shrinkSignal && ((lambda <= lambdaPeak) && (lambda>0)))
|
||||
if shrink
|
||||
shrink=0;
|
||||
factor = factor^.6;
|
||||
%if ( abs(lambda)*(factor-1)*dxnorm< MINDX ) | ( abs(lambda)*(factor-1)< MINLAMB)
|
||||
%if ( abs(lambda)*(factor-1)*dxnorm< MINDX ) || ( abs(lambda)*(factor-1)< MINLAMB)
|
||||
if abs(factor-1)<MINDFAC
|
||||
if abs(lambda)<4
|
||||
retcode=4;
|
||||
|
@ -174,7 +174,7 @@ else
|
|||
done=1;
|
||||
end
|
||||
end
|
||||
if ( f<fPeak ) & (lambda>0)
|
||||
if ( f<fPeak ) && (lambda>0)
|
||||
fPeak=f;
|
||||
lambdaPeak=lambda;
|
||||
if lambdaMax<=lambdaPeak
|
||||
|
|
|
@ -85,7 +85,7 @@ while ~done
|
|||
% itct=itct+1;
|
||||
fcount = fcount+fc;
|
||||
% erased on 8/4/94
|
||||
% if (retcode == 1) | (abs(f1-f) < crit)
|
||||
% if (retcode == 1) || (abs(f1-f) < crit)
|
||||
% done=1;
|
||||
% end
|
||||
% if itct > nit
|
||||
|
@ -93,7 +93,7 @@ while ~done
|
|||
% retcode = -retcode;
|
||||
% end
|
||||
if retcode1 ~= 1
|
||||
if retcode1==2 | retcode1==4
|
||||
if retcode1==2 || retcode1==4
|
||||
wall1=1; badg1=1;
|
||||
else
|
||||
if NumGrad
|
||||
|
@ -113,7 +113,7 @@ while ~done
|
|||
%ARGLIST
|
||||
%save g1 g1 x1 f1 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;
|
||||
end
|
||||
if wall1 % & (~done) by Jinill
|
||||
if wall1 % && (~done) by Jinill
|
||||
% Bad gradient or back and forth on step length. Possibly at
|
||||
% cliff edge. Try perturbing search direction.
|
||||
%
|
||||
|
@ -133,7 +133,7 @@ while ~done
|
|||
% P5,P6,P7,P8,P9,P10,P11,P12,P13);
|
||||
fcount = fcount+fc; % put by Jinill
|
||||
if f2 < f
|
||||
if retcode2==2 | retcode2==4
|
||||
if retcode2==2 || retcode2==4
|
||||
wall2=1; badg2=1;
|
||||
else
|
||||
if NumGrad
|
||||
|
@ -166,7 +166,7 @@ while ~done
|
|||
% P4,P5,P6,P7,P8,...
|
||||
% P9,P10,P11,P12,P13);
|
||||
fcount = fcount+fc; % put by Jinill
|
||||
if retcode3==2 | retcode3==4
|
||||
if retcode3==2 || retcode3==4
|
||||
wall3=1; badg3=1;
|
||||
else
|
||||
if NumGrad
|
||||
|
@ -202,13 +202,13 @@ while ~done
|
|||
f1=f; f2=f; f3=f; retcode2=retcode1; retcode3=retcode1;
|
||||
end
|
||||
%how to pick gh and xh
|
||||
if f3<f & badg3==0
|
||||
if f3<f && badg3==0
|
||||
if dispIndx, ih=3, end
|
||||
fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3;
|
||||
elseif f2<f & badg2==0
|
||||
elseif f2<f && badg2==0
|
||||
if dispIndx, ih=2, end
|
||||
fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2;
|
||||
elseif f1<f & badg1==0
|
||||
elseif f1<f && badg1==0
|
||||
if dispIndx, ih=1, end
|
||||
fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1;
|
||||
else
|
||||
|
@ -272,7 +272,7 @@ while ~done
|
|||
if dispIndx, disp('smallest step still improving too slow, reversed gradient'), end
|
||||
elseif rc == 5
|
||||
if dispIndx, disp('largest step still improving too fast'), end
|
||||
elseif (rc == 4) | (rc==2)
|
||||
elseif (rc == 4) || (rc==2)
|
||||
if dispIndx, disp('back and forth on step length never finished'), end
|
||||
elseif rc == 3
|
||||
if dispIndx, disp('smallest step still improving too slow'), end
|
||||
|
|
|
@ -12,7 +12,7 @@ function [xdsube,Brow,Erow] = fn_dataext(Byrqm,Eyrqm,xdatae)
|
|||
%
|
||||
% Tao Zha, April 2000
|
||||
|
||||
if (Byrqm(2)==0) & (Eyrqm(2)~=0)
|
||||
if (Byrqm(2)==0) && (Eyrqm(2)~=0)
|
||||
error('If annual data, make sure both Byrqm(2) and Eyrqm(2) are zero')
|
||||
end
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ if nargin==4
|
|||
nyr = floor((Erow-Brow+1)/q_m);
|
||||
yrsg = [xdatae(q_m+1,1):xdatae(q_m+1,1)+nyr-2]'; % for annual growth later on
|
||||
else
|
||||
if Byrqm(2)<1 | Eyrqm(2)<1
|
||||
if Byrqm(2)<1 || Eyrqm(2)<1
|
||||
error('This function requires specifying both years and months (quarters) in Byrqm and Eyrqm')
|
||||
end
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ function [yhat,Estr,rcon,Rcon,u,v,d] = fn_fcstidcnd(valuecon,stepcon,varcon,nste
|
|||
DLSIdShock = ~isempty(eq_ms); % if not empty, the MS shock is identified as in DLS
|
||||
|
||||
impsteps=size(imf3s_h,1);
|
||||
if (forep<nstepsm) | (impsteps<nstepsm)
|
||||
if (forep<nstepsm) || (impsteps<nstepsm)
|
||||
disp('Increase # of forecast or impulse steps!!')
|
||||
disp('Or decrease # of constraints (nconstr) or constrained steps (stepcon(i))!!')
|
||||
error('Maximum of conditional steps > # of forecast or impulse steps!!')
|
||||
|
@ -142,7 +142,7 @@ end
|
|||
% No uncertainty at all or only random (A0,A+)
|
||||
% In other words, no future shocks
|
||||
%---------------------------------------
|
||||
if (~Sband) %| (nconstr & (length(eq_ms)==1))
|
||||
if (~Sband) %|| (nconstr && (length(eq_ms)==1))
|
||||
% length(eq_ms)==1 implies one-one mapping between MS shocks and, say, FFR
|
||||
% if nstepsm==nconstr. If this condition does not hold, this procedure
|
||||
% is incorrect. I don't have time to fix it now (3/20/99). So I use
|
||||
|
@ -175,7 +175,7 @@ else
|
|||
%--------------
|
||||
% Condition on variables and A random
|
||||
%--------------
|
||||
if nconstr & Aband
|
||||
if nconstr && Aband
|
||||
warning(' ')
|
||||
disp('This situation (both E and A random) is still under construction')
|
||||
disp('It is closely related to Waggoner and Zha ReStat Gibbs sampling method')
|
||||
|
|
|
@ -164,7 +164,7 @@ else
|
|||
return
|
||||
end
|
||||
%
|
||||
if nEnd>0 | nStart<0
|
||||
if nEnd>0 || nStart<0
|
||||
disp('Warning: this particular sample consider is out of bounds of the data!!!')
|
||||
return
|
||||
end
|
||||
|
@ -639,7 +639,7 @@ if options_.ms.indxestima
|
|||
end
|
||||
|
||||
if cnum
|
||||
if options_.ms.real_pseudo_forecast & options_.ms.banact
|
||||
if options_.ms.real_pseudo_forecast && options_.ms.banact
|
||||
for i=1:length(banstp{1})
|
||||
banval{1}(1:length(banstp{1}),1) = ...
|
||||
yactCalyg(yAg-yFg+1:yAg-yFg+length(banstp{1}),banvar(1)) - 2;
|
||||
|
@ -662,7 +662,7 @@ if options_.ms.indxestima
|
|||
%===== Converted to mg, qg, and calendar yg
|
||||
[yacyrghate,yacyrhate,yacqmyghate] = fn_datana(yachate,options_.ms.freq,options_.ms.log_var(1:nlogeno),options_.ms.percent_var(1:npereno));
|
||||
% actual and conditional forecast growth rates
|
||||
if options_.ms.indxgdls & nconstr
|
||||
if options_.ms.indxgdls && nconstr
|
||||
keyindx = [1:nvar];
|
||||
% conlab=['conditional on' ylab{PorR(1)}];
|
||||
conlab=['v-conditions'];
|
||||
|
@ -732,7 +732,7 @@ end
|
|||
% SpHR=A0in'*A0in;
|
||||
%end
|
||||
%%
|
||||
%if ~isnan(SpHR) & ~options_.ms.contemp_reduced_form
|
||||
%if ~isnan(SpHR) && ~options_.ms.contemp_reduced_form
|
||||
% warning(' ')
|
||||
% disp('Make sure you run the program with options_.ms.contemp_reduced_form =1 first.')
|
||||
% disp('Otherwise, the following test results such as Schwartz are incorrect.')
|
||||
|
@ -779,8 +779,8 @@ end
|
|||
|
||||
%***** Simply regression
|
||||
%X=[phi(:,3) y(:,2)-phi(:,2) y(:,1)-phi(:,7) ones(fss,1)];
|
||||
%» Y=y(:,3);
|
||||
%» b=regress(Y,X)
|
||||
%<EFBFBD> Y=y(:,3);
|
||||
%<EFBFBD> b=regress(Y,X)
|
||||
|
||||
%=== Computes the roots for the whole system.
|
||||
rootsinv = fn_varoots(Bhat,nvar,options_.ms.nlags )
|
||||
|
|
|
@ -322,7 +322,7 @@ for j=1:totCPU,
|
|||
|
||||
|
||||
case 1
|
||||
if Parallel(indPC).Local == 1 & newInstance, % 1.1 Run on the local machine.
|
||||
if Parallel(indPC).Local == 1 && newInstance, % 1.1 Run on the local machine.
|
||||
if ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac),
|
||||
if exist('OCTAVE_VERSION')
|
||||
command1=['octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];
|
||||
|
|
Loading…
Reference in New Issue