more short-circuit logicals in the place of element-wise logicals

time-shift
Houtan Bastani 2011-02-16 18:31:48 +01:00
parent a153f81156
commit c59133562c
10 changed files with 36 additions and 36 deletions

View File

@ -29,7 +29,7 @@ function [LIK, lik] = missing_observations_kalman_filter(T,R,Q,H,P,Y,start,mf,k
% NOTES % NOTES
% The vector "lik" is used to evaluate the jacobian of the likelihood. % 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. % This file is part of Dynare.
% %
@ -59,7 +59,7 @@ oldK = Inf;
notsteady = 1; % Steady state flag. notsteady = 1; % Steady state flag.
F_singular = 1; F_singular = 1;
while notsteady & t<smpl while notsteady && t<smpl
t = t+1; t = t+1;
d_index = data_index{t}; d_index = data_index{t};
if isempty(d_index) if isempty(d_index)

View File

@ -29,7 +29,7 @@ function [LIK, llik] = univariate_diffuse_kalman_filter_corr(T,R,Q,H,Pinf,Pstar,
% NOTES % NOTES
% The vector "lik" is used to evaluate the jacobian of the likelihood. % 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. % This file is part of Dynare.
% %
@ -109,7 +109,7 @@ while newRank && (t<smpl)
lik(t) = lik(t) + llik(t,i); lik(t) = lik(t) + llik(t,i);
if ~isempty(options_.diffuse_d) if ~isempty(options_.diffuse_d)
newRank = (icc<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; options_.diffuse_d = icc;
newRank=0; newRank=0;
disp('WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF') disp('WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF')

View File

@ -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 % Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
% Analysis, vol. 24(1), pp. 85-98). % 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. % This file is part of Dynare.
% %
@ -87,7 +87,7 @@ P(:,:,1) = P0;
t = 0; t = 0;
notsteady = 1; notsteady = 1;
F_singular = 1; F_singular = 1;
while notsteady & t<smpl while notsteady && t<smpl
t = t+1; t = t+1;
v(:,t) = Y(:,t)-a(mf,t); v(:,t) = Y(:,t)-a(mf,t);
F = P(mf,mf,t) + H; F = P(mf,mf,t) + H;

View File

@ -44,7 +44,7 @@ fhat=f0;
g = g0; g = g0;
gnorm = norm(g); 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; retcode =1;
dxnorm=0; dxnorm=0;
% gradient convergence % gradient convergence
@ -126,14 +126,14 @@ else
fcount=fcount+1; fcount=fcount+1;
shrinkSignal = (~badg & (f0-f < max([-THETA*dfhat*lambda 0]))) | (badg & (f0-f) < 0) ; shrinkSignal = (~badg & (f0-f < max([-THETA*dfhat*lambda 0]))) | (badg & (f0-f) < 0) ;
growSignal = ~badg & ( (lambda > 0) & (f0-f > -(1-THETA)*dfhat*lambda) ); growSignal = ~badg & ( (lambda > 0) & (f0-f > -(1-THETA)*dfhat*lambda) );
if shrinkSignal & ( (lambda>lambdaPeak) | (lambda<0) ) if shrinkSignal && ( (lambda>lambdaPeak) || (lambda<0) )
if (lambda>0) & ((~shrink) | (lambda/factor <= lambdaPeak)) if (lambda>0) && ((~shrink) || (lambda/factor <= lambdaPeak))
shrink=1; shrink=1;
factor=factor^.6; factor=factor^.6;
while lambda/factor <= lambdaPeak while lambda/factor <= lambdaPeak
factor=factor^.6; factor=factor^.6;
end 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(factor-1)<MINDFAC
if abs(lambda)<4 if abs(lambda)<4
retcode=2; retcode=2;
@ -143,12 +143,12 @@ else
done=1; done=1;
end end
end end
if (lambda<lambdaMax) & (lambda>lambdaPeak) if (lambda<lambdaMax) && (lambda>lambdaPeak)
lambdaMax=lambda; lambdaMax=lambda;
end end
lambda=lambda/factor; lambda=lambda/factor;
if abs(lambda) < MINLAMB if abs(lambda) < MINLAMB
if (lambda > 0) & (f0 <= fhat) if (lambda > 0) && (f0 <= fhat)
% try going against gradient, which may be inaccurate % try going against gradient, which may be inaccurate
if dispIndx, lambda = -lambda*factor^6, end if dispIndx, lambda = -lambda*factor^6, end
else else
@ -160,11 +160,11 @@ else
done = 1; done = 1;
end end
end end
elseif (growSignal & lambda>0) | (shrinkSignal & ((lambda <= lambdaPeak) & (lambda>0))) elseif (growSignal && lambda>0) || (shrinkSignal && ((lambda <= lambdaPeak) && (lambda>0)))
if shrink if shrink
shrink=0; shrink=0;
factor = factor^.6; 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(factor-1)<MINDFAC
if abs(lambda)<4 if abs(lambda)<4
retcode=4; retcode=4;
@ -174,7 +174,7 @@ else
done=1; done=1;
end end
end end
if ( f<fPeak ) & (lambda>0) if ( f<fPeak ) && (lambda>0)
fPeak=f; fPeak=f;
lambdaPeak=lambda; lambdaPeak=lambda;
if lambdaMax<=lambdaPeak if lambdaMax<=lambdaPeak

View File

@ -85,7 +85,7 @@ while ~done
% itct=itct+1; % itct=itct+1;
fcount = fcount+fc; fcount = fcount+fc;
% erased on 8/4/94 % erased on 8/4/94
% if (retcode == 1) | (abs(f1-f) < crit) % if (retcode == 1) || (abs(f1-f) < crit)
% done=1; % done=1;
% end % end
% if itct > nit % if itct > nit
@ -93,7 +93,7 @@ while ~done
% retcode = -retcode; % retcode = -retcode;
% end % end
if retcode1 ~= 1 if retcode1 ~= 1
if retcode1==2 | retcode1==4 if retcode1==2 || retcode1==4
wall1=1; badg1=1; wall1=1; badg1=1;
else else
if NumGrad if NumGrad
@ -113,7 +113,7 @@ while ~done
%ARGLIST %ARGLIST
%save g1 g1 x1 f1 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13; %save g1 g1 x1 f1 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;
end end
if wall1 % & (~done) by Jinill if wall1 % && (~done) by Jinill
% Bad gradient or back and forth on step length. Possibly at % Bad gradient or back and forth on step length. Possibly at
% cliff edge. Try perturbing search direction. % cliff edge. Try perturbing search direction.
% %
@ -133,7 +133,7 @@ while ~done
% P5,P6,P7,P8,P9,P10,P11,P12,P13); % P5,P6,P7,P8,P9,P10,P11,P12,P13);
fcount = fcount+fc; % put by Jinill fcount = fcount+fc; % put by Jinill
if f2 < f if f2 < f
if retcode2==2 | retcode2==4 if retcode2==2 || retcode2==4
wall2=1; badg2=1; wall2=1; badg2=1;
else else
if NumGrad if NumGrad
@ -166,7 +166,7 @@ while ~done
% P4,P5,P6,P7,P8,... % P4,P5,P6,P7,P8,...
% P9,P10,P11,P12,P13); % P9,P10,P11,P12,P13);
fcount = fcount+fc; % put by Jinill fcount = fcount+fc; % put by Jinill
if retcode3==2 | retcode3==4 if retcode3==2 || retcode3==4
wall3=1; badg3=1; wall3=1; badg3=1;
else else
if NumGrad if NumGrad
@ -202,13 +202,13 @@ while ~done
f1=f; f2=f; f3=f; retcode2=retcode1; retcode3=retcode1; f1=f; f2=f; f3=f; retcode2=retcode1; retcode3=retcode1;
end end
%how to pick gh and xh %how to pick gh and xh
if f3<f & badg3==0 if f3<f && badg3==0
if dispIndx, ih=3, end if dispIndx, ih=3, end
fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3; 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 if dispIndx, ih=2, end
fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2; 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 if dispIndx, ih=1, end
fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1; fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1;
else else
@ -272,7 +272,7 @@ while ~done
if dispIndx, disp('smallest step still improving too slow, reversed gradient'), end if dispIndx, disp('smallest step still improving too slow, reversed gradient'), end
elseif rc == 5 elseif rc == 5
if dispIndx, disp('largest step still improving too fast'), end 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 if dispIndx, disp('back and forth on step length never finished'), end
elseif rc == 3 elseif rc == 3
if dispIndx, disp('smallest step still improving too slow'), end if dispIndx, disp('smallest step still improving too slow'), end

