diff --git a/matlab/kalman/likelihood/missing_observations_kalman_filter.m b/matlab/kalman/likelihood/missing_observations_kalman_filter.m index fe6d43c537101c7ddedaa29e77be3b3b8ceafee8..af84bceef9c3f2105a6f259a37e05a3eb7a2298c 100644 --- a/matlab/kalman/likelihood/missing_observations_kalman_filter.m +++ b/matlab/kalman/likelihood/missing_observations_kalman_filter.m @@ -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) diff --git a/matlab/kalman/likelihood/univariate_diffuse_kalman_filter_corr.m b/matlab/kalman/likelihood/univariate_diffuse_kalman_filter_corr.m index 21230302c43b2d648530a356eca916dcf3fcc731..bb298bac87a4191118d4c11f1087dc09a4343e0e 100644 --- a/matlab/kalman/likelihood/univariate_diffuse_kalman_filter_corr.m +++ b/matlab/kalman/likelihood/univariate_diffuse_kalman_filter_corr.m @@ -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') diff --git a/matlab/kalman/smoother/kalman_smoother.m b/matlab/kalman/smoother/kalman_smoother.m index bc7ae38b235bbf673385f38bfe3f9a3713e38d24..1e9bbb2e015de7e2bab61b3658db248b74ba94b5 100644 --- a/matlab/kalman/smoother/kalman_smoother.m +++ b/matlab/kalman/smoother/kalman_smoother.m @@ -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; diff --git a/matlab/ms-sbvar/cstz/csminit.m b/matlab/ms-sbvar/cstz/csminit.m index 2cdf687dcf241db4e79cc4c43271eb7532959b6d..b40c36f8ac4b3d86ff3b394c09d92580bd8ccd2e 100644 --- a/matlab/ms-sbvar/cstz/csminit.m +++ b/matlab/ms-sbvar/cstz/csminit.m @@ -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 diff --git a/matlab/ms-sbvar/cstz/csminwel.m b/matlab/ms-sbvar/cstz/csminwel.m index f32c03533d30d09a6c49bc7f3fc0d138d341d123..e0d6f5ee71ab126f5e49c690267eaa28dc72eaf7 100644 --- a/matlab/ms-sbvar/cstz/csminwel.m +++ b/matlab/ms-sbvar/cstz/csminwel.m @@ -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 diff --git a/matlab/ms-sbvar/cstz/fn_dataext.m b/matlab/ms-sbvar/cstz/fn_dataext.m index 0eaa3ae18718dc7af9a14448818a0f43ae2db633..3460fff9120059cb232795c370eac5f8b2bce5fe 100644 --- a/matlab/ms-sbvar/cstz/fn_dataext.m +++ b/matlab/ms-sbvar/cstz/fn_dataext.m @@ -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 diff --git a/matlab/ms-sbvar/cstz/fn_datana.m b/matlab/ms-sbvar/cstz/fn_datana.m index 91d57321d97757811c9ff3b89e168e347f0ac939..380d906a2b8574e9cfbd590f71b63df9c33a0291 100644 --- a/matlab/ms-sbvar/cstz/fn_datana.m +++ b/matlab/ms-sbvar/cstz/fn_datana.m @@ -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 diff --git a/matlab/ms-sbvar/cstz/fn_fcstidcnd.m b/matlab/ms-sbvar/cstz/fn_fcstidcnd.m index 8fbf866fdab6d4e5abb2676c40604ca849eeb444..37a7819e9e36f5ad5ee79124ea14e35a17194154 100644 --- a/matlab/ms-sbvar/cstz/fn_fcstidcnd.m +++ b/matlab/ms-sbvar/cstz/fn_fcstidcnd.m @@ -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') diff --git a/matlab/ms-sbvar/msstart2.m b/matlab/ms-sbvar/msstart2.m index b72be117e43710fa9a0beb687eb12a588a9a049e..fcc4c888acebc991199cc8bc190b9827378a88c1 100644 --- a/matlab/ms-sbvar/msstart2.m +++ b/matlab/ms-sbvar/msstart2.m @@ -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) +%� Y=y(:,3); +%� b=regress(Y,X) %=== Computes the roots for the whole system. rootsinv = fn_varoots(Bhat,nvar,options_.ms.nlags ) diff --git a/matlab/parallel/masterParallel.m b/matlab/parallel/masterParallel.m index 77b94f4f72f6d723c53b09178162e00fd5390f23..91e485b77d8662632f7fecb8f70f4d36d64b0e70 100644 --- a/matlab/parallel/masterParallel.m +++ b/matlab/parallel/masterParallel.m @@ -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),')" &'];