diff --git a/matlab/AIM/SPExact_shift.m b/matlab/AIM/SPExact_shift.m index 8d8d5a1c4fb86651cf2dac365999779537b2ec42..6b39ad82ddfc6327065dedd356e7f7409c4cc070 100644 --- a/matlab/AIM/SPExact_shift.m +++ b/matlab/AIM/SPExact_shift.m @@ -34,7 +34,7 @@ left = 1:qcols; right = qcols+1:qcols+neq; zerorows = find( sum(abs( hs(:,right)' ))==0 ); -while( any(zerorows) & iq <= qrows ) +while( any(zerorows) && iq <= qrows ) nz = length(zerorows); q(iq+1:iq+nz,:) = hs(zerorows,left); hs(zerorows,:) = SPShiftright(hs(zerorows,:),neq); diff --git a/matlab/AIM/SPNumeric_shift.m b/matlab/AIM/SPNumeric_shift.m index c826491febe373397a39297c314fcc4e9c6cdd08..09a745f7c1a297c800eb73da5b67071c81b6096b 100644 --- a/matlab/AIM/SPNumeric_shift.m +++ b/matlab/AIM/SPNumeric_shift.m @@ -35,7 +35,7 @@ right = qcols+1:qcols+neq; [Q,R,E] = qr( h(:,right) ); zerorows = find( abs(diag(R)) <= condn ); -while( any(zerorows) & iq <= qrows ) +while( any(zerorows) && iq <= qrows ) h=sparse(h); Q=sparse(Q); h = Q'*h; diff --git a/matlab/CutSample.m b/matlab/CutSample.m index 779251f76ae4316a8aff809ab3fed343595d52cb..18595631c9a37ef1ca0d5701f5837b5f8e3c7a0a 100644 --- a/matlab/CutSample.m +++ b/matlab/CutSample.m @@ -14,7 +14,7 @@ function CutSample(M_, options_, estim_params_) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2005-2009 Dynare Team +% Copyright (C) 2005-2011 Dynare Team % % This file is part of Dynare. % @@ -60,7 +60,7 @@ if (TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1 > 0 record.MhDraws(end,3) ]; elseif TotalNumberOfMhFiles == 1 record.KeepedDraws.Distribution = []; -elseif TotalNumberOfMhFiles == 2 & FirstMhFile > 1 +elseif TotalNumberOfMhFiles == 2 && FirstMhFile > 1 record.KeepedDraws.Distribution = [MAX_nruns-FirstLine+1 ; record.MhDraws(end,3)]; end save([DirectoryName '/' M_.fname '_mh_history.mat'],'record'); diff --git a/matlab/DsgeLikelihood.m b/matlab/DsgeLikelihood.m index 4468b411a61ccc4bef0a5d0393c2baf902c74b11..e20a13f3b56f95d6dd0922ac3778b07fdfecd7a7 100644 --- a/matlab/DsgeLikelihood.m +++ b/matlab/DsgeLikelihood.m @@ -47,14 +47,14 @@ nobs = size(options_.varobs,1); %------------------------------------------------------------------------------ % 1. Get the structural parameters & define penalties %------------------------------------------------------------------------------ -if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb) +if options_.mode_compute ~= 1 && any(xparam1 < bayestopt_.lb) k = find(xparam1 < bayestopt_.lb); fval = bayestopt_.penalty+sum((bayestopt_.lb(k)-xparam1(k)).^2); cost_flag = 0; info = 41; return; end -if options_.mode_compute ~= 1 & any(xparam1 > bayestopt_.ub) +if options_.mode_compute ~= 1 && any(xparam1 > bayestopt_.ub) k = find(xparam1 > bayestopt_.ub); fval = bayestopt_.penalty+sum((xparam1(k)-bayestopt_.ub(k)).^2); cost_flag = 0; diff --git a/matlab/DsgeVarLikelihood.m b/matlab/DsgeVarLikelihood.m index 450d0aa6348f2e238088216451a3d438d9753849..d4ce41fe87015c0d936f7bdd88d10cade479f3ca 100644 --- a/matlab/DsgeVarLikelihood.m +++ b/matlab/DsgeVarLikelihood.m @@ -59,7 +59,7 @@ mXX = evalin('base', 'mXX'); fval = []; cost_flag = 1; -if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb) +if options_.mode_compute ~= 1 && any(xparam1 < bayestopt_.lb) k = find(xparam1 < bayestopt_.lb); fval = bayestopt_.penalty+sum((bayestopt_.lb(k)-xparam1(k)).^2); cost_flag = 0; @@ -67,7 +67,7 @@ if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb) return; end -if options_.mode_compute ~= 1 & any(xparam1 > bayestopt_.ub) +if options_.mode_compute ~= 1 && any(xparam1 > bayestopt_.ub) k = find(xparam1 > bayestopt_.ub); fval = bayestopt_.penalty+sum((xparam1(k)-bayestopt_.ub(k)).^2); cost_flag = 0; diff --git a/matlab/bvar_toolbox.m b/matlab/bvar_toolbox.m index e67e46d759172e81d89d0283767396952219620c..917e6100e7f9c746dc9c63a39f0be156702cc342 100644 --- a/matlab/bvar_toolbox.m +++ b/matlab/bvar_toolbox.m @@ -42,7 +42,7 @@ function [ny, nx, posterior, prior, forecast_data] = bvar_toolbox(nlags) % - bvar_prior_{tau,decay,lambda,mu,omega,flat,train} % Copyright (C) 2003-2007 Christopher Sims -% Copyright (C) 2007-2009 Dynare Team +% Copyright (C) 2007-2011 Dynare Team % % This file is part of Dynare. % @@ -87,7 +87,7 @@ end idx = options_.first_obs+options_.presample-train-nlags:options_.first_obs+options_.nobs-1; % Prepare dataset -if options_.loglinear & ~options_.logdata +if options_.loglinear && ~options_.logdata dataset = log(dataset); end if options_.prefilter @@ -106,7 +106,7 @@ mu = options_.bvar_prior_mu; flat = options_.bvar_prior_flat; ny = size(dataset, 2); -if options_.prefilter | options_.noconstant +if options_.prefilter || options_.noconstant nx = 0; else nx = 1; @@ -204,7 +204,7 @@ else breaks = []; lbreak = 0; end -if ~isempty(vprior) & vprior.w>0 +if ~isempty(vprior) && vprior.w>0 ydum2 = zeros(lags+1,nv,nv); xdum2 = zeros(lags+1,nx,nv); ydum2(end,:,:) = diag(vprior.sig); @@ -286,7 +286,7 @@ y = ydata(smpl,:); % Everything now set up with input data for y=Xb+e % Add persistence dummies -if lambda ~= 0 | mu > 0 +if lambda ~= 0 || mu > 0 ybar = mean(ydata(1:lags,:),1); if ~nox xbar = mean(xdata(1:lags,:),1); diff --git a/matlab/check.m b/matlab/check.m index 05eaa745aa70d195cec08f3c62f01e616a167e01..b3129c657632ee4af722fa0c2f63d66aaa1c0448 100644 --- a/matlab/check.m +++ b/matlab/check.m @@ -11,7 +11,7 @@ function [result,info] = check % SPECIAL REQUIREMENTS % none -% Copyright (C) 2001-2010 Dynare Team +% Copyright (C) 2001-2011 Dynare Team % % This file is part of Dynare. % @@ -33,7 +33,7 @@ global M_ options_ oo_ temp_options = options_; tempex = oo_.exo_simul; -if ~options_.initval_file & M_.exo_nbr > 1 +if ~options_.initval_file && M_.exo_nbr > 1 oo_.exo_simul = ones(M_.maximum_lead+M_.maximum_lag+1,1)*oo_.exo_steady_state'; end @@ -47,7 +47,7 @@ end oo_.dr = dr; -if info(1) ~= 0 & info(1) ~= 3 & info(1) ~= 4 +if info(1) ~= 0 && info(1) ~= 3 && info(1) ~= 4 print_info(info, options_.noprint); end @@ -76,7 +76,7 @@ if options_.noprint == 0 disp(sprintf('\nThere are %d eigenvalue(s) larger than 1 in modulus ', n_explod)); disp(sprintf('for %d forward-looking variable(s)',nyf)); disp(' ') - if dr.rank == nyf & nyf == n_explod + if dr.rank == nyf && nyf == n_explod disp('The rank condition is verified.') else disp('The rank conditions ISN''T verified!') diff --git a/matlab/check_model.m b/matlab/check_model.m index 22679c26996b495bf9913696df93a92b9121fb63..7e15d8d1c7523e4e2978b2a5ff4d6b29f275e257 100644 --- a/matlab/check_model.m +++ b/matlab/check_model.m @@ -1,6 +1,6 @@ function check_model() -% Copyright (C) 2005-2009 Dynare Team +% Copyright (C) 2005-2011 Dynare Team % % This file is part of Dynare. % @@ -29,7 +29,7 @@ if xlen > 1 ' current period. Use additional endogenous variables']) ; end -if (M_.exo_det_nbr > 0) & (M_.maximum_lag > 1 | M_.maximum_lead > 1) +if (M_.exo_det_nbr > 0) && (M_.maximum_lag > 1 || M_.maximum_lead > 1) error(['Exogenous deterministic variables are currently only allowed in' ... ' models with leads and lags on only one period']) end diff --git a/matlab/csminit.m b/matlab/csminit.m index 41aadfc6e4da23027e6de1cdac1ee2d950025b14..8d7f542c3c8704083e6908044263ca7070d5a3c9 100644 --- a/matlab/csminit.m +++ b/matlab/csminit.m @@ -20,7 +20,7 @@ function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin) % http://sims.princeton.edu/yftp/optimize/mfiles/csminit.m % Copyright (C) 1993-2007 Christopher Sims -% Copyright (C) 2008-2009 Dynare Team +% Copyright (C) 2008-2011 Dynare Team % % This file is part of Dynare. % @@ -59,7 +59,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 @@ -138,14 +138,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; @@ -155,12 +155,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 lambda = -lambda*factor^6 else @@ -172,11 +172,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; @@ -186,7 +186,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/csminwel1.m b/matlab/csminwel1.m index 7d3847a5ee70a2ab2570879aa66c7ca874d7eb05..2769ba4f7dc9971d13197a9e8bfd97321a4f6d7c 100644 --- a/matlab/csminwel1.m +++ b/matlab/csminwel1.m @@ -23,7 +23,7 @@ function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel1(fcn,x0,H0,grad,crit,nit,m % http://sims.princeton.edu/yftp/optimize/mfiles/csminwel.m % Copyright (C) 1993-2007 Christopher Sims -% Copyright (C) 2006-2010 Dynare Team +% Copyright (C) 2006-2011 Dynare Team % % This file is part of Dynare. % @@ -105,7 +105,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 @@ -113,7 +113,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 @@ -134,7 +134,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. % @@ -147,7 +147,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 @@ -182,7 +182,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 @@ -218,13 +218,13 @@ while ~done f2=f;f3=f;f1=f;retcode2=retcode1;retcode3=retcode1; end %how to pick gh and xh - if f3 < f - crit & badg3==0 & f3 < f2 & f3 < f1 + if f3 < f - crit && badg3==0 && f3 < f2 && f3 < f1 ih=3; fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3; - elseif f2 < f - crit & badg2==0 & f2 < f1 + elseif f2 < f - crit && badg2==0 && f2 < f1 ih=2; fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2; - elseif f1 < f - crit & badg1==0 + elseif f1 < f - crit && badg1==0 ih=1; fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1; else @@ -271,7 +271,7 @@ while ~done %gh %badgh stuck = (abs(fh-f) < crit); - if (~badg)&(~badgh)&(~stuck) + if (~badg) && (~badgh) && (~stuck) H = bfgsi(H,gh-g,xh-x); end if Verbose @@ -293,7 +293,7 @@ while ~done disp('smallest step still improving too slow, reversed gradient') elseif rc == 5 disp('largest step still improving too fast') - elseif (rc == 4) | (rc==2) + elseif (rc == 4) || (rc==2) disp('back and forth on step length never finished') elseif rc == 3 disp('smallest step still improving too slow') diff --git a/matlab/csolve.m b/matlab/csolve.m index ae78b26cf7f9655ef4240f71c5cfc5a13050ef23..8bcb81f2663044e0151d9ecfa670f425b9f05f19 100644 --- a/matlab/csolve.m +++ b/matlab/csolve.m @@ -22,7 +22,7 @@ function [x,rc] = csolve(FUN,x,gradfun,crit,itmax,varargin) % http://sims.princeton.edu/yftp/optimize/mfiles/csolve.m % Copyright (C) 1993-2007 Christopher Sims -% Copyright (C) 2007 Dynare Team +% Copyright (C) 2007-2011 Dynare Team % % This file is part of Dynare. % @@ -66,7 +66,7 @@ af00=af0; itct=0; while ~done % disp([af00-af0 crit*max(1,af0)]) - if itct>3 & af00-af0<crit*max(1,af0) & rem(itct,2)==1 + if itct>3 && af00-af0<crit*max(1,af0) && rem(itct,2)==1 randomize=1; else if ~analyticg @@ -117,14 +117,14 @@ while ~done lambdamin=lambda; xmin=x+dx; end - if ((lambda >0) & (af0-af < alpha*lambda*af0)) | ((lambda<0) & (af0-af < 0) ) + if ((lambda >0) && (af0-af < alpha*lambda*af0)) || ((lambda<0) && (af0-af < 0) ) if ~shrink factor=factor^.6; shrink=1; end if abs(lambda*(1-factor))*dxSize > .1*delta; lambda = factor*lambda; - elseif (lambda > 0) & (factor==.6) %i.e., we've only been shrinking + elseif (lambda > 0) && (factor==.6) %i.e., we've only been shrinking lambda=-.3; else % subDone=1; @@ -138,7 +138,7 @@ while ~done rc=3; end end - elseif (lambda >0) & (af-af0 > (1-alpha)*lambda*af0) + elseif (lambda >0) && (af-af0 > (1-alpha)*lambda*af0) if shrink factor=factor^.6; shrink=0; diff --git a/matlab/draw_prior_density.m b/matlab/draw_prior_density.m index 3552a6033e6a6ce906df4fb740e7c5c61f40a7ce..183a0386556e9926dc5acea8d67afc1850a384a5 100644 --- a/matlab/draw_prior_density.m +++ b/matlab/draw_prior_density.m @@ -113,7 +113,7 @@ end k = [1:length(dens)]; if pshape(indx) ~= 5 [junk,k1] = max(dens); - if k1 == 1 | k1 == length(dens) + if k1 == 1 || k1 == length(dens) k = find(dens < 10); end end diff --git a/matlab/dyn_ramsey_dynamic_.m b/matlab/dyn_ramsey_dynamic_.m index a497797211e85ba74355b88f8117fa8c3d60f6b0..6d64290cd3fd7e9409d422501dad59197736d830 100644 --- a/matlab/dyn_ramsey_dynamic_.m +++ b/matlab/dyn_ramsey_dynamic_.m @@ -213,7 +213,7 @@ k = 1:size(J,2); for i=1:n if sum(abs(J(:,i))) < 1e-8 - if m(i) < n1 | m(i) > n2 + if m(i) < n1 || m(i) > n2 k(i) = 0; m(i) = 0; end diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m index 9b318fcdb9e0e0934a466d991ab1c5eec0571ade..9a546aea95d79f4fa6c45127713ccf16d66f5fce 100644 --- a/matlab/dynare_estimation.m +++ b/matlab/dynare_estimation.m @@ -11,7 +11,7 @@ function dynare_estimation(var_list,varargin) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2010 Dynare Team +% Copyright (C) 2003-2011 Dynare Team % % This file is part of Dynare. % @@ -62,13 +62,13 @@ else dynare_estimation_1(var_list,varargin{:}); end -if nnobs > 1 & horizon > 0 +if nnobs > 1 && horizon > 0 mh_replic = options_.mh_replic; rawdata = read_variables(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range); gend = options_.nobs; rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:); % Take the log of the variables if needed - if options_.loglinear & ~options_.logdata % and if the data are not in logs, then... + if options_.loglinear && ~options_.logdata % and if the data are not in logs, then... rawdata = log(rawdata); end diff --git a/matlab/dynare_estimation_1.m b/matlab/dynare_estimation_1.m index 9898651832cd855e9217c3038e10035c28c02c5a..8828b902a03d4ac0675dc7fb70ac6d0bd3b76590 100644 --- a/matlab/dynare_estimation_1.m +++ b/matlab/dynare_estimation_1.m @@ -77,10 +77,10 @@ if options_.prefilter == 1 end %% Set options related to filtered variables. -if options_.filtered_vars ~= 0 & isempty(options_.filter_step_ahead), +if options_.filtered_vars ~= 0 && isempty(options_.filter_step_ahead), options_.filter_step_ahead = 1; end -if options_.filtered_vars ~= 0 & options_.filter_step_ahead == 0, +if options_.filtered_vars ~= 0 && options_.filter_step_ahead == 0, options_.filter_step_ahead = 1; end if options_.filter_step_ahead ~= 0 @@ -120,7 +120,7 @@ if ~isempty(estim_params_) end % Test if initial values of the estimated parameters are all between % the prior lower and upper bounds. - if any(xparam1 < bounds(:,1)) | any(xparam1 > bounds(:,2)) + if any(xparam1 < bounds(:,1)) || any(xparam1 > bounds(:,2)) find(xparam1 < bounds(:,1)) find(xparam1 > bounds(:,2)) error('Initial parameter values are outside parameter bounds') @@ -684,7 +684,7 @@ if ~options_.mh_posterior_mode_estimation end end -if options_.mode_check == 1 & ~options_.mh_posterior_mode_estimation +if options_.mode_check == 1 && ~options_.mh_posterior_mode_estimation mode_check(xparam1,0,hh,gend,data,lb,ub,data_index,number_of_observations,no_more_missing_observations); end @@ -703,7 +703,7 @@ else end -if any(bayestopt_.pshape > 0) & ~options_.mh_posterior_mode_estimation +if any(bayestopt_.pshape > 0) && ~options_.mh_posterior_mode_estimation disp(' ') disp('RESULTS FROM POSTERIOR MAXIMIZATION') tstath = zeros(nx,1); @@ -815,7 +815,7 @@ if any(bayestopt_.pshape > 0) & ~options_.mh_posterior_mode_estimation disp(' ') disp(sprintf('Log data density [Laplace approximation] is %f.',md_Laplace)) disp(' ') -elseif ~any(bayestopt_.pshape > 0) & options_.mh_posterior_mode_estimation +elseif ~any(bayestopt_.pshape > 0) && options_.mh_posterior_mode_estimation disp(' ') disp('RESULTS FROM MAXIMUM LIKELIHOOD') tstath = zeros(nx,1); @@ -900,7 +900,7 @@ end OutputDirectoryName = CheckPath('Output'); -if any(bayestopt_.pshape > 0) & options_.TeX %% Bayesian estimation (posterior mode) Latex output +if any(bayestopt_.pshape > 0) && options_.TeX %% Bayesian estimation (posterior mode) Latex output if np filename = [OutputDirectoryName '/' M_.fname '_Posterior_Mode_1.TeX']; fidTeX = fopen(filename,'w'); @@ -1083,21 +1083,21 @@ if np > 0 save([M_.fname '_params.mat'],'pindx'); end -if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ... - (any(bayestopt_.pshape >0 ) & options_.load_mh_file) %% not ML estimation +if (any(bayestopt_.pshape >0 ) && options_.mh_replic) || ... + (any(bayestopt_.pshape >0 ) && options_.load_mh_file) %% not ML estimation bounds = prior_bounds(bayestopt_); bounds(:,1)=max(bounds(:,1),lb); bounds(:,2)=min(bounds(:,2),ub); bayestopt_.lb = bounds(:,1); bayestopt_.ub = bounds(:,2); - if any(xparam1 < bounds(:,1)) | any(xparam1 > bounds(:,2)) + if any(xparam1 < bounds(:,1)) || any(xparam1 > bounds(:,2)) find(xparam1 < bounds(:,1)) find(xparam1 > bounds(:,2)) error('Mode values are outside prior bounds. Reduce prior_trunc.') end % runs MCMC if options_.mh_replic - if options_.load_mh_file & options_.use_mh_covariance_matrix + if options_.load_mh_file && options_.use_mh_covariance_matrix invhess = compute_mh_covariance_matrix; end if options_.dsge_var @@ -1111,7 +1111,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ... CutSample(M_, options_, estim_params_); return else - if ~options_.nodiagnostic & options_.mh_replic > 1000 & options_.mh_nblck > 1 + if ~options_.nodiagnostic && options_.mh_replic > 1000 && options_.mh_nblck > 1 McMCDiagnostics(options_, estim_params_, M_); end %% Here i discard first half of the draws: @@ -1131,7 +1131,7 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ... if options_.moments_varendo oo_ = compute_moments_varendo('posterior',options_,M_,oo_,var_list_); end - if options_.smoother | ~isempty(options_.filter_step_ahead) | options_.forecast + if options_.smoother || ~isempty(options_.filter_step_ahead) || options_.forecast prior_posterior_statistics('posterior',data,gend,data_index,missing_value); end xparam = get_posterior_parameters('mean'); @@ -1139,9 +1139,9 @@ if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ... end end -if (~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape ... - > 0) & options_.load_mh_file)) ... - | ~options_.smoother ) & M_.endo_nbr^2*gend < 1e7 & options_.partial_information == 0 % to be fixed +if (~((any(bayestopt_.pshape > 0) && options_.mh_replic) || (any(bayestopt_.pshape ... + > 0) && options_.load_mh_file)) ... + || ~options_.smoother ) && M_.endo_nbr^2*gend < 1e7 && options_.partial_information == 0 % to be fixed %% ML estimation, or posterior mode without metropolis-hastings or metropolis without bayesian smooth variable [atT,innov,measurement_error,updated_variables,ys,trend_coeff,aK,T,R,P,PK,decomp] = DsgeSmoother(xparam1,gend,data,data_index,missing_value); oo_.Smoother.SteadyState = ys; @@ -1713,7 +1713,7 @@ if (~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape end end -if options_.forecast > 0 & options_.mh_replic == 0 & ~options_.load_mh_file +if options_.forecast > 0 && options_.mh_replic == 0 && ~options_.load_mh_file forecast(var_list_,'smoother'); end diff --git a/matlab/initial_estimation_checks.m b/matlab/initial_estimation_checks.m index 1712e78413b1a9734f261fc09783207aaf4cc70e..95e7a827b04012a81e4795c5faf7a2f3651258d5 100644 --- a/matlab/initial_estimation_checks.m +++ b/matlab/initial_estimation_checks.m @@ -75,7 +75,7 @@ if options_.steadystate_flag % Check if the steady state obtained from the _steadystate file is a % steady state. check1 = 0; - if isfield(options_,'unit_root_vars') & options_.diffuse_filter == 0 + if isfield(options_,'unit_root_vars') && options_.diffuse_filter == 0 if isempty(options_.unit_root_vars) if ~options_.bytecode check1 = max(abs(feval([M_.fname '_static'],... @@ -101,7 +101,7 @@ if info(1) > 0 print_info(info, options_.noprint) end -if any(abs(oo_.steady_state(bayestopt_.mfys))>1e-9) & (options_.prefilter==1) +if any(abs(oo_.steady_state(bayestopt_.mfys))>1e-9) && (options_.prefilter==1) disp(['You are trying to estimate a model with a non zero steady state for the observed endogenous']) disp(['variables using demeaned data!']) error('You should change something in your mod file...') diff --git a/matlab/kalman/likelihood/kalman_filter.m b/matlab/kalman/likelihood/kalman_filter.m index 20a899ccdc7ddc110b198aefb77d3b196673c91d..0fb0a1cffcda0f6553b9784df6ce4e7e96bf7f70 100644 --- a/matlab/kalman/likelihood/kalman_filter.m +++ b/matlab/kalman/likelihood/kalman_filter.m @@ -25,7 +25,7 @@ function [LIK, lik] = kalman_filter(T,R,Q,H,P,Y,start,mf,kalman_tol,riccati_tol) % 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. % @@ -55,7 +55,7 @@ oldK = Inf; notsteady = 1; % Steady state flag. F_singular = 1; -while notsteady & t<smpl +while notsteady && t<smpl t = t+1; v = Y(:,t)-a(mf); F = P(mf,mf) + H; diff --git a/matlab/make_ex_.m b/matlab/make_ex_.m index 496c89a3a7678bd1fb2b708ca23e1a61eb711f72..492a948db6702e5b8702c8c7a214c5fe0dde5342 100644 --- a/matlab/make_ex_.m +++ b/matlab/make_ex_.m @@ -12,7 +12,7 @@ function make_ex_ % SPECIAL REQUIREMENTS % -% Copyright (C) 1996-2009 Dynare Team +% Copyright (C) 1996-2011 Dynare Team % % This file is part of Dynare. % @@ -36,7 +36,7 @@ options_ = set_default_option(options_,'periods',0); if isempty(oo_.exo_steady_state) oo_.exo_steady_state = zeros(M_.exo_nbr,1); end -if M_.exo_det_nbr > 1 & isempty(oo_.exo_det_steady_state) +if M_.exo_det_nbr > 1 && isempty(oo_.exo_det_steady_state) oo_.exo_det_steady_state = zeros(M_.exo_det_nbr,1); end if isempty(oo_.exo_simul) diff --git a/matlab/marginal_density.m b/matlab/marginal_density.m index b87807a185051d236dcb63361bb078500f29d208..e423ea807deb68f807ba2349815105a450bbe17c 100644 --- a/matlab/marginal_density.m +++ b/matlab/marginal_density.m @@ -15,7 +15,7 @@ function [marginal,oo_] = marginal_density(M_, options_, estim_params_, oo_) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2005-2009 Dynare Team +% Copyright (C) 2005-2011 Dynare Team % % This file is part of Dynare. % @@ -94,7 +94,7 @@ while check_coverage marginal(linee,:) = [p, lpost_mode-log(tmp/((TotalNumberOfMhDraws-TODROP)*nblck))]; warning(warning_old_state); end - if abs((marginal(9,2)-marginal(1,2))/marginal(9,2)) > 0.01 | isinf(marginal(1,2)) + if abs((marginal(9,2)-marginal(1,2))/marginal(9,2)) > 0.01 || isinf(marginal(1,2)) if increase == 1 disp('MH: The support of the weighting density function is not large enough...') disp('MH: I increase the variance of this distribution.') diff --git a/matlab/metropolis_hastings_initialization.m b/matlab/metropolis_hastings_initialization.m index fe9adc5c47fdfea6148a1dcc1b209ab5d7f0cd17..01b4dc8e97b0becdf9dd9b15667cdb3bb33f9110 100644 --- a/matlab/metropolis_hastings_initialization.m +++ b/matlab/metropolis_hastings_initialization.m @@ -16,7 +16,7 @@ function [ ix2, ilogpo2, ModelName, MhDirectoryName, fblck, fline, npar, nblck, % SPECIAL REQUIREMENTS % None. -% Copyright (C) 2006-2010 Dynare Team +% Copyright (C) 2006-2011 Dynare Team % % This file is part of Dynare. % @@ -51,7 +51,7 @@ npar = length(xparam1); MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8); d = chol(vv); -if ~options_.load_mh_file & ~options_.mh_recover +if ~options_.load_mh_file && ~options_.mh_recover %% Here we start a new metropolis-hastings, previous draws are not %% considered. if nblck > 1 @@ -90,9 +90,9 @@ if ~options_.load_mh_file & ~options_.mh_recover validate = 0; init_iter = 0; trial = 1; - while validate == 0 & trial <= 10 + while validate == 0 && trial <= 10 candidate = rand_multivariate_normal( transpose(xparam1), d * options_.mh_init_scale, npar); - if all(candidate(:) > mh_bounds(:,1)) & all(candidate(:) < mh_bounds(:,2)) + if all(candidate(:) > mh_bounds(:,1)) && all(candidate(:) < mh_bounds(:,2)) ix2(j,:) = candidate; ilogpo2(j) = - feval(TargetFun,ix2(j,:)',varargin{:}); if ilogpo2(j) <= - bayestopt_.penalty+1e-6 @@ -108,7 +108,7 @@ if ~options_.load_mh_file & ~options_.mh_recover end end init_iter = init_iter + 1; - if init_iter > 100 & validate == 0 + if init_iter > 100 && validate == 0 disp(['MH: I couldn''t get a valid initial value in 100 trials.']) disp(['MH: You should Reduce mh_init_scale...']) disp(sprintf('MH: Parameter mh_init_scale is equal to %f.',options_.mh_init_scale)) @@ -116,7 +116,7 @@ if ~options_.load_mh_file & ~options_.mh_recover trial = trial+1; end end - if trial > 10 & ~validate + if trial > 10 && ~validate disp(['MH: I''m unable to find a starting value for block ' int2str(j)]) return end @@ -127,7 +127,7 @@ if ~options_.load_mh_file & ~options_.mh_recover else% Case 2: one chain (we start from the posterior mode) fprintf(fidlog,[' Initial values of the parameters:\n']); candidate = transpose(xparam1); - if all(candidate' > mh_bounds(:,1)) & all(candidate' < mh_bounds(:,2)) + if all(candidate' > mh_bounds(:,1)) && all(candidate' < mh_bounds(:,2)) ix2 = candidate; ilogpo2 = - feval(TargetFun,ix2',varargin{:}); disp('MH: Initialization at the posterior mode.') @@ -197,7 +197,7 @@ if ~options_.load_mh_file & ~options_.mh_recover end, fprintf(fidlog,' \n'); fclose(fidlog); -elseif options_.load_mh_file & ~options_.mh_recover +elseif options_.load_mh_file && ~options_.mh_recover %% Here we consider previous mh files (previous mh did not crash). disp('MH: I''m loading past metropolis-hastings simulations...') file = dir([ MhDirectoryName '/' ModelName '_mh_history.mat' ]); diff --git a/matlab/mh_optimal_bandwidth.m b/matlab/mh_optimal_bandwidth.m index 69f0814ec00e5504c9013e4de5e4e10322f78430..a4cf6ada5469f3ab4edc969dbac32831d0f0a832 100644 --- a/matlab/mh_optimal_bandwidth.m +++ b/matlab/mh_optimal_bandwidth.m @@ -24,7 +24,7 @@ function optimal_bandwidth = mh_optimal_bandwidth(data,number_of_draws,bandwidth % [1] M. Skold and G.O. Roberts [2003], "Density estimation for the Metropolis-Hastings algorithm". % [2] Silverman [1986], "Density estimation for statistics and data analysis". -% Copyright (C) 2004-2009 Dynare Team +% Copyright (C) 2004-2011 Dynare Team % % This file is part of Dynare. % @@ -91,7 +91,7 @@ end %% Get the Skold and Roberts' correction. -if bandwidth==0 | bandwidth==-1 +if bandwidth==0 || bandwidth==-1 correction = correction_for_repeated_draws(data,number_of_draws); else correction = 0; @@ -103,9 +103,9 @@ if bandwidth == 0; % Rule of thumb bandwidth parameter (Silverman [1986]. h = 2*sigma*(sqrt(pi)*mu02/(12*(mu21^2)*number_of_draws))^(1/5); h = h*correction^(1/5); elseif bandwidth == -1; % Sheather and Jones [1991] plug-in estimation of the optimal bandwidth parameter. - if strcmp(kernel_function,'uniform') | ... - strcmp(kernel_function,'triangle') | ... - strcmp(kernel_function,'epanechnikov') | ... + if strcmp(kernel_function,'uniform') || ... + strcmp(kernel_function,'triangle') || ... + strcmp(kernel_function,'epanechnikov') || ... strcmp(kernel_function,'quartic') error(['I can''t compute the optimal bandwidth with this kernel...' ... 'Try the gaussian, triweight or cosinus kernels.']); @@ -126,9 +126,9 @@ elseif bandwidth == -1; % Sheather and Jones [1991] plug-in estimation of the op h = (correction*mu02/(number_of_draws*Ihat2*mu21^2))^(1/5); % equation (22) in Skold and Roberts [2003]. elseif bandwidth == -2; % Bump killing... I compute local bandwith parameters in order to remove % spurious bumps introduced by long rejecting periods. - if strcmp(kernel_function,'uniform') | ... - strcmp(kernel_function,'triangle') | ... - strcmp(kernel_function,'epanechnikov') | ... + if strcmp(kernel_function,'uniform') || ... + strcmp(kernel_function,'triangle') || ... + strcmp(kernel_function,'epanechnikov') || ... strcmp(kernel_function,'quartic') error(['I can''t compute the optimal bandwidth with this kernel...' ... 'Try the gaussian, triweight or cosinus kernels.']); @@ -136,7 +136,7 @@ elseif bandwidth == -2; % Bump killing... I compute local bandwith parameter T = zeros(n,1); for i=1:n j = i; - while j<= n & (data(j,1)-data(i,1))<2*eps; + while j<= n && (data(j,1)-data(i,1))<2*eps; j = j+1; end T(i) = (j-i); diff --git a/matlab/missing_DiffuseKalmanSmootherH1_Z.m b/matlab/missing_DiffuseKalmanSmootherH1_Z.m index 54b493ee920ae67d2c6f02ff6da2c17f8ccd438d..b1ab7336df66b856ff6052b62fe1b7d418d62526 100644 --- a/matlab/missing_DiffuseKalmanSmootherH1_Z.m +++ b/matlab/missing_DiffuseKalmanSmootherH1_Z.m @@ -97,7 +97,7 @@ epsilonhat = zeros(rr,smpl); r = zeros(mm,smpl+1); t = 0; -while rank(Pinf(:,:,t+1),crit1) & t<smpl +while rank(Pinf(:,:,t+1),crit1) && t<smpl t = t+1; di = data_index{t}; if isempty(di) @@ -160,7 +160,7 @@ Kstar = Kstar(:,:,1:d); Pstar = Pstar(:,:,1:d); Pinf = Pinf(:,:,1:d); notsteady = 1; -while notsteady & t<smpl +while notsteady && t<smpl t = t+1; P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1)); di = data_index{t}; diff --git a/matlab/missing_DiffuseKalmanSmootherH3_Z.m b/matlab/missing_DiffuseKalmanSmootherH3_Z.m index 3e8aaa8f861beeaaec13dd3dbb40e0cfc57e02a6..b80761dc48f80040151371bcd5cfd1b8cbdcea85 100644 --- a/matlab/missing_DiffuseKalmanSmootherH3_Z.m +++ b/matlab/missing_DiffuseKalmanSmootherH3_Z.m @@ -113,7 +113,7 @@ r = zeros(mm,smpl); t = 0; icc=0; newRank = rank(Pinf(:,:,1),crit1); -while newRank & t < smpl +while newRank && t < smpl t = t+1; a(:,t) = a1(:,t); Pstar1(:,:,t) = Pstar(:,:,t); @@ -125,7 +125,7 @@ while newRank & t < smpl Fstar(i,t) = Zi*Pstar(:,:,t)*Zi' +H(i); Finf(i,t) = Zi*Pinf(:,:,t)*Zi'; Kstar(:,i,t) = Pstar(:,:,t)*Zi'; - if Finf(i,t) > crit & newRank + if Finf(i,t) > crit && newRank icc=icc+1; Kinf(:,i,t) = Pinf(:,:,t)*Zi'; Kinf_Finf = Kinf(:,i,t)/Finf(i,t); @@ -172,7 +172,7 @@ Pinf = Pinf(:,:,1:d); Pstar1 = Pstar1(:,:,1:d); Pinf1 = Pinf1(:,:,1:d); notsteady = 1; -while notsteady & t<smpl +while notsteady && t<smpl t = t+1; a(:,t) = a1(:,t); P1(:,:,t) = P(:,:,t); @@ -254,7 +254,7 @@ if d for t = d:-1:1 di = flipud(data_index{t})'; for i = di - % if Finf(i,t) > crit & ~(t==d & i>options_.diffuse_d), % use of options_.diffuse_d to be sure of DKF termination + % if Finf(i,t) > crit && ~(t==d && i>options_.diffuse_d), % use of options_.diffuse_d to be sure of DKF termination if Finf(i,t) > crit r1(:,t) = Z(i,:)'*v(i,t)/Finf(i,t) + ... (Kinf(:,i,t)'*Fstar(i,t)/Finf(i,t)-Kstar(:,i,t)')*r0(:,t)/Finf(i,t)*Z(i,:)' + ... diff --git a/matlab/osr1.m b/matlab/osr1.m index 2b8ce11571861e4f983caa4800796f0ce38d85a5..624a623ec203451eaa6306292da7b625d2eb6540 100644 --- a/matlab/osr1.m +++ b/matlab/osr1.m @@ -62,7 +62,7 @@ else % testing if ys isn't a steady state or if we aren't computing Ramsey policy fh = str2func([M_.fname '_static']); if max(abs(feval(fh,oo_.steady_state,[oo_.exo_steady_state; oo_.exo_det_steady_state], M_.params))) ... - > options_.dynatol & options_.ramsey_policy == 0 + > options_.dynatol && options_.ramsey_policy == 0 if options_.linear == 0 % nonlinear models [dr.ys,check1] = dynare_solve(fh,dr.ys,options_.jacobian_flag,... diff --git a/matlab/partial_information/PCL_resol.m b/matlab/partial_information/PCL_resol.m index 1e6cfd34c0f8dac76e35474d7eb7e9a501d8ad9d..4c3ac93b149d3307222152b257c518616423740b 100644 --- a/matlab/partial_information/PCL_resol.m +++ b/matlab/partial_information/PCL_resol.m @@ -125,7 +125,7 @@ if ~isreal(dr.ys) end dr.fbias = zeros(M_.endo_nbr,1); -if( (options_.partial_information ==1) | (options_.ACES_solver==1))%&& (check_flag == 0) +if( (options_.partial_information ==1) || (options_.ACES_solver==1))%&& (check_flag == 0) [dr,info,M_,options_,oo_] = dr1_PI(dr,check_flag,M_,options_,oo_); else [dr,info,M_,options_,oo_] = dr1(dr,check_flag,M_,options_,oo_); diff --git a/matlab/partial_information/PI_gensys.m b/matlab/partial_information/PI_gensys.m index d410b3e353ab26ad48135bc69c4456b34e9b7149..b1144cf0e77a9a353dce0e3f659eaae5d9b9b8f8 100644 --- a/matlab/partial_information/PI_gensys.m +++ b/matlab/partial_information/PI_gensys.m @@ -90,7 +90,7 @@ try end warning('on','MATLAB:singularMatrix'); warning('on','MATLAB:nearlySingularMatrix'); - if (isinf(UAVinv) | isnan(UAVinv)) + if (isinf(UAVinv) || isnan(UAVinv)) if(options_.useACES==1) disp('ERROR! saving PI_gensys_data_dump'); save PI_gensys_data_dump @@ -232,14 +232,14 @@ for i=1:nn % bug detected by Vasco Curdia and Daria Finocchiaro, 2/25/2004 A root of % exactly 1.01 and no root between 1 and 1.02, led to div being stuck at 1.01 % and the 1.01 root being misclassified as stable. Changing < to <= below fixes this. - if 1+realsmall<divhat & divhat<=div + if 1+realsmall<divhat && divhat<=div div=.5*(1+divhat); end end end % ---------------------------------------- nunstab=nunstab+(abs(b(i,i))>div*abs(a(i,i))); - if abs(a(i,i))<realsmall & abs(b(i,i))<realsmall + if abs(a(i,i))<realsmall && abs(b(i,i))<realsmall zxz=1; end end @@ -257,7 +257,7 @@ if zxz nmat=[]; %;gev=[] return end -if (FL_RANK ~= nunstab & options_.ACES_solver~=1) +if (FL_RANK ~= nunstab && options_.ACES_solver~=1) disp(['Number of unstable variables ' num2str(nunstab)]); disp( ['does not match number of expectational equations ' num2str(FL_RANK)]); nmat=[];% gev=[]; diff --git a/matlab/partial_information/dr1_PI.m b/matlab/partial_information/dr1_PI.m index ffe02625575e63a910fff62a5a561730c9c80036..afc9b0605c2410e1d7fe82d26980f6f5ed2e7094 100644 --- a/matlab/partial_information/dr1_PI.m +++ b/matlab/partial_information/dr1_PI.m @@ -78,7 +78,7 @@ if (options_.order > 1) end % expanding system for Optimal Linear Regulator -if options_.ramsey_policy & options_.ACES_solver == 0 +if options_.ramsey_policy && options_.ACES_solver == 0 if isfield(M_,'orig_model') orig_model = M_.orig_model; M_.endo_nbr = orig_model.endo_nbr; @@ -194,7 +194,7 @@ end % end if useAIM and... %end if isfield(lq_instruments,'names') num_inst=size(lq_instruments.names,1); - if ~isfield(lq_instruments,'inst_var_indices') & num_inst>0 + if ~isfield(lq_instruments,'inst_var_indices') && num_inst>0 for i=1:num_inst i_tmp = strmatch(deblank(lq_instruments.names(i,:)),M_.endo_names,'exact'); if isempty(i_tmp) @@ -213,7 +213,7 @@ end % end if useAIM and... i_var=[]; num_inst=0; end - if size(i_var,2)>0 & size(i_var,2)==num_inst + if size(i_var,2)>0 && size(i_var,2)==num_inst m_var=zeros(nendo,1); for i=1:nendo if isempty(find(i_var==i)) @@ -262,7 +262,7 @@ end % end if useAIM and... fnd = find(lead_lag(:,M_.maximum_lag+2)); AA0(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,M_.maximum_lag+2))); %forwd jacobian end - if npred>0 & M_.maximum_lag ==1 + if npred>0 && M_.maximum_lag ==1 fnd = find(lead_lag(:,1)); AA2(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,1))); %backward end @@ -285,7 +285,7 @@ end % end if useAIM and... lq_instruments.B0=[lq_instruments.ij0; eye(num_inst)]; AA0=[AA0, zeros(xlen,num_inst); zeros(num_inst,xlen+num_inst)]; end - if npred>0 & M_.maximum_lag ==1 + if npred>0 && M_.maximum_lag ==1 AA_all(:,:)=0.0; fnd = find(lead_lag(:,1)); AA_all(:, fnd)= jacobia_(:,nonzeros(lead_lag(:,1))); %backward @@ -353,7 +353,7 @@ end % end if useAIM and... end % reuse some of the bypassed code and tests that may be needed - if eu ~=[1; 1] & options_.ACES_solver==0 + if eu ~=[1; 1] && options_.ACES_solver==0 info(1) = abs(eu(1)+eu(2)); info(2) = 1.0e+8; % return diff --git a/matlab/qzdiv.m b/matlab/qzdiv.m index 2ab7fb2a74b9d17cb0693054b79dbfbdc4a541da..2c88184f1599dbee88e34098e6147e00592d6945 100644 --- a/matlab/qzdiv.m +++ b/matlab/qzdiv.m @@ -10,6 +10,7 @@ function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z) % http://sims.princeton.edu/yftp/gensys/mfiles/qzdiv.m % Copyright (C) 1993-2007 Christopher Sims +% Copyright (C) 2008-2011 Dynare Team % % This file is part of Dynare. % @@ -33,7 +34,7 @@ root(:,2) = root(:,2)./root(:,1); for i = n:-1:1 m=0; for j=i:-1:1 - if (root(j,2) > stake | root(j,2) < -.1) + if (root(j,2) > stake || root(j,2) < -.1) m=j; break end diff --git a/matlab/qzswitch.m b/matlab/qzswitch.m index ab2dd6a23651d09dca06b21dead65a7add21e70d..eeb73c6811c5a7543ce60b1341b0eb7c55ac96e4 100644 --- a/matlab/qzswitch.m +++ b/matlab/qzswitch.m @@ -14,6 +14,7 @@ function [A,B,Q,Z] = qzswitch(i,A,B,Q,Z) % http://sims.princeton.edu/yftp/gensys/mfiles/qzswitch.m % Copyright (C) 1993-2007 Christopher Sims +% Copyright (C) 2008-2011 Dynare Team % % This file is part of Dynare. % @@ -36,7 +37,7 @@ a = A(i,i); d = B(i,i); b = A(i,i+1); e = B(i,i+1); c = A(i+1,i+1); f = B(i+1,i+1); % A(i:i+1,i:i+1)=[a b; 0 c]; % B(i:i+1,i:i+1)=[d e; 0 f]; -if (abs(c)<realsmall & abs(f)<realsmall) +if (abs(c)<realsmall && abs(f)<realsmall) if abs(a)<realsmall % l.r. coincident 0's with u.l. of A=0; do nothing return @@ -47,7 +48,7 @@ if (abs(c)<realsmall & abs(f)<realsmall) wz=[wz [wz(2)';-wz(1)'] ]; xy=eye(2); end -elseif (abs(a)<realsmall & abs(d)<realsmall) +elseif (abs(a)<realsmall && abs(d)<realsmall) if abs(c)<realsmall % u.l. coincident zeros with l.r. of A=0; do nothing return diff --git a/matlab/random_walk_metropolis_hastings.m b/matlab/random_walk_metropolis_hastings.m index 6d41f7f726cdc6575bfff662323ebce6cdc07f3a..cf55d0e6535b93de18f3b64739a11723bfe4c99c 100644 --- a/matlab/random_walk_metropolis_hastings.m +++ b/matlab/random_walk_metropolis_hastings.m @@ -122,7 +122,7 @@ else if options_.steadystate_flag, NamFileInput(length(NamFileInput)+1,:)={'',[ModelName '_steadystate.m']}; end - if (options_.load_mh_file~=0) & any(fline>1) , + if (options_.load_mh_file~=0) && any(fline>1) , NamFileInput(length(NamFileInput)+1,:)={[M_.dname '/metropolis/'],[ModelName '_mh' int2str(NewFile(1)) '_blck*.mat']}; end if exist([ModelName '_optimal_mh_scale_parameter.mat']) diff --git a/matlab/random_walk_metropolis_hastings_core.m b/matlab/random_walk_metropolis_hastings_core.m index 1c6dc24af7ffbefe846586a08a94ca62ca0b40ae..768c993442a8f3f2d7b8870fdf085005d52114fa 100644 --- a/matlab/random_walk_metropolis_hastings_core.m +++ b/matlab/random_walk_metropolis_hastings_core.m @@ -136,7 +136,7 @@ for b = fblck:nblck, jloop=jloop+1; randn('state',record.Seeds(b).Normal); rand('state',record.Seeds(b).Unifor); - if (options_.load_mh_file~=0) & (fline(b)>1) & OpenOldFile(b) + if (options_.load_mh_file~=0) && (fline(b)>1) && OpenOldFile(b) load(['./' MhDirectoryName '/' ModelName '_mh' int2str(NewFile(b)) ... '_blck' int2str(b) '.mat']) x2 = [x2;zeros(InitSizeArray(b)-fline(b)+1,npar)]; @@ -177,7 +177,7 @@ for b = fblck:nblck, j = 1; while j <= nruns(b) par = feval(ProposalFun, ix2(b,:), proposal_covariance_Cholesky_decomposition, n); - if all( par(:) > mh_bounds(:,1) ) & all( par(:) < mh_bounds(:,2) ) + if all( par(:) > mh_bounds(:,1) ) && all( par(:) < mh_bounds(:,2) ) try logpost = - feval(TargetFun, par(:),varargin{:}); catch @@ -210,22 +210,22 @@ for b = fblck:nblck, fprintf([s0,'%s'],newString); end end - if mod(j,50)==0 & whoiam + if mod(j,50)==0 && whoiam % keyboard; waitbarString = [ '(' int2str(b) '/' int2str(options_.mh_nblck) '), ' sprintf('accept. %3.f%%', 100 * isux/j)]; fMessageStatus((b-fblck)/(nblck-fblck+1)+prtfrc/(nblck-fblck+1),whoiam,waitbarString, '', options_.parallel(ThisMatlab)); end else - if mod(j, 3)==0 & ~whoiam + if mod(j, 3)==0 && ~whoiam waitbar(prtfrc,hh,[ '(' int2str(b) '/' int2str(options_.mh_nblck) ') ' sprintf('%f done, acceptation rate %f',prtfrc,isux/j)]); - elseif mod(j,50)==0 & whoiam, + elseif mod(j,50)==0 && whoiam, % keyboard; waitbarString = [ '(' int2str(b) '/' int2str(options_.mh_nblck) ') ' sprintf('%f done, acceptation rate %f',prtfrc,isux/j)]; fMessageStatus(prtfrc,whoiam,waitbarString, waitbarTitle, options_.parallel(ThisMatlab)); end end - if (irun == InitSizeArray(b)) | (j == nruns(b)) % Now I save the simulations + if (irun == InitSizeArray(b)) || (j == nruns(b)) % Now I save the simulations save([MhDirectoryName '/' ModelName '_mh' int2str(NewFile(b)) '_blck' int2str(b) '.mat'],'x2','logpo2'); fidlog = fopen([MhDirectoryName '/metropolis.log'],'a'); fprintf(fidlog,['\n']); @@ -238,7 +238,7 @@ for b = fblck:nblck, fprintf(fidlog,[' params:' int2str(i) ': ' num2str(mean(x2(:,i))) '\n']); end fprintf(fidlog,[' log2po:' num2str(mean(logpo2)) '\n']); - fprintf(fidlog,[' Minimum value.........:\n']);; + fprintf(fidlog,[' Minimum value.........:\n']); for i=1:length(x2(1,:)) fprintf(fidlog,[' params:' int2str(i) ': ' num2str(min(x2(:,i))) '\n']); end diff --git a/matlab/read_variables.m b/matlab/read_variables.m index 8f27a861e8bc1c16e20e7b9177d9007307603fef..06f6d2f84fd42b9ad780e8c6c91592863afac80c 100644 --- a/matlab/read_variables.m +++ b/matlab/read_variables.m @@ -17,7 +17,7 @@ function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sh % all local variables have complicated names in order to avoid name % conflicts with possible user variable names -% Copyright (C) 2005-2009 Dynare Team +% Copyright (C) 2005-2011 Dynare Team % % This file is part of Dynare. % @@ -50,7 +50,7 @@ if exist(file_name_01) eval(dyn_instr_01); for dyn_i_01=1:var_size_01 dyn_tmp_01 = eval(var_names_01(dyn_i_01,:)); - if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0 + if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0 cd(old_pwd) error('data size is too large') end @@ -61,7 +61,7 @@ elseif exist([file_name_01 '.mat']) s = load(file_name_01); for dyn_i_01=1:var_size_01 dyn_tmp_01 = s.(deblank(var_names_01(dyn_i_01,:))); - if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0 + if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0 cd(old_pwd) error('data size is too large') end @@ -73,7 +73,7 @@ elseif exist([file_name_01 '.xls']) for dyn_i_01=1:var_size_01 iv = strmatch(var_names_01(dyn_i_01,:),raw(1,:),'exact'); dyn_tmp_01 = [raw{2:end,iv}]'; - if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0 + if length(dyn_tmp_01) > dyn_size_01 && dyn_size_01 > 0 cd(old_pwd) error('data size is too large') end diff --git a/matlab/set_shocks.m b/matlab/set_shocks.m index d402700058125cbd6a92909e6a89526e35875f14..410d3b5f43fdfc7377415680003ec97213daf74a 100644 --- a/matlab/set_shocks.m +++ b/matlab/set_shocks.m @@ -18,7 +18,7 @@ function set_shocks(flag,k,ivar,values) % SPECIAL REQUIREMENTS % none -% Copyright (C) 2003-2009 Dynare Team +% Copyright (C) 2003-2011 Dynare Team % % This file is part of Dynare. % @@ -40,9 +40,9 @@ global oo_ M_ k = k + M_.maximum_lag; n1 = size(oo_.exo_simul,1); n2 = size(oo_.exo_det_simul,1); -if k(end) > n1 & flag <= 1 +if k(end) > n1 && flag <= 1 oo_.exo_simul = [oo_.exo_simul; repmat(oo_.exo_steady_state',k(end)-n1,1)]; -elseif k(end) > n2 & flag > 1 +elseif k(end) > n2 && flag > 1 oo_.exo_det_simul = [oo_.exo_det_simul; repmat(oo_.exo_det_steady_state',k(end)-n2,1)]; end diff --git a/matlab/simul.m b/matlab/simul.m index ece7b4db9d6448d191c50c226d306aeedbd353ac..aafc4f8c11b9b89ef8e797ea2fa62e8f0347c00a 100644 --- a/matlab/simul.m +++ b/matlab/simul.m @@ -69,7 +69,7 @@ if ~ options_.initval_file end end -if isempty(options_.scalv) | options_.scalv == 0 +if isempty(options_.scalv) || options_.scalv == 0 options_.scalv = oo_.steady_state ; end diff --git a/matlab/solve_two_boundaries.m b/matlab/solve_two_boundaries.m index d6b508b6db4adf5a8bad8247d23c9d12139672a2..fabc0d9228460ea29442540ec0c7212bc4f46406 100644 --- a/matlab/solve_two_boundaries.m +++ b/matlab/solve_two_boundaries.m @@ -42,7 +42,7 @@ function y = solve_two_boundaries(fname, y, x, params, y_index, nze, periods, y_ % none. % -% Copyright (C) 1996-2010 Dynare Team +% Copyright (C) 1996-2011 Dynare Team % % This file is part of Dynare. % @@ -72,7 +72,7 @@ max_resa=1e100; Jacobian_Size=Blck_size*(y_kmin+y_kmax_l +periods); g1=spalloc( Blck_size*periods, Jacobian_Size, nze*periods); reduced = 0; -while ~(cvg==1 | iter>maxit_), +while ~(cvg==1 || iter>maxit_), [r, y, g1, g2, g3, b]=feval(fname, y, x, params, periods, 0, y_kmin, Blck_size); % fjac = zeros(Blck_size, Blck_size*(y_kmin_l+1+y_kmax_l)); % disp(['Blck_size=' int2str(Blck_size) ' size(y_index)=' int2str(size(y_index,2))]); @@ -146,16 +146,16 @@ while ~(cvg==1 | iter>maxit_), % else % max_res=max(max(abs(r))); % end; - if(~isreal(max_res) | isnan(max_res)) + if(~isreal(max_res) || isnan(max_res)) cvg = 0; - elseif(is_linear & iter>0) + elseif(is_linear && iter>0) cvg = 1; else cvg=(max_res<solve_tolf); end; if(~cvg) if(iter>0) - if(~isreal(max_res) | isnan(max_res) | (max_resa<max_res && iter>1)) + if(~isreal(max_res) || isnan(max_res) || (max_resa<max_res && iter>1)) if(~isreal(max_res)) disp(['Variable ' M_.endo_names(max_indx,:) ' (' int2str(max_indx) ') returns an undefined value']); end; @@ -257,7 +257,7 @@ while ~(cvg==1 | iter>maxit_), while(flag1>0) [L1, U1]=luinc(g1a,luinc_tol); [za,flag1] = gmres(g1a,b,Blck_size,1e-6,Blck_size*periods,L1,U1); - if (flag1>0 | reduced) + if (flag1>0 || reduced) if(flag1==1) disp(['Error in simul: No convergence inside GMRES after ' num2str(periods*10,'%6d') ' iterations, in block' num2str(Block_Size,'%3d')]); elseif(flag1==2) @@ -278,7 +278,7 @@ while ~(cvg==1 | iter>maxit_), while(flag1>0) [L1, U1]=luinc(g1a,luinc_tol); [za,flag1] = bicgstab(g1a,b,1e-7,Blck_size*periods,L1,U1); - if (flag1>0 | reduced) + if (flag1>0 || reduced) if(flag1==1) disp(['Error in simul: No convergence inside BICGSTAB after ' num2str(periods*10,'%6d') ' iterations, in block' num2str(Block_Size,'%3d')]); elseif(flag1==2) diff --git a/matlab/th_autocovariances.m b/matlab/th_autocovariances.m index 5fc3920961988a8bf719f8fb61757f300258bcdd..c91d71928d510e96f3a22e0dfaa09b5ce6b9c698 100644 --- a/matlab/th_autocovariances.m +++ b/matlab/th_autocovariances.m @@ -96,7 +96,7 @@ ipred = nstatic+(1:npred)'; % Compute stationary variables (before HP filtering), % and compute 2nd order mean correction on stationary variables (in case of % HP filtering, this mean correction is computed *before* filtering) -if options_.order == 2 | options_.hp_filter == 0 +if options_.order == 2 || options_.hp_filter == 0 [vx, u] = lyapunov_symm(A,B*M_.Sigma_e*B',options_.qz_criterium,options_.lyapunov_complex_threshold); iky = inv_order_var(ivar); stationary_vars = (1:length(ivar))';