View File

@ -12,7 +12,7 @@ function [xdsube,Brow,Erow] = fn_dataext(Byrqm,Eyrqm,xdatae)
% %
% Tao Zha, April 2000 % 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') error('If annual data, make sure both Byrqm(2) and Eyrqm(2) are zero')
end end

View File

@ -36,7 +36,7 @@ if nargin==4
nyr = floor((Erow-Brow+1)/q_m); 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 yrsg = [xdatae(q_m+1,1):xdatae(q_m+1,1)+nyr-2]'; % for annual growth later on
else 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') error('This function requires specifying both years and months (quarters) in Byrqm and Eyrqm')
end end

View File

@ -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 DLSIdShock = ~isempty(eq_ms); % if not empty, the MS shock is identified as in DLS
impsteps=size(imf3s_h,1); impsteps=size(imf3s_h,1);
if (forep<nstepsm) | (impsteps<nstepsm) if (forep<nstepsm) || (impsteps<nstepsm)
disp('Increase # of forecast or impulse steps!!') disp('Increase # of forecast or impulse steps!!')
disp('Or decrease # of constraints (nconstr) or constrained steps (stepcon(i))!!') disp('Or decrease # of constraints (nconstr) or constrained steps (stepcon(i))!!')
error('Maximum of conditional steps > # of forecast or impulse steps!!') error('Maximum of conditional steps > # of forecast or impulse steps!!')
@ -142,7 +142,7 @@ end
% No uncertainty at all or only random (A0,A+) % No uncertainty at all or only random (A0,A+)
% In other words, no future shocks % 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 % 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 % 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 % 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 % Condition on variables and A random
%-------------- %--------------
if nconstr & Aband if nconstr && Aband
warning(' ') warning(' ')
disp('This situation (both E and A random) is still under construction') 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') disp('It is closely related to Waggoner and Zha ReStat Gibbs sampling method')

View File

@ -164,7 +164,7 @@ else
return return
end end
% %
if nEnd>0 | nStart<0 if nEnd>0 || nStart<0
disp('Warning: this particular sample consider is out of bounds of the data!!!') disp('Warning: this particular sample consider is out of bounds of the data!!!')
return return
end end
@ -639,7 +639,7 @@ if options_.ms.indxestima
end end
if cnum 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}) for i=1:length(banstp{1})
banval{1}(1:length(banstp{1}),1) = ... banval{1}(1:length(banstp{1}),1) = ...
yactCalyg(yAg-yFg+1:yAg-yFg+length(banstp{1}),banvar(1)) - 2; 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 %===== 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)); [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 % actual and conditional forecast growth rates
if options_.ms.indxgdls & nconstr if options_.ms.indxgdls && nconstr
keyindx = [1:nvar]; keyindx = [1:nvar];
% conlab=['conditional on' ylab{PorR(1)}]; % conlab=['conditional on' ylab{PorR(1)}];
conlab=['v-conditions']; conlab=['v-conditions'];
@ -732,7 +732,7 @@ end
% SpHR=A0in'*A0in; % SpHR=A0in'*A0in;
%end %end
%% %%
%if ~isnan(SpHR) & ~options_.ms.contemp_reduced_form %if ~isnan(SpHR) && ~options_.ms.contemp_reduced_form
% warning(' ') % warning(' ')
% disp('Make sure you run the program with options_.ms.contemp_reduced_form =1 first.') % 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.') % disp('Otherwise, the following test results such as Schwartz are incorrect.')
@ -779,8 +779,8 @@ end
%***** Simply regression %***** Simply regression
%X=[phi(:,3) y(:,2)-phi(:,2) y(:,1)-phi(:,7) ones(fss,1)]; %X=[phi(:,3) y(:,2)-phi(:,2) y(:,1)-phi(:,7) ones(fss,1)];
%» Y=y(:,3); %<EFBFBD> Y=y(:,3);
%» b=regress(Y,X) %<EFBFBD> b=regress(Y,X)
%=== Computes the roots for the whole system. %=== Computes the roots for the whole system.
rootsinv = fn_varoots(Bhat,nvar,options_.ms.nlags ) rootsinv = fn_varoots(Bhat,nvar,options_.ms.nlags )

View File

@ -322,7 +322,7 @@ for j=1:totCPU,
case 1 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 ~ispc, %isunix || (~matlab_ver_less_than('7.4') && ismac),
if exist('OCTAVE_VERSION') if exist('OCTAVE_VERSION')
command1=['octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &']; command1=['octave --eval "addpath(''',Parallel(indPC).DynarePath,'''), dynareroot = dynare_config(); slaveParallel(',int2str(j),',',int2str(indPC),')" &'];