diff --git a/matlab/DsgeLikelihood.m b/matlab/DsgeLikelihood.m
index a6bad363a..c87e95716 100644
--- a/matlab/DsgeLikelihood.m
+++ b/matlab/DsgeLikelihood.m
@@ -162,7 +162,9 @@ function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data
end
else
if options_.kalman_algo == 1
- LIK = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,data,trend,start);
+ nv = size(bayestopt_.Z,1);
+ LIK = kalman_filter(bayestopt_.Z,zeros(nv,nv),T,R,Q,data,zeros(size(T,1),1),Pstar,'u');
+% LIK = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,data,trend,start);
if isinf(LIK)
LIK = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,data,trend,start);
end
diff --git a/matlab/doc/CheckPath.html b/matlab/doc/CheckPath.html
new file mode 100644
index 000000000..a33da81fa
--- /dev/null
+++ b/matlab/doc/CheckPath.html
@@ -0,0 +1,55 @@
+
+
+
+ Description of CheckPath
+
+
+
+
+
+
+
+
+
+
+
+
+
+CheckPath
+
+
+ PURPOSE
+06-03-2005
+
+ SYNOPSIS
+function DirectoryName = CheckPath(type)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/CreateBenchmark.html b/matlab/doc/CreateBenchmark.html
new file mode 100644
index 000000000..f14eba009
--- /dev/null
+++ b/matlab/doc/CreateBenchmark.html
@@ -0,0 +1,54 @@
+
+
+
+ Description of CreateBenchmark
+
+
+
+
+
+
+
+
+
+Home >
. > CreateBenchmark.m
+
+
+
+CreateBenchmark
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [12-06-2004]
+
+ SYNOPSIS
+function CreateBenchmark
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function CreateBenchmark
+0002
+0003
+0004
+0005 global oo_
+0006
+0007 eval([M_.fname '_oo_ = oo_;' ])
+0008 eval(['save ' M_.fname '_benchmark_oo ' M_.fname '_oo_' ])
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/CutSample.html b/matlab/doc/CutSample.html
new file mode 100644
index 000000000..41ff1f1aa
--- /dev/null
+++ b/matlab/doc/CutSample.html
@@ -0,0 +1,89 @@
+
+
+
+ Description of CutSample
+
+
+
+
+
+
+
+
+
+
+
+
+
+CutSample
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-09-2005]
+
+ SYNOPSIS
+function CutSample()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function CutSample()
+0002
+0003 global M_ options_ estim_params_
+0004
+0005 npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
+0006
+0007 DirectoryName = CheckPath ('metropolis' );
+0008 file = dir([ DirectoryName '/' M_.fname '_mh_history.mat' ]);
+0009 files = dir([ DirectoryName '/' M_.fname '_mh*.mat' ]);
+0010 if ~length(files)
+0011 disp('MH:: FAILURE! there is no MH file to load here!' )
+0012 return
+0013 end
+0014 if ~length(file)
+0015 disp('MH:: FAILURE! there is no MH-history file!' )
+0016 return
+0017 else
+0018 load([ DirectoryName '/' M_.fname '_mh_history' ])
+0019 end
+0020 TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
+0021 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
+0022 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8)
+0023 FirstDraw = floor(options_.mh_drop*TotalNumberOfMhDraws);
+0024 FirstMhFile = ceil(FirstDraw/MAX_nruns);
+0025 FirstLine = FirstDraw-(FirstMhFile-1)*MAX_nruns+1;
+0026 record.KeepedDraws.FirstMhFile = FirstMhFile;
+0027 record.KeepedDraws.FirstLine = FirstLine;
+0028 if (TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1 > 0
+0029 record.KeepedDraws.Distribution = [ MAX_nruns-FirstLine+1 ; ...
+0030 ones((TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1,1)*MAX_nruns ; ...
+0031 record.MhDraws(end ,3) ];
+0032 elseif TotalNumberOfMhFiles == 1
+0033 record.KeepedDraws.Distribution = [];
+0034 elseif TotalNumberOfMhFiles == 2 & FirstMhFile > 1
+0035 record.KeepedDraws.Distribution = [MAX_nruns-FirstLine+1 ; record.MhDraws(end ,3)];
+0036 end
+0037 save([DirectoryName '/' M_.fname '_mh_history' ],'record' );
+0038 fprintf('MH: Total number of Mh draws: %d.\n' ,TotalNumberOfMhDraws);
+0039 fprintf('MH: Total number of generated Mh files: %d.\n' ,TotalNumberOfMhFiles);
+0040 fprintf('MH: I''ll use mh-files %d to %d.\n' ,FirstMhFile,TotalNumberOfMhFiles);
+0041 fprintf('MH: In mh-file number %d i''ll start at line %d.\n' ,FirstMhFile,FirstLine);
+0042 fprintf('MH: Finally I keep %d draws.\n' ,TotalNumberOfMhDraws-FirstDraw);
+0043 disp(' ' );
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseKalmanSmoother1.html b/matlab/doc/DiffuseKalmanSmoother1.html
new file mode 100644
index 000000000..f8e77c0f9
--- /dev/null
+++ b/matlab/doc/DiffuseKalmanSmoother1.html
@@ -0,0 +1,193 @@
+
+
+
+ Description of DiffuseKalmanSmoother1
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseKalmanSmoother1.m
+
+
+
+DiffuseKalmanSmoother1
+
+
+ PURPOSE
+modified by M. Ratto:
+
+ SYNOPSIS
+function [alphahat,etahat,a, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+steady Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+DsgeSmoother stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
+
+
+
+ SOURCE CODE
+0001 function [alphahat,etahat,a, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014 global options_
+0015
+0016 nk = options_.nk;
+0017 spinf = size(Pinf1);
+0018 spstar = size(Pstar1);
+0019 v = zeros(pp,smpl);
+0020 a = zeros(mm,smpl+1);
+0021 aK = zeros(nk,mm,smpl+1);
+0022 iF = zeros(pp,pp,smpl);
+0023 Fstar = zeros(pp,pp,smpl);
+0024 iFinf = zeros(pp,pp,smpl);
+0025 K = zeros(mm,pp,smpl);
+0026 L = zeros(mm,mm,smpl);
+0027 Linf = zeros(mm,mm,smpl);
+0028 Kstar = zeros(mm,pp,smpl);
+0029 P = zeros(mm,mm,smpl+1);
+0030 Pstar = zeros(spstar(1),spstar(2),smpl+1); Pstar(:,:,1) = Pstar1;
+0031 Pinf = zeros(spinf(1),spinf(2),smpl+1); Pinf(:,:,1) = Pinf1;
+0032 crit = options_.kalman_tol;
+0033 crit1 = 1.e-8;
+0034 steady = smpl;
+0035 rr = size(Q,1);
+0036 QQ = R*Q*transpose(R);
+0037 QRt = Q*transpose(R);
+0038 alphahat = zeros(mm,smpl);
+0039 etahat = zeros(rr,smpl);
+0040 r = zeros(mm,smpl);
+0041
+0042 Z = zeros(pp,mm);
+0043 for i=1:pp;
+0044 Z(i,mf(i)) = 1;
+0045 end
+0046
+0047 t = 0;
+0048 while rank(Pinf(:,:,t+1),crit1) & t<smpl
+0049 t = t+1;
+0050 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
+0051 if rcond(Pinf(mf,mf,t)) < crit
+0052 return
+0053 end
+0054 iFinf(:,:,t) = inv(Pinf(mf,mf,t));
+0055 Kinf(:,:,t) = T*Pinf(:,mf,t)*iFinf(:,:,t);
+0056 a(:,t+1) = T*a(:,t) + Kinf(:,:,t)*v(:,t);
+0057 aK(1,:,t+1) = a(:,t+1);
+0058 for jnk=2:nk,
+0059 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
+0060 end
+0061 Linf(:,:,t) = T - Kinf(:,:,t)*Z;
+0062 Fstar(:,:,t) = Pstar(mf,mf,t);
+0063 Kstar(:,:,t) = (T*Pstar(:,mf,t)-Kinf(:,:,t)*Fstar(:,:,t))*iFinf(:,:,t);
+0064 Pstar(:,:,t+1) = T*Pstar(:,:,t)*transpose(T)-T*Pstar(:,mf,t)*transpose(Kinf(:,:,t))-Kinf(:,:,t)*Pinf(mf,mf,t)*transpose(Kstar(:,:,t)) + QQ;
+0065 Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T)-T*Pinf(:,mf,t)*transpose(Kinf(:,:,t));
+0066 end
+0067 d = t;
+0068 P(:,:,d+1) = Pstar(:,:,d+1);
+0069 iFinf = iFinf(:,:,1:d);
+0070 Linf = Linf(:,:,1:d);
+0071 Fstar = Fstar(:,:,1:d);
+0072 Kstar = Kstar(:,:,1:d);
+0073 Pstar = Pstar(:,:,1:d);
+0074 Pinf = Pinf(:,:,1:d);
+0075 notsteady = 1;
+0076 while notsteady & t<smpl
+0077 t = t+1;
+0078 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
+0079 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0080 if rcond(P(mf,mf,t)) < crit
+0081 return
+0082 end
+0083 iF(:,:,t) = inv(P(mf,mf,t));
+0084 K(:,:,t) = T*P(:,mf,t)*iF(:,:,t);
+0085 L(:,:,t) = T-K(:,:,t)*Z;
+0086 a(:,t+1) = T*a(:,t) + K(:,:,t)*v(:,t);
+0087 aK(1,:,t+1) = a(:,t+1);
+0088 for jnk=2:nk,
+0089 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
+0090 end
+0091 P(:,:,t+1) = T*P(:,:,t)*transpose(T)-T*P(:,mf,t)*transpose(K(:,:,t)) + QQ;
+0092 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
+0093 end
+0094 K_s = K(:,:,t);
+0095 iF_s = iF(:,:,t);
+0096 P_s = P(:,:,t+1);
+0097 if t<smpl
+0098 t_steady = t+1;
+0099 P = cat(3,P(:,:,1:t),repmat(P(:,:,t),[1 1 smpl-t_steady+1]));
+0100 iF = cat(3,iF(:,:,1:t),repmat(inv(P_s(mf,mf)),[1 1 smpl-t_steady+1]));
+0101 L = cat(3,L(:,:,1:t),repmat(T-K_s*Z,[1 1 smpl-t_steady+1]));
+0102 K = cat(3,K(:,:,1:t),repmat(T*P_s(:,mf)*iF_s,[1 1 smpl-t_steady+1]));
+0103 end
+0104 while t<smpl
+0105 t=t+1;
+0106 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
+0107 a(:,t+1) = T*a(:,t) + K_s*v(:,t);
+0108 aK(1,:,t+1) = a(:,t+1);
+0109 for jnk=2:nk,
+0110 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
+0111 end
+0112 end
+0113 t = smpl+1;
+0114 while t>d+1 & t>2
+0115 t = t-1;
+0116 r(:,t-1) = transpose(Z)*iF(:,:,t)*v(:,t) + transpose(L(:,:,t))*r(:,t);
+0117 alphahat(:,t) = a(:,t) + P(:,:,t)*r(:,t-1);
+0118 etahat(:,t) = QRt*r(:,t);
+0119 end
+0120 if d
+0121 r0 = zeros(mm,d); r0(:,d) = r(:,d);
+0122 r1 = zeros(mm,d);
+0123 for t = d:-1:2
+0124 r0(:,t-1) = transpose(Linf(:,:,t))*r0(:,t);
+0125 r1(:,t-1) = transpose(Z)*(iFinf(:,:,t)*v(:,t)-transpose(Kstar(:,:,t))*r0(:,t)) + transpose(Linf(:,:,t))*r1(:,t);
+0126 alphahat(:,t) = a(:,t) + Pstar(:,:,t)*r0(:,t-1) + Pinf(:,:,t)*r1(:,t-1);
+0127 etahat(:,t) = QRt*r0(:,t);
+0128 end
+0129 r0_0 = transpose(Linf(:,:,1))*r0(:,1);
+0130 r1_0 = transpose(Z)*(iFinf(:,:,1)*v(:,1)-transpose(Kstar(:,:,1))*r0(:,1)) + transpose(Linf(:,:,1))*r1(:,1);
+0131 alphahat(:,1) = a(:,1) + Pstar(:,:,1)*r0_0 + Pinf(:,:,1)*r1_0;
+0132 etahat(:,1) = QRt*r0(:,1);
+0133 else
+0134 r0 = transpose(Z)*iF(:,:,1)*v(:,1) + transpose(L(:,:,1))*r(:,1);
+0135 alphahat(:,1) = a(:,1) + P(:,:,1)*r0;
+0136 etahat(:,1) = QRt*r(:,1);
+0137 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseKalmanSmoother3.html b/matlab/doc/DiffuseKalmanSmoother3.html
new file mode 100644
index 000000000..392edfcb1
--- /dev/null
+++ b/matlab/doc/DiffuseKalmanSmoother3.html
@@ -0,0 +1,318 @@
+
+
+
+ Description of DiffuseKalmanSmoother3
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseKalmanSmoother3.m
+
+
+
+DiffuseKalmanSmoother3
+
+
+ PURPOSE
+function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+
+ SYNOPSIS
+function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+steady Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+DsgeSmoother stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
+
+
+
+ SOURCE CODE
+0001 function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021 global options_
+0022
+0023 nk = options_.nk;
+0024 spinf = size(Pinf1);
+0025 spstar = size(Pstar1);
+0026 v = zeros(pp,smpl);
+0027 a = zeros(mm,smpl+1);
+0028 a1 = a;
+0029 aK = zeros(nk,mm,smpl+nk);
+0030 Fstar = zeros(pp,smpl);
+0031 Finf = zeros(pp,smpl);
+0032 Ki = zeros(mm,pp,smpl);
+0033 Li = zeros(mm,mm,pp,smpl);
+0034 Linf = zeros(mm,mm,pp,smpl);
+0035 L0 = zeros(mm,mm,pp,smpl);
+0036 Kstar = zeros(mm,pp,smpl);
+0037 P = zeros(mm,mm,smpl+1);
+0038 P1 = P;
+0039 Pstar = zeros(spstar(1),spstar(2),smpl+1); Pstar(:,:,1) = Pstar1;
+0040 Pinf = zeros(spinf(1),spinf(2),smpl+1); Pinf(:,:,1) = Pinf1;
+0041 Pstar1 = Pstar;
+0042 Pinf1 = Pinf;
+0043 crit = options_.kalman_tol;
+0044 crit1 = 1.e-6;
+0045 steady = smpl;
+0046 rr = size(Q,1);
+0047 QQ = R*Q*transpose(R);
+0048 QRt = Q*transpose(R);
+0049 alphahat = zeros(mm,smpl);
+0050 etahat = zeros(rr,smpl);
+0051 r = zeros(mm,smpl);
+0052
+0053 Z = zeros(pp,mm);
+0054 for i=1:pp;
+0055 Z(i,mf(i)) = 1;
+0056 end
+0057
+0058 t = 0;
+0059 icc=0;
+0060 newRank = rank(Pinf(:,:,1),crit1);
+0061 while newRank & t < smpl
+0062 t = t+1;
+0063 a1(:,t) = a(:,t);
+0064 Pstar(:,:,t)=tril(Pstar(:,:,t))+transpose(tril(Pstar(:,:,t),-1));
+0065 Pinf(:,:,t)=tril(Pinf(:,:,t))+transpose(tril(Pinf(:,:,t),-1));
+0066 Pstar1(:,:,t) = Pstar(:,:,t);
+0067 Pinf1(:,:,t) = Pinf(:,:,t);
+0068 for i=1:pp
+0069 v(i,t) = Y(i,t)-a(mf(i),t)-trend(i,t);
+0070 Fstar(i,t) = Pstar(mf(i),mf(i),t);
+0071 Finf(i,t) = Pinf(mf(i),mf(i),t);
+0072 Kstar(:,i,t) = Pstar(:,mf(i),t);
+0073 if Finf(i,t) > crit & newRank,
+0074 icc=icc+1;
+0075 Kinf(:,i,t) = Pinf(:,mf(i),t);
+0076 Linf(:,:,i,t) = eye(mm) - Kinf(:,i,t)*Z(i,:)/Finf(i,t);
+0077 L0(:,:,i,t) = (Kinf(:,i,t)*Fstar(i,t)/Finf(i,t) - Kstar(:,i,t))*Z(i,:)/Finf(i,t);
+0078 a(:,t) = a(:,t) + Kinf(:,i,t)*v(i,t)/Finf(i,t);
+0079 Pstar(:,:,t) = Pstar(:,:,t) + ...
+0080 Kinf(:,i,t)*transpose(Kinf(:,i,t))*Fstar(i,t)/(Finf(i,t)*Finf(i,t)) - ...
+0081 (Kstar(:,i,t)*transpose(Kinf(:,i,t)) +...
+0082 Kinf(:,i,t)*transpose(Kstar(:,i,t)))/Finf(i,t);
+0083 Pinf(:,:,t) = Pinf(:,:,t) - Kinf(:,i,t)*transpose(Kinf(:,i,t))/Finf(i,t);
+0084 Pstar(:,:,t)=tril(Pstar(:,:,t))+transpose(tril(Pstar(:,:,t),-1));
+0085 Pinf(:,:,t)=tril(Pinf(:,:,t))+transpose(tril(Pinf(:,:,t),-1));
+0086
+0087 P0=Pinf(:,:,t);
+0088
+0089
+0090 if ~isempty(options_.diffuse_d),
+0091 newRank = (icc<options_.diffuse_d);
+0092
+0093 if newRank & (any(diag(P0(mf,mf))>crit)==0 & rank(P0,crit1)==0);
+0094 disp('WARNING!! Change in OPTIONS_.DIFFUSE_D in univariate DKF' )
+0095 options_.diffuse_d = icc;
+0096 newRank=0;
+0097 end
+0098 else
+0099
+0100 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1));
+0101 if newRank==0,
+0102 options_.diffuse_d = icc;
+0103 end
+0104 end ,
+0105
+0106
+0107
+0108
+0109 else
+0110
+0111
+0112
+0113 Li(:,:,i,t) = eye(mm)-Kstar(:,i,t)*Z(i,:)/Fstar(i,t);
+0114 a(:,t) = a(:,t) + Kstar(:,i,t)*v(i,t)/Fstar(i,t);
+0115 Pstar(:,:,t) = Pstar(:,:,t) - Kstar(:,i,t)*transpose(Kstar(:,i,t))/Fstar(i,t);
+0116 Pstar(:,:,t)=tril(Pstar(:,:,t))+transpose(tril(Pstar(:,:,t),-1));
+0117 end
+0118 end
+0119 a(:,t+1) = T*a(:,t);
+0120 for jnk=1:nk,
+0121 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
+0122 end
+0123 Pstar(:,:,t+1) = T*Pstar(:,:,t)*transpose(T)+ QQ;
+0124 Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T);
+0125 P0=Pinf(:,:,t+1);
+0126 if newRank,
+0127
+0128 newRank = rank(P0,crit1);
+0129 end
+0130 end
+0131
+0132
+0133 d = t;
+0134 P(:,:,d+1) = Pstar(:,:,d+1);
+0135 Linf = Linf(:,:,:,1:d);
+0136 L0 = L0(:,:,:,1:d);
+0137 Fstar = Fstar(:,1:d);
+0138 Finf = Finf(:,1:d);
+0139 Kstar = Kstar(:,:,1:d);
+0140 Pstar = Pstar(:,:,1:d);
+0141 Pinf = Pinf(:,:,1:d);
+0142 Pstar1 = Pstar1(:,:,1:d);
+0143 Pinf1 = Pinf1(:,:,1:d);
+0144 notsteady = 1;
+0145 while notsteady & t<smpl
+0146 t = t+1;
+0147 a1(:,t) = a(:,t);
+0148 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0149 P1(:,:,t) = P(:,:,t);
+0150 for i=1:pp
+0151 v(i,t) = Y(i,t) - a(mf(i),t) - trend(i,t);
+0152 Fi(i,t) = P(mf(i),mf(i),t);
+0153 Ki(:,i,t) = P(:,mf(i),t);
+0154 if Fi(i,t) > crit
+0155 Li(:,:,i,t) = eye(mm)-Ki(:,i,t)*Z(i,:)/Fi(i,t);
+0156 a(:,t) = a(:,t) + Ki(:,i,t)*v(i,t)/Fi(i,t);
+0157 P(:,:,t) = P(:,:,t) - Ki(:,i,t)*transpose(Ki(:,i,t))/Fi(i,t);
+0158 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0159 end
+0160 end
+0161 a(:,t+1) = T*a(:,t);
+0162 for jnk=1:nk,
+0163 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
+0164 end
+0165 P(:,:,t+1) = T*P(:,:,t)*transpose(T) + QQ;
+0166 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
+0167 end
+0168 P_s=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0169 Fi_s = Fi(:,t);
+0170 Ki_s = Ki(:,:,t);
+0171 L_s =Li(:,:,:,t);
+0172 if t<smpl
+0173 t_steady = t+1;
+0174 P = cat(3,P(:,:,1:t),repmat(P(:,:,t),[1 1 smpl-t_steady+1]));
+0175 Fi = cat(2,Fi(:,1:t),repmat(Fi_s,[1 1 smpl-t_steady+1]));
+0176 Li = cat(4,Li(:,:,:,1:t),repmat(L_s,[1 1 smpl-t_steady+1]));
+0177 Ki = cat(3,Ki(:,:,1:t),repmat(Ki_s,[1 1 smpl-t_steady+1]));
+0178 end
+0179 while t<smpl
+0180 t=t+1;
+0181 a1(:,t) = a(:,t);
+0182 for i=1:pp
+0183 v(i,t) = Y(i,t) - a(mf(i),t) - trend(i,t);
+0184 if Fi_s(i) > crit
+0185 a(:,t) = a(:,t) + Ki_s(:,i)*v(i,t)/Fi_s(i);
+0186 end
+0187 end
+0188 a(:,t+1) = T*a(:,t);
+0189 for jnk=1:nk,
+0190 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
+0191 end
+0192 end
+0193 a1(:,t+1) = a(:,t+1);
+0194 ri=r;
+0195 t = smpl+1;
+0196 while t>d+1 & t>2,
+0197 t = t-1;
+0198 for i=pp:-1:1
+0199 if Fi(i,t) > crit
+0200 ri(:,t)=transpose(Z(i,:))/Fi(i,t)*v(i,t)+transpose(Li(:,:,i,t))*ri(:,t);
+0201 end
+0202 end
+0203 r(:,t-1) = ri(:,t);
+0204 alphahat(:,t) = a1(:,t) + P1(:,:,t)*r(:,t-1);
+0205 etahat(:,t) = QRt*r(:,t);
+0206 ri(:,t-1) = transpose(T)*ri(:,t);
+0207 end
+0208 if d
+0209 r0 = zeros(mm,d); r0(:,d) = ri(:,d);
+0210 r1 = zeros(mm,d);
+0211 for t = d:-1:2
+0212 for i=pp:-1:1
+0213 if Finf(i,t) > crit & ~(t==d & i>options_.diffuse_d),
+0214
+0215 r1(:,t) = transpose(Z(i,:))*v(i,t)/Finf(i,t) + ...
+0216 transpose(L0(:,:,i,t))*r0(:,t) + transpose(Linf(:,:,i,t))*r1(:,t);
+0217 r0(:,t) = transpose(Linf(:,:,i,t))*r0(:,t);
+0218 elseif Fstar(i,t) > crit
+0219 r0(:,t)=transpose(Z(i,:))/Fstar(i,t)*v(i,t)+Li(:,:,i,t)'*r0(:,t);
+0220 end
+0221 end
+0222 alphahat(:,t) = a1(:,t) + Pstar1(:,:,t)*r0(:,t) + Pinf1(:,:,t)*r1(:,t);
+0223 r(:,t-1) = r0(:,t);
+0224 etahat(:,t) = QRt*r(:,t);
+0225 r0(:,t-1) = transpose(T)*r0(:,t);
+0226 r1(:,t-1) = transpose(T)*r1(:,t);
+0227 end
+0228 r0_0 = r0(:,1);
+0229 r1_0 = r1(:,1);
+0230 for i=pp:-1:1
+0231 if Finf(i,1) > crit,
+0232
+0233 r1_0 = transpose(Z(i,:))*v(i,1)/Finf(i,1) + ...
+0234 transpose(L0(:,:,i,1))*r0_0 + transpose(Linf(:,:,i,1))*r1_0;
+0235 r0_0 = transpose(Linf(:,:,i,1))*r0_0;
+0236 elseif Fstar(i,1) > crit,
+0237 r0_0=transpose(Z(i,:))/Fstar(i,1)*v(i,1)+Li(:,:,i,1)'*r0_0;
+0238 end
+0239 end
+0240
+0241 alphahat(:,1) = a1(:,1) + Pstar1(:,:,1)*r0_0 + Pinf1(:,:,1)*r1_0;
+0242 etahat(:,1) = QRt*r(:,1);
+0243 else
+0244 r0 = ri(:,1);
+0245 for i=pp:-1:1
+0246 if Fi(i,1) > crit
+0247 r0=transpose(Z(i,:))/Fi(i,1)*v(i,1)+transpose(Li(:,:,i,1))*r0;
+0248 end
+0249 end
+0250
+0251 alphahat(:,1) = a1(:,1) + P1(:,:,1)*r0;
+0252 etahat(:,1) = QRt*r(:,1);
+0253 end
+0254
+0255 a=a(:,1:end-1);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseKalmanSmootherH1.html b/matlab/doc/DiffuseKalmanSmootherH1.html
new file mode 100644
index 000000000..8a027610c
--- /dev/null
+++ b/matlab/doc/DiffuseKalmanSmootherH1.html
@@ -0,0 +1,194 @@
+
+
+
+ Description of DiffuseKalmanSmootherH1
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseKalmanSmootherH1.m
+
+
+
+DiffuseKalmanSmootherH1
+
+
+ PURPOSE
+modified by M. Ratto:
+
+ SYNOPSIS
+function [alphahat,epsilonhat,etahat,a, aK] = DiffuseKalmanSmootherH1(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+steady Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+DsgeSmoother stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
+
+
+
+ SOURCE CODE
+0001 function [alphahat,epsilonhat,etahat,a, aK] = DiffuseKalmanSmootherH1(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014 global options_
+0015
+0016 nk = options_.nk;
+0017 spinf = size(Pinf1);
+0018 spstar = size(Pstar1);
+0019 v = zeros(pp,smpl);
+0020 a = zeros(mm,smpl+1);
+0021 iF = zeros(pp,pp,smpl);
+0022 Fstar = zeros(pp,pp,smpl);
+0023 iFinf = zeros(pp,pp,smpl);
+0024 K = zeros(mm,pp,smpl);
+0025 L = zeros(mm,mm,smpl);
+0026 Linf = zeros(mm,mm,smpl);
+0027 Kstar = zeros(mm,pp,smpl);
+0028 P = zeros(mm,mm,smpl+1);
+0029 Pstar = zeros(spstar(1),spstar(2),smpl+1); Pstar(:,:,1) = Pstar1;
+0030 Pinf = zeros(spinf(1),spinf(2),smpl+1); Pinf(:,:,1) = Pinf1;
+0031 crit = options_.kalman_tol;
+0032 crit1 = 1.e-8;
+0033 steady = smpl;
+0034 rr = size(Q,1);
+0035 QQ = R*Q*transpose(R);
+0036 QRt = Q*transpose(R);
+0037 alphahat = zeros(mm,smpl);
+0038 etahat = zeros(rr,smpl);
+0039 epsilonhat = zeros(size(Y));
+0040 r = zeros(mm,smpl);
+0041
+0042 Z = zeros(pp,mm);
+0043 for i=1:pp;
+0044 Z(i,mf(i)) = 1;
+0045 end
+0046
+0047 t = 0;
+0048 while rank(Pinf(:,:,t+1),crit1) & t<smpl
+0049 t = t+1;
+0050 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
+0051 if rcond(Pinf(mf,mf,t)) < crit
+0052 return
+0053 end
+0054 iFinf(:,:,t) = inv(Pinf(mf,mf,t));
+0055 Kinf(:,:,t) = T*Pinf(:,mf,t)*iFinf(:,:,t);
+0056 a(:,t+1) = T*a(:,t) + Kinf(:,:,t)*v(:,t);
+0057 aK(1,:,t+1) = a(:,t+1);
+0058 for jnk=2:nk,
+0059 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
+0060 end
+0061 Linf(:,:,t) = T - Kinf(:,:,t)*Z;
+0062 Fstar(:,:,t) = Pstar(mf,mf,t) + H;
+0063 Kstar(:,:,t) = (T*Pstar(:,mf,t)-Kinf(:,:,t)*Fstar(:,:,t))*iFinf(:,:,t);
+0064 Pstar(:,:,t+1) = T*Pstar(:,:,t)*transpose(T)-T*Pstar(:,mf,t)*transpose(Kinf(:,:,t))-Kinf(:,:,t)*Pinf(mf,mf,t)*transpose(Kstar(:,:,t)) + QQ;
+0065 Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T)-T*Pinf(:,mf,t)*transpose(Kinf(:,:,t));
+0066 end
+0067 d = t;
+0068 P(:,:,d+1) = Pstar(:,:,d+1);
+0069 iFinf = iFinf(:,:,1:d);
+0070 Linf = Linf(:,:,1:d);
+0071 Fstar = Fstar(:,:,1:d);
+0072 Kstar = Kstar(:,:,1:d);
+0073 Pstar = Pstar(:,:,1:d);
+0074 Pinf = Pinf(:,:,1:d);
+0075 notsteady = 1;
+0076 while notsteady & t<smpl
+0077 t = t+1;
+0078 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
+0079 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0080 if rcond(P(mf,mf,t) + H) < crit
+0081 return
+0082 end
+0083 iF(:,:,t) = inv(P(mf,mf,t) + H);
+0084 K(:,:,t) = T*P(:,mf,t)*iF(:,:,t);
+0085 L(:,:,t) = T-K(:,:,t)*Z;
+0086 a(:,t+1) = T*a(:,t) + K(:,:,t)*v(:,t);
+0087 aK(1,:,t+1) = a(:,t+1);
+0088 for jnk=2:nk,
+0089 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
+0090 end
+0091 P(:,:,t+1) = T*P(:,:,t)*transpose(T)-T*P(:,mf,t)*transpose(K(:,:,t)) + QQ;
+0092 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
+0093 end
+0094 K_s = K(:,:,t);
+0095 iF_s = iF(:,:,t);
+0096 P_s = P(:,:,t+1);
+0097 if t<smpl
+0098 t_steady = t+1;
+0099 P = cat(3,P(:,:,1:t),repmat(P(:,:,t),[1 1 smpl-t_steady+1]));
+0100 iF = cat(3,iF(:,:,1:t),repmat(inv(P_s(mf,mf)+H),[1 1 smpl-t_steady+1]));
+0101 L = cat(3,L(:,:,1:t),repmat(T-K_s*Z,[1 1 smpl-t_steady+1]));
+0102 K = cat(3,K(:,:,1:t),repmat(T*P_s(:,mf)*iF_s,[1 1 smpl-t_steady+1]));
+0103 end
+0104 while t<smpl
+0105 t=t+1;
+0106 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
+0107 a(:,t+1) = T*a(:,t) + K_s*v(:,t);
+0108 aK(1,:,t+1) = a(:,t+1);
+0109 for jnk=2:nk,
+0110 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
+0111 end
+0112 end
+0113 t = smpl+1;
+0114 while t>d+1 & t>2
+0115 t = t-1;
+0116 r(:,t-1) = transpose(Z)*iF(:,:,t)*v(:,t) + transpose(L(:,:,t))*r(:,t);
+0117 alphahat(:,t) = a(:,t) + P(:,:,t)*r(:,t-1);
+0118 etahat(:,t) = QRt*r(:,t);
+0119 end
+0120 if d
+0121 r0 = zeros(mm,d); r0(:,d) = r(:,d);
+0122 r1 = zeros(mm,d);
+0123 for t = d:-1:2
+0124 r0(:,t-1) = transpose(Linf(:,:,t))*r0(:,t);
+0125 r1(:,t-1) = transpose(Z)*(iFinf(:,:,t)*v(:,t)-transpose(Kstar(:,:,t))*r0(:,t)) + transpose(Linf(:,:,t))*r1(:,t);
+0126 alphahat(:,t) = a(:,t) + Pstar(:,:,t)*r0(:,t-1) + Pinf(:,:,t)*r1(:,t-1);
+0127 etahat(:,t) = QRt*r0(:,t);
+0128 end
+0129 r0_0 = transpose(Linf(:,:,1))*r0(:,1);
+0130 r1_0 = transpose(Z)*(iFinf(:,:,1)*v(:,1)-transpose(Kstar(:,:,1))*r0(:,1)) + transpose(Linf(:,:,1))*r1(:,1);
+0131 alphahat(:,1) = a(:,1) + Pstar(:,:,1)*r0_0 + Pinf(:,:,1)*r1_0;
+0132 etahat(:,1) = QRt*r0(:,1);
+0133 else
+0134 r0 = transpose(Z)*iF(:,:,1)*v(:,1) + transpose(L(:,:,1))*r(:,1);
+0135 alphahat(:,1) = a(:,1) + P(:,:,1)*r0;
+0136 etahat(:,1) = QRt*r(:,1);
+0137 end
+0138 epsilonhat = Y-alphahat(mf,:)-trend;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseKalmanSmootherH3.html b/matlab/doc/DiffuseKalmanSmootherH3.html
new file mode 100644
index 000000000..d78979230
--- /dev/null
+++ b/matlab/doc/DiffuseKalmanSmootherH3.html
@@ -0,0 +1,317 @@
+
+
+
+ Description of DiffuseKalmanSmootherH3
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseKalmanSmootherH3.m
+
+
+
+DiffuseKalmanSmootherH3
+
+
+ PURPOSE
+Modified by M. Ratto
+
+ SYNOPSIS
+function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+steady Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+DsgeSmoother stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
+
+
+
+ SOURCE CODE
+0001 function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020 global options_
+0021
+0022 nk = options_.nk;
+0023 spinf = size(Pinf1);
+0024 spstar = size(Pstar1);
+0025 v = zeros(pp,smpl);
+0026 a = zeros(mm,smpl+1);
+0027 a1 = a;
+0028 aK = zeros(nk,mm,smpl+nk);
+0029 Fstar = zeros(pp,smpl);
+0030 Finf = zeros(pp,smpl);
+0031 Ki = zeros(mm,pp,smpl);
+0032 Li = zeros(mm,mm,pp,smpl);
+0033 Linf = zeros(mm,mm,pp,smpl);
+0034 L0 = zeros(mm,mm,pp,smpl);
+0035 Kstar = zeros(mm,pp,smpl);
+0036 P = zeros(mm,mm,smpl+1);
+0037 P1 = P;
+0038 Pstar = zeros(spstar(1),spstar(2),smpl+1); Pstar(:,:,1) = Pstar1;
+0039 Pinf = zeros(spinf(1),spinf(2),smpl+1); Pinf(:,:,1) = Pinf1;
+0040 Pstar1 = Pstar;
+0041 Pinf1 = Pinf;
+0042 crit = options_.kalman_tol;
+0043 crit1 = 1.e-6;
+0044 steady = smpl;
+0045 rr = size(Q,1);
+0046 QQ = R*Q*transpose(R);
+0047 QRt = Q*transpose(R);
+0048 alphahat = zeros(mm,smpl);
+0049 etahat = zeros(rr,smpl);
+0050 epsilonhat = zeros(size(Y));
+0051 r = zeros(mm,smpl);
+0052
+0053 Z = zeros(pp,mm);
+0054 for i=1:pp;
+0055 Z(i,mf(i)) = 1;
+0056 end
+0057
+0058 t = 0;
+0059 icc=0;
+0060 newRank = rank(Pinf(:,:,1),crit1);
+0061 while newRank & t < smpl
+0062 t = t+1;
+0063 a1(:,t) = a(:,t);
+0064 Pstar(:,:,t)=tril(Pstar(:,:,t))+transpose(tril(Pstar(:,:,t),-1));
+0065 Pinf(:,:,t)=tril(Pinf(:,:,t))+transpose(tril(Pinf(:,:,t),-1));
+0066 Pstar1(:,:,t) = Pstar(:,:,t);
+0067 Pinf1(:,:,t) = Pinf(:,:,t);
+0068 for i=1:pp
+0069 v(i,t) = Y(i,t)-a(mf(i),t)-trend(i,t);
+0070 Fstar(i,t) = Pstar(mf(i),mf(i),t) + H(i,i);
+0071 Finf(i,t) = Pinf(mf(i),mf(i),t);
+0072 Kstar(:,i,t) = Pstar(:,mf(i),t);
+0073 if Finf(i,t) > crit & newRank,
+0074 icc=icc+1;
+0075 Kinf(:,i,t) = Pinf(:,mf(i),t);
+0076 Linf(:,:,i,t) = eye(mm) - Kinf(:,i,t)*Z(i,:)/Finf(i,t);
+0077 L0(:,:,i,t) = (Kinf(:,i,t)*Fstar(i,t)/Finf(i,t) - Kstar(:,i,t))*Z(i,:)/Finf(i,t);
+0078 a(:,t) = a(:,t) + Kinf(:,i,t)*v(i,t)/Finf(i,t);
+0079 Pstar(:,:,t) = Pstar(:,:,t) + ...
+0080 Kinf(:,i,t)*transpose(Kinf(:,i,t))*Fstar(i,t)/(Finf(i,t)*Finf(i,t)) - ...
+0081 (Kstar(:,i,t)*transpose(Kinf(:,i,t)) +...
+0082 Kinf(:,i,t)*transpose(Kstar(:,i,t)))/Finf(i,t);
+0083 Pinf(:,:,t) = Pinf(:,:,t) - Kinf(:,i,t)*transpose(Kinf(:,i,t))/Finf(i,t);
+0084 Pstar(:,:,t)=tril(Pstar(:,:,t))+transpose(tril(Pstar(:,:,t),-1));
+0085 Pinf(:,:,t)=tril(Pinf(:,:,t))+transpose(tril(Pinf(:,:,t),-1));
+0086
+0087 P0=Pinf(:,:,t);
+0088
+0089
+0090 if ~isempty(options_.diffuse_d),
+0091 newRank = (icc<options_.diffuse_d);
+0092
+0093 if newRank & (any(diag(P0(mf,mf))>crit)==0 & rank(P0,crit1)==0);
+0094 disp('WARNING!! Change in OPTIONS_.DIFFUSE_D in univariate DKF' )
+0095 options_.diffuse_d = icc;
+0096 newRank=0;
+0097 end
+0098 else
+0099
+0100 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1));
+0101 if newRank==0,
+0102 options_.diffuse_d = icc;
+0103 end
+0104 end ,
+0105
+0106
+0107
+0108
+0109 else
+0110
+0111
+0112
+0113 Li(:,:,i,t) = eye(mm)-Kstar(:,i,t)*Z(i,:)/Fstar(i,t);
+0114 a(:,t) = a(:,t) + Kstar(:,i,t)*v(i,t)/Fstar(i,t);
+0115 Pstar(:,:,t) = Pstar(:,:,t) - Kstar(:,i,t)*transpose(Kstar(:,i,t))/Fstar(i,t);
+0116 Pstar(:,:,t)=tril(Pstar(:,:,t))+transpose(tril(Pstar(:,:,t),-1));
+0117 end
+0118 end
+0119 a(:,t+1) = T*a(:,t);
+0120 for jnk=1:nk,
+0121 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
+0122 end
+0123 Pstar(:,:,t+1) = T*Pstar(:,:,t)*transpose(T)+ QQ;
+0124 Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T);
+0125 P0=Pinf(:,:,t+1);
+0126 if newRank,
+0127
+0128 newRank = rank(P0,crit1);
+0129 end
+0130 end
+0131
+0132
+0133 d = t;
+0134 P(:,:,d+1) = Pstar(:,:,d+1);
+0135 Linf = Linf(:,:,:,1:d);
+0136 L0 = L0(:,:,:,1:d);
+0137 Fstar = Fstar(:,1:d);
+0138 Finf = Finf(:,1:d);
+0139 Kstar = Kstar(:,:,1:d);
+0140 Pstar = Pstar(:,:,1:d);
+0141 Pinf = Pinf(:,:,1:d);
+0142 Pstar1 = Pstar1(:,:,1:d);
+0143 Pinf1 = Pinf1(:,:,1:d);
+0144 notsteady = 1;
+0145 while notsteady & t<smpl
+0146 t = t+1;
+0147 a1(:,t) = a(:,t);
+0148 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0149 P1(:,:,t) = P(:,:,t);
+0150 for i=1:pp
+0151 v(i,t) = Y(i,t) - a(mf(i),t) - trend(i,t);
+0152 Fi(i,t) = P(mf(i),mf(i),t);
+0153 Ki(:,i,t) = P(:,mf(i),t) + H(i,i);
+0154 if Fi(i,t) > crit
+0155 Li(:,:,i,t) = eye(mm)-Ki(:,i,t)*Z(i,:)/Fi(i,t);
+0156 a(:,t) = a(:,t) + Ki(:,i,t)*v(i,t)/Fi(i,t);
+0157 P(:,:,t) = P(:,:,t) - Ki(:,i,t)*transpose(Ki(:,i,t))/Fi(i,t);
+0158 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0159 end
+0160 end
+0161 a(:,t+1) = T*a(:,t);
+0162 for jnk=1:nk,
+0163 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
+0164 end
+0165 P(:,:,t+1) = T*P(:,:,t)*transpose(T) + QQ;
+0166 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
+0167 end
+0168 P_s=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0169 Fi_s = Fi(:,t);
+0170 Ki_s = Ki(:,:,t);
+0171 L_s =Li(:,:,:,t);
+0172 if t<smpl
+0173 t_steady = t+1;
+0174 P = cat(3,P(:,:,1:t),repmat(P(:,:,t),[1 1 smpl-t_steady+1]));
+0175 Fi = cat(2,Fi(:,1:t),repmat(Fi_s,[1 1 smpl-t_steady+1]));
+0176 Li = cat(4,Li(:,:,:,1:t),repmat(L_s,[1 1 smpl-t_steady+1]));
+0177 Ki = cat(3,Ki(:,:,1:t),repmat(Ki_s,[1 1 smpl-t_steady+1]));
+0178 end
+0179 while t<smpl
+0180 t=t+1;
+0181 a1(:,t) = a(:,t);
+0182 for i=1:pp
+0183 v(i,t) = Y(i,t) - a(mf(i),t) - trend(i,t);
+0184 if Fi_s(i) > crit
+0185 a(:,t) = a(:,t) + Ki_s(:,i)*v(i,t)/Fi_s(i);
+0186 end
+0187 end
+0188 a(:,t+1) = T*a(:,t);
+0189 for jnk=1:nk,
+0190 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
+0191 end
+0192 end
+0193 a1(:,t+1) = a(:,t+1);
+0194 ri=r;
+0195 t = smpl+1;
+0196 while t>d+1 & t>2,
+0197 t = t-1;
+0198 for i=pp:-1:1
+0199 if Fi(i,t) > crit
+0200 ri(:,t)=transpose(Z(i,:))/Fi(i,t)*v(i,t)+transpose(Li(:,:,i,t))*ri(:,t);
+0201 end
+0202 end
+0203 r(:,t-1) = ri(:,t);
+0204 alphahat(:,t) = a1(:,t) + P1(:,:,t)*r(:,t-1);
+0205 etahat(:,t) = QRt*r(:,t);
+0206 ri(:,t-1) = transpose(T)*ri(:,t);
+0207 end
+0208 if d
+0209 r0 = zeros(mm,d); r0(:,d) = ri(:,d);
+0210 r1 = zeros(mm,d);
+0211 for t = d:-1:2
+0212 for i=pp:-1:1
+0213 if Finf(i,t) > crit & ~(t==d & i>options_.diffuse_d),
+0214
+0215 r1(:,t) = transpose(Z(i,:))*v(i,t)/Finf(i,t) + ...
+0216 transpose(L0(:,:,i,t))*r0(:,t) + transpose(Linf(:,:,i,t))*r1(:,t);
+0217 r0(:,t) = transpose(Linf(:,:,i,t))*r0(:,t);
+0218 elseif Fstar(i,t) > crit
+0219 r0(:,t)=transpose(Z(i,:))/Fstar(i,t)*v(i,t)+Li(:,:,i,t)'*r0(:,t);
+0220 end
+0221 end
+0222 alphahat(:,t) = a1(:,t) + Pstar1(:,:,t)*r0(:,t) + Pinf1(:,:,t)*r1(:,t);
+0223 r(:,t-1) = r0(:,t);
+0224 etahat(:,t) = QRt*r(:,t);
+0225 r0(:,t-1) = transpose(T)*r0(:,t);
+0226 r1(:,t-1) = transpose(T)*r1(:,t);
+0227 end
+0228 r0_0 = r0(:,1);
+0229 r1_0 = r1(:,1);
+0230 for i=pp:-1:1
+0231 if Finf(i,1) > crit,
+0232
+0233 r1_0 = transpose(Z(i,:))*v(i,1)/Finf(i,1) + ...
+0234 transpose(L0(:,:,i,1))*r0_0 + transpose(Linf(:,:,i,1))*r1_0;
+0235 r0_0 = transpose(Linf(:,:,i,1))*r0_0;
+0236 elseif Fstar(i,1) > crit,
+0237 r0_0=transpose(Z(i,:))/Fstar(i,1)*v(i,1)+Li(:,:,i,1)'*r0_0;
+0238 end
+0239 end
+0240
+0241 alphahat(:,1) = a1(:,1) + Pstar1(:,:,1)*r0_0 + Pinf1(:,:,1)*r1_0;
+0242 etahat(:,1) = QRt*r(:,1);
+0243 else
+0244 r0 = ri(:,1);
+0245 for i=pp:-1:1
+0246 if Fi(i,1) > crit
+0247 r0=transpose(Z(i,:))/Fi(i,1)*v(i,1)+transpose(Li(:,:,i,1))*r0;
+0248 end
+0249 end
+0250
+0251 alphahat(:,1) = a1(:,1) + P1(:,:,1)*r0;
+0252 etahat(:,1) = QRt*r(:,1);
+0253 end
+0254 epsilonhat = Y-alphahat(mf,:)-trend;
+0255
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseKalmanSmootherH3corr.html b/matlab/doc/DiffuseKalmanSmootherH3corr.html
new file mode 100644
index 000000000..49ad1179d
--- /dev/null
+++ b/matlab/doc/DiffuseKalmanSmootherH3corr.html
@@ -0,0 +1,253 @@
+
+
+
+ Description of DiffuseKalmanSmootherH3corr
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseKalmanSmootherH3corr.m
+
+
+
+DiffuseKalmanSmootherH3corr
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
+
+ SYNOPSIS
+function [alphahat,epsilonhat,etahat,a1] = DiffuseKalmanSmootherH3corr(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+steady Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [alphahat,epsilonhat,etahat,a1] = DiffuseKalmanSmootherH3corr(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
+0002
+0003
+0004
+0005
+0006
+0007
+0008 global options_;
+0009
+0010 rr = size(Q,1);
+0011 T = cat(1,cat(2,T,zeros(mm,pp)),zeros(pp,mm+pp));
+0012 R = cat(1,cat(2,R,zeros(mm,pp)),cat(2,zeros(pp,rr),eye(pp)));
+0013 Q = cat(1,cat(2,Q,zeros(rr,pp)),cat(2,zeros(pp,rr),H));
+0014 if size(Pinf1,1)
+0015 Pinf1 = cat(1,cat(2,Pinf1,zeros(mm,pp)),zeros(pp,mm+pp));
+0016 end
+0017 Pstar1 = cat(1,cat(2,Pstar1,zeros(mm,pp)),cat(2,zeros(pp,mm),H));
+0018 spinf = size(Pinf1);
+0019 spstar = size(Pstar1);
+0020 Pstar = zeros(spstar(1),spstar(2),smpl+1); Pstar(:,:,1) = Pstar1;
+0021 Pinf = zeros(spinf(1),spinf(2),smpl+1); Pinf(:,:,1) = Pinf1;
+0022 Pstar1 = Pstar;
+0023 Pinf1 = Pinf;
+0024 v = zeros(pp,smpl);
+0025 a = zeros(mm+pp,smpl+1);
+0026 a1 = a;
+0027 Fstar = zeros(pp,smpl);
+0028 Finf = zeros(pp,smpl);
+0029 Fi = zeros(pp,smpl);
+0030 Ki = zeros(mm+pp,pp,smpl);
+0031 Li = zeros(mm+pp,mm+pp,pp,smpl);
+0032 Linf = zeros(mm+pp,mm+pp,pp,smpl);
+0033 L0 = zeros(mm+pp,mm+pp,pp,smpl);
+0034 Kstar = zeros(mm+pp,pp,smpl);
+0035 Kinf = zeros(mm+pp,pp,smpl);
+0036 P = zeros(mm+pp,mm+pp,smpl+1);
+0037 P1 = zeros(mm+pp,mm+pp,smpl+1);
+0038 crit = options_.kalman_tol;
+0039 steady = smpl;
+0040 QQ = R*Q*transpose(R);
+0041 QRt = Q*transpose(R);
+0042 alphahat = zeros(mm+pp,smpl);
+0043 etahat = zeros(rr,smpl);
+0044 epsilonhat = zeros(pp,smpl);
+0045 r = zeros(mm+pp,smpl);
+0046 Z = zeros(pp,mm+pp);
+0047 for i=1:pp;
+0048 Z(i,mf(i)) = 1;
+0049 Z(i,mm+i) = 1;
+0050 end
+0051
+0052 t = 0;
+0053 newRank = rank(Pinf(:,:,1),crit);
+0054 while newRank & t < smpl
+0055 t = t+1;
+0056 a1(:,t) = a(:,t);
+0057 Pstar1(:,:,t) = Pstar(:,:,t);
+0058 Pinf1(:,:,t) = Pinf(:,:,t);
+0059 for i=1:pp
+0060 v(i,t) = Y(i,t)-a(mf(i),t)-a(mm+i,t)-trend(i,t);
+0061 Fstar(i,t) = Pstar(mf(i),mf(i),t)+Pstar(mm+i,mm+i,t);
+0062 Finf(i,t) = Pinf(mf(i),mf(i),t);
+0063 Kstar(:,i,t) = Pstar(:,mf(i),t)+Pstar(:,mm+i,t);
+0064 if Finf(i,t) > crit
+0065 Kinf(:,i,t) = Pinf(:,mf(i),t);
+0066 Linf(:,:,i,t) = eye(mm+pp) - Kinf(:,i,t)*Z(i,:)/Finf(i,t);
+0067 L0(:,:,i,t) = (Kinf(:,i,t)*Fstar(i,t)/Finf(i,t) - Kstar(:,i,t))*Z(i,:)/Finf(i,t);
+0068 a(:,t) = a(:,t) + Kinf(:,i,t)*v(i,t)/Finf(i,t);
+0069 Pstar(:,:,t) = Pstar(:,:,t) + ...
+0070 Kinf(:,i,t)*transpose(Kinf(:,i,t))*Fstar(i,t)/(Finf(i,t)*Finf(i,t)) - ...
+0071 (Kstar(:,i,t)*transpose(Kinf(:,i,t)) +...
+0072 Kinf(:,i,t)*transpose(Kstar(:,i,t)))/Finf(i,t);
+0073 Pinf(:,:,t) = Pinf(:,:,t) - Kinf(:,i,t)*transpose(Kinf(:,i,t))/Finf(i,t);
+0074 else
+0075
+0076
+0077 a(:,t) = a(:,t) + Kstar(:,i,t)*v(i,t)/Fstar(i,t);
+0078 Pstar(:,:,t) = Pstar(:,:,t) - Kstar(:,i,t)*transpose(Kstar(:,i,t))/Fstar(i,t);
+0079 end
+0080 end
+0081 a(:,t+1) = T*a(:,t);
+0082 Pstar(:,:,t+1) = T*Pstar(:,:,t)*transpose(T)+ QQ;
+0083 Pinf(:,:,t+1) = T*Pinf(:,:,t)*transpose(T);
+0084 P0=Pinf(:,:,t+1);
+0085 newRank = ~all(abs(P0(:))<crit);
+0086 end
+0087 d = t;
+0088 P(:,:,d+1) = Pstar(:,:,d+1);
+0089 Linf = Linf(:,:,:,1:d);
+0090 L0 = L0(:,:,:,1:d);
+0091 Fstar = Fstar(:,1:d);
+0092 Finf = Finf(:,1:d);
+0093 Kstar = Kstar(:,:,1:d);
+0094 Pstar = Pstar(:,:,1:d);
+0095 Pinf = Pinf(:,:,1:d);
+0096 Pstar1 = Pstar1(:,:,1:d);
+0097 Pinf1 = Pinf1(:,:,1:d);
+0098 notsteady = 1;
+0099 while notsteady & t<smpl
+0100 t = t+1;
+0101 a1(:,t) = a(:,t);
+0102 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0103 P1(:,:,t) = P(:,:,t);
+0104 for i=1:pp
+0105 v(i,t) = Y(i,t) - a(mf(i),t) - a(mm+i,t) - trend(i,t);
+0106 Fi(i,t) = P(mf(i),mf(i),t)+P(mm+i,mm+i,t);
+0107 Ki(:,i,t) = P(:,mf(i),t)+P(:,mm+i,t);
+0108 if Fi(i,t) > crit
+0109 Li(:,:,i,t) = eye(mm+pp)-Ki(:,i,t)*Z(i,:)/Fi(i,t);
+0110 a(:,t) = a(:,t) + Ki(:,i,t)*v(i,t)/Fi(i,t);
+0111 P(:,:,t) = P(:,:,t) - Ki(:,i,t)*transpose(Ki(:,i,t))/Fi(i,t);
+0112 P(:,:,t)=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0113 end
+0114 end
+0115 a(:,t+1) = T*a(:,t);
+0116 P(:,:,t+1) = T*P(:,:,t)*transpose(T) + QQ;
+0117 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
+0118 end
+0119 P_s=tril(P(:,:,t))+transpose(tril(P(:,:,t),-1));
+0120 Fi_s = Fi(:,t);
+0121 Ki_s = Ki(:,:,t);
+0122 L_s =Li(:,:,:,t);
+0123 if t<smpl
+0124 t_steady = t+1;
+0125 P = cat(3,P(:,:,1:t),repmat(P(:,:,t),[1 1 smpl-t_steady+1]));
+0126 Fi = cat(2,Fi(:,1:t),repmat(Fi_s,[1 1 smpl-t_steady+1]));
+0127 Li = cat(4,Li(:,:,:,1:t),repmat(L_s,[1 1 smpl-t_steady+1]));
+0128 Ki = cat(3,Ki(:,:,1:t),repmat(Ki_s,[1 1 smpl-t_steady+1]));
+0129 end
+0130 while t<smpl
+0131 t=t+1;
+0132 a1(:,t) = a(:,t);
+0133 for i=1:pp
+0134 v(i,t) = Y(i,t) - a(mf(i),t) - a(mm+i,t) - trend(i,t);
+0135 if Fi_s(i) > crit
+0136 a(:,t) = a(:,t) + Ki_s(:,i)*v(i,t)/Fi_s(i);
+0137 end
+0138 end
+0139 a(:,t+1) = T*a(:,t);
+0140 end
+0141 a1(:,t+1) = a(:,t+1);
+0142
+0143 ri=r;
+0144 t = smpl+1;
+0145 while t>d+1 & t>2,
+0146 t = t-1;
+0147 for i=pp:-1:1
+0148 if Fi(i,t) > crit
+0149 ri(:,t)=transpose(Z(i,:))/Fi(i,t)*v(i,t)+transpose(Li(:,:,i,t))*ri(:,t);
+0150 end
+0151 end
+0152 r(:,t-1) = ri(:,t);
+0153 alphahat(:,t) = a1(:,t) + P1(:,:,t)*r(:,t-1);
+0154 tmp = QRt*r(:,t);
+0155 etahat(:,t) = tmp(1:rr);
+0156 epsilonhat(:,t) = tmp(rr+1:rr+pp);
+0157 ri(:,t-1) = transpose(T)*ri(:,t);
+0158 end
+0159 if d
+0160 r0 = zeros(mm+pp,d); r0(:,d) = ri(:,d);
+0161 r1 = zeros(mm+pp,d);
+0162 for t = d:-1:2
+0163 for i=pp:-1:1
+0164 if Finf(i,t) > crit
+0165 r1(:,t) = transpose(Z)*v(:,t)/Finf(i,t) + ...
+0166 transpose(L0(:,:,i,t))*r0(:,t) + transpose(Linf(:,:,i,t))*r1(:,t);
+0167 r0(:,t) = transpose(Linf(:,:,i,t))*r0(:,t);
+0168 end
+0169 end
+0170 alphahat(:,t) = a1(:,t) + Pstar1(:,:,t)*r0(:,t) + Pinf1(:,:,t)*r1(:,t);
+0171 r(:,t-1) = r0(:,t);
+0172 tmp = QRt*r(:,t);
+0173 etahat(:,t) = tmp(1:rr);
+0174 epsilonhat(:,t) = tmp(rr+1:rr+pp);
+0175 r0(:,t-1) = transpose(T)*r0(:,t);
+0176 r1(:,t-1) = transpose(T)*r1(:,t);
+0177 end
+0178 r0_0 = r0(:,1);
+0179 r1_0 = r1(:,1);
+0180 for i=pp:-1:1
+0181 if Finf(i,1) > crit,
+0182 r1_0 = transpose(Z)*v(:,1)/Finf(i,1) + ...
+0183 transpose(L0(:,:,i,1))*r0_0 + transpose(Linf(:,:,i,1))*r1_0;
+0184 r0_0 = transpose(Linf(:,:,i,1))*r0_0;
+0185 end
+0186 end
+0187 alphahat(:,1) = a(:,1) + Pstar(:,:,1)*r0_0 + Pinf(:,:,1)*r1_0;
+0188 tmp = QRt*r(:,1);
+0189 etahat(:,1) = tmp(1:rr);
+0190 epsilonhat(:,1) = tmp(rr+1:rr+pp);
+0191 else
+0192 r0 = ri(:,1);
+0193 for i=pp:-1:1
+0194 if Fi(i,1) > crit
+0195 r0=transpose(Z(i,:))/Fi(i,1)*v(i,1)+transpose(Li(:,:,i,1))*r0;
+0196 end
+0197 end
+0198 alphahat(:,1) = a(:,1) + P(:,:,1)*r0;
+0199 tmp = QRt*r(:,1);
+0200 etahat(:,1) = tmp(1:rr);
+0201 epsilonhat(:,1) = tmp(rr+1:rr+pp);
+0202 end
+0203 alphahat = alphahat(1:mm,:);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseLikelihood1.html b/matlab/doc/DiffuseLikelihood1.html
new file mode 100644
index 000000000..c3a267b99
--- /dev/null
+++ b/matlab/doc/DiffuseLikelihood1.html
@@ -0,0 +1,140 @@
+
+
+
+ Description of DiffuseLikelihood1
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseLikelihood1.m
+
+
+
+DiffuseLikelihood1
+
+
+ PURPOSE
+M. Ratto added lik in output
+
+ SYNOPSIS
+function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)
+0002
+0003
+0004
+0005
+0006 global bayestopt_ options_
+0007
+0008 mf = bayestopt_.mf;
+0009 smpl = size(Y,2);
+0010 mm = size(T,2);
+0011 pp = size(Y,1);
+0012 a = zeros(mm,1);
+0013 dF = 1;
+0014 QQ = R*Q*transpose(R);
+0015 t = 0;
+0016 lik = zeros(smpl+1,1);
+0017 LIK = Inf;
+0018 lik(smpl+1) = smpl*pp*log(2*pi);
+0019 notsteady = 1;
+0020 crit = options_.kalman_tol;
+0021 reste = 0;
+0022 while rank(Pinf,crit) & t < smpl
+0023 t = t+1;
+0024 v = Y(:,t)-a(mf)-trend(:,t);
+0025 Finf = Pinf(mf,mf);
+0026 if rcond(Finf) < crit
+0027 if ~all(abs(Finf(:)) < crit)
+0028 return
+0029 else
+0030 iFstar = inv(Pstar(mf,mf));
+0031 dFstar = det(Pstar(mf,mf));
+0032 Kstar = Pstar(:,mf)*iFstar;
+0033 lik(t) = log(dFstar) + transpose(v)*iFstar*v;
+0034 Pinf = T*Pinf*transpose(T);
+0035 Pstar = T*(Pstar-Pstar(:,mf)*transpose(Kstar))*transpose(T)+QQ;
+0036 a = T*(a+Kstar*v);
+0037 end
+0038 else
+0039 lik(t) = log(det(Finf));
+0040 iFinf = inv(Finf);
+0041 Kinf = Pinf(:,mf)*iFinf;
+0042 Fstar = Pstar(mf,mf);
+0043 Kstar = (Pstar(:,mf)-Kinf*Fstar)*iFinf;
+0044 Pstar = T*(Pstar-Pstar(:,mf)*transpose(Kinf)-Pinf(:,mf)*transpose(Kstar))*transpose(T)+QQ;
+0045 Pinf = T*(Pinf-Pinf(:,mf)*transpose(Kinf))*transpose(T);
+0046 a = T*(a+Kinf*v);
+0047 end
+0048 end
+0049 if t == smpl
+0050 error(['There isn''t enough information to estimate the initial' ...
+0051 ' conditions of the nonstationary variables' ]);
+0052 end
+0053 F_singular = 1;
+0054 while notsteady & t < smpl
+0055 t = t+1;
+0056 v = Y(:,t)-a(mf)-trend(:,t);
+0057 F = Pstar(mf,mf);
+0058 oldPstar = Pstar;
+0059 dF = det(F);
+0060 if rcond(F) < crit
+0061 if ~all(abs(F(:))<crit)
+0062 return
+0063 else
+0064 a = T*a;
+0065 Pstar = T*Pstar*transpose(T)+QQ;
+0066 end
+0067 else
+0068 F_singular = 0;
+0069 iF = inv(F);
+0070 lik(t) = log(dF)+transpose(v)*iF*v;
+0071 K = Pstar(:,mf)*iF;
+0072 a = T*(a+K*v);
+0073 Pstar = T*(Pstar-K*Pstar(mf,:))*transpose(T)+QQ;
+0074 end
+0075 notsteady = ~(max(max(abs(Pstar-oldPstar)))<crit);
+0076 end
+0077 if F_singular == 1
+0078 error(['The variance of the forecast error remains singular until the' ...
+0079 'end of the sample' ])
+0080 end
+0081 reste = smpl-t;
+0082 while t < smpl
+0083 t = t+1;
+0084 v = Y(:,t)-a(mf)-trend(:,t);
+0085 a = T*(a+K*v);
+0086 lik(t) = transpose(v)*iF*v;
+0087 end
+0088 lik(t) = lik(t) + reste*log(dF);
+0089
+0090
+0091 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseLikelihood3.html b/matlab/doc/DiffuseLikelihood3.html
new file mode 100644
index 000000000..7b60a47b8
--- /dev/null
+++ b/matlab/doc/DiffuseLikelihood3.html
@@ -0,0 +1,348 @@
+
+
+
+ Description of DiffuseLikelihood3
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseLikelihood3.m
+
+
+
+DiffuseLikelihood3
+
+
+ PURPOSE
+M. Ratto added lik in output [October 2005]
+
+ SYNOPSIS
+function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)%//Z,T,R,Q,Pinf,Pstar,Y)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077
+0078
+0079
+0080
+0081
+0082
+0083 global bayestopt_ options_
+0084
+0085 mf = bayestopt_.mf;
+0086 pp = size(Y,1);
+0087 mm = size(T,1);
+0088 smpl = size(Y,2);
+0089 a = zeros(mm,1);
+0090 QQ = R*Q*transpose(R);
+0091 t = 0;
+0092 lik = zeros(smpl+1,1);
+0093 lik(smpl+1) = smpl*pp*log(2*pi);
+0094 notsteady = 1;
+0095 crit = options_.kalman_tol;
+0096 crit1 = 1.e-6;
+0097 newRank = rank(Pinf,crit1);
+0098 icc=0;
+0099 while newRank & t < smpl
+0100 t = t+1;
+0101 for i=1:pp
+0102 v(i) = Y(i,t)-a(mf(i))-trend(i,t);
+0103 Fstar = Pstar(mf(i),mf(i));
+0104 Finf = Pinf(mf(i),mf(i));
+0105 Kstar = Pstar(:,mf(i));
+0106 if Finf > crit & newRank,
+0107 icc=icc+1;
+0108 Kinf = Pinf(:,mf(i));
+0109 a = a + Kinf*v(i)/Finf;
+0110 Pstar = Pstar + Kinf*transpose(Kinf)*Fstar/(Finf*Finf) - ...
+0111 (Kstar*transpose(Kinf)+Kinf*transpose(Kstar))/Finf;
+0112 Pinf = Pinf - Kinf*transpose(Kinf)/Finf;
+0113 lik(t) = lik(t) + log(Finf);
+0114
+0115 if ~isempty(options_.diffuse_d),
+0116 newRank = (icc<options_.diffuse_d);
+0117
+0118 if newRank & (any(diag(Pinf(mf,mf))>crit)==0 & rank(Pinf,crit1)==0);
+0119 options_.diffuse_d = icc;
+0120 newRank=0;
+0121 disp('WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF' )
+0122 disp(['new OPTIONS_.DIFFUSE_D = ' ,int2str(icc)])
+0123 disp('You may have to reset the optimisation' )
+0124 end
+0125 else
+0126
+0127 newRank = (any(diag(Pinf(mf,mf))>crit) | rank(Pinf,crit1));
+0128 if newRank==0,
+0129 P0= T*Pinf*transpose(T);
+0130
+0131 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1));
+0132 if newRank==0,
+0133 options_.diffuse_d = icc;
+0134 end
+0135 end
+0136 end ,
+0137
+0138 elseif Fstar > crit
+0139
+0140
+0141
+0142
+0143
+0144
+0145
+0146
+0147 lik(t) = lik(t) + log(Fstar) + v(i)*v(i)/Fstar;
+0148
+0149 a = a + Kstar*v(i)/Fstar;
+0150 Pstar = Pstar - Kstar*transpose(Kstar)/Fstar;
+0151 else
+0152
+0153 end
+0154 end
+0155
+0156
+0157
+0158
+0159
+0160 if newRank,
+0161 oldRank = rank(Pinf,crit1);
+0162 else
+0163 oldRank = 0;
+0164 end
+0165 a = T*a;
+0166 Pstar = T*Pstar*transpose(T)+QQ;
+0167 Pinf = T*Pinf*transpose(T);
+0168
+0169
+0170
+0171
+0172
+0173 if newRank,
+0174 newRank = rank(Pinf,crit1);
+0175 end
+0176 if oldRank ~= newRank
+0177 disp('DiffuseLiklihood3 :: T does influence the rank of Pinf!' )
+0178 end
+0179 end
+0180 if t == smpl
+0181 error(['There isn''t enough information to estimate the initial' ...
+0182 ' conditions of the nonstationary variables' ]);
+0183 end
+0184 while notsteady & t < smpl
+0185 t = t+1;
+0186 oldP = Pstar;
+0187 for i=1:pp
+0188 v(i) = Y(i,t) - a(mf(i)) - trend(i,t);
+0189 Fi = Pstar(mf(i),mf(i));
+0190 if Fi > crit
+0191 Ki = Pstar(:,mf(i));
+0192 a = a + Ki*v(i)/Fi;
+0193 Pstar = Pstar - Ki*transpose(Ki)/Fi;
+0194 lik(t) = lik(t) + log(Fi) + v(i)*v(i)/Fi;
+0195 else
+0196
+0197 end
+0198 end
+0199 a = T*a;
+0200 Pstar = T*Pstar*transpose(T) + QQ;
+0201 notsteady = ~(max(max(abs(Pstar-oldP)))<crit);
+0202 end
+0203 while t < smpl
+0204 t = t+1;
+0205 Pstar = oldP;
+0206 for i=1:pp
+0207 v(i) = Y(i,t) - a(mf(i)) - trend(i,t);
+0208 Fi = Pstar(mf(i),mf(i));
+0209 if Fi > crit
+0210 Ki = Pstar(:,mf(i));
+0211 a = a + Ki*v(i)/Fi;
+0212 Pstar = Pstar - Ki*transpose(Ki)/Fi;
+0213 lik(t) = lik(t) + log(Fi) + v(i)*v(i)/Fi;
+0214 else
+0215
+0216 end
+0217 end
+0218 a = T*a;
+0219 end
+0220
+0221 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
+0222
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseLikelihoodH1.html b/matlab/doc/DiffuseLikelihoodH1.html
new file mode 100644
index 000000000..52d940259
--- /dev/null
+++ b/matlab/doc/DiffuseLikelihoodH1.html
@@ -0,0 +1,282 @@
+
+
+
+ Description of DiffuseLikelihoodH1
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseLikelihoodH1.m
+
+
+
+DiffuseLikelihoodH1
+
+
+ PURPOSE
+M. Ratto added lik in output
+
+ SYNOPSIS
+function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077 global bayestopt_ options_
+0078
+0079 mf = bayestopt_.mf;
+0080 smpl = size(Y,2);
+0081 mm = size(T,2);
+0082 pp = size(Y,1);
+0083 a = zeros(mm,1);
+0084 dF = 1;
+0085 QQ = R*Q*transpose(R);
+0086 t = 0;
+0087 lik = zeros(smpl+1,1);
+0088 LIK = Inf;
+0089 lik(smpl+1) = smpl*pp*log(2*pi);
+0090 notsteady = 1;
+0091 crit = options_.kalman_tol;
+0092 reste = 0;
+0093 while rank(Pinf,crit) & t < smpl
+0094 t = t+1;
+0095 v = Y(:,t)-a(mf)-trend(:,t);
+0096 Finf = Pinf(mf,mf);
+0097 if rcond(Finf) < crit
+0098 if ~all(abs(Finf(:))<crit)
+0099 return
+0100 else
+0101 iFstar = inv(Pstar(mf,mf)+H);
+0102 dFstar = det(Pstar(mf,mf)+H);
+0103 Kstar = Pstar(:,mf)*iFstar;
+0104 lik(t) = log(dFstar) + transpose(v)*iFstar*v;
+0105 Pinf = T*Pinf*transpose(T);
+0106 Pstar = T*(Pstar-Pstar(:,mf)*transpose(Kstar))*transpose(T)+QQ;
+0107 a = T*(a+Kstar*v);
+0108 end
+0109 else
+0110 lik(t) = log(det(Finf));
+0111 iFinf = inv(Finf);
+0112 Kinf = Pinf(:,mf)*iFinf;
+0113 Fstar = Pstar(mf,mf)+H;
+0114 Kstar = (Pstar(:,mf)-Kinf*Fstar)*iFinf;
+0115 Pstar = T*(Pstar-Pstar(:,mf)*transpose(Kinf)-Pinf(:,mf)*transpose(Kstar))*transpose(T)+QQ;
+0116 Pinf = T*(Pinf-Pinf(:,mf)*transpose(Kinf))*transpose(T);
+0117 a = T*(a+Kinf*v);
+0118 end
+0119 end
+0120 if t == smpl
+0121 error(['There isn''t enough information to estimate the initial' ...
+0122 ' conditions of the nonstationary variables' ]);
+0123 end
+0124 F_singular = 1;
+0125 while notsteady & t < smpl
+0126 t = t+1;
+0127 v = Y(:,t)-a(mf)-trend(:,t);
+0128 F = Pstar(mf,mf)+H;
+0129 oldPstar = Pstar;
+0130 dF = det(F);
+0131 if rcond(F) < crit
+0132 if ~all(abs(F(:))<crit)
+0133 return
+0134 else
+0135 a = T*a;
+0136 Pstar = T*Pstar*transpose(T)+QQ;
+0137 end
+0138 else
+0139 F_singular = 0;
+0140 iF = inv(F);
+0141 lik(t) = log(dF)+transpose(v)*iF*v;
+0142 K = Pstar(:,mf)*iF;
+0143 a = T*(a+K*v);
+0144 Pstar = T*(Pstar-K*Pstar(mf,:))*transpose(T)+QQ;
+0145 end
+0146 notsteady = ~(max(max(abs(Pstar-oldPstar)))<crit);
+0147 end
+0148 if F_singular == 1
+0149 error(['The variance of the forecast error remains singular until the' ...
+0150 'end of the sample' ])
+0151 end
+0152 reste = smpl-t;
+0153 while t < smpl
+0154 t = t+1;
+0155 v = Y(:,t)-a(mf)-trend(:,t);
+0156 a = T*(a+K*v);
+0157 lik(t) = transpose(v)*iF*v;
+0158 end
+0159 lik(t) = lik(t) + reste*log(dF);
+0160 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
+0161
+0162
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseLikelihoodH3.html b/matlab/doc/DiffuseLikelihoodH3.html
new file mode 100644
index 000000000..3d856d8e3
--- /dev/null
+++ b/matlab/doc/DiffuseLikelihoodH3.html
@@ -0,0 +1,329 @@
+
+
+
+ Description of DiffuseLikelihoodH3
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseLikelihoodH3.m
+
+
+
+DiffuseLikelihoodH3
+
+
+ PURPOSE
+M. Ratto added lik in output [October 2005]
+
+ SYNOPSIS
+function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077
+0078
+0079
+0080
+0081
+0082 global bayestopt_ options_
+0083
+0084 mf = bayestopt_.mf;
+0085 pp = size(Y,1);
+0086 mm = size(T,1);
+0087 smpl = size(Y,2);
+0088 a = zeros(mm,1);
+0089 QQ = R*Q*transpose(R);
+0090 t = 0;
+0091 lik = zeros(smpl+1,1);
+0092 lik(smpl+1) = smpl*pp*log(2*pi);
+0093 notsteady = 1;
+0094 crit = options_.kalman_tol;
+0095 crit1 = 1.e-6;
+0096 newRank = rank(Pinf,crit1);
+0097 icc = 0;
+0098 while newRank & t < smpl
+0099 t = t+1;
+0100 for i=1:pp
+0101 v(i) = Y(i,t)-a(mf(i))-trend(i,t);
+0102 Fstar = Pstar(mf(i),mf(i))+H(i,i);
+0103 Finf = Pinf(mf(i),mf(i));
+0104 Kstar = Pstar(:,mf(i));
+0105 if Finf > crit & newRank
+0106 icc = icc + 1;
+0107 Kinf = Pinf(:,mf(i));
+0108 a = a + Kinf*v(i)/Finf;
+0109 Pstar = Pstar + Kinf*transpose(Kinf)*Fstar/(Finf*Finf) - ...
+0110 (Kstar*transpose(Kinf)+Kinf*transpose(Kstar))/Finf;
+0111 Pinf = Pinf - Kinf*transpose(Kinf)/Finf;
+0112 lik(t) = lik(t) + log(Finf);
+0113
+0114 if ~isempty(options_.diffuse_d),
+0115 newRank = (icc<options_.diffuse_d);
+0116
+0117 if newRank & (any(diag(Pinf(mf,mf))>crit)==0 & rank(Pinf,crit1)==0);
+0118 options_.diffuse_d = icc;
+0119 newRank=0;
+0120 disp('WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF' )
+0121 disp(['new OPTIONS_.DIFFUSE_D = ' ,int2str(icc)])
+0122 disp('You may have to reset the optimisation' )
+0123 end
+0124 else
+0125
+0126 newRank = (any(diag(Pinf(mf,mf))>crit) | rank(Pinf,crit1));
+0127 if newRank==0,
+0128 P0= T*Pinf*transpose(T);
+0129
+0130 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1));
+0131 if newRank==0,
+0132 options_.diffuse_d = icc;
+0133 end
+0134 end
+0135 end ,
+0136
+0137 elseif Finf > crit
+0138
+0139
+0140
+0141
+0142
+0143
+0144
+0145 lik(t) = lik(t) + log(Fstar) + v(i)*v(i)/Fstar;
+0146
+0147 a = a + Kstar*v(i)/Fstar;
+0148 Pstar = Pstar - Kstar*transpose(Kstar)/Fstar;
+0149 else
+0150
+0151 end
+0152 end
+0153 if newRank
+0154 oldRank = rank(Pinf,crit1);
+0155 else
+0156 oldRank = 0;
+0157 end
+0158 a = T*a;
+0159 Pstar = T*Pstar*transpose(T)+QQ;
+0160 Pinf = T*Pinf*transpose(T);
+0161 if newRank
+0162 newRank = rank(Pinf,crit1);
+0163 end
+0164 if oldRank ~= newRank
+0165 disp('DiffuseLiklihoodH3 :: T does influence the rank of Pinf!' )
+0166 end
+0167 end
+0168 if t == smpl
+0169 error(['There isn''t enough information to estimate the initial' ...
+0170 ' conditions of the nonstationary variables' ]);
+0171 end
+0172 while notsteady & t < smpl
+0173 t = t+1;
+0174 for i=1:pp
+0175 v(i) = Y(i,t) - a(mf(i)) - trend(i,t);
+0176 Fi = Pstar(mf(i),mf(i))+H(i,i);
+0177 if Fi > crit
+0178 Ki = Pstar(:,mf(i));
+0179 a = a + Ki*v(i)/Fi;
+0180 Pstar = Pstar - Ki*transpose(Ki)/Fi;
+0181 lik(t) = lik(t) + log(Fi) + v(i)*v(i)/Fi;
+0182 end
+0183 end
+0184 oldP = Pstar;
+0185 a = T*a;
+0186 Pstar = T*Pstar*transpose(T) + QQ;
+0187 notsteady = ~(max(max(abs(Pstar-oldP)))<crit);
+0188 end
+0189 while t < smpl
+0190 t = t+1;
+0191 for i=1:pp
+0192 v(i) = Y(i,t) - a(mf(i)) - trend(i,t);
+0193 Fi = Pstar(mf(i),mf(i))+H(i,i);
+0194 if Fi > crit
+0195 Ki = Pstar(:,mf(i));
+0196 a = a + Ki*v(i)/Fi;
+0197 Pstar = Pstar - Ki*transpose(Ki)/Fi;
+0198 lik(t) = lik(t) + log(Fi) + v(i)*v(i)/Fi;
+0199 end
+0200 end
+0201 a = T*a;
+0202 end
+0203 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
+0204
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DiffuseLikelihoodH3corr.html b/matlab/doc/DiffuseLikelihoodH3corr.html
new file mode 100644
index 000000000..1d67cbbaa
--- /dev/null
+++ b/matlab/doc/DiffuseLikelihoodH3corr.html
@@ -0,0 +1,147 @@
+
+
+
+ Description of DiffuseLikelihoodH3corr
+
+
+
+
+
+
+
+
+
+Home >
. > DiffuseLikelihoodH3corr.m
+
+
+
+DiffuseLikelihoodH3corr
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [12-13-2004]
+
+ SYNOPSIS
+function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)
+0002
+0003
+0004
+0005
+0006
+0007 global bayestopt_ options_
+0008
+0009 mf = bayestopt_.mf;
+0010 pp = size(Y,1);
+0011 mm = size(T,1);
+0012 rr = size(Q,1);
+0013 smpl = size(Y,2);
+0014 T = cat(1,cat(2,T,zeros(mm,pp)),zeros(pp,mm+pp));
+0015 R = cat(1,cat(2,R,zeros(mm,pp)),cat(2,zeros(pp,rr),eye(pp)));
+0016 Q = cat(1,cat(2,Q,zeros(rr,pp)),cat(2,zeros(pp,rr),H));
+0017 if size(Pinf,1)
+0018 Pinf = cat(1,cat(2,Pinf,zeros(mm,pp)),zeros(pp,mm+pp));
+0019 end
+0020 Pstar = cat(1,cat(2,Pstar,zeros(mm,pp)),cat(2,zeros(pp,mm),H));
+0021 a = zeros(mm+pp,1);
+0022 QQ = R*Q*transpose(R);
+0023 t = 0;
+0024 lik = zeros(smpl+1,1);
+0025 lik(smpl+1) = smpl*pp*log(2*pi);
+0026 notsteady = 1;
+0027 crit = options_.kalman_tol;
+0028 newRank = rank(Pinf,crit);
+0029
+0030 while rank(Pinf,crit) & t < smpl
+0031 t = t+1;
+0032 for i=1:pp
+0033 v(i) = Y(i,t)-a(mf(i))-a(mm+i)-trend(i,t);
+0034 Fstar = Pstar(mf(i),mf(i))+Pstar(mm+i,mm+i);
+0035 Finf = Pinf(mf(i),mf(i));
+0036 Kstar = Pstar(:,mf(i))+Pstar(:,mm+i);
+0037 if Finf > crit
+0038 Kinf = Pinf(:,mf(i));
+0039 a = a + Kinf*v(i)/Finf;
+0040 Pstar = Pstar + Kinf*transpose(Kinf)*Fstar/(Finf*Finf) - ...
+0041 (Kstar*transpose(Kinf)+Kinf*transpose(Kstar))/Finf;
+0042 Pinf = Pinf - Kinf*transpose(Kinf)/Finf;
+0043 lik(t) = lik(t) + log(Finf);
+0044 else
+0045
+0046
+0047 if rank(Pinf) == 0
+0048 lik(t) = lik(t) + log(Fstar) + v(i)*v(i)/Fstar;
+0049 end
+0050 a = a + Kstar*v(i)/Fstar;
+0051 Pstar = Pstar - Kstar*transpose(Kstar)/Fstar;
+0052 end
+0053 oldRank = rank(Pinf,crit);
+0054 a = T*a;
+0055 Pstar = T*Pstar*transpose(T)+QQ;
+0056 Pinf = T*Pinf*transpose(T);
+0057 newRank = rank(Pinf,crit);
+0058 if oldRank ~= newRank
+0059 disp('DiffuseLiklihoodH3 :: T does influence the rank of Pinf!' )
+0060 end
+0061 end
+0062 end
+0063 if t == smpl
+0064 error(['There isn''t enough information to estimate the initial' ...
+0065 ' conditions of the nonstationary variables' ]);
+0066 end
+0067 while notsteady & t < smpl
+0068 t = t+1;
+0069 for i=1:pp
+0070 v(i) = Y(i,t) - a(mf(i)) - trend(i,t) -a(mm+i);
+0071 Fi = Pstar(mf(i),mf(i))+Pstar(mm+i,mm+i);
+0072 if Fi > crit
+0073 Ki = Pstar(:,mf(i))+Pstar(:,mm+i);
+0074 a = a + Ki*v(i)/Fi;
+0075 Pstar = Pstar - Ki*transpose(Ki)/Fi;
+0076 lik(t) = lik(t) + log(Fi) + v(i)*v(i)/Fi;
+0077 end
+0078 end
+0079 oldP = Pstar;
+0080 a = T*a;
+0081 Pstar = T*Pstar*transpose(T) + QQ;
+0082 notsteady = ~(max(max(abs(Pstar-oldP)))<crit);
+0083 end
+0084 while t < smpl
+0085 t = t+1;
+0086 for i=1:pp
+0087 v(i) = Y(i,t) - a(mf(i)) - trend(i,t) - a(mm+i);
+0088 Fi = Pstar(mf(i),mf(i))+Pstar(mm+i,mm+i);
+0089 if Fi > crit
+0090 Ki = Pstar(:,mf(i))+Pstar(:,mm+i);
+0091 a = a + Ki*v(i)/Fi;
+0092 Pstar = Pstar - Ki*transpose(Ki)/Fi;
+0093 lik(t) = lik(t) + log(Fi) + v(i)*v(i)/Fi;
+0094 end
+0095 end
+0096 a = T*a;
+0097 end
+0098 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DsgeLikelihood.html b/matlab/doc/DsgeLikelihood.html
new file mode 100644
index 000000000..7ad2a7986
--- /dev/null
+++ b/matlab/doc/DsgeLikelihood.html
@@ -0,0 +1,232 @@
+
+
+
+ Description of DsgeLikelihood
+
+
+
+
+
+
+
+
+
+Home >
. > DsgeLikelihood.m
+
+
+
+DsgeLikelihood
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
+
+ SYNOPSIS
+function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)
+0002
+0003
+0004
+0005 global bayestopt_ estim_params_ options_ trend_coeff_ M_ oo_ xparam1_test
+0006
+0007 fval = [];
+0008 ys = [];
+0009 trend_coeff = [];
+0010 xparam1_test = xparam1;
+0011 cost_flag = 1;
+0012 nobs = size(options_.varobs,1);
+0013
+0014
+0015
+0016 if options_.mode_compute ~= 1 & any(xparam1 < bayestopt_.lb)
+0017 k = find(xparam1 < bayestopt_.lb);
+0018 fval = bayestopt_.penalty+sum((bayestopt_.lb(k)-xparam1(k)).^2);
+0019 cost_flag = 0;
+0020 return ;
+0021 end
+0022 if options_.mode_compute ~= 1 & any(xparam1 > bayestopt_.ub)
+0023 k = find(xparam1 > bayestopt_.ub);
+0024 fval = bayestopt_.penalty+sum((xparam1(k)-bayestopt_.ub(k)).^2);
+0025 cost_flag = 0;
+0026 return ;
+0027 end
+0028 Q = M_.Sigma_e;
+0029 for i=1:estim_params_.nvx
+0030 k =estim_params_.var_exo(i,1);
+0031 Q(k,k) = xparam1(i)*xparam1(i);
+0032 end
+0033 offset = estim_params_.nvx;
+0034 if estim_params_.nvn
+0035 H = zeros(nobs,nobs);
+0036 for i=1:estim_params_.nvn
+0037 k = estim_params_.var_endo(i,1);
+0038 H(k,k) = xparam1(i+offset)*xparam1(i+offset);
+0039 end
+0040 offset = offset+estim_params_.nvn;
+0041 end
+0042 if estim_params_.ncx
+0043 for i=1:estim_params_.ncx
+0044 k1 =estim_params_.corrx(i,1);
+0045 k2 =estim_params_.corrx(i,2);
+0046 Q(k1,k2) = xparam1(i+offset)*sqrt(Q(k1,k1)*Q(k2,k2));
+0047 Q(k2,k1) = Q(k1,k2);
+0048 end
+0049 [CholQ,testQ] = chol(Q);
+0050 if testQ
+0051
+0052 a = diag(eig(Q));
+0053 k = find(a < 0);
+0054 if k > 0
+0055 fval = bayestopt_.penalty+sum(-a(k));
+0056 cost_flag = 0;
+0057 return
+0058 end
+0059 end
+0060 offset = offset+estim_params_.ncx;
+0061 end
+0062 if estim_params_.ncn
+0063 for i=1:estim_params_.ncn
+0064 k1 = options_.lgyidx2varobs(estim_params_.corrn(i,1));
+0065 k2 = options_.lgyidx2varobs(estim_params_.corrn(i,2));
+0066 H(k1,k2) = xparam1(i+offset)*sqrt(H(k1,k1)*H(k2,k2));
+0067 H(k2,k1) = H(k1,k2);
+0068 end
+0069 [CholH,testH] = chol(H);
+0070 if testH
+0071 a = diag(eig(H));
+0072 k = find(a < 0);
+0073 if k > 0
+0074 fval = bayestopt_.penalty+sum(-a(k));
+0075 cost_flag = 0;
+0076 return
+0077 end
+0078 end
+0079 offset = offset+estim_params_.ncn;
+0080 end
+0081 M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
+0082
+0083
+0084
+0085 M_.Sigma_e = Q;
+0086
+0087
+0088
+0089 [T,R,SteadyState,info] = dynare_resolve ;
+0090 rs = bayestopt_.restrict_state;
+0091 if info(1) == 1 | info(1) == 2 | info(1) == 5
+0092 fval = bayestopt_.penalty+1;
+0093 cost_flag = 0;
+0094 return
+0095 elseif info(1) == 3 | info(1) == 4 | info(1) == 20
+0096 fval = bayestopt_.penalty+info(2)^2;
+0097 cost_flag = 0;
+0098 return
+0099 end
+0100 T = T(rs,rs);
+0101 R = R(rs,:);
+0102 bayestopt_.mf = bayestopt_.mf1;
+0103 if options_.loglinear == 1
+0104 constant = log(SteadyState(bayestopt_.mfys));
+0105 else
+0106 constant = SteadyState(bayestopt_.mfys);
+0107 end
+0108 if bayestopt_.with_trend == 1
+0109 trend_coeff = zeros(nobs,1);
+0110 for i=1:nobs
+0111 trend_coeff(i) = evalin('base' ,bayestopt_.trend_coeff{i});
+0112 end
+0113 trend = repmat(constant,1,gend)+trend_coeff*[1:gend];
+0114 else
+0115 trend = repmat(constant,1,gend);
+0116 end
+0117 start = options_.presample+1;
+0118 np = size(T,1);
+0119 mf = bayestopt_.mf;
+0120
+0121
+0122
+0123 if options_.lik_init == 1
+0124 Pstar = lyapunov_symm (T,R*Q*transpose(R));
+0125 Pinf = [];
+0126 elseif options_.lik_init == 2
+0127 Pstar = 10*eye(np);
+0128 Pinf = [];
+0129 elseif options_.lik_init == 3
+0130 Pstar = zeros(np,np);
+0131 ivs = bayestopt_.i_T_var_stable;
+0132 Pstar(ivs,ivs) = lyapunov_symm (T(ivs,ivs),R(ivs,:)*Q* ...
+0133 transpose(R(ivs,:)));
+0134 Pinf = bayestopt_.Pinf;
+0135
+0136 RR=T(:,find(~ismember([1:np],ivs)));
+0137 i=find(abs(RR)>1.e-10);
+0138 R0=zeros(size(RR));
+0139 R0(i)=sign(RR(i));
+0140 Pinf=R0*R0';
+0141
+0142 end
+0143
+0144
+0145
+0146 if estim_params_.nvn
+0147 if options_.kalman_algo == 1
+0148 LIK = DiffuseLikelihoodH1 (T,R,Q,H,Pinf,Pstar,data,trend,start);
+0149 if isinf(LIK) & ~estim_params_.ncn
+0150
+0151 LIK = DiffuseLikelihoodH3 (T,R,Q,H,Pinf,Pstar,data,trend,start);
+0152 elseif isinf(LIK) & estim_params_.ncn
+0153 LIK = DiffuseLikelihoodH3corr (T,R,Q,H,Pinf,Pstar,data,trend,start);
+0154 end
+0155 elseif options_.kalman_algo == 3
+0156 if ~estim_params_.ncn
+0157
+0158 LIK = DiffuseLikelihoodH3 (T,R,Q,H,Pinf,Pstar,data,trend,start);
+0159 else
+0160 LIK = DiffuseLikelihoodH3corr (T,R,Q,H,Pinf,Pstar,data,trend,start);
+0161 end
+0162 end
+0163 else
+0164 if options_.kalman_algo == 1
+0165 nv = size(bayestopt_.Z,1);
+0166 LIK = kalman_filter (bayestopt_.Z,zeros(nv,nv),T,R,Q,data,zeros(size(T,1),1),Pstar,'u' );
+0167
+0168 if isinf(LIK)
+0169 LIK = DiffuseLikelihood3 (T,R,Q,Pinf,Pstar,data,trend,start);
+0170 end
+0171 elseif options_.kalman_algo == 3
+0172 LIK = DiffuseLikelihood3 (T,R,Q,Pinf,Pstar,data,trend,start);
+0173 end
+0174 end
+0175 if imag(LIK) ~= 0
+0176 likelihood = bayestopt_.penalty;
+0177 else
+0178 likelihood = LIK;
+0179 end
+0180
+0181
+0182
+0183 lnprior = priordens (xparam1,bayestopt_.pshape,bayestopt_.p1,bayestopt_.p2,bayestopt_.p3,bayestopt_.p4);
+0184 fval = (likelihood-lnprior);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/DsgeSmoother.html b/matlab/doc/DsgeSmoother.html
new file mode 100644
index 000000000..1e6f7477e
--- /dev/null
+++ b/matlab/doc/DsgeSmoother.html
@@ -0,0 +1,139 @@
+
+
+
+ Description of DsgeSmoother
+
+
+
+
+
+
+
+
+
+Home >
. > DsgeSmoother.m
+
+
+
+DsgeSmoother
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
+
+ SYNOPSIS
+function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+DiffuseKalmanSmoother1 modified by M. Ratto:DiffuseKalmanSmoother3 function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)DiffuseKalmanSmootherH1 modified by M. Ratto:DiffuseKalmanSmootherH3 Modified by M. Rattodynare_resolve lyapunov_symm solves x-a*x*a'=b for b (and then x) symmetricalset_all_parameters
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)
+0002
+0003
+0004
+0005 global bayestopt_ M_ oo_ estim_params_ options_
+0006
+0007 alphahat = [];
+0008 epsilonhat = [];
+0009 etahat = [];
+0010 nobs = size(options_.varobs,1);
+0011 smpl = size(Y,2);
+0012
+0013 set_all_parameters (xparam1);
+0014
+0015
+0016
+0017
+0018 [T,R,SteadyState] = dynare_resolve ;
+0019 bayestopt_.mf = bayestopt_.mf2;
+0020 if options_.loglinear == 1
+0021 constant = log(SteadyState(bayestopt_.mfys));
+0022 else
+0023 constant = SteadyState(bayestopt_.mfys);
+0024 end
+0025 trend_coeff = zeros(nobs,1);
+0026 if bayestopt_.with_trend == 1
+0027 trend_coeff = zeros(nobs,1);
+0028 nx1 = estim_params_.nvx+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn;
+0029 for i=1:nobs
+0030 trend_coeff(i) = evalin('base' ,bayestopt_.trend_coeff{i});
+0031 end
+0032 trend = constant*ones(1,gend)+trend_coeff*(1:gend);
+0033 else
+0034 trend = constant*ones(1,gend);
+0035 end
+0036 start = options_.presample+1;
+0037 np = size(T,1);
+0038 mf = bayestopt_.mf;
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047 Q = M_.Sigma_e;
+0048 H = M_.H;
+0049
+0050 if options_.lik_init == 1
+0051 Pstar = lyapunov_symm (T,R*Q*transpose(R));
+0052 Pinf = [];
+0053 elseif options_.lik_init == 2
+0054 Pstar = 10*eye(np);
+0055 Pinf = [];
+0056 elseif options_.lik_init == 3
+0057 Pstar = zeros(np,np);
+0058 ivs = bayestopt_.i_T_var_stable;
+0059 Pstar(ivs,ivs) = lyapunov_symm (T(ivs,ivs),R(ivs,:)*Q* ...
+0060 transpose(R(ivs,:)));
+0061 Pinf = bayestopt_.Pinf;
+0062
+0063 RR=T(:,find(~ismember([1:np],ivs)));
+0064 i=find(abs(RR)>1.e-10);
+0065 R0=zeros(size(RR));
+0066 R0(i)=sign(RR(i));
+0067 Pinf=R0*R0';
+0068
+0069 end
+0070
+0071
+0072
+0073 if estim_params_.nvn
+0074 if options_.kalman_algo == 1
+0075 [alphahat,epsilonhat,etahat,ahat,aK] = DiffuseKalmanSmootherH1 (T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
+0076 if all(alphahat(:)==0)
+0077 [alphahat,epsilonhat,etahat,ahat,aK] = DiffuseKalmanSmootherH3 (T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
+0078 end
+0079 elseif options_.kalman_algo == 3
+0080 [alphahat,epsilonhat,etahat,ahat,aK] = DiffuseKalmanSmootherH3 (T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
+0081 end
+0082 else
+0083 if options_.kalman_algo == 1
+0084 [alphahat,etahat,ahat,aK] = DiffuseKalmanSmoother1 (T,R,Q,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
+0085 if all(alphahat(:)==0)
+0086 [alphahat,etahat,ahat,aK] = DiffuseKalmanSmoother3 (T,R,Q,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
+0087 end
+0088 elseif options_.kalman_algo == 3
+0089 [alphahat,etahat,ahat,aK] = DiffuseKalmanSmoother3 (T,R,Q,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
+0090 end
+0091 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/GetAllPosteriorDraws.html b/matlab/doc/GetAllPosteriorDraws.html
new file mode 100644
index 000000000..c5a6cf9dc
--- /dev/null
+++ b/matlab/doc/GetAllPosteriorDraws.html
@@ -0,0 +1,76 @@
+
+
+
+ Description of GetAllPosteriorDraws
+
+
+
+
+
+
+
+
+
+Home >
. > GetAllPosteriorDraws.m
+
+
+
+GetAllPosteriorDraws
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-09-2005]
+
+ SYNOPSIS
+function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)
+0002
+0003 global M_ options_
+0004
+0005 nblck = options_.mh_nblck;
+0006 iline = FirstLine;
+0007 linee = 1;
+0008 DirectoryName = CheckPath ('metropolis' );
+0009 Draws = zeros(NumberOfDraws*nblck,1);
+0010 logpo = zeros(NumberOfDraws*nblck,1);
+0011 ipost=0;
+0012 if column<0,
+0013 column=1;
+0014 ipost=1;
+0015 end
+0016
+0017 for file = FirstMhFile:TotalNumberOfMhFile
+0018 for blck = 1:nblck
+0019 load([DirectoryName '/' M_.fname '_mh' int2str(file) '_blck' int2str(blck)],'x2' ,'logpo2' )
+0020 NumberOfLines = size(x2(iline:end ,:),1);
+0021 Draws(linee:linee+NumberOfLines-1) = x2(iline:end ,column);
+0022 logpo(linee:linee+NumberOfLines-1) = logpo2(iline:end);
+0023 linee = linee+NumberOfLines;
+0024 end
+0025 iline = 1;
+0026 end
+0027
+0028 if ipost,
+0029 Draws=logpo;
+0030 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/GetOneDraw.html b/matlab/doc/GetOneDraw.html
new file mode 100644
index 000000000..2303c26a6
--- /dev/null
+++ b/matlab/doc/GetOneDraw.html
@@ -0,0 +1,55 @@
+
+
+
+ Description of GetOneDraw
+
+
+
+
+
+
+
+
+
+
+
+
+
+GetOneDraw
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-25-2005]
+
+ SYNOPSIS
+function [xparams, logpost] = GetOneDraw(type)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/GetPosteriorParametersStatistics.html b/matlab/doc/GetPosteriorParametersStatistics.html
new file mode 100644
index 000000000..9f176f848
--- /dev/null
+++ b/matlab/doc/GetPosteriorParametersStatistics.html
@@ -0,0 +1,204 @@
+
+
+
+ Description of GetPosteriorParametersStatistics
+
+
+
+
+
+
+
+
+
+Home >
. > GetPosteriorParametersStatistics.m
+
+
+
+GetPosteriorParametersStatistics
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-09-2005]
+
+ SYNOPSIS
+function GetPosteriorParametersStatistics()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function GetPosteriorParametersStatistics()
+0002
+0003 global estim_params_ M_ options_ bayestopt_ oo_
+0004
+0005 TeX = options_.TeX;
+0006 nblck = options_.mh_nblck;
+0007 nvx = estim_params_.nvx;
+0008 nvn = estim_params_.nvn;
+0009 ncx = estim_params_.ncx;
+0010 ncn = estim_params_.ncn;
+0011 np = estim_params_.np ;
+0012 nx = nvx+nvn+ncx+ncn+np;
+0013
+0014 DirectoryName = CheckPath ('metropolis' );
+0015 load([ DirectoryName '/' M_.fname '_mh_history' ])
+0016 FirstMhFile = record.KeepedDraws.FirstMhFile;
+0017 FirstLine = record.KeepedDraws.FirstLine; ifil = FirstLine;
+0018 TotalNumberOfMhFiles = sum(record.MhDraws(:,2))
+0019 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
+0020 FirstMhFile = record.KeepedDraws.FirstMhFile;
+0021 NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
+0022 clear record;
+0023
+0024 disp(' ' )
+0025 disp(' ' )
+0026 disp('ESTIMATION RESULTS' )
+0027 disp(' ' )
+0028 disp(sprintf('Log data density is %f.' ,oo_.MarginalDensity.ModifiedHarmonicMean))
+0029 pnames=[' ' ;'beta ' ;'gamm ' ;'norm ' ;'invg ' ;'unif ' ;'invg2' ];
+0030 tit2 = sprintf('%10s %7s %10s %14s %4s %6s\n' ,' ' ,'prior mean' ,'post. mean' ,'conf. interval' ,'prior' ,'pstdev' );
+0031 if np
+0032 disp(' ' )
+0033 disp('parameters' )
+0034 disp(tit2)
+0035 ip = nvx+nvn+ncx+ncn+1;
+0036 for i=1:np
+0037 Draws = GetAllPosteriorDraws (ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
+0038 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments (Draws,1);
+0039 name = bayestopt_.name{ip};
+0040 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , ...
+0041 name, ...
+0042 bayestopt_.pmean(ip),post_mean,hpd_interval, ...
+0043 pnames(bayestopt_.pshape(ip)+1,:), ...
+0044 bayestopt_.pstdev(ip)));
+0045 eval(['oo_.posterior_mean.parameters.' name ' = post_mean;' ]);
+0046 eval(['oo_.posterior_hpdinf.parameters.' name ' = hpd_interval(1);' ]);
+0047 eval(['oo_.posterior_hpdsup.parameters.' name ' = hpd_interval(2);' ]);
+0048 eval(['oo_.posterior_median.' name ' = post_median;' ]);
+0049 eval(['oo_.posterior_variance.' name ' = post_var;' ]);
+0050 eval(['oo_.posterior_deciles.' name ' = post_deciles;' ]);
+0051 eval(['oo_.posterior_density.' name ' = density;' ]);
+0052 ip = ip+1;
+0053 end
+0054 end
+0055 if nvx
+0056 ip = 1;
+0057 disp(' ' )
+0058 disp('standard deviation of shocks' )
+0059 disp(tit2)
+0060 for i=1:nvx
+0061 Draws = GetAllPosteriorDraws (ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
+0062 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments (Draws,1);
+0063 k = estim_params_.var_exo(i,1);
+0064 name = deblank(M_.exo_names(k,:));
+0065 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , ...
+0066 name,bayestopt_.pmean(ip),post_mean, ...
+0067 hpd_interval,pnames(bayestopt_.pshape(ip)+1,:), ...
+0068 bayestopt_.pstdev(ip)));
+0069 M_.Sigma_e(k,k) = post_mean*post_mean;
+0070 eval(['oo_.posterior_mean.shocks_std.' name ' = post_mean;' ]);
+0071 eval(['oo_.posterior_hpdinf.shocks_std.' name ' = hpd_interval(1);' ]);
+0072 eval(['oo_.posterior_hpdsup.shocks_std.' name ' = hpd_interval(2);' ]);
+0073 eval(['oo_.posterior_median.shocks_std.' name ' = post_median;' ]);
+0074 eval(['oo_.posterior_variance.shocks_std.' name ' = post_var;' ]);
+0075 eval(['oo_.posterior_deciles.shocks_std.' name ' = post_deciles;' ]);
+0076 eval(['oo_.posterior_density.shocks_std.' name ' = density;' ]);
+0077 ip = ip+1;
+0078 end
+0079 end
+0080 if nvn
+0081 disp(' ' )
+0082 disp('standard deviation of measurement errors' )
+0083 disp(tit2)
+0084 ip = nvx+1;
+0085 for i=1:nvn
+0086 Draws = GetAllPosteriorDraws (ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
+0087 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments (Draws,1);
+0088 name = deblank(options_.varobs(estim_params_.var_endo(i,1),:));
+0089 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , ...
+0090 name,...
+0091 bayestopt_.pmean(ip), ...
+0092 post_mean,hpd_interval, ...
+0093 pnames(bayestopt_.pshape(ip)+1,:), ...
+0094 bayestopt_.pstdev(ip)));
+0095 eval(['oo_.posterior_mean.measurement_errors_std.' name ' = post_mean;' ]);
+0096 eval(['oo_.posterior_hpdinf.measurement_errors_std.' name ' = hpd_interval(1);' ]);
+0097 eval(['oo_.posterior_hpdsup.measurement_errors_std.' name ' = hpd_interval(2);' ]);
+0098 eval(['oo_.posterior_median.measurement_errors_std.' name ' = post_median;' ]);
+0099 eval(['oo_.posterior_variance.measurement_errors_std.' name ' = post_var;' ]);
+0100 eval(['oo_.posterior_deciles.measurement_errors_std.' name ' = post_deciles;' ]);
+0101 eval(['oo_.posterior_density.measurement_errors_std.' name ' = density;' ]);
+0102 ip = ip+1;
+0103 end
+0104 end
+0105 if ncx
+0106 disp(' ' )
+0107 disp('correlation of shocks' )
+0108 disp(tit2)
+0109 ip = nvx+nvn+1;
+0110 for i=1:ncx
+0111 Draws = GetAllPosteriorDraws (ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
+0112 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments (Draws,1);
+0113 k1 = estim_params_.corrx(i,1);
+0114 k2 = estim_params_.corrx(i,2);
+0115 name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
+0116 NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
+0117 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , name, ...
+0118 bayestopt_.pmean(ip),post_mean,hpd_interval, ...
+0119 pnames(bayestopt_.pshape(ip)+1,:), ...
+0120 bayestopt_.pstdev(ip)));
+0121 eval(['oo_.posterior_mean.shocks_corr.' NAME ' = post_mean;' ]);
+0122 eval(['oo_.posterior_hpdinf.shocks_corr.' NAME ' = hpd_interval(1);' ]);
+0123 eval(['oo_.posterior_hpdsup.shocks_corr.' NAME ' = hpd_interval(2);' ]);
+0124 eval(['oo_.posterior_median.shocks_corr.' NAME ' = post_median;' ]);
+0125 eval(['oo_.posterior_variance.shocks_corr.' NAME ' = post_var;' ]);
+0126 eval(['oo_.posterior_deciles.shocks_corr.' NAME ' = post_deciles;' ]);
+0127 eval(['oo_.posterior_density.shocks_corr.' NAME ' = density;' ]);
+0128 M_.Sigma_e(k1,k2) = post_mean*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
+0129 M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
+0130 ip = ip+1;
+0131 end
+0132 end
+0133 if ncn
+0134 disp(' ' )
+0135 disp('correlation of measurement errors' )
+0136 disp(tit2)
+0137 ip = nvx+nvn+ncx+1;
+0138 for i=1:ncn
+0139 Draws = GetAllPosteriorDraws (ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
+0140 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments (Draws,1);
+0141 k1 = estim_params_.corrn(i,1);
+0142 k2 = estim_params_.corrn(i,2);
+0143 name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
+0144 NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
+0145 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , name, ...
+0146 bayestopt_.pmean(ip),post_mean,hpd_interval, ...
+0147 pnames(bayestopt_.pshape(ip)+1,:), ...
+0148 bayestopt_.pstdev(ip)));
+0149 eval(['oo_.posterior_mean.measurement_errors_corr.' NAME ' = post_mean;' ]);
+0150 eval(['oo_.posterior_hpdinf.measurement_errors_corr.' NAME ' = hpd_interval(1);' ]);
+0151 eval(['oo_.posterior_hpdsup.measurement_errors_corr.' NAME ' = hpd_interval(2);' ]);
+0152 eval(['oo_.posterior_median.measurement_errors_corr.' NAME ' = post_median;' ]);
+0153 eval(['oo_.posterior_variance.measurement_errors_corr.' NAME ' = post_var;' ]);
+0154 eval(['oo_.posterior_deciles.measurement_errors_corr.' NAME ' = post_decile;' ]);
+0155 eval(['oo_.posterior_density.measurement_errors_corr.' NAME ' = density;' ]);
+0156 ip = ip+1;
+0157 end
+0158 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/InitSeed.html b/matlab/doc/InitSeed.html
new file mode 100644
index 000000000..e78e83bf0
--- /dev/null
+++ b/matlab/doc/InitSeed.html
@@ -0,0 +1,91 @@
+
+
+
+ Description of InitSeed
+
+
+
+
+
+
+
+
+
+
+
+
+
+InitSeed
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [12-02-2004]
+
+ SYNOPSIS
+function InitSeed
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function InitSeed
+0002
+0003
+0004
+0005 normalseed = [ 220271 ;
+0006 220378];
+0007
+0008 uniformseed = [ 0.6776 ; ...
+0009 0.8239 ; ...
+0010 0.6219 ; ...
+0011 0.8169 ; ...
+0012 0.2796 ; ...
+0013 0.4337 ; ...
+0014 0.6205 ; ...
+0015 0.8994 ; ...
+0016 0.9718 ; ...
+0017 0.7993 ; ...
+0018 0.4444 ; ...
+0019 0.8896 ; ...
+0020 0.9231 ; ...
+0021 0.5838 ; ...
+0022 0.1788 ; ...
+0023 0.6556 ; ...
+0024 0.7464 ; ...
+0025 0.7545 ; ...
+0026 0.2400 ; ...
+0027 0.4431 ; ...
+0028 0.3453 ; ...
+0029 0.6687 ; ...
+0030 0.6287 ; ...
+0031 0.8371 ; ...
+0032 0.8041 ; ...
+0033 0.6802 ; ...
+0034 0.5864 ; ...
+0035 0.7713 ; ...
+0036 0.8282 ; ...
+0037 0.5748 ; ...
+0038 0.0999 ; ...
+0039 0.6360 ; ...
+0040 0 ; ...
+0041 0.0000 ; ...
+0042 0.0000];
+0043
+0044 randn('state' ,normalseed);
+0045 rand('state' ,uniformseed);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/LPTAU.html b/matlab/doc/LPTAU.html
new file mode 100644
index 000000000..8fcb4b8da
--- /dev/null
+++ b/matlab/doc/LPTAU.html
@@ -0,0 +1,628 @@
+
+
+
+ Description of LPTAU
+
+
+
+
+
+
+
+
+
+
+
+
+
+LPTAU
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function VECTOR = LPTAU(I, N)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function VECTOR = LPTAU(I, N)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073 MAXDIM=51; QP=30; MAXNUM=2^30-1;
+0074
+0075
+0076
+0077
+0078
+0079
+0080
+0081
+0082
+0083
+0084
+0085
+0086
+0087 VECTOR=zeros(1,N);
+0088 SCALE =9.31322574615478516E-10;
+0089
+0090 persistent PRVNUM PRVDIM MASKV DIRECT
+0091 if isempty(PRVNUM), PRVNUM=-2; end ,
+0092 if isempty(PRVDIM), PRVDIM=0; end ,
+0093
+0094 if isempty(DIRECT), ...
+0095 DIRECT(1:MAXDIM,1)=[
+0096 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0097 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0098 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0099 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0100 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0101 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0102 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0103 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0104 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0105 536870912, 536870912, 536870912, 536870912, 536870912, ...
+0106 536870912]';
+0107 DIRECT(1:MAXDIM,2)=[
+0108 805306368, 268435456, 805306368, 268435456, 805306368, ...
+0109 268435456, 805306368, 268435456, 268435456, 805306368, ...
+0110 268435456, 805306368, 268435456, 805306368, 268435456, ...
+0111 805306368, 805306368, 268435456, 805306368, 268435456, ...
+0112 805306368, 268435456, 805306368, 268435456, 268435456, ...
+0113 805306368, 268435456, 805306368, 268435456, 805306368, ...
+0114 268435456, 805306368, 805306368, 268435456, 805306368, ...
+0115 268435456, 805306368, 268435456, 805306368, 268435456, ...
+0116 268435456, 805306368, 268435456, 805306368, 268435456, ...
+0117 805306368, 268435456, 805306368, 805306368, 268435456, ...
+0118 805306368]';
+0119 DIRECT(1:MAXDIM,3)=[
+0120 939524096, 939524096, 134217728, 671088640, 402653184, ...
+0121 402653184, 671088640, 134217728, 671088640, 402653184, ...
+0122 939524096, 134217728, 671088640, 939524096, 134217728, ...
+0123 671088640, 134217728, 939524096, 939524096, 402653184, ...
+0124 402653184, 134217728, 671088640, 402653184, 671088640, ...
+0125 402653184, 402653184, 671088640, 134217728, 134217728, ...
+0126 939524096, 939524096, 939524096, 939524096, 134217728, ...
+0127 671088640, 402653184, 402653184, 671088640, 134217728, ...
+0128 671088640, 402653184, 939524096, 134217728, 671088640, ...
+0129 939524096, 134217728, 671088640, 134217728, 939524096, ...
+0130 939524096]';
+0131 DIRECT(1:MAXDIM,4)=[
+0132 1006632960, 67108864, 603979776, 1006632960, 335544320, ...
+0133 469762048, 872415232, 738197504, 469762048, 872415232, ...
+0134 1006632960, 67108864, 872415232, 469762048, 469762048, ...
+0135 469762048, 1006632960, 335544320, 872415232, 603979776, ...
+0136 201326592, 67108864, 335544320, 67108864, 201326592, ...
+0137 738197504, 1006632960, 738197504, 603979776, 335544320, ...
+0138 738197504, 67108864, 1006632960, 67108864, 603979776, ...
+0139 1006632960, 335544320, 469762048, 872415232, 738197504, ...
+0140 469762048, 872415232, 1006632960, 67108864, 872415232, ...
+0141 469762048, 469762048, 469762048, 1006632960, 335544320, ...
+0142 872415232]';
+0143 DIRECT(1:MAXDIM,5)=[
+0144 1040187392, 637534208, 1040187392, 838860800, 167772160, ...
+0145 234881024, 167772160, 1040187392, 436207616, 33554432, ...
+0146 570425344, 1040187392, 503316480, 838860800, 973078528, ...
+0147 167772160, 234881024, 436207616, 771751936, 100663296, ...
+0148 234881024, 905969664, 771751936, 33554432, 838860800, ...
+0149 973078528, 905969664, 33554432, 301989888, 838860800, ...
+0150 100663296, 234881024, 1040187392, 637534208, 1040187392, ...
+0151 838860800, 167772160, 234881024, 167772160, 1040187392, ...
+0152 436207616, 33554432, 570425344, 1040187392, 503316480, ...
+0153 838860800, 973078528, 167772160, 234881024, 436207616, ...
+0154 771751936]';
+0155 DIRECT(1:MAXDIM,6)=[
+0156 1056964608, 352321536, 50331648, 419430400, 956301312, ...
+0157 889192448, 620756992, 117440512, 956301312, 922746880, ...
+0158 822083584, 218103808, 587202560, 385875968, 452984832, ...
+0159 218103808, 184549376, 285212672, 150994944, 956301312, ...
+0160 352321536, 654311424, 553648128, 352321536, 788529152, ...
+0161 956301312, 587202560, 251658240, 218103808, 721420288, ...
+0162 251658240, 1056964608, 520093696, 889192448, 587202560, ...
+0163 956301312, 419430400, 352321536, 83886080, 654311424, ...
+0164 419430400, 385875968, 285212672, 754974720, 50331648, ...
+0165 922746880, 989855744, 754974720, 721420288, 822083584, ...
+0166 687865856]';
+0167 DIRECT(1:MAXDIM,7)=[
+0168 1065353216, 1065353216, 578813952, 25165824, 125829120, ...
+0169 964689920, 327155712, 310378496, 360710144, 360710144, ...
+0170 159383552, 444596224, 947912704, 662700032, 444596224, ...
+0171 528482304, 578813952, 578813952, 75497472, 1065353216, ...
+0172 92274688, 511705088, 897581056, 847249408, 662700032, ...
+0173 931135488, 411041792, 713031680, 696254464, 528482304, ...
+0174 209715200, 578813952, 1065353216, 1065353216, 578813952, ...
+0175 25165824, 125829120, 964689920, 327155712, 310378496, ...
+0176 360710144, 360710144, 159383552, 444596224, 947912704, ...
+0177 662700032, 444596224, 528482304, 578813952, 578813952, ...
+0178 75497472]';
+0179 DIRECT(1:MAXDIM,8)=[
+0180 1069547520, 4194304, 826277888, 624951296, 616562688, ...
+0181 801112064, 952107008, 406847488, 398458880, 331350016, ...
+0182 356515840, 46137344, 1010827264, 1069547520, 734003200, ...
+0183 113246208, 490733568, 633339904, 910163968, 801112064, ...
+0184 893386752, 851443712, 801112064, 918552576, 742391808, ...
+0185 499122176, 62914560, 264241152, 708837376, 717225984, ...
+0186 759169024, 499122176, 272629760, 423624704, 155189248, ...
+0187 239075328, 205520896, 943718400, 373293056, 457179136, ...
+0188 406847488, 71303168, 473956352, 54525952, 624951296, ...
+0189 104857600, 1019215872, 901775360, 213909504, 281018368, ...
+0190 851443712]';
+0191 DIRECT(1:MAXDIM,9)=[
+0192 1071644672, 543162368, 190840832, 329252864, 853540864, ...
+0193 132120576, 778043392, 73400320, 178257920, 522190848, ...
+0194 639631360, 534773760, 991952896, 333447168, 48234496, ...
+0195 1059061760, 761266176, 673185792, 220200960, 396361728, ...
+0196 362807296, 815792128, 819986432, 346030080, 39845888, ...
+0197 752877568, 387973120, 643825664, 291504128, 274726912, ...
+0198 568328192, 526385152, 673185792, 98566144, 396361728, ...
+0199 727711744, 1042284544, 106954752, 299892736, 912261120, ...
+0200 44040192, 895483904, 333447168, 551550976, 467664896, ...
+0201 618659840, 606076928, 274726912, 245366784, 446693376, ...
+0202 421527552]';
+0203 DIRECT(1:MAXDIM,10)=[
+0204 1072693248, 273678336, 644874240, 753926144, 495976448, ...
+0205 869269504, 355467264, 57671680, 816840704, 961544192, ...
+0206 804257792, 495976448, 347078656, 426770432, 1066401792, ...
+0207 372244480, 84934656, 208666624, 313524224, 598736896, ...
+0208 487587840, 965738496, 1011875840, 296747008, 393216000, ...
+0209 523239424, 720371712, 823132160, 128974848, 407896064, ...
+0210 747634688, 850395136, 873463808, 504365056, 481296384, ...
+0211 686817280, 592445440, 995098624, 498073600, 969932800, ...
+0212 586153984, 1039138816, 814743552, 523239424, 294649856, ...
+0213 305135616, 506462208, 11534336, 449839104, 619708416, ...
+0214 479199232]';
+0215 DIRECT(1:MAXDIM,11)=[
+0216 1073217536, 947388416, 1070071808, 977797120, 365428736, ...
+0217 702021632, 461897728, 829947904, 425197568, 634912768, ...
+0218 437780480, 582483968, 792199168, 315097088, 611844096, ...
+0219 667418624, 166199296, 513277952, 187170816, 1036517376, ...
+0220 25690112, 201850880, 443023360, 990380032, 63438848, ...
+0221 211288064, 983040000, 1069023232, 421003264, 742916096, ...
+0222 487063552, 363331584, 973602816, 286785536, 171442176, ...
+0223 669515776, 110624768, 383254528, 289931264, 352845824, ...
+0224 878182400, 655884288, 836239360, 765984768, 549978112, ...
+0225 655884288, 85458944, 591921152, 563609600, 277348352, ...
+0226 919076864]';
+0227 DIRECT(1:MAXDIM,12)=[
+0228 1073479680, 71565312, 2359296, 891551744, 158597120, ...
+0229 383516672, 1019478016, 947126272, 621019136, 714866688, ...
+0230 738459648, 265027584, 468975616, 131858432, 504627200, ...
+0231 581173248, 266600448, 865861632, 658243584, 546045952, ...
+0232 521404416, 304873472, 1060896768, 163840000, 305922048, ...
+0233 257163264, 50069504, 773062656, 59506688, 779354112, ...
+0234 165937152, 587988992, 486801408, 160694272, 90439680, ...
+0235 423362560, 536608768, 614203392, 56885248, 999030784, ...
+0236 10747904, 764674048, 25952256, 989069312, 352583680, ...
+0237 799801344, 261357568, 873201664, 40108032, 769392640, ...
+0238 254541824]';
+0239 DIRECT(1:MAXDIM,13)=[
+0240 1073610752, 644218880, 538836992, 455475200, 1062600704, ...
+0241 139329536, 205651968, 905052160, 797048832, 452329472, ...
+0242 973471744, 627703808, 614072320, 803078144, 637403136, ...
+0243 835059712, 949878784, 662044672, 767950848, 426901504, ...
+0244 448659456, 23986176, 1016201216, 524943360, 525991936, ...
+0245 618790912, 781058048, 761659392, 458096640, 226361344, ...
+0246 950665216, 952500224, 516030464, 337510400, 496107520, ...
+0247 830865408, 944111616, 636354560, 978452480, 921567232, ...
+0248 533594112, 7471104, 678035456, 471203840, 1065746432, ...
+0249 575275008, 996540416, 909246464, 879362048, 637927424, ...
+0250 25821184]';
+0251 DIRECT(1:MAXDIM,14)=[
+0252 1073676288, 357892096, 808648704, 2424832, 2555904, ...
+0253 624230400, 69271552, 456851456, 1052966912, 600637440, ...
+0254 487260160, 794624000, 386727936, 467599360, 798031872, ...
+0255 630652928, 340983808, 493944832, 37945344, 264175616, ...
+0256 263520256, 833421312, 235077632, 464846848, 534839296, ...
+0257 992411648, 10813440, 367067136, 116457472, 115015680, ...
+0258 928710656, 619773952, 813760512, 1043398656, 967770112, ...
+0259 912850944, 72155136, 1009057792, 668532736, 462356480, ...
+0260 267321344, 795803648, 635764736, 574160896, 1003421696, ...
+0261 181075968, 56688640, 388562944, 190906368, 657915904, ...
+0262 474939392]';
+0263 DIRECT(1:MAXDIM,15)=[
+0264 1073709056, 1073709056, 137003008, 547782656, 545095680, ...
+0265 26836992, 34701312, 354385920, 925663232, 656965632, ...
+0266 327581696, 894795776, 110067712, 1038057472, 209354752, ...
+0267 596541440, 42631168, 471433216, 52527104, 666861568, ...
+0268 706707456, 674070528, 824410112, 305496064, 136282112, ...
+0269 847740928, 531464192, 222920704, 379289600, 507740160, ...
+0270 11894784, 1053392896, 129990656, 557547520, 666468352, ...
+0271 1061912576, 576684032, 1041334272, 380469248, 114196480, ...
+0272 133070848, 517046272, 129990656, 790396928, 563773440, ...
+0273 388333568, 661749760, 446791680, 737378304, 229998592, ...
+0274 348225536]';
+0275 DIRECT(1:MAXDIM,16)=[
+0276 1073725440, 16384, 605372416, 275234816, 817971200, ...
+0277 603963392, 555335680, 721534976, 997801984, 1028767744, ...
+0278 407060480, 375275520, 256688128, 1021165568, 303349760, ...
+0279 1022476288, 234143744, 106708992, 732971008, 733954048, ...
+0280 789889024, 879575040, 764657664, 762658816, 1010843648, ...
+0281 941080576, 827932672, 98942976, 1051738112, 624934912, ...
+0282 993280000, 134070272, 201375744, 567558144, 882163712, ...
+0283 649084928, 356564992, 489439232, 637091840, 60637184, ...
+0284 199278592, 815677440, 927678464, 94519296, 419184640, ...
+0285 933838848, 426655744, 911130624, 171393024, 561332224, ...
+0286 471613440]';
+0287 DIRECT(1:MAXDIM,17)=[
+0288 1073733632, 536895488, 1043685376, 679944192, 417505280, ...
+0289 301981696, 832561152, 210542592, 167501824, 1071341568, ...
+0290 229302272, 970661888, 732176384, 576659456, 402464768, ...
+0291 451584000, 368467968, 928260096, 933847040, 29319168, ...
+0292 582934528, 772612096, 330014720, 647323648, 174071808, ...
+0293 1008689152, 295919616, 353869824, 177774592, 580198400, ...
+0294 381837312, 638574592, 637558784, 679370752, 504012800, ...
+0295 747118592, 429973504, 1032609792, 932667392, 583360512, ...
+0296 969498624, 1056333824, 660955136, 247488512, 153509888, ...
+0297 242180096, 205840384, 797499392, 824565760, 234348544, ...
+0298 842326016]';
+0299 DIRECT(1:MAXDIM,18)=[
+0300 1073737728, 268455936, 52785152, 1020628992, 345018368, ...
+0301 452972544, 704442368, 255987712, 750759936, 697692160, ...
+0302 196677632, 764604416, 485625856, 522022912, 680620032, ...
+0303 362270720, 838103040, 83972096, 629133312, 46108672, ...
+0304 867561472, 725422080, 184504320, 751112192, 191918080, ...
+0305 306425856, 507310080, 30453760, 281858048, 604000256, ...
+0306 208662528, 319557632, 318779392, 476139520, 863719424, ...
+0307 567062528, 521179136, 712790016, 610299904, 293687296, ...
+0308 1023086592, 549089280, 1065242624, 707751936, 363024384, ...
+0309 16674816, 197136384, 1037561856, 195112960, 372707328, ...
+0310 992751616]';
+0311 DIRECT(1:MAXDIM,19)=[
+0312 1073739776, 939554816, 580732928, 854333440, 172619776, ...
+0313 511694848, 936142848, 518199296, 593348608, 225527808, ...
+0314 900982784, 180279296, 168904704, 62814208, 754485248, ...
+0315 730691584, 1005996032, 411174912, 249866240, 641669120, ...
+0316 1008719872, 749066240, 860993536, 94177280, 432564224, ...
+0317 226355200, 925784064, 995657728, 967731200, 436226048, ...
+0318 913799168, 549894144, 964696064, 843315200, 445863936, ...
+0319 1047422976, 548947968, 492066816, 953870336, 1002653696, ...
+0320 861440000, 385636352, 325253120, 187353088, 653584384, ...
+0321 1008269312, 748693504, 1013016576, 55814144, 255170560, ...
+0322 260708352]';
+0323 DIRECT(1:MAXDIM,20)=[
+0324 1073740800, 67126272, 829514752, 423777280, 968297472, ...
+0325 205511680, 147076096, 926669824, 202300416, 118395904, ...
+0326 381332480, 1002738688, 743042048, 292551680, 584567808, ...
+0327 284339200, 183936000, 616762368, 435221504, 159376384, ...
+0328 907322368, 595696640, 247497728, 553735168, 826051584, ...
+0329 564454400, 446024704, 214236160, 33661952, 251685888, ...
+0330 660327424, 284244992, 859868160, 722502656, 622844928, ...
+0331 324342784, 682374144, 400579584, 405353472, 605187072, ...
+0332 840682496, 212956160, 157891584, 193201152, 437990400, ...
+0333 573578240, 368053248, 580197376, 937905152, 565527552, ...
+0334 89064448]';
+0335 DIRECT(1:MAXDIM,21)=[
+0336 1073741312, 637560320, 189496832, 27474432, 129338880, ...
+0337 908054016, 641870336, 186375680, 302677504, 763663872, ...
+0338 103878144, 325187072, 858254848, 922041856, 261924352, ...
+0339 954978816, 292822528, 849512960, 210311680, 933232128, ...
+0340 691981824, 155417088, 627070464, 416795136, 182081024, ...
+0341 513433088, 848658944, 515770880, 627273216, 629169664, ...
+0342 414566912, 147450368, 698353152, 244844032, 226578944, ...
+0343 1020087808, 886978048, 389697024, 1007004160, 839646720, ...
+0344 621924864, 549962240, 609583616, 735976960, 87342592, ...
+0345 1058542080, 163066368, 307997184, 876471808, 794280448, ...
+0346 675386880]';
+0347 DIRECT(1:MAXDIM,22)=[
+0348 1073741568, 352343296, 644236032, 636735232, 615860480, ...
+0349 959444224, 287380736, 1007410432, 890187008, 399480576, ...
+0350 520092928, 643311360, 816901376, 695310080, 1019229440, ...
+0351 77034240, 733295872, 1035127552, 986582784, 332381952, ...
+0352 334852352, 364956416, 596672256, 800381696, 480316672, ...
+0353 574863104, 647347968, 702910208, 499965184, 364968704, ...
+0354 120862976, 1023256320, 995114240, 13951232, 32520448, ...
+0355 702127360, 45176064, 444945664, 237860096, 152839936, ...
+0356 530633984, 429135616, 267272448, 884808960, 933712640, ...
+0357 61605632, 174335744, 564911360, 302327552, 650589440, ...
+0358 450649344]';
+0359 DIRECT(1:MAXDIM,23)=[
+0360 1073741696, 1065385856, 1073734272, 331949184, 842310784, ...
+0361 799537536, 965852032, 369351808, 662886016, 86119808, ...
+0362 865109888, 299633792, 422735488, 181087360, 174252416, ...
+0363 1041212544, 840196224, 750314368, 391053440, 903306880, ...
+0364 742365312, 236995200, 42492800, 946000512, 771692416, ...
+0365 897405824, 613803136, 924258688, 808338304, 1038125440, ...
+0366 683814272, 177186176, 766008960, 704549248, 194555008, ...
+0367 306383744, 496592512, 416020864, 655186816, 1032204928, ...
+0368 694773632, 577910144, 45797760, 910332544, 536014976, ...
+0369 675946368, 987635840, 788223872, 353993856, 96313472, ...
+0370 85248640]';
+0371 DIRECT(1:MAXDIM,24)=[
+0372 1073741760, 4210752, 12608, 744788544, 494377792, ...
+0373 115601344, 769248448, 990895808, 851706304, 979326784, ...
+0374 692061120, 429015104, 217132864, 736067008, 55694400, ...
+0375 456152640, 631601984, 787264192, 898599104, 478383808, ...
+0376 507774272, 458270272, 392995136, 872482496, 124824768, ...
+0377 1034161344, 362141632, 1053833280, 943810496, 428920128, ...
+0378 795835200, 835462848, 961843520, 606198080, 785652672, ...
+0379 154954432, 491617344, 297351232, 580735552, 634587968, ...
+0380 185277760, 141505600, 417673280, 106907456, 395575616, ...
+0381 566958656, 352651200, 415242688, 26635200, 1030317504, ...
+0382 247212992]';
+0383 DIRECT(1:MAXDIM,25)=[
+0384 1073741792, 543187040, 536882016, 981766752, 357858144, ...
+0385 810665952, 369083488, 613015520, 86115232, 845149216, ...
+0386 606076960, 1018241504, 35245536, 635403744, 236633696, ...
+0387 407451232, 427671904, 460141792, 116344544, 990246688, ...
+0388 1024892576, 883429408, 150655392, 173476896, 197666464, ...
+0389 1016740448, 605376608, 970487008, 1006881248, 598265632, ...
+0390 1022861728, 489055392, 216680608, 371439072, 53140576, ...
+0391 965114400, 98534112, 209692256, 264598496, 321437280, ...
+0392 545303840, 324119904, 876587488, 778239712, 802033120, ...
+0393 44406496, 665829024, 803213920, 309742112, 735181344, ...
+0394 1036125600]';
+0395 DIRECT(1:MAXDIM,26)=[
+0396 1073741808, 273698896, 805312112, 903123536, 153504624, ...
+0397 689632208, 432848944, 859888752, 510853776, 240805744, ...
+0398 250610192, 852489168, 139460144, 283082224, 222702928, ...
+0399 342181488, 922872432, 187528656, 360637424, 814514736, ...
+0400 301037840, 800872624, 272595184, 158627600, 238839088, ...
+0401 927181136, 710248688, 788854608, 1048376560, 484709072, ...
+0402 85709008, 1065469744, 429237328, 490778384, 848024144, ...
+0403 443114288, 687907504, 474573648, 45706416, 681465296, ...
+0404 805303216, 14567920, 369839504, 440402480, 797652624, ...
+0405 115959088, 929784560, 91226544, 205943056, 288358704, ...
+0406 950217296]';
+0407 DIRECT(1:MAXDIM,27)=[
+0408 1073741816, 947419256, 134232008, 460100200, 1073685336, ...
+0409 398354904, 1069834248, 686054696, 108299224, 273898840, ...
+0410 731382552, 938170664, 86812552, 677346808, 602208712, ...
+0411 652635752, 209797064, 323968376, 384078968, 561178056, ...
+0412 923399256, 996597176, 942777416, 885167400, 89791048, ...
+0413 956122504, 87393464, 987661336, 993412952, 827749496, ...
+0414 903211272, 33649816, 594875176, 65052056, 822835240, ...
+0415 625704888, 1065374584, 612232920, 536299720, 1046858504, ...
+0416 939518840, 160843032, 654656088, 744496936, 872197704, ...
+0417 219111576, 829112632, 455614152, 1064192952, 313010856, ...
+0418 820754920]';
+0419 DIRECT(1:MAXDIM,28)=[
+0420 1073741820, 71582788, 603989028, 37500, 120660, ...
+0421 182195932, 213921796, 473570692, 41763004, 156352828, ...
+0422 88343188, 698012780, 666108868, 337608156, 1054329884, ...
+0423 799472220, 641885244, 392104980, 502284340, 1002405628, ...
+0424 249907140, 75586228, 206587660, 565275348, 1021426548, ...
+0425 425987996, 598058580, 401940420, 919427316, 822049324, ...
+0426 115655868, 759299588, 562394644, 990942164, 1003212268, ...
+0427 598750292, 675334852, 675293340, 445665316, 903023756, ...
+0428 872412692, 172640916, 1051615436, 91229620, 94586692, ...
+0429 344873452, 7029156, 683421900, 434258804, 955002092, ...
+0430 436424380]';
+0431 DIRECT(1:MAXDIM,29)=[
+0432 1073741822, 644245094, 1040195102, 537039474, 537089354, ...
+0433 642656334, 73402402, 664239174, 1014620426, 500917234, ...
+0434 1042677826, 347788318, 1069154738, 373259762, 362587674, ...
+0435 239395914, 132283950, 903121466, 445210638, 968851198, ...
+0436 230153254, 935549622, 308815630, 861891286, 496995094, ...
+0437 670740382, 657311830, 573565382, 248331478, 1064650798, ...
+0438 338312798, 669059078, 1065190902, 379125622, 111897166, ...
+0439 520650422, 740300390, 1046483950, 66254898, 992513134, ...
+0440 234871606, 610553330, 450553866, 566758134, 787800806, ...
+0441 1071709866, 971732606, 528102354, 790919122, 917384366, ...
+0442 656244162]';
+0443 DIRECT(1:MAXDIM,30)=[
+0444 1073741823, 357913941, 50344755, 268538457, 805540473, ...
+0445 3487029, 3146769, 592038967, 729591963, 781578389, ...
+0446 66781679, 113956361, 331153483, 967802327, 935343371, ...
+0447 324351309, 609305915, 818137857, 131059769, 918519549, ...
+0448 827341719, 922770101, 456972047, 363883221, 1057014661, ...
+0449 900956063, 580478293, 520383687, 315470533, 227601711, ...
+0450 169598765, 909227271, 796983815, 349496709, 393974911, ...
+0451 378320037, 777004343, 927999269, 616377385, 345930959, ...
+0452 989849787, 627400495, 892675125, 260314121, 1041964063, ...
+0453 531367163, 195776757, 237309785, 949187605, 719002587, ...
+0454 495745187]';
+0455 end
+0456
+0457
+0458
+0459
+0460 if ((I<0) | (N<1) | (I>MAXNUM) | (N>MAXDIM)),
+0461 disp('LP-TAU CALL FAILED' )
+0462 disp(' PRESS <ENTER> TO EXIT LPTAU' )
+0463 pause
+0464 return
+0465 end
+0466 if ((PRVNUM+1==I) & (N<=PRVDIM)),
+0467
+0468
+0469
+0470
+0471
+0472
+0473
+0474 L=0;
+0475 POS=0;
+0476 while L<QP & POS==0,
+0477 L=L+1;
+0478 POS=bitand(bitshift(I,-(L-1)),1);
+0479 end
+0480
+0481
+0482
+0483 for J=1:N
+0484 MASKV(J)=bitxor(MASKV(J),DIRECT(J,L));
+0485 VECTOR(J)=MASKV(J)*SCALE;
+0486 end
+0487 else
+0488
+0489
+0490
+0491 MASKV=zeros(1,N);
+0492 IM=bitxor(I,bitshift(I,-1));
+0493 M=0;
+0494 while IM~=0 & M<QP,
+0495 M=M+1;
+0496 if (bitand(IM,1)==1),
+0497 for J=1:N
+0498 MASKV(J)=bitxor(MASKV(J),DIRECT(J,M));
+0499 end
+0500 end
+0501 IM=bitshift(IM,-1);
+0502 end
+0503 for J=1:N
+0504 VECTOR(J)=MASKV(J)*SCALE;
+0505 end
+0506 end
+0507
+0508 PRVNUM=I;
+0509 PRVDIM=N;
+0510 return
+0511
+0512
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/MakeAllFigures.html b/matlab/doc/MakeAllFigures.html
new file mode 100644
index 000000000..6d95bf2dc
--- /dev/null
+++ b/matlab/doc/MakeAllFigures.html
@@ -0,0 +1,198 @@
+
+
+
+ Description of MakeAllFigures
+
+
+
+
+
+
+
+
+
+Home >
. > MakeAllFigures.m
+
+
+
+MakeAllFigures
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [02-04-2005]
+
+ SYNOPSIS
+function MakeAllFigures(NumberOfPlots,Caption,FigureProperties,Info)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function MakeAllFigures(NumberOfPlots,Caption,FigureProperties,Info)
+0002
+0003 global M_ options_
+0004
+0005 FigHandle = figure('Name' ,FigureProperties.Name);
+0006
+0007 NAMES = cell(NumberOfPlots,1);
+0008 if options_.TeX
+0009 TeXNAMES = cell(NumberOfPlots,1);
+0010 end
+0011
+0012 if NumberOfPlots == 9
+0013 nr = 3;
+0014 nc = 3;
+0015 elseif NumberOfPlots == 8
+0016 nr = 3;
+0017 nc = 3;
+0018 elseif NumberOfPlots == 7
+0019 nr = 3;
+0020 nc = 3;
+0021 elseif NumberOfPlots == 6
+0022 nr = 2;
+0023 nc = 3;
+0024 elseif NumberOfPlots == 5
+0025 nr = 3;
+0026 nc = 2;
+0027 elseif NumberOfPlots == 4
+0028 nr = 2;
+0029 nc = 2;
+0030 elseif NumberOfPlots == 3
+0031 nr = 2;
+0032 nc = 2;
+0033 elseif NumberOfPlots == 2
+0034 nr = 1;
+0035 nc = 2;
+0036 elseif NumberOfPlots == 1
+0037 nr = 1;
+0038 nc = 1;
+0039 end
+0040
+0041 for plt = 1:NumberOfPlots
+0042 eval(['NumberOfCurves = Info.Box' int2str(plt) '.Number;' ])
+0043 NumberOfObservations = zeros(2,1);
+0044 x = cell(NumberOfCurves,1);
+0045 y = cell(NumberOfCurves,1);
+0046 PltType = cell(NumberofCurves,1);
+0047 top = NaN(NumberOfCurves,1);
+0048 bottom = NaN(NumberOfCurves,1);
+0049 binf = NaN(NumberOfCurves,1);
+0050 bsup = NaN(NumberOfCurves,1);
+0051 for curve = 1:NumberOfCurves
+0052 eval(['x{' curve '} = Info.Box' int2str(plt) '.Curve' int2str(curve) '.xdata;' ])
+0053 eval(['y{' curve '} = Info.Box' int2str(plt) '.Curve' int2str(curve) '.ydata;' ])
+0054 eval(['name = Info.Box' int2str(plt) '.Curve' int2str(curve) '.variablename;' ])
+0055 eval(['PltType{' curve '} = Info.Box' int2str(plt) '.Curve' int2str(curve) '.type' ]);
+0056 if length(x{curve})-length(y{curve})
+0057 disp('MakeFigure :: The number of observations in x doesn''t match with ' )
+0058 disp(['the number of observation in y for ' name ])
+0059 return
+0060 end
+0061 if Info.PlotProperties.CutTop
+0062 top(curve) = max(y{curve});
+0063 else Info.PlotProperties.CutBottom
+0064 bottom(curve) = min(y{curve});
+0065 end
+0066 binf(curve) = min(x{curve});
+0067 bsup(curve) = max(x{curve});
+0068 end
+0069 ymax = max(top);
+0070 ymin = min(bottom);
+0071 xmin = min(binf);
+0072 xmax = max(bsup);
+0073 if isnan(ymin(plt))
+0074 ymin = 0;
+0075 end
+0076 eval(['NAMES{' int2str(plt) '} = Info.Box' int2str(plt) '.name;' ])
+0077 if options_.TeX
+0078 eval(['TeXNAMES{' int2str(plt) '} = Info.Box' int2str(plt) '.texname;' ])
+0079 end
+0080 subplot(nr,nc,plt)
+0081 hold on
+0082 for curve = 1:NumberOfCurves
+0083 hh = plot(x{curve},y{curve});
+0084 if strcmpi(PltType{curve},'PriorDensity' )
+0085 set(hh,'Color' ,[0.7 0.7 0.7],'LineStyle' ,'-' ,'LineWidth' ,2)
+0086
+0087
+0088 elseif strcmpi(PltType{curve},'DensityEstimate' )
+0089 set(hh,'Color' ,'k' ,'LineStyle' ,'-' ,'LineWidth' ,2)
+0090
+0091
+0092 elseif strcmpi(PltType{curve},'ModeEstimate' )
+0093 set(hh,'Color' ,'g' ,'LineStyle' ,'--' ,'LineWidth' ,2)
+0094
+0095
+0096 elseif strcmpi(PltType{curve},'SmoothVariable' )
+0097 set(hh,'Color' ,'k' ,'LineStyle' ,'-' ,'LineWidth' ,2)
+0098
+0099
+0100 elseif strcmpi(PltType{curve},'Deciles' )
+0101 set(hh,'Color' ,'g' ,'LineStyle' ,'-' ,'LineWidth' ,1)
+0102
+0103
+0104 elseif strcmpi(PltType{curve},'Forecasts' )
+0105 set(hh,'Color' ,'' ,'LineStyle' ,'-' ,'LineWidth' ,2)
+0106
+0107
+0108 elseif strcmpi(PltType{curve},'ForecastsHPD' )
+0109 set(hh,'Color' ,'k' ,'LineStyle' ,'-' ,'LineWidth' ,1)
+0110
+0111
+0112 elseif strcmpi(PltType{curve},'ForecastsDeciles' )
+0113 set(hh,'Color' ,'g' ,'LineStyle' ,'-' ,'LineWidth' ,1)
+0114
+0115
+0116 elseif strcmpi(PltType{curve},'DiagnosticWithin' )
+0117 set(hh,'Color' ,'b' ,'LineStyle' ,'-' ,'LineWidth' ,2)
+0118
+0119
+0120 elseif strcmpi(PltType{curve},'DiagnosticPooled' )
+0121 set(hh,'Color' ,'r' ,'LineStyle' ,'-' ,'LineWidth' ,2)
+0122
+0123
+0124 end
+0125 end
+0126 axis([xmin xmax ymin ymax])
+0127 title(NAMES{plt})
+0128 drawnow
+0129 hold off
+0130 end
+0131
+0132 if Info.SaveFormat.Eps
+0133 if isempty(Info.SaveFormat.Name)
+0134 eval(['print -depsc2 ' M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number)]);
+0135 else
+0136 eval(['print -depsc2 ' M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name]);
+0137 end
+0138 end
+0139 if Info.SaveFormat.Pdf
+0140 if isempty(Info.SaveFormat.Name)
+0141 eval(['print -dpdf ' M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number)]);
+0142 else
+0143 eval(['print -dpdf ' M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name]);
+0144 end
+0145 end
+0146 if Info.SaveFormat.Fig
+0147 if isempty(Info.SaveFormat.Name)
+0148 saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number) '.fig' ]);
+0149 else
+0150 saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name '.fig' ]);
+0151 end
+0152 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/McMCDiagnostics.html b/matlab/doc/McMCDiagnostics.html
new file mode 100644
index 000000000..3c37500c9
--- /dev/null
+++ b/matlab/doc/McMCDiagnostics.html
@@ -0,0 +1,399 @@
+
+
+
+ Description of McMCDiagnostics
+
+
+
+
+
+
+
+
+
+Home >
. > McMCDiagnostics.m
+
+
+
+McMCDiagnostics
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [06-04-2005]
+
+ SYNOPSIS
+function McmcDiagnostic
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function McmcDiagnostic
+0002
+0003
+0004 global options_ estim_params_ M_
+0005
+0006 DirectoryName = CheckPath ('Output' );
+0007 MhDirectoryName = CheckPath ('metropolis' );
+0008
+0009 TeX = options_.TeX;
+0010 nblck = options_.mh_nblck;
+0011
+0012 if nblck == 1
+0013 return ;
+0014 end
+0015 npar = estim_params_.nvx;
+0016 npar = npar + estim_params_.nvn;
+0017 npar = npar + estim_params_.ncx;
+0018 npar = npar + estim_params_.ncn;
+0019 npar = npar + estim_params_.np ;
+0020 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
+0021
+0022 load([MhDirectoryName '/' M_.fname '_mh_history.mat' ])
+0023
+0024 mcfiles = [];
+0025 for blck = 1:nblck
+0026 mcfiles = cat(3,mcfiles,dir([MhDirectoryName '/' M_.fname '_mh*_blck' int2str(blck) '.mat' ]));
+0027 end
+0028 NumberOfMcFilesPerBlock = size(mcfiles,1);
+0029
+0030
+0031 PastDraws = sum(record.MhDraws,1);
+0032 LastFileNumber = PastDraws(2);
+0033 LastLineNumber = record.MhDraws(end ,3);
+0034 NumberOfDraws = PastDraws(1);
+0035
+0036 Origin = 1000;
+0037 StepSize = ceil((NumberOfDraws-Origin)/100);
+0038 ALPHA = 0.2;
+0039 time = 1:NumberOfDraws;
+0040 xx = Origin:StepSize:NumberOfDraws;
+0041 NumberOfLines = length(xx);
+0042 tmp = zeros(NumberOfDraws*nblck,3);
+0043 UDIAG = zeros(NumberOfLines,6,npar);
+0044
+0045 if NumberOfDraws < Origin
+0046 disp('MCMC Diagnostics :: The number of simulations is to small to compute the MCMC convergence diagnostics.' )
+0047 return
+0048 end
+0049
+0050 if TeX
+0051 fidTeX = fopen([DirectoryName '/' M_.fname '_UnivariateDiagnostics.TeX' ],'w' );
+0052 fprintf(fidTeX,'%% TeX eps-loader file generated by McmcDiagnostics.m (Dynare).\n' );
+0053 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0054 fprintf(fidTeX,' \n' );
+0055 end
+0056
+0057
+0058 disp('MCMC Diagnostics: Univariate convergence diagnostic, Brooks and Gelman (1998):' )
+0059 for j=1:npar
+0060 fprintf(' Parameter %d... ' ,j);
+0061 for b = 1:nblck
+0062 startline = 0;
+0063 for n = 1:NumberOfMcFilesPerBlock-1
+0064
+0065 load([MhDirectoryName '/' M_.fname '_mh' ,int2str(n),'_blck' int2str(b) '.mat' ],'x2' );
+0066 tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+MAX_nruns*n,1) = x2(:,j);
+0067 clear x2;
+0068 startline = startline + MAX_nruns;
+0069 end
+0070
+0071 load([MhDirectoryName '/' M_.fname '_mh' ,int2str(NumberOfMcFilesPerBlock),'_blck' int2str(b) '.mat' ],'x2' );
+0072 tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+MAX_nruns*(LastFileNumber-1)+LastLineNumber,1) = x2(:,j);
+0073 clear x2;
+0074 startline = startline + LastLineNumber;
+0075 end
+0076 tmp(:,2) = kron(transpose(1:nblck),ones(NumberOfDraws,1));
+0077 tmp(:,3) = kron(ones(nblck,1),time');
+0078 tmp = sortrows(tmp,1);
+0079 ligne = 0;
+0080 for iter = Origin:StepSize:NumberOfDraws
+0081 ligne = ligne+1;
+0082 linea = ceil(0.5*iter);
+0083 n = iter-linea+1;
+0084 cinf = round(n*ALPHA/2);
+0085 csup = round(n*(1-ALPHA/2));
+0086 CINF = round(nblck*n*ALPHA/2);
+0087 CSUP = round(nblck*n*(1-ALPHA/2));
+0088 temp = tmp(find((tmp(:,3)>=linea) & (tmp(:,3)<=iter)),1:2);
+0089 UDIAG(ligne,1,j) = temp(CSUP,1)-temp(CINF,1);
+0090 moyenne = mean(temp(:,1));
+0091 UDIAG(ligne,3,j) = sum((temp(:,1)-moyenne).^2)/(nblck*n-1);
+0092 UDIAG(ligne,5,j) = sum(abs(temp(:,1)-moyenne).^3)/(nblck*n-1);
+0093 for i=1:nblck
+0094 pmet = temp(find(temp(:,2)==i));
+0095 UDIAG(ligne,2,j) = UDIAG(ligne,2,j) + pmet(csup,1)-pmet(cinf,1);
+0096 moyenne = mean(pmet,1);
+0097 UDIAG(ligne,4,j) = UDIAG(ligne,4,j) + sum((pmet(:,1)-moyenne).^2)/(n-1);
+0098 UDIAG(ligne,6,j) = UDIAG(ligne,6,j) + sum(abs(pmet(:,1)-moyenne).^3)/(n-1);
+0099 end
+0100 end
+0101 fprintf('Done! \n' );
+0102 end
+0103 UDIAG(:,[2 4 6],:) = UDIAG(:,[2 4 6],:)/nblck;
+0104 disp(' ' )
+0105 clear pmet temp moyenne CSUP CINF csup cinf n linea iter tmp;
+0106 pages = floor(npar/3);
+0107 k = 0;
+0108 for i = 1:pages
+0109 if options_.nograph
+0110 h = figure('Name' ,'MCMC univariate diagnostic (Brooks and Gelman,1998)' ,'Visible' ,'off' );
+0111 else
+0112 h = figure('Name' ,'MCMC univariate diagnostic (Brooks and Gelman,1998)' );
+0113 end
+0114 boxplot = 1;
+0115 if TeX
+0116 NAMES = [];
+0117 TEXNAMES = [];
+0118 end
+0119 for j = 1:3
+0120 k = k+1;
+0121 [nam,namtex] = get_the_name (k,TeX);
+0122 for crit = 1:3
+0123 if crit == 1
+0124 plt1 = UDIAG(:,1,k);
+0125 plt2 = UDIAG(:,2,k);
+0126 namnam = [nam , ' (Interval)' ];
+0127 elseif crit == 2
+0128 plt1 = UDIAG(:,3,k);
+0129 plt2 = UDIAG(:,4,k);
+0130 namnam = [nam , ' (m2)' ];
+0131 elseif crit == 3
+0132 plt1 = UDIAG(:,5,k);
+0133 plt2 = UDIAG(:,6,k);
+0134 namnam = [nam , ' (m3)' ];
+0135 end
+0136 if TeX
+0137 NAMES = strvcat(NAMES,deblank(namnam));
+0138 TEXNAMES = strvcat(TEXNAMES,deblank(namtex));
+0139 end
+0140 subplot(3,3,boxplot);
+0141 plot(xx,plt1,'-b' );
+0142 hold on;
+0143 plot(xx,plt2,'-r' );
+0144 hold off;
+0145 xlim([xx(1) xx(NumberOfLines)])
+0146 title(namnam,'Interpreter' ,'none' )
+0147 boxplot = boxplot + 1;
+0148 end
+0149 end
+0150 eval(['print -depsc2 ' DirectoryName '/' M_.fname '_udiag' int2str(i)]);
+0151 eval(['print -dpdf ' DirectoryName '/' M_.fname '_udiag' int2str(i)]);
+0152 if options_.nograph, set(h,'visible' ,'on' ), end
+0153 saveas(h,[DirectoryName '/' M_.fname '_udiag' int2str(i) '.fig' ]);
+0154 if options_.nograph, close(h), end
+0155 if TeX
+0156 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0157 for jj = 1:size(NAMES,1)
+0158 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
+0159 end
+0160 fprintf(fidTeX,'\\centering \n' );
+0161 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_udiag%s}\n' ,M_.fname,int2str(i));
+0162 fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n' );
+0163 fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n' );
+0164 fprintf(fidTeX,'the eighty percent interval, the second and third moments.}' );
+0165 fprintf(fidTeX,'\\label{Fig:UnivariateDiagnostics:%s}\n' ,int2str(i));
+0166 fprintf(fidTeX,'\\end{figure}\n' );
+0167 fprintf(fidTeX,'\n' );
+0168 end
+0169 end
+0170 reste = npar-k;
+0171 if reste
+0172 if reste == 1
+0173 nr = 3;
+0174 nc = 1;
+0175 elseif reste == 2;
+0176 nr = 2;
+0177 nc = 3;
+0178 end
+0179 if TeX
+0180 NAMES = [];
+0181 TEXNAMES = [];
+0182 end
+0183 if options_.nograph
+0184 h = figure('Name' ,'MCMC univariate diagnostic (Brooks and Gelman, 1998)' ,'Visible' ,'off' );
+0185 else
+0186 h = figure('Name' ,'MCMC univariate diagnostic (Brooks and Gelman, 1998)' );
+0187 end
+0188 boxplot = 1;
+0189 for j = 1:reste
+0190 k = k+1;
+0191 [nam,namtex] = get_the_name (k,TeX);
+0192 for crit = 1:3
+0193 if crit == 1
+0194 plt1 = UDIAG(:,1,k);
+0195 plt2 = UDIAG(:,2,k);
+0196 namnam = [nam , ' (Interval)' ];
+0197 elseif crit == 2
+0198 plt1 = UDIAG(:,3,k);
+0199 plt2 = UDIAG(:,4,k);
+0200 namnam = [nam , ' (m2)' ];
+0201 elseif crit == 3
+0202 plt1 = UDIAG(:,5,k);
+0203 plt2 = UDIAG(:,6,k);
+0204 namnam = [nam , ' (m3)' ];
+0205 end
+0206 if TeX
+0207 NAMES = strvcat(NAMES,deblank(namnam));
+0208 TEXNAMES = strvcat(TEXNAMES,deblank(namtex));
+0209 end
+0210 subplot(nr,nc,boxplot);
+0211 plot(xx,plt1,'-b' );
+0212 hold on;
+0213 plot(xx,plt2,'-r' );
+0214 hold off;
+0215 xlim([xx(1) xx(NumberOfLines)]);
+0216 title(namnam,'Interpreter' ,'none' );
+0217 boxplot = boxplot + 1;
+0218 end
+0219 end
+0220 eval(['print -depsc2 ' DirectoryName '/' M_.fname '_udiag' int2str(pages+1)]);
+0221 eval(['print -dpdf ' DirectoryName '/' M_.fname '_udiag' int2str(pages+1)]);
+0222 if options_.nograph, set(h,'visible' ,'on' ), end
+0223 saveas(h,[DirectoryName '/' M_.fname '_udiag' int2str(pages+1) '.fig' ]);
+0224 if options_.nograph, close(h), end
+0225 if TeX
+0226 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0227 for jj = 1:size(NAMES,1);
+0228 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
+0229 end
+0230 fprintf(fidTeX,'\\centering \n' );
+0231 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_udiag%s}\n' ,M_.fname,int2str(pages+1));
+0232 if reste == 2
+0233 fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n' );
+0234 fprintf(fidTeX,'The first, second and third columns are respectively the criteria based on\n' );
+0235 fprintf(fidTeX,'the eighty percent interval, the second and third moments.}' );
+0236 elseif reste == 1
+0237 fprintf(fidTeX,'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n' );
+0238 fprintf(fidTeX,'The first, second and third rows are respectively the criteria based on\n' );
+0239 fprintf(fidTeX,'the eighty percent interval, the second and third moments.}' );
+0240 end
+0241 fprintf(fidTeX,'\\label{Fig:UnivariateDiagnostics:%s}\n' ,int2str(pages+1));
+0242 fprintf(fidTeX,'\\end{figure}\n' );
+0243 fprintf(fidTeX,'\n' );
+0244 fprintf(fidTeX,'% End Of TeX file.' );
+0245 fclose(fidTeX);
+0246 end
+0247 end
+0248 clear UDIAG;
+0249
+0250
+0251
+0252 if TeX
+0253 fidTeX = fopen([DirectoryName '/' M_.fname '_MultivariateDiagnostics.TeX' ],'w' );
+0254 fprintf(fidTeX,'%% TeX eps-loader file generated by McmcDiagnostics.m (Dynare).\n' );
+0255 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0256 fprintf(fidTeX,' \n' );
+0257 NAMES = [];
+0258 end
+0259 tmp = zeros(NumberOfDraws*nblck,3);
+0260 MDIAG = zeros(NumberOfLines,6);
+0261 for b = 1:nblck
+0262 startline = 0;
+0263 for n = 1:NumberOfMcFilesPerBlock-1
+0264
+0265 load([MhDirectoryName '/' M_.fname '_mh' ,int2str(n),'_blck' int2str(b) '.mat' ],'logpo2' );
+0266 tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+MAX_nruns*n,1) = logpo2;
+0267 startline = startline+MAX_nruns;
+0268 end
+0269
+0270 load([MhDirectoryName '/' M_.fname '_mh' ,int2str(NumberOfMcFilesPerBlock),'_blck' int2str(b) '.mat' ],'logpo2' );
+0271 tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+ MAX_nruns*(LastFileNumber-1)+LastLineNumber,1) = logpo2;
+0272 end
+0273 clear logpo2;
+0274 tmp(:,2) = kron(transpose(1:nblck),ones(NumberOfDraws,1));
+0275 tmp(:,3) = kron(ones(nblck,1),time');
+0276 tmp = sortrows(tmp,1);
+0277 ligne = 0;
+0278 for iter = Origin:StepSize:NumberOfDraws
+0279 ligne = ligne+1;
+0280 linea = ceil(0.5*iter);
+0281 n = iter-linea+1;
+0282 cinf = round(n*ALPHA/2);
+0283 csup = round(n*(1-ALPHA/2));
+0284 CINF = round(nblck*n*ALPHA/2);
+0285 CSUP = round(nblck*n*(1-ALPHA/2));
+0286 temp = tmp(find((tmp(:,3)>=linea) & (tmp(:,3)<=iter)),1:2);
+0287 MDIAG(ligne,1) = temp(CSUP,1)-temp(CINF,1);
+0288 moyenne = mean(temp(:,1));
+0289 MDIAG(ligne,3) = sum((temp(:,1)-moyenne).^2)/(nblck*n-1);
+0290 MDIAG(ligne,5) = sum(abs(temp(:,1)-moyenne).^3)/(nblck*n-1);
+0291 for i=1:nblck
+0292 pmet = temp(find(temp(:,2)==i));
+0293 MDIAG(ligne,2) = MDIAG(ligne,2) + pmet(csup,1)-pmet(cinf,1);
+0294 moyenne = mean(pmet,1);
+0295 MDIAG(ligne,4) = MDIAG(ligne,4) + sum((pmet(:,1)-moyenne).^2)/(n-1);
+0296 MDIAG(ligne,6) = MDIAG(ligne,6) + sum(abs(pmet(:,1)-moyenne).^3)/(n-1);
+0297 end
+0298 end
+0299 MDIAG(:,[2 4 6],:) = MDIAG(:,[2 4 6],:)/nblck;
+0300 if options_.nograph
+0301 h = figure('Name' ,'Multivatiate diagnostic' ,'Visible' ,'off' );
+0302 else
+0303 h = figure('Name' ,'Multivatiate diagnostic' );
+0304 end
+0305 boxplot = 1;
+0306 for crit = 1:3
+0307 if crit == 1
+0308 plt1 = MDIAG(:,1);
+0309 plt2 = MDIAG(:,2);
+0310 namnam = 'Interval' ;
+0311 elseif crit == 2
+0312 plt1 = MDIAG(:,3);
+0313 plt2 = MDIAG(:,4);
+0314 namnam = 'm2' ;
+0315 elseif crit == 3
+0316 plt1 = MDIAG(:,5);
+0317 plt2 = MDIAG(:,6);
+0318 namnam = 'm3' ;
+0319 end
+0320 if TeX
+0321 NAMES = strvcat(NAMES,namnam);
+0322 end
+0323 subplot(3,1,boxplot);
+0324 plot(xx,plt1,'-b' );
+0325 hold on
+0326 plot(xx,plt2,'-r' );
+0327 hold off
+0328 xlim([xx(1) xx(NumberOfLines)])
+0329 title(namnam,'Interpreter' ,'none' );
+0330 boxplot = boxplot + 1;
+0331 end
+0332 eval(['print -depsc2 ' DirectoryName '/' M_.fname '_mdiag' ]);
+0333 eval(['print -dpdf ' DirectoryName '/' M_.fname '_mdiag' ]);
+0334 if options_.nograph, set(h,'visible' ,'on' ), end
+0335 saveas(h,[DirectoryName '/' M_.fname '_mdiag.fig' ]);
+0336 if options_.nograph, close(h), end
+0337 if TeX
+0338 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0339 for jj = 1:3
+0340 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),' ' );
+0341 end
+0342 fprintf(fidTeX,'\\centering \n' );
+0343 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_mdiag}\n' ,M_.fname);
+0344 fprintf(fidTeX,'\\caption{Multivariate convergence diagnostics for the Metropolis-Hastings.\n' );
+0345 fprintf(fidTeX,'The first, second and third rows are respectively the criteria based on\n' );
+0346 fprintf(fidTeX,'the eighty percent interval, the second and third moments. The different \n' );
+0347 fprintf(fidTeX,'parameters are aggregated using the posterior kernel.}' );
+0348 fprintf(fidTeX,'\\label{Fig:MultivariateDiagnostics}\n' );
+0349 fprintf(fidTeX,'\\end{figure}\n' );
+0350 fprintf(fidTeX,'\n' );
+0351 fprintf(fidTeX,'% End Of TeX file.' );
+0352 fclose(fidTeX);
+0353 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/PlotPosteriorDistributions.html b/matlab/doc/PlotPosteriorDistributions.html
new file mode 100644
index 000000000..87b901b93
--- /dev/null
+++ b/matlab/doc/PlotPosteriorDistributions.html
@@ -0,0 +1,178 @@
+
+
+
+ Description of PlotPosteriorDistributions
+
+
+
+
+
+
+
+
+
+Home >
. > PlotPosteriorDistributions.m
+
+
+
+PlotPosteriorDistributions
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-09-2005]
+
+ SYNOPSIS
+function PlotPosteriorDistributions()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function PlotPosteriorDistributions()
+0002
+0003 global estim_params_ M_ options_ bayestopt_ oo_
+0004
+0005 OutputDirectoryName = CheckPath ('Output' );
+0006
+0007 TeX = options_.TeX;
+0008 nblck = options_.mh_nblck;
+0009 nvx = estim_params_.nvx;
+0010 nvn = estim_params_.nvn;
+0011 ncx = estim_params_.ncx;
+0012 ncn = estim_params_.ncn;
+0013 np = estim_params_.np ;
+0014 npar = nvx+nvn+ncx+ncn+np;
+0015
+0016 MaxNumberOfPlotPerFigure = 9;
+0017 nn = sqrt(MaxNumberOfPlotPerFigure);
+0018
+0019 figurename = 'Priors and posteriors' ;
+0020
+0021 if TeX
+0022 fidTeX = fopen([OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors.TeX' ],'w' );
+0023 fprintf(fidTeX,'%% TeX eps-loader file generated by PlotPosteriorDistributions.m (Dynare).\n' );
+0024 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0025 fprintf(fidTeX,' \n' );
+0026 end
+0027
+0028 figunumber = 0;
+0029 subplotnum = 0;
+0030
+0031 for i=1:npar
+0032 subplotnum = subplotnum+1;
+0033 if subplotnum == 1
+0034 figunumber = figunumber+1;
+0035 if options_.nograph
+0036 hfig = figure('Name' ,figurename,'Visible' ,'off' );
+0037 else
+0038 hfig = figure('Name' ,figurename);
+0039 end
+0040 end
+0041 if subplotnum == 1
+0042 if TeX
+0043 TeXNAMES = [];
+0044 end
+0045 NAMES = [];
+0046 end
+0047 [nam,texnam] = get_the_name (i,TeX);
+0048 NAMES = strvcat(NAMES,nam);
+0049 if TeX
+0050 TeXNAMES = strvcat(TeXNAMES,texnam);
+0051 end
+0052 [x2,f2,abscissa,dens,binf2,bsup2] = draw_prior_density (i);
+0053 top2 = max(f2);
+0054 if i <= nvx
+0055 name = deblank(M_.exo_names(estim_params_.var_exo(i,1),:));
+0056 eval(['x1 = oo_.posterior_density.shocks_std.' name '(:,1);' ])
+0057 eval(['f1 = oo_.posterior_density.shocks_std.' name '(:,2);' ])
+0058 eval(['pmode = oo_.posterior_mode.shocks_std.' name ';' ])
+0059 elseif i <= nvx+nvn
+0060 name = deblank(options_.varobs(estim_params_.var_endo(i-nvx,1),:));
+0061 eval(['x1 = oo_.posterior_density.measurement_errors_std.' name '(:,1);' ])
+0062 eval(['f1 = oo_.posterior_density.measurement_errors_std.' name '(:,2);' ])
+0063 eval(['pmode = oo_.posterior_mode.measurement_errors_std.' name ';' ])
+0064 elseif i <= nvx+nvn+ncx
+0065 j = i - (nvx+nvn)
+0066 k1 = estim_params_.corrx(j,1);
+0067 k2 = estim_params_.corrx(j,2);
+0068 name = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
+0069 eval(['x1 = oo_.posterior_density.shocks_corr.' name '(:,1);' ])
+0070 eval(['f1 = oo_.posterior_density.shocks_corr.' name '(:,2);' ])
+0071 eval(['pmode = oo_.posterior_mode.shocks_corr.' name ';' ])
+0072 elseif i <= nvx+nvn+ncx+ncn
+0073 j = i - (nvx+nvn+ncx);
+0074 k1 = estim_params_.corrn(j,1);
+0075 k2 = estim_params_.corrn(j,2);
+0076 name = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
+0077 eval(['x1 = oo_.posterior_density.measurement_errors_corr.' name '(:,1);' ])
+0078 eval(['f1 = oo_.posterior_density.measurement_errors_corr.' name '(:,2);' ])
+0079 eval(['pmode = oo_.posterior_mode.measurement_errors_corr.' name ';' ])
+0080 else
+0081 j = i - (nvx+nvn+ncx+ncn);
+0082 name = deblank(M_.param_names(estim_params_.param_vals(j,1),:));
+0083 eval(['x1 = oo_.posterior_density.' name '(:,1);' ])
+0084 eval(['f1 = oo_.posterior_density.' name '(:,2);' ])
+0085 eval(['pmode = oo_.posterior_mode.parameters.' name ';' ])
+0086 end
+0087 top1 = max(f1);
+0088 top0 = max([top1;top2]);
+0089 binf1 = x1(1);
+0090 bsup1 = x1(end);
+0091 borneinf = min(binf1,binf2);
+0092 bornesup = max(bsup1,bsup2);
+0093 subplot(nn,nn,subplotnum)
+0094 hh = plot(x2,f2,'-k' ,'linewidth' ,2);
+0095 set(hh,'color' ,[0.7 0.7 0.7]);
+0096 hold on;
+0097 plot(x1,f1,'-k' ,'linewidth' ,2);
+0098 plot( [pmode pmode], [0.0 1.1*top0], '--g' , 'linewidth' , 2);
+0099 box on;
+0100 axis([borneinf bornesup 0 1.1*top0]);
+0101 title(nam,'Interpreter' ,'none' );
+0102 hold off;
+0103 drawnow
+0104 if subplotnum == MaxNumberOfPlotPerFigure | i == npar;
+0105 eval(['print -depsc2 ' OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)]);
+0106 eval(['print -dpdf ' OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber)]);
+0107 if options_.nograph,
+0108 set(hfig,'Visible' ,'on' );
+0109 end
+0110 saveas(hfig,[OutputDirectoryName '/' M_.fname '_PriorsAndPosteriors' int2str(figunumber) '.fig' ]);
+0111 if TeX
+0112 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0113 for j = 1:size(NAMES,1)
+0114 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(j,:)),deblank(TeXNAMES(j,:)));
+0115 end
+0116 fprintf(fidTeX,'\\centering\n' );
+0117 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_PriorsAndPosteriors%s}\n' ,M_.fname,int2str(figunumber));
+0118 fprintf(fidTeX,'\\caption{Priors and posteriors.}' );
+0119 fprintf(fidTeX,'\\label{Fig:PriorsAndPosteriors:%s}\n' ,int2str(figunumber));
+0120 fprintf(fidTeX,'\\end{figure}\n' );
+0121 fprintf(fidTeX,' \n' );
+0122 if i == npar
+0123 fprintf(fidTeX,'%% End of TeX file.\n' );
+0124 fclose(fidTeX);
+0125 end
+0126 end
+0127 if options_.nograph,
+0128 close(hfig),
+0129 end
+0130 subplotnum = 0;
+0131 end
+0132 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/PosteriorIRF.html b/matlab/doc/PosteriorIRF.html
new file mode 100644
index 000000000..330424589
--- /dev/null
+++ b/matlab/doc/PosteriorIRF.html
@@ -0,0 +1,288 @@
+
+
+
+ Description of PosteriorIRF
+
+
+
+
+
+
+
+
+
+Home >
. > PosteriorIRF.m
+
+
+
+PosteriorIRF
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-25-2005]
+
+ SYNOPSIS
+function PosteriorIRF(type)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function PosteriorIRF(type)
+0002
+0003 global options_ estim_params_ oo_ M_
+0004 nvx = estim_params_.nvx;
+0005 nvn = estim_params_.nvn;
+0006 ncx = estim_params_.ncx;
+0007 ncn = estim_params_.ncn;
+0008 np = estim_params_.np ;
+0009 npar = nvx+nvn+ncx+ncn+np;
+0010 offset = npar-np;
+0011
+0012 MaxNumberOfPlotPerFigure = 9;
+0013 nn = sqrt(MaxNumberOfPlotPerFigure);
+0014 DirectoryName = CheckPath ('Output' );
+0015 if strcmpi(type,'posterior' )
+0016 MhDirectoryName = CheckPath ('metropolis' );
+0017 else
+0018 MhDirectoryName = CheckPath ('prior' );
+0019 end
+0020 MAX_nirfs = ceil(options_.MaxNumberOfBytes/(options_.irf*length(oo_.steady_state)*M_.exo_nbr)/8)+50;
+0021 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
+0022
+0023 if strcmpi(type,'posterior' )
+0024 load([ MhDirectoryName '/' M_.fname '_mh_history' ])
+0025 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
+0026 NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
+0027 else
+0028 NumberOfDraws = 500;
+0029 end
+0030 B = min([round(.5*NumberOfDraws),500]); options_.B = B;
+0031 try delete([MhDirectoryName '\' M_.fname '_IRFs*' ]);
+0032 catch disp('No _IRFs files to be deleted!' )
+0033 end
+0034 irun = 0;
+0035 irun2 = 0;
+0036 NumberOfIRFfiles = 1;
+0037 ifil2 = 1;
+0038 if strcmpi(type,'posterior' )
+0039 h = waitbar(0,'Bayesian (posterior) IRFs...' );
+0040 else
+0041 h = waitbar(0,'Bayesian (prior) IRFs...' );
+0042 end
+0043 if B <= MAX_nruns
+0044 stock_param = zeros(B, npar);
+0045 else
+0046 stock_param = zeros(MAX_nruns, npar);
+0047 end
+0048 if B >= MAX_nirfs
+0049 stock_irf = zeros(options_.irf,M_.endo_nbr,M_.exo_nbr,MAX_nirfs);
+0050 else
+0051 stock_irf = zeros(options_.irf,M_.endo_nbr,M_.exo_nbr,B);
+0052 end
+0053 for b=1:B
+0054 irun = irun+1;
+0055 irun2 = irun2+1;
+0056 deep = GetOneDraw (type);
+0057 stock_param(irun2,:) = deep;
+0058 set_parameters (deep);
+0059 dr = resol (oo_.steady_state,0);
+0060 SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord) = M_.Sigma_e+1e-14*eye(M_.exo_nbr);
+0061 SS = transpose(chol(SS));
+0062 for i = 1:M_.exo_nbr
+0063 if SS(i,i) > 1e-13
+0064 y=irf (dr,SS(M_.exo_names_orig_ord,i), options_.irf, options_.drop,options_.replic,options_.order);
+0065 if options_.relative_irf
+0066 y = 100*y/cs(i,i);
+0067 end
+0068 for j = 1:M_.endo_nbr
+0069 if max(y(j,:)) - min(y(j,:)) > 1e-10
+0070 stock_irf(:,j,i,irun) = transpose(y(j,:));
+0071 end
+0072 end
+0073 end
+0074 end
+0075 if irun == MAX_nirfs | irun == B | b == B
+0076 if b == B
+0077 stock_irf = stock_irf(:,:,:,1:irun);
+0078 end
+0079 save([MhDirectoryName '/' M_.fname '_irf' int2str(NumberOfIRFfiles)],'stock_irf' );
+0080 NumberOfIRFfiles = NumberOfIRFfiles+1;
+0081 irun = 0;
+0082 end
+0083 if irun2 > MAX_nruns | b == B
+0084 if b == B
+0085 stock_param = stock_param(1:irun2,:);
+0086 end
+0087 stock = stock_param;
+0088 save([MhDirectoryName '/' M_.fname '_param_irf' int2str(ifil2)],'stock' );
+0089 ifil2 = ifil2 + 1;
+0090 irun2 = 1;
+0091 end
+0092 waitbar(b/B,h);
+0093 end
+0094 NumberOfIRFfiles = NumberOfIRFfiles-1;
+0095 ifil2 = ifil2-1;
+0096 close(h);
+0097
+0098 ReshapeMatFiles ('irf' )
+0099
+0100 varlist = options_.varlist;
+0101 if isempty(varlist)
+0102 varlist = M_.endo_names;
+0103 SelecVariables = transpose(1:M_.endo_nbr);
+0104 nvar = M_.endo_nbr;
+0105 else
+0106 nvar = size(varlist,1);
+0107 SelecVariables = [];
+0108 for i=1:nvar
+0109 if ~isempty(strmatch(varlist(i,:),M_.endo_names,'exact' ))
+0110 SelecVariables = [SelecVariables;strmatch(varlist(i,:),M_.endo_names,'exact' )];
+0111 end
+0112 end
+0113 end
+0114
+0115 MeanIRF = zeros(options_.irf,nvar,M_.exo_nbr);
+0116 MedianIRF = zeros(options_.irf,nvar,M_.exo_nbr);
+0117 StdIRF = zeros(options_.irf,nvar,M_.exo_nbr);
+0118 DistribIRF = zeros(options_.irf,9,nvar,M_.exo_nbr);
+0119 HPDIRF = zeros(options_.irf,2,nvar,M_.exo_nbr);
+0120
+0121 if options_.TeX
+0122 varlist_TeX = [];
+0123 for i=1:nvar
+0124 varlist_TeX = strvcat(varlist_TeX,M_.endo_names_tex(SelecVariables(i),:));
+0125 end
+0126 end
+0127
+0128 fprintf('MH: Posterior IRFs...\n' );
+0129 tit(M_.exo_names_orig_ord,:) = M_.exo_names;
+0130 kdx = 0;
+0131 for file = 1:NumberOfIRFfiles
+0132 load([MhDirectoryName '/' M_.fname '_IRFs' int2str(file)]);
+0133 for i = 1:M_.exo_nbr
+0134 for j = 1:nvar
+0135 for k = 1:size(STOCK_IRF,1)
+0136 kk = k+kdx;
+0137 [MeanIRF(kk,j,i),MedianIRF(kk,j,i),VarIRF(kk,j,i),HPDIRF(kk,:,j,i),DistribIRF(kk,:,j,i)] = ...
+0138 posterior_moments (squeeze(STOCK_IRF(k,SelecVariables(j),i,:)),0);
+0139 end
+0140 end
+0141 end
+0142 kdx = kdx + size(STOCK_IRF,1);
+0143 end
+0144 clear STOCK_IRF;
+0145
+0146 for i = 1:M_.exo_nbr
+0147 for j = 1:nvar
+0148 name = [deblank(M_.endo_names(SelecVariables(j),:)) '_' deblank(tit(i,:))];
+0149 eval(['oo_.PosteriorIRF.Mean.' name ' = MeanIRF(:,j,i);' ]);
+0150 eval(['oo_.PosteriorIRF.Median.' name ' = MedianIRF(:,j,i);' ]);
+0151 eval(['oo_.PosteriorIRF.Var.' name ' = VarIRF(:,j,i);' ]);
+0152 eval(['oo_.PosteriorIRF.Distribution.' name ' = DistribIRF(:,:,j,i);' ]);
+0153 eval(['oo_.PosteriorIRF.HPDinf.' name ' = HPDIRF(:,1,j,i);' ]);
+0154 eval(['oo_.PosteriorIRF.HPDsup.' name ' = HPDIRF(:,2,j,i);' ]);
+0155 end
+0156 end
+0157
+0158
+0159
+0160 if options_.TeX
+0161 fidTeX = fopen([DirectoryName '/' M_.fname '_BayesianIRF.TeX' ],'w' );
+0162 fprintf(fidTeX,'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n' );
+0163 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0164 fprintf(fidTeX,' \n' );
+0165 titTeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex;
+0166 end
+0167
+0168 subplotnum = 0;
+0169 for i=1:M_.exo_nbr
+0170 NAMES = [];
+0171 if options_.TeX
+0172 TEXNAMES = [];
+0173 end
+0174 figunumber = 0;
+0175 for j=1:nvar
+0176 if max(abs(MeanIRF(:,j,i))) > 10^(-6)
+0177 subplotnum = subplotnum+1;
+0178 if options_.nograph
+0179 if subplotnum == 1 & options_.relative_irf
+0180 hh = figure('Name' ,['Relative response to orthogonalized shock to ' tit(i,:)],'Visible' ,'off' );
+0181 elseif subplotnum == 1 & ~options_.relative_irf
+0182 hh = figure('Name' ,['Orthogonalized shock to ' tit(i,:)],'Visible' ,'off' );
+0183 end
+0184 else
+0185 if subplotnum == 1 & options_.relative_irf
+0186 hh = figure('Name' ,['Relative response to orthogonalized shock to ' tit(i,:)]);
+0187 elseif subplotnum == 1 & ~options_.relative_irf
+0188 hh = figure('Name' ,['Orthogonalized shock to ' tit(i,:)]);
+0189 end
+0190 end
+0191 set(0,'CurrentFigure' ,hh)
+0192 subplot(nn,nn,subplotnum);
+0193 plot([1 options_.irf],[0 0],'-r' ,'linewidth' ,0.5);
+0194 hold on
+0195 for k = 1:9
+0196 plot(1:options_.irf,DistribIRF(:,k,j,i),'-g' ,'linewidth' ,0.5)
+0197 end
+0198 plot(1:options_.irf,MeanIRF(:,j,i),'-k' ,'linewidth' ,1)
+0199 xlim([1 options_.irf]);
+0200 hold off
+0201 name = deblank(varlist(j,:));
+0202 NAMES = strvcat(NAMES,name);
+0203 if options_.TeX
+0204 texname = deblank(varlist_TeX(j,:));
+0205 TEXNAMES = strvcat(TEXNAMES,['$' texname '$' ]);
+0206 end
+0207 title(name,'Interpreter' ,'none' )
+0208 end
+0209 if subplotnum == MaxNumberOfPlotPerFigure | (j == nvar & subplotnum>0)
+0210 figunumber = figunumber+1;
+0211 set(hh,'visible' ,'on' )
+0212 eval(['print -depsc2 ' DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)]);
+0213 eval(['print -dpdf ' DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber)]);
+0214 saveas(hh,[DirectoryName '/' M_.fname '_Bayesian_IRF_' deblank(tit(i,:)) '_' int2str(figunumber) '.fig' ]);
+0215 set(hh,'visible' ,'off' )
+0216 if options_.nograph, close(hh), end
+0217 if options_.TeX
+0218 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0219 for jj = 1:size(TEXNAMES,1)
+0220 fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{%s}\n' ],deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
+0221 end
+0222 fprintf(fidTeX,'\\centering \n' );
+0223 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Bayesian_IRF_%s}\n' ,M_.fname,deblank(tit(i,:)));
+0224 if options_.relative_irf
+0225 fprintf(fidTeX,['\\caption{Bayesian relative IRF.}' ]);
+0226 else
+0227 fprintf(fidTeX,'\\caption{Bayesian IRF.}' );
+0228 end
+0229 fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s}\n' ,deblank(tit(i,:)));
+0230 fprintf(fidTeX,'\\end{figure}\n' );
+0231 fprintf(fidTeX,' \n' );
+0232 end
+0233 subplotnum = 0;
+0234 end
+0235 end
+0236 end
+0237
+0238 if options_.TeX
+0239 fprintf(fidTeX,'%% End of TeX file.\n' );
+0240 fclose(fidTeX);
+0241 end
+0242 fprintf('MH: Posterior IRFs, done!\n' );
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/PosteriorSmoother.html b/matlab/doc/PosteriorSmoother.html
new file mode 100644
index 000000000..f52c94188
--- /dev/null
+++ b/matlab/doc/PosteriorSmoother.html
@@ -0,0 +1,228 @@
+
+
+
+ Description of PosteriorSmoother
+
+
+
+
+
+
+
+
+
+Home >
. > PosteriorSmoother.m
+
+
+
+PosteriorSmoother
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-25-2005]
+
+ SYNOPSIS
+function PosteriorSmoother(Y,gend, type)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function PosteriorSmoother(Y,gend, type)
+0002
+0003 global options_ estim_params_ oo_ M_
+0004
+0005 nvx = estim_params_.nvx;
+0006 nvn = estim_params_.nvn;
+0007 ncx = estim_params_.ncx;
+0008 ncn = estim_params_.ncn;
+0009 np = estim_params_.np ;
+0010 npar = nvx+nvn+ncx+ncn+np;
+0011 offset = npar-np;
+0012 naK = length(options_.filter_step_ahead);
+0013
+0014 MaxNumberOfPlotPerFigure = 4;
+0015 MaxNumberOfBytes=options_.MaxNumberOfBytes;
+0016 endo_nbr=M_.endo_nbr;
+0017 exo_nbr=M_.exo_nbr;
+0018 nvobs = size(options_.varobs,1);
+0019 nn = sqrt(MaxNumberOfPlotPerFigure);
+0020
+0021 CheckPath ('Plots/' );
+0022 DirectoryName = CheckPath ('metropolis' );
+0023 load([ DirectoryName '/' M_.fname '_mh_history' ])
+0024 FirstMhFile = record.KeepedDraws.FirstMhFile;
+0025 FirstLine = record.KeepedDraws.FirstLine;
+0026 TotalNumberOfMhFiles = sum(record.MhDraws(:,2)); LastMhFile = TotalNumberOfMhFiles;
+0027 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
+0028 NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
+0029 clear record;
+0030 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
+0031 MAX_nsmoo = ceil(MaxNumberOfBytes/((endo_nbr)*gend)/8);
+0032 MAX_ninno = ceil(MaxNumberOfBytes/(exo_nbr*gend)/8);
+0033 MAX_nerro = ceil(MaxNumberOfBytes/(size(options_.varobs,1)*gend)/8);
+0034 MAX_naK = ceil(MaxNumberOfBytes/(size(options_.varobs,1)*length(options_.filter_step_ahead)*gend)/8);
+0035
+0036 B = round(0.25*NumberOfDraws);
+0037
+0038 varlist = options_.varlist;
+0039 if isempty(varlist)
+0040 varlist = M_.endo_names;
+0041 SelecVariables = transpose(1:M_.endo_nbr);
+0042 nvar = M_.endo_nbr;
+0043 else
+0044 nvar = size(varlist,1);
+0045 SelecVariables = [];
+0046 for i=1:nvar
+0047 if ~isempty(strmatch(varlist(i,:),M_.endo_names,'exact' ))
+0048 SelecVariables = [SelecVariables;strmatch(varlist(i,:),M_.endo_names,'exact' )];
+0049 end
+0050 end
+0051 end
+0052
+0053 irun1 = 1;
+0054 irun2 = 1;
+0055 irun3 = 1;
+0056 irun4 = 1;
+0057 irun5 = 1;
+0058 ifil1 = 1;
+0059 ifil2 = 1;
+0060 ifil3 = 1;
+0061 ifil4 = 1;
+0062 ifil5 = 1;
+0063 h = waitbar(0,'Bayesian smoother...' );
+0064 if B <= MAX_nruns
+0065 stock_param = zeros(B, npar);
+0066 stock_logpo = zeros(B,1);
+0067 stock_ys = zeros(B,endo_nbr);
+0068 else
+0069 stock_param = zeros(MAX_nruns, npar);
+0070 stock_logpo = zeros(MAX_nruns,1);
+0071 stock_ys = zeros(MAX_nruns,endo_nbr);
+0072 end
+0073 if options_.smoother
+0074 if B <= MAX_nsmoo
+0075 stock_smooth = zeros(endo_nbr,gend,B);
+0076 else
+0077 stock_smooth = zeros(endo_nbr,gend,MAX_nsmoo);
+0078 end
+0079 if B <= MAX_ninno
+0080 stock_innov = zeros(exo_nbr,gend,B);
+0081 else
+0082 stock_innov = zeros(exo_nbr,gend,MAX_ninno);
+0083 end
+0084 if nvn & B <= MAX_nerro
+0085 stock_error = zeros(nvobs,gend,B);
+0086 else nvn & B > MAX_nerro
+0087 stock_error = zeros(nvobs,gend,MAX_nerro);
+0088 end
+0089 end
+0090 if options_.filter_step_ahead ~= 0
+0091 if B <= MAX_naK
+0092 stock_filter = zeros(naK,endo_nbr,gend+options_.filter_step_ahead(end),B);
+0093 else
+0094 stock_filter = zeros(naK,endo_nbr,gend+options_.filter_step_ahead(end),MAX_naK);
+0095 end
+0096 end
+0097 for b=1:B
+0098
+0099 [deep, logpo] = GetOneDraw (type);
+0100 set_all_parameters (deep);
+0101 dr = resol (oo_.steady_state,0);
+0102 [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother (deep,gend,Y);
+0103
+0104 stock_smooth(:,:,irun1) = alphahat(1:endo_nbr,:);
+0105 if nvx
+0106 stock_innov(:,:,irun2) = etahat;
+0107 end
+0108 if nvn
+0109 stock_error(:,:,irun3) = epsilonhat;
+0110 end
+0111 if naK
+0112 stock_filter(:,:,:,irun4) = aK(options_.filter_step_ahead,1:endo_nbr,:);
+0113 end
+0114 stock_param(irun5,:) = deep;
+0115 stock_logpo(irun5,1) = logpo;
+0116 stock_ys(irun5,:) = SteadyState';
+0117
+0118 irun1 = irun1 + 1;
+0119 irun2 = irun2 + 1;
+0120 irun3 = irun3 + 1;
+0121 irun4 = irun4 + 1;
+0122 irun5 = irun5 + 1;
+0123
+0124 if irun1 > MAX_nsmoo | b == B
+0125 if b == B
+0126 stock_smooth = stock_smooth(:,:,1:irun1-1);
+0127 end
+0128 stock = stock_smooth;
+0129 save([DirectoryName '/' M_.fname '_smooth' int2str(ifil1)],'stock' );
+0130 ifil1 = ifil1 + 1;
+0131 irun1 = 1;
+0132 end
+0133
+0134 if nvx & (irun2 > MAX_ninno | b == B)
+0135 if b == B
+0136 stock_innov = stock_innov(:,:,1:irun2-1);
+0137 end
+0138 stock = stock_innov;
+0139 save([DirectoryName '/' M_.fname '_inno' int2str(ifil2)],'stock' );
+0140 ifil2 = ifil2 + 1;
+0141 irun2 = 1;
+0142 end
+0143
+0144 if nvn & (irun3 > MAX_error | b == B)
+0145 if b == B
+0146 stock_error = stock_error(:,:,1:irun3-1);
+0147 end
+0148 stock = stock_error;
+0149 save([DirectoryName '/' M_.fname '_error' int2str(ifil3)],'stock' );
+0150 ifil3 = ifil3 + 1;
+0151 irun3 = 1;
+0152 end
+0153
+0154 if naK & (irun4 > MAX_naK | b == B)
+0155 if b == B
+0156 stock_filter = stock_filter(:,:,:,1:irun4-1);
+0157 end
+0158 stock = stock_filter;
+0159 save([DirectoryName '/' M_.fname '_filter' int2str(ifil4)],'stock' );
+0160 ifil4 = ifil4 + 1;
+0161 irun4 = 1;
+0162 end
+0163
+0164 if irun5 > MAX_nruns | b == B
+0165 if b == B
+0166 stock_param = stock_param(1:irun5-1,:);
+0167 stock_logpo = stock_logpo(1:irun5-1,1);
+0168 stock_ys = stock_ys(1:irun5-1,:);
+0169 end
+0170 stock = stock_param;
+0171 save([DirectoryName '/' M_.fname '_param' int2str(ifil5)],'stock' ,'stock_logpo' ,'stock_ys' );
+0172 ifil5 = ifil5 + 1;
+0173 irun5 = 1;
+0174 end
+0175
+0176 waitbar(b/B,h);
+0177 end
+0178 close(h)
+0179
+0180 stock_gend=gend;
+0181 stock_data=Y;
+0182 save([DirectoryName '/' M_.fname '_data' ],'stock_gend' ,'stock_data' );
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/ReshapeMatFiles.html b/matlab/doc/ReshapeMatFiles.html
new file mode 100644
index 000000000..2261ba816
--- /dev/null
+++ b/matlab/doc/ReshapeMatFiles.html
@@ -0,0 +1,170 @@
+
+
+
+ Description of ReshapeMatFiles
+
+
+
+
+
+
+
+
+
+Home >
. > ReshapeMatFiles.m
+
+
+
+ReshapeMatFiles
+
+
+ PURPOSE
+Reshape and sort (along the mcmc simulations) the mat files generated
+
+ SYNOPSIS
+function ReshapeMatFiles(type)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function ReshapeMatFiles(type)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 global M_ options_
+0010
+0011 MhDirectoryName = [ CheckPath ('metropolis' ) '/' ];
+0012
+0013 switch type
+0014 case 'irf'
+0015 CAPtype = 'IRF' ;
+0016 TYPEsize = [ options_.irf , M_.endo_nbr , M_.exo_nbr ];
+0017 TYPEarray = 4;
+0018 case 'smooth'
+0019 CAPtype = 'SMOOTH' ;
+0020 TYPEsize = [ M_.endo_nbr , options_.nobs ];
+0021 TYPEarray = 3;
+0022 case 'filter'
+0023 CAPtype = 'FILTER' ;
+0024 TYPEsize = [ M_.endo_nbr , options_.nobs + 1 ];
+0025 TYPEarray = 3;
+0026 case 'error'
+0027 CAPtype = 'ERROR' ;
+0028 TYPEsize = [ size(options_.varobs,1) , options_.nobs ];
+0029 TYPEarray = 3;
+0030 case 'innov'
+0031 CAPtype = 'INNOV' ;
+0032 TYPEsize = [ M_.exo_nbr , options_.nobs ];
+0033 TYPEarray = 3;
+0034 case 'forcst'
+0035 CAPtype = 'FORCST' ;
+0036 TYPEsize = [ M_.endo_nbr , options_.forecast ];
+0037 TYPEarray = 3;
+0038 case 'forcst1'
+0039 CAPtype = 'FORCST1' ;
+0040 TYPEsize = [ M_.endo_nbr , options_.forecast ];
+0041 TYPEarray = 3;
+0042 otherwise
+0043 disp('ReshapeMatFiles :: Unknown argument!' )
+0044 return
+0045 end
+0046
+0047 TYPEfiles = dir([MhDirectoryName M_.fname '_' type '*' ]);
+0048 NumberOfTYPEfiles = length(TYPEfiles);
+0049 B = options_.B;
+0050
+0051 switch TYPEarray
+0052 case 4
+0053 if NumberOfTYPEfiles > 1
+0054 NumberOfPeriodsPerTYPEfiles = ceil(TYPEsize(1)/NumberOfTYPEfiles);
+0055 reste = TYPEsize(1)-NumberOfPeriodsPerTYPEfiles*(NumberOfTYPEfiles-1);
+0056 idx = 0;
+0057 jdx = 0;
+0058 for f1=1:NumberOfTYPEfiles-1
+0059 eval(['STOCK_' CAPtype ' = zeros(NumberOfPeriodsPerTYPEfiles,TYPEsize(2),TYPEsize(3),B);' ])
+0060 for f2 = 1:NumberOfTYPEfiles
+0061 load([MhDirectoryName M_.fname '_' type int2str(f2)]);
+0062 eval(['STOCK_' CAPtype '(:,:,:,idx+1:idx+size(stock_' type ',4))=stock_' type '(jdx+1:jdx+NumberOfPeriodsPerTYPEfiles,:,:,:);' ])
+0063 eval(['idx = idx + size(stock_' type ',4);' ])
+0064 end
+0065 eval(['STOCK_' CAPtype ' = sort(STOCK_' CAPtype ',4);' ])
+0066 save([MhDirectoryName M_.fname '_' CAPtype 's' int2str(f1)],['STOCK_' CAPtype]);
+0067 jdx = jdx + NumberOfPeriodsPerTYPEfiles;
+0068 idx = 0;
+0069 end
+0070 eval(['STOCK_' CAPtype ' = zeros(reste,TYPEsize(2),TYPEsize(3),B);' ])
+0071 for f2 = 1:NumberOfTYPEfiles
+0072 load([MhDirectoryName M_.fname '_' type int2str(f2)]);
+0073 eval(['STOCK_' CAPtype '(:,:,:,idx+1:idx+size(stock_' type ',4))=stock_' type '(jdx+1:jdx+reste,:,:,:);' ])
+0074 eval(['idx = idx + size(stock_' type ',4);' ])
+0075 end
+0076 eval(['STOCK_' CAPtype ' = sort(STOCK_' CAPtype ',4);' ])
+0077 save([MhDirectoryName M_.fname '_' CAPtype 's' int2str(NumberOfTYPEfiles)],['STOCK_' CAPtype]);
+0078 else
+0079 load([MhDirectoryName M_.fname '_' type '1' ]);
+0080 eval(['STOCK_' CAPtype ' = sort(stock_' type ',4);' ])
+0081 save([MhDirectoryName M_.fname '_' CAPtype 's' int2str(1)],['STOCK_' CAPtype ]);
+0082 end
+0083 for file = 1:NumberOfTYPEfiles
+0084 delete([MhDirectoryName M_.fname '_' type int2str(file) '.mat' ])
+0085 end
+0086 case 3
+0087 if NumberOfTYPEfiles>1
+0088 NumberOfPeriodsPerTYPEfiles = ceil( TYPEsize(2)/NumberOfTYPEfiles );
+0089 reste = TYPEsize(2)-NumberOfPeriodsPerTYPEfiles*(NumberOfTYPEfiles-1);
+0090 idx = 0;
+0091 jdx = 0;
+0092 for f1=1:NumberOfTYPEfiles-1
+0093 eval(['STOCK_' CAPtype ' = zeros(TYPEsize(1),NumberOfPeriodsPerTYPEfiles,B);' ])
+0094 for f2 = 1:NumberOfTYPEfiles
+0095 load([MhDirectoryName M_.fname '_' type int2str(f2)]);
+0096 eval(['STOCK_' CAPtype '(:,:,idx+1:idx+size(stock_ ' type ',3))=stock_' type '(:,jdx+1:jdx+NumberOfPeriodsPerTYPEfiles,:);' ])
+0097 eval(['idx = idx + size(stock_' type ',3);' ])
+0098 end
+0099 eval(['STOCK_' CAPtype ' = sort(STOCK_' CAPtype ',3);' ])
+0100 save([MhDirectoryName M_.fname '_' CAPtype 's' int2str(f1)],['STOCK_' CAPtype]);
+0101 jdx = jdx + NumberOfPeriodsPerTYPEfiles;
+0102 idx = 0;
+0103 end
+0104 eval(['STOCK_' CAPtype ' = zeros(TYPEsize(1),reste,B);' ])
+0105 for f2 = 1:NumberOfTYPEfiles
+0106 load([MhDirectoryName M_.fname '_' type int2str(f2)]);
+0107 eval(['STOCK_' CAPtype '(:,:,idx+1:idx+size(stock_' type ',3))=stock_' type '(:,jdx+1:jdx+reste,:);' ])
+0108 eval(['idx = idx + size(stock_' type ',3);' ])
+0109 end
+0110 eval(['STOCK_' CAPtype ' = sort(STOCK_' CAPtype ',3);' ])
+0111 save([MhDirectoryName M_.fname '_' CAPtype 's' int2str(NumberOfTYPEfiles)],['STOCK_' CAPtype]);
+0112 else
+0113 load([MhDirectoryName M_.fname '_' type '1' ]);
+0114 eval(['STOCK_' CAPtype ' = sort(stock_' type ',3);' ])
+0115 save([MhDirectoryName M_.fname '_' CAPtype 's' int2str(1)],['STOCK_' CAPtype ]);
+0116 end
+0117 for file = 1:NumberOfTYPEfiles
+0118 delete([MhDirectoryName M_.fname '_' type int2str(file) '.mat' ])
+0119 end
+0120 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/UnivariateSpectralDensity.html b/matlab/doc/UnivariateSpectralDensity.html
new file mode 100644
index 000000000..51b1e3181
--- /dev/null
+++ b/matlab/doc/UnivariateSpectralDensity.html
@@ -0,0 +1,178 @@
+
+
+
+ Description of UnivariateSpectralDensity
+
+
+
+
+
+
+
+
+
+Home >
. > UnivariateSpectralDensity.m
+
+
+
+UnivariateSpectralDensity
+
+
+ PURPOSE
+stephane.adjemian@ens.fr
+
+ SYNOPSIS
+function [omega,f] = UnivariateSpectralDensity(dr,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002 function [omega,f] = UnivariateSpectralDensity(dr,var_list)
+0003
+0004
+0005
+0006
+0007
+0008 global options_ oo_ M_
+0009
+0010 omega = []; f = [];
+0011
+0012 if options_.order > 1
+0013 disp('UnivariateSpectralDensity :: I Cannot compute the theoretical spectral density' )
+0014 disp('with a second order approximation of the DSGE model!' )
+0015 disp('Set order = 1.' )
+0016 return
+0017 end
+0018
+0019 pltinfo = 1;
+0020 cutoff = 100;
+0021 sdl = 0.1;
+0022 omega = (0:sdl:pi)';
+0023 GridSize = length(omega);
+0024 exo_names_orig_ord = M_.exo_names_orig_ord;
+0025 if sscanf(version('-release' ),'%d' ) < 13
+0026 warning off
+0027 else
+0028 eval('warning off MATLAB:dividebyzero' )
+0029 end
+0030 if nargin<2
+0031 var_list = [];
+0032 end
+0033 nvar = size(var_list,1);
+0034 if nvar == 0
+0035 nvar = length(dr.order_var);
+0036 ivar = [1:nvar]';
+0037 else
+0038 ivar=zeros(nvar,1);
+0039 for i=1:nvar
+0040 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0041 if isempty(i_tmp)
+0042 error (['One of the variable specified does not exist' ]) ;
+0043 else
+0044 ivar(i) = i_tmp;
+0045 end
+0046 end
+0047 end
+0048 f = zeros(nvar,GridSize);
+0049 ghx = dr.ghx;
+0050 ghu = dr.ghu;
+0051 npred = dr.npred;
+0052 nstatic = dr.nstatic;
+0053 kstate = dr.kstate;
+0054 order = dr.order_var;
+0055 iv(order) = [1:length(order)];
+0056 nx = size(ghx,2);
+0057 ikx = [nstatic+1:nstatic+npred];
+0058 A = zeros(nx,nx);
+0059 k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
+0060 i0 = find(k0(:,2) == M_.maximum_lag+1);
+0061 i00 = i0;
+0062 n0 = length(i0);
+0063 A(i0,:) = ghx(ikx,:);
+0064 AS = ghx(:,i0);
+0065 ghu1 = zeros(nx,M_.exo_nbr);
+0066 ghu1(i0,:) = ghu(ikx,:);
+0067 for i=M_.maximum_lag:-1:2
+0068 i1 = find(k0(:,2) == i);
+0069 n1 = size(i1,1);
+0070 j1 = zeros(n1,1);
+0071 j2 = j1;
+0072 for k1 = 1:n1
+0073 j1(k1) = find(k0(i00,1)==k0(i1(k1),1));
+0074 j2(k1) = find(k0(i0,1)==k0(i1(k1),1));
+0075 end
+0076 AS(:,j1) = AS(:,j1)+ghx(:,i1);
+0077 i0 = i1;
+0078 end
+0079 b = ghu1*M_.Sigma_e*ghu1';
+0080 [A,B] = kalman_transition_matrix (dr);
+0081
+0082 i_pred = [nstatic+(1:npred) M_.endo_nbr+1:length(A)];
+0083 A = A(i_pred,i_pred);
+0084 [vx, ns_var] = lyapunov_symm (A,b);
+0085 i_ivar = find(~ismember(ivar,dr.order_var(ns_var+nstatic)));
+0086 ivar = ivar(i_ivar);
+0087 iky = iv(ivar);
+0088 aa = ghx(iky,:);
+0089 bb = ghu(iky,:);
+0090 Gamma = zeros(nvar,cutoff+1);
+0091 tmp = aa*vx*aa'+ bb*M_.Sigma_e*bb';
+0092 k = find(abs(tmp) < 1e-12);
+0093 tmp(k) = 0;
+0094 Gamma(:,1) = diag(tmp);
+0095 vxy = (A*vx*aa'+ghu1*M_.Sigma_e*bb');
+0096 tmp = aa*vxy;
+0097 k = find(abs(tmp) < 1e-12);
+0098 tmp(k) = 0;
+0099 Gamma(:,2) = diag(tmp);
+0100 for i=2:cutoff
+0101 vxy = A*vxy;
+0102 tmp = aa*vxy;
+0103 k = find(abs(tmp) < 1e-12);
+0104 tmp(k) = 0;
+0105 Gamma(:,i+1) = diag(tmp);
+0106 end
+0107 H = 1:cutoff;
+0108 for i=1:nvar
+0109 f(i,:) = Gamma(i,1)/(2*pi) + Gamma(i,H+1)*cos(H'*omega')/pi;
+0110 end
+0111
+0112 if sscanf(version('-release' ),'%d' ) < 13
+0113 warning on
+0114 else
+0115 eval('warning on MATLAB:dividebyzero' )
+0116 end
+0117
+0118 if pltinfo
+0119 for i= 1:nvar
+0120 figure('Name' ,['Spectral Density of ' deblank(M_.endo_names(ivar(i),:)) '.' ])
+0121 plot(omega,f(i,:),'-k' ,'linewidth' ,2)
+0122 xlabel('0 \leq \omega \leq \pi' )
+0123 ylabel('f(\omega)' )
+0124 box on
+0125 axis tight
+0126 end
+0127 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/alpha.png b/matlab/doc/alpha.png
new file mode 100644
index 000000000..c73de7b05
Binary files /dev/null and b/matlab/doc/alpha.png differ
diff --git a/matlab/doc/asamin.html b/matlab/doc/asamin.html
new file mode 100644
index 000000000..98385865d
--- /dev/null
+++ b/matlab/doc/asamin.html
@@ -0,0 +1,364 @@
+
+
+
+ Description of asamin
+
+
+
+
+
+
+
+
+
+
+
+
+
+asamin
+
+
+ PURPOSE
+ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)
+
+ SYNOPSIS
+This is a script file.
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077
+0078
+0079
+0080
+0081
+0082
+0083
+0084
+0085
+0086
+0087
+0088
+0089
+0090
+0091
+0092
+0093
+0094
+0095
+0096
+0097
+0098
+0099
+0100
+0101
+0102
+0103
+0104
+0105
+0106
+0107
+0108
+0109
+0110
+0111
+0112
+0113
+0114
+0115
+0116
+0117
+0118
+0119
+0120
+0121
+0122
+0123
+0124
+0125
+0126
+0127
+0128
+0129
+0130
+0131
+0132
+0133
+0134
+0135
+0136
+0137
+0138
+0139
+0140
+0141
+0142
+0143
+0144
+0145
+0146
+0147
+0148
+0149
+0150
+0151
+0152
+0153
+0154
+0155
+0156
+0157
+0158
+0159
+0160
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/beta_rnd.html b/matlab/doc/beta_rnd.html
new file mode 100644
index 000000000..0818caef7
--- /dev/null
+++ b/matlab/doc/beta_rnd.html
@@ -0,0 +1,91 @@
+
+
+
+ Description of beta_rnd
+
+
+
+
+
+
+
+
+
+
+
+
+
+beta_rnd
+
+
+ PURPOSE
+PURPOSE: random draws from the beta(a,b) distribution
+
+ SYNOPSIS
+function rnd = beta_rnd (n, a, b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+gamm_rnd PURPOSE: a matrix of random draws from the gamma distribution
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function rnd = beta_rnd (n, a, b)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023 if (nargin ~= 3)
+0024 error('Wrong # of arguments to beta_rnd' );
+0025 end ;
+0026
+0027 if any(any((a<=0)|(b<=0)))
+0028 error('Parameter a or b is nonpositive' )
+0029 end
+0030
+0031 a1n = gamm_rnd (n,a,1);
+0032 a1d = gamm_rnd (n,b,1);
+0033 rnd = a1n./(a1n+a1d);
+0034
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/bfgsi.html b/matlab/doc/bfgsi.html
new file mode 100644
index 000000000..139a9efe8
--- /dev/null
+++ b/matlab/doc/bfgsi.html
@@ -0,0 +1,76 @@
+
+
+
+ Description of bfgsi
+
+
+
+
+
+
+
+
+
+
+
+
+
+bfgsi
+
+
+ PURPOSE
+H = bfgsi(H0,dg,dx)
+
+ SYNOPSIS
+function H = bfgsi(H0,dg,dx)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+csminwel [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)
+
+
+
+ SOURCE CODE
+0001 function H = bfgsi(H0,dg,dx)
+0002
+0003
+0004
+0005
+0006
+0007
+0008 if size(dg,2)>1
+0009 dg=dg';
+0010 end
+0011 if size(dx,2)>1
+0012 dx=dx';
+0013 end
+0014 Hdg = H0*dg;
+0015 dgdx = dg'*dx;
+0016 if (abs(dgdx) >1e-12)
+0017 H = H0 + (1+(dg'*Hdg)/dgdx)*(dx*dx')/dgdx - (dx*Hdg'+Hdg*dx')/dgdx;
+0018 else
+0019 disp('bfgs update failed.' )
+0020 disp(['|dg| = ' num2str(sqrt(dg'*dg)) '|dx| = ' num2str(sqrt(dx'*dx))]);
+0021 disp(['dg''*dx = ' num2str(dgdx)])
+0022 disp(['|H*dg| = ' num2str(Hdg'*Hdg)])
+0023 H=H0;
+0024 end
+0025 save H.dat H
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/bicgstab.html b/matlab/doc/bicgstab.html
new file mode 100644
index 000000000..f61d67829
--- /dev/null
+++ b/matlab/doc/bicgstab.html
@@ -0,0 +1,78 @@
+
+
+
+ Description of bicgstab
+
+
+
+
+
+
+
+
+
+
+
+
+
+bicgstab
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [x,status]=bicgstab(func,b,x,tole,kmax,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+calib_obj targets and iy order: 1) variances 2) correlations
+
+
+
+ SOURCE CODE
+0001 function [x,status]=bicgstab(func,b,x,tole,kmax,varargin)
+0002 status = 0;
+0003 r=b-feval(func,x,varargin{:});
+0004 rh_0 = r;
+0005 rh = r;
+0006 rho_0 = 1;
+0007 alpha = 1;
+0008 w = 1;
+0009 v = 0;
+0010 p = 0;
+0011 k = 0;
+0012 rho_1 = rh_0'*r;
+0013 tolr = tole*norm(b);
+0014
+0015 while norm(r) > tolr & k < kmax
+0016 k = k+1;
+0017 beta = (rho_1/rho_0)*(alpha/w);
+0018 p = r+beta*(p-w*v);
+0019 v = feval(func,p,varargin{:});
+0020 alpha = rho_1/(rh_0'*v);
+0021 r = r-alpha*v;
+0022 t = feval(func,r,varargin{:});
+0023 w = (t'*r)/(t'*t);
+0024 rho_0 = rho_1;
+0025 rho_1 = -w*(rh_0'*t);
+0026 x = x+alpha*p+w*r;
+0027 r = r-w*t;
+0028 end
+0029 if k == kmax
+0030 status = 1;
+0031 warning(sprintf('BICSTABN didn''t converge after %d iterations: norm(r) = %g' ,kmax,norm(r)));
+0032 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/bksup.html b/matlab/doc/bksup.html
new file mode 100644
index 000000000..7fe09c044
--- /dev/null
+++ b/matlab/doc/bksup.html
@@ -0,0 +1,95 @@
+
+
+
+ Description of bksup
+
+
+
+
+
+
+
+
+
+
+
+
+
+bksup
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function d1 = bksupk(ny,fid,jcf,icc1)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+irf selif Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function d1 = bksupk(ny,fid,jcf,icc1)
+0004
+0005 global M_ options_ c ncc
+0006
+0007 icf = [1:jcf-1] ;
+0008 ir = [(options_.periods-1)*ny+1:ny*options_.periods] ;
+0009 irf = icc1+(options_.periods-1)*ny ;
+0010 d1 = zeros(options_.periods*ny,1) ;
+0011
+0012 ofs = (((options_.periods-1)*ny+1)-1)*ncc*8 ;
+0013 junk = fseek(fid,ofs,-1) ;
+0014 c = fread(fid,[ncc,ny],'float64' ) ;
+0015 c = c' ;
+0016
+0017 d1(ir) = c(:,jcf) ;
+0018 ir = ir-ny ;
+0019
+0020 i = 2 ;
+0021
+0022 while i <= M_.maximum_lead | i <= options_.periods
+0023 irf1 = selif (irf ,irf <options_.periods*ny) ;
+0024
+0025 ofs = (((options_.periods-i)*ny+1)-1)*ncc*8 ;
+0026 junk = fseek(fid,ofs,-1) ;
+0027 c = fread(fid,[ncc,ny],'float64' ) ;
+0028 c = c' ;
+0029
+0030 d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
+0031 ir = ir - ny ;
+0032 irf = irf - ny ;
+0033 i = i + 1 ;
+0034 end
+0035
+0036 while i <= options_.periods
+0037
+0038 ofs = (((options_.periods-i)*ny+1)-1)*ncc*8 ;
+0039 junk = fseek(fid,ofs,-1) ;
+0040 c = fread(fid,[ncc,ny],'float64' ) ;
+0041 c = c' ;
+0042
+0043 d1(ir) = c(:,jcf)-c(:,icf)*d1(irf ) ;
+0044 ir = ir-ny ;
+0045 irf = irf -ny ;
+0046 i = i+1;
+0047 end
+0048
+0049 return ;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/bksup1.html b/matlab/doc/bksup1.html
new file mode 100644
index 000000000..2d63c1304
--- /dev/null
+++ b/matlab/doc/bksup1.html
@@ -0,0 +1,65 @@
+
+
+
+ Description of bksup1
+
+
+
+
+
+
+
+
+
+
+
+
+
+bksup1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function d = bksup1(ny,jcf)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+sim1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function d = bksup1(ny,jcf)
+0004
+0005 global options_ iyf c
+0006
+0007 ir = [(options_.periods-2)*ny+1:ny+(options_.periods-2)*ny] ;
+0008 irf = iyf+(options_.periods-1)*ny ;
+0009 icf = [1:size(iyf,2)] ;
+0010
+0011 for i = 2:options_.periods
+0012 c(ir,jcf) = c(ir,jcf)-c(ir,icf)*c(irf ,jcf) ;
+0013 ir = ir-ny ;
+0014 irf = irf -ny ;
+0015 end
+0016
+0017 d = c(:,jcf) ;
+0018
+0019 return ;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/bksupk.html b/matlab/doc/bksupk.html
new file mode 100644
index 000000000..ef0db5d09
--- /dev/null
+++ b/matlab/doc/bksupk.html
@@ -0,0 +1,90 @@
+
+
+
+ Description of bksupk
+
+
+
+
+
+
+
+
+
+
+
+
+
+bksupk
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function d1 = bksupk(ny,fid,jcf,icc1)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+irf selif Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+simk Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001 function d1 = bksupk(ny,fid,jcf,icc1)
+0002
+0003 global M_ options_
+0004
+0005 icf = [1:jcf-1] ;
+0006 ir = [(options_.periods-1)*ny+1:ny*options_.periods] ;
+0007 irf = icc1+(options_.periods-1)*ny ;
+0008 d1 = zeros(options_.periods*ny,1) ;
+0009
+0010 ofs = (((options_.periods-1)*ny+1)-1)*jcf*8 ;
+0011 junk = fseek(fid,ofs,-1) ;
+0012 c = fread(fid,[jcf,ny],'float64' ) ;
+0013
+0014 d1(ir) = c(:,jcf) ;
+0015 ir = ir-ny ;
+0016
+0017 i = 2 ;
+0018
+0019 while i <= M_.maximum_lead | i <= options_.periods
+0020 irf1 = selif (irf ,irf <=options_.periods*ny) ;
+0021
+0022 ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
+0023 junk = fseek(fid,ofs,-1) ;
+0024 c = fread(fid,[jcf,ny],'float64' ) ;
+0025
+0026 d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
+0027 ir = ir - ny ;
+0028 irf = irf - ny ;
+0029 i = i + 1 ;
+0030 end
+0031
+0032 while i <= options_.periods
+0033
+0034 ofs = (((options_.periods-i)*ny+1)-1)*jcf*8 ;
+0035 junk = fseek(fid,ofs,-1) ;
+0036 c = fread(fid,[jcf,ny],'float64' ) ;
+0037
+0038 d1(ir) = c(:,jcf)-c(:,icf)*d1(irf ) ;
+0039 ir = ir-ny ;
+0040 irf = irf -ny ;
+0041 i = i+1;
+0042 end
+0043
+0044 return ;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/bseastr.html b/matlab/doc/bseastr.html
new file mode 100644
index 000000000..3dd8ccfc7
--- /dev/null
+++ b/matlab/doc/bseastr.html
@@ -0,0 +1,79 @@
+
+
+
+ Description of bseastr
+
+
+
+
+
+
+
+
+
+
+
+
+
+bseastr
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function x = bseastr(s1,s2)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dcompare Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function x = bseastr(s1,s2)
+0004
+0005 m = size(s1,1) ;
+0006 x = zeros(m,1) ;
+0007 s1=upper(deblank(s1));
+0008 s2=upper(deblank(s2));
+0009
+0010 for im = 1:m
+0011 key = s1(im,:) ;
+0012 h = size(s2,1) ;
+0013 l = 1 ;
+0014 while l <= h
+0015 mid = round((h+l)/2) ;
+0016 temp = s2(mid,:) ;
+0017 if ~ strcmp(key,temp)
+0018 for i = 1:min(length(key),length(temp))
+0019 if temp(i) > key(i)
+0020 h = mid - 1 ;
+0021 break
+0022 else
+0023 l = mid + 1 ;
+0024 break
+0025 end
+0026 end
+0027 else
+0028 x(im) = mid ;
+0029 break
+0030 end
+0031 end
+0032 end
+0033
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/c++.png b/matlab/doc/c++.png
new file mode 100644
index 000000000..24f56e629
Binary files /dev/null and b/matlab/doc/c++.png differ
diff --git a/matlab/doc/c.png b/matlab/doc/c.png
new file mode 100644
index 000000000..c39fbf0e2
Binary files /dev/null and b/matlab/doc/c.png differ
diff --git a/matlab/doc/calib.html b/matlab/doc/calib.html
new file mode 100644
index 000000000..5e17924f6
--- /dev/null
+++ b/matlab/doc/calib.html
@@ -0,0 +1,221 @@
+
+
+
+ Description of calib
+
+
+
+
+
+
+
+
+
+
+
+
+
+calib
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function M_.Sigma_e = calib(var_indices,targets,var_weights,nar,cova,M_.Sigma_e)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+calib_obj targets and iy order: 1) variances 2) correlationscalib_obj2 targets and iy order: 1) variances 2) correlationsindnv Copyright (C) 2001 Michel Juillardresol Copyright (C) 2001 Michel Juillardunion
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function M_.Sigma_e = calib(var_indices,targets,var_weights,nar,cova,M_.Sigma_e)
+0002 global oo_ M_ vx
+0003
+0004 ncstr = 0;
+0005 ni = size(var_indices,1);
+0006 for i=1:nar+3
+0007 ncstr = ncstr + size(var_indices{i},1);
+0008 end
+0009 if cova
+0010 if ncstr < M_.exo_nbr*(M_.exo_nbr+1)/2
+0011 error(['number of preset variances is smaller than number of shock' ...
+0012 ' variances and covariances to be estimated !' ])
+0013 end
+0014 else
+0015 if ncstr < M_.exo_nbr
+0016 error(['number of preset variances is smaller than number of shock' ...
+0017 ' variances to be estimated !' ])
+0018 end
+0019 end
+0020
+0021
+0022 dr = resol (oo_.steady_state,0,0,1);
+0023
+0024 ghx = dr.ghx;
+0025 ghu = dr.ghu;
+0026 npred = dr.npred;
+0027 nstatic = dr.nstatic;
+0028 kstate = dr.kstate;
+0029 order = dr.order_var;
+0030 iv(order) = [1:M_.endo_nbr];
+0031 iv = iv';
+0032 nx = size(ghx,2);
+0033
+0034 ikx = [nstatic+1:nstatic+npred];
+0035
+0036 A = zeros(nx,nx);
+0037 A(1:npred,:)=ghx(ikx,:);
+0038 offset_r = npred;
+0039 offset_c = 0;
+0040 i0 = find(kstate(:,2) == M_.maximum_lag+1);
+0041 n0 = size(i0,1);
+0042 for i=M_.maximum_lag:-1:2
+0043 i1 = find(kstate(:,2) == i);
+0044 n1 = size(i1,1);
+0045 j = zeros(n1,1);
+0046 for j1 = 1:n1
+0047 j(j1) = find(kstate(i0,1)==kstate(i1(j1),1));
+0048 end
+0049 A(offset_r+1:offset_r+n1,offset_c+j)=eye(n1);
+0050 offset_r = offset_r + n1;
+0051 offset_c = offset_c + n0;
+0052 i0 = i1;
+0053 n0 = n1;
+0054 end
+0055 ghu1 = [ghu(ikx,:);zeros(nx-npred,M_.exo_nbr)];
+0056
+0057
+0058
+0059
+0060 vx1 = [];
+0061
+0062 IA = [];
+0063 kron_ghu = [];
+0064
+0065
+0066 iiy = [];
+0067 for i=1:nar+3
+0068 if i ~= 3 & ~isempty(var_indices{i})
+0069 iiy = union (iiy, iv(var_indices{i}(:,1)));
+0070 end
+0071 end
+0072 if ~isempty(var_indices{2})
+0073 iiy = union (iiy, iv(var_indices{2}(:,2)));
+0074 end
+0075 ny = size(iiy,1);
+0076
+0077 for i=1:nar+3
+0078 if i ~= 3 & ~isempty(var_indices{i})
+0079 var_indices{i}(:,1) = indnv (iv(var_indices{i}(:,1)),iiy);
+0080 end
+0081 if i ~= 2 & i ~= 3 & ~isempty(var_indices{i})
+0082 var_indices{i} = sub2ind([ny ny],var_indices{i},var_indices{i});
+0083 end
+0084 end
+0085 if ~isempty(var_indices{2})
+0086 var_indices{2}(:,2) = indnv (iv(var_indices{2}(:,2)),iiy);
+0087 var_indices{2} = sub2ind([ny ny],var_indices{2}(:,1),var_indices{2}(:,2));
+0088 end
+0089 if ~isempty(var_indices{3})
+0090 var_indices{3} = sub2ind([M_.exo_nbr M_.exo_nbr],var_indices{3}(:,1),var_indices{3}(:,2));
+0091 end
+0092 if isempty(M_.Sigma_e)
+0093 M_.Sigma_e = 0.01*eye(M_.exo_nbr);
+0094 b = 0.1*ghu1*ghu1';
+0095 else
+0096 b = ghu1*M_.Sigma_e*ghu1';
+0097 M_.Sigma_e = chol(M_.Sigma_e+1e-14*eye(M_.exo_nbr));
+0098 end
+0099 options=optimset('LargeScale' ,'on' ,'MaxFunEvals' ,20000*ny,'TolX' ,1e-4, ...
+0100 'TolFun' ,1e-4,'Display' ,'Iter' ,'MaxIter' ,10000);
+0101
+0102 [M_.Sigma_e,f]=fmincon(@calib_obj ,diag(M_.Sigma_e).^2,-eye(M_.exo_nbr),zeros(M_.exo_nbr,1),[],[],[],[],[],options,A,ghu1,ghx(iiy,:),ghu(iiy,:),targets,var_weights,var_indices,nar);
+0103 M_.Sigma_e = diag(M_.Sigma_e);
+0104
+0105 objective = calib_obj2 (diag(M_.Sigma_e),A,ghu1,ghx(iiy,:),ghu(iiy,:),targets,var_weights,var_indices,nar);
+0106 disp('CALIBRATION' )
+0107 disp('' )
+0108 if ~isempty(var_indices{1})
+0109 disp(sprintf('%16s %14s %14s %14s %14s' ,'Std. Dev' ,'Target' ,'Obtained' ,'Diff' ));
+0110 str = ' ' ;
+0111 for i=1:size(var_indices{1},1)
+0112 [i1,i2] = ind2sub([ny ny],var_indices{1}(i));
+0113 str = sprintf('%16s: %14.2f %14.2f %14.2f' ,M_.endo_names(order(iiy(i1)),:),targets{1}(i),objective{1}(i),objective{1}(i)-targets{1}(i));
+0114 disp(str);
+0115 end
+0116 end
+0117 if ~isempty(var_indices{2})
+0118 disp(sprintf('%32s %14s %14s' ,'Correlations' ,'Target' ,'Obtained' ,'Diff' ));
+0119 str = ' ' ;
+0120 for i=1:size(var_indices{2},1)
+0121 [i1,i2]=ind2sub([ny ny],var_indices{2}(i));
+0122 str = sprintf('%16s,%16s: %14.2f %14.2f %14.2f' ,M_.endo_names(order(iiy(i1)),:), ...
+0123 M_.endo_names(order(iiy(i2)),:),targets{2}(i),objective{2}(i),objective{2}(i)-targets{2}(i));
+0124 disp(str);
+0125 end
+0126 end
+0127 if ~isempty(var_indices{3})
+0128 disp(sprintf('%32s %16s %16s' ,'Constrained shocks (co)variances' ,'Target' ,'Obtained' ));
+0129 str = ' ' ;
+0130 for i=1:size(var_indices{3},1)
+0131 [i1,i2]=ind2sub([M_.exo_nbr M_.exo_nbr],var_indices{3}(i));
+0132 if i1 == i2
+0133 str = sprintf('%32s: %16.4f %16.4f' ,M_.exo_name(order(i1),:), ...
+0134 targets{3}(i),objective{3}(i));
+0135 else
+0136 str = sprintf('%16s,%16s: %16.4f %16.4f' ,M_.exo_name(order(i1),:), ...
+0137 M_.exo_name(order(i2), :),targets{3}(i),objective{3}(i));
+0138 end
+0139 disp(str);
+0140 end
+0141 end
+0142 flag = 1;
+0143 for j=4:nar+3
+0144 if ~isempty(var_indices{j})
+0145 if flag
+0146 disp(sprintf('%16s %16s %16s' ,'Autocorrelations' ,'Target' ,'Obtained' ));
+0147 str = ' ' ;
+0148 flag = 0;
+0149 end
+0150 for i=1:size(var_indices{j},1)
+0151 [i1,i2] = ind2sub([ny ny],var_indices{j}(i));
+0152 str = sprintf('%16s(%d): %16.4f %16.4f' ,M_.endo_names(order(iiy(i1)),:), ...
+0153 j-3,targets{j}(i),objective{j}(i));
+0154 disp(str);
+0155 end
+0156 end
+0157 end
+0158
+0159 disp('' );
+0160 disp('Calibrated variances' )
+0161 str = ' ' ;
+0162 for i=1:M_.exo_nbr
+0163 str = [str sprintf('%16s' ,M_.exo_name(i,:))];
+0164 end
+0165 disp(str);
+0166 disp('' );
+0167 str = ' ' ;
+0168 for i=1:M_.exo_nbr
+0169 str = [str sprintf('%16f' ,M_.Sigma_e(i,i))];
+0170 end
+0171 disp(str);
+0172
+0173
+0174
+0175
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/calib_obj.html b/matlab/doc/calib_obj.html
new file mode 100644
index 000000000..95f0681ee
--- /dev/null
+++ b/matlab/doc/calib_obj.html
@@ -0,0 +1,114 @@
+
+
+
+ Description of calib_obj
+
+
+
+
+
+
+
+
+
+
+
+
+
+calib_obj
+
+
+ PURPOSE
+targets and iy order: 1) variances 2) correlations
+
+ SYNOPSIS
+function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)
+0004 global vx fold
+0005
+0006 oo_.gamma_y = cell(nar+1,1);
+0007
+0008 M_.Sigma_e=diag(M_.Sigma_e);
+0009 nx = size(ghx,2);
+0010 b=ghu1*M_.Sigma_e*ghu1';
+0011 vx = [];
+0012 if isempty(vx)
+0013 vx = lyapunov_symm (A,b);
+0014 else
+0015 [vx,status] = bicgstab (@f_var ,b(:),vx(:),1e-8,50,A,nx);
+0016 if status
+0017 vx = lyapunov_symm (A,b);
+0018 else
+0019 vx=reshape(vx,nx,nx);
+0020 end
+0021 end
+0022 oo_.gamma_y{1} = ghx*vx*ghx'+ ghu*M_.Sigma_e*ghu';
+0023 f = 0;
+0024 if ~isempty(targets{1})
+0025 e = targets{1}-sqrt(oo_.gamma_y{1}(iy{1}));
+0026 f = e'*(var_weights{1}.*e);
+0027 end
+0028
+0029 sy = sqrt(diag(oo_.gamma_y{1}));
+0030 sy = sy *sy';
+0031 if ~isempty(targets{2})
+0032 e = targets{2}-oo_.gamma_y{1}(iy{2})./(sy(iy{2})+1e-10);
+0033 f = f+e'*(var_weights{2}.*e);
+0034 end
+0035
+0036 if ~isempty(targets{3})
+0037 e = targets{3}-sqrt(M_.Sigma_e(iy{3}));
+0038 f = f+e'*(var_weights{3}.*e);
+0039 end
+0040
+0041
+0042 if nar > 0
+0043 vxy = (A*vx*ghx'+ghu1*M_.Sigma_e*ghu');
+0044
+0045 oo_.gamma_y{2} = ghx*vxy./(sy+1e-10);
+0046 if ~isempty(targets{4})
+0047 e = targets{4}-oo_.gamma_y{2}(iy{4});
+0048 f = f+e'*(var_weights{4}.*e);
+0049 end
+0050
+0051 for i=2:nar
+0052 vxy = A*vxy;
+0053 oo_.gamma_y{i+1} = ghx*vxy./(sy+1e-10);
+0054 if ~isempty(targets{i+3})
+0055 e = targets{i+3}-oo_.gamma_y{i+1}(iy{i+3});
+0056 f = f+e'*(var_weights{i+3}.*e);
+0057 end
+0058 end
+0059 end
+0060 if isempty(fold) | f < 2*fold
+0061 fold = f;
+0062 vxold = vx;
+0063 end
+0064
+0065
+0066
+0067
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/calib_obj2.html b/matlab/doc/calib_obj2.html
new file mode 100644
index 000000000..d1da90a62
--- /dev/null
+++ b/matlab/doc/calib_obj2.html
@@ -0,0 +1,93 @@
+
+
+
+ Description of calib_obj2
+
+
+
+
+
+
+
+
+
+
+
+
+
+calib_obj2
+
+
+ PURPOSE
+targets and iy order: 1) variances 2) correlations
+
+ SYNOPSIS
+function objective=calib_obj2(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function objective=calib_obj2(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)
+0004 global vx fold
+0005
+0006 objective = cell (nar+3);
+0007 oo_.gamma_y = cell(nar+1,1);
+0008 M_.Sigma_e=diag(M_.Sigma_e);
+0009 nx = size(ghx,2);
+0010 b=ghu1*M_.Sigma_e*ghu1';
+0011 vx = lyapunov_symm (A,b);
+0012 oo_.gamma_y{1} = ghx*vx*ghx'+ ghu*M_.Sigma_e*ghu';
+0013 if ~isempty(targets{1})
+0014 objective{1} = sqrt(oo_.gamma_y{1}(iy{1}));
+0015 end
+0016
+0017 sy = sqrt(diag(oo_.gamma_y{1}));
+0018 sy = sy *sy';
+0019 if ~isempty(targets{2})
+0020 objective{2} = oo_.gamma_y{1}(iy{2})./(sy(iy{2})+1e-10);
+0021 end
+0022
+0023 if ~isempty(targets{3})
+0024 objective{3} = M_.Sigma_e(iy{3});
+0025 end
+0026
+0027
+0028 if nar > 0
+0029 vxy = (A*vx*ghx'+ghu1*M_.Sigma_e*ghu');
+0030
+0031 oo_.gamma_y{2} = ghx*vxy./(sy+1e-10);
+0032 if ~isempty(targets{4})
+0033 objective{4} = oo_.gamma_y{2}(iy{4});
+0034 end
+0035
+0036 for i=2:nar
+0037 vxy = A*vxy;
+0038 oo_.gamma_y{i+1} = ghx*vxy./(sy+1e-10);
+0039 if ~isempty(targets{i+3})
+0040 objecitve{i+3} = oo_.gamma_y{i+1}(iy{i+3});
+0041 end
+0042 end
+0043 end
+0044
+0045
+0046
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/check.html b/matlab/doc/check.html
new file mode 100644
index 000000000..6403f8378
--- /dev/null
+++ b/matlab/doc/check.html
@@ -0,0 +1,115 @@
+
+
+
+ Description of check
+
+
+
+
+
+
+
+
+
+
+
+
+
+check
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function result = check
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+lnsrch Copyright (C) 2001 Michel Juillardlnsrch1 Copyright (C) 2001 Michel Juillardnewrat olr1 Copyright (C) 2001 Michel Juillardosr1 simult_ Copyright (C) 2001 Michel Juillardsolve1 Copyright (C) 2001 Michel Juillardsteady_ Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004 function result = check
+0005 global M_ options_ oo_
+0006 global it_
+0007
+0008 temp_options = options_;
+0009 tempex = oo_.exo_simul;
+0010 if ~options_.initval_file
+0011 oo_.exo_simul = ones(M_.maximum_lead+M_.maximum_lag+1,1)*oo_.exo_steady_state';
+0012 end
+0013
+0014 options_ = set_default_option (options_,'noprint' ,0);
+0015 options_ = set_default_option (options_,'order' ,1);
+0016 options_ = set_default_option (options_,'linear' ,0);
+0017 options_ = set_default_option (options_,'dr_algo' ,0);
+0018
+0019 [dr, info] = resol (oo_.steady_state,1);
+0020
+0021 if info(1) ~= 0 & info(1) ~= 3 & info(1) ~= 4
+0022 print_info (info);
+0023 end
+0024
+0025 oo_.exo_simul = tempex;
+0026
+0027 eigenvalues_ = dr.eigval;
+0028 nyf = nnz(dr.kstate(:,2)>M_.maximum_lag+1);
+0029 [m_lambda,i]=sort(abs(eigenvalues_));
+0030
+0031 if options_.noprint == 0
+0032 disp(' ' )
+0033 disp('EIGENVALUES:' )
+0034 disp(sprintf('%16s %16s %16s\n' ,'Modulus' ,'Real' ,'Imaginary' ))
+0035 z=[m_lambda real(eigenvalues_(i)) imag(eigenvalues_(i))]';
+0036 disp(sprintf('%16.4g %16.4g %16.4g\n' ,z))
+0037 options_ = set_default_option (options_,'qz_criterium' ,1.000001);
+0038 disp(sprintf('\nThere are %d eigenvalue(s) larger than 1 in modulus ' , ...
+0039 nnz(abs(eigenvalues_) > options_.qz_criterium)));
+0040 disp(sprintf('for %d forward-looking variable(s)' ,nyf));
+0041 disp(' ' )
+0042 if info(1) == 0
+0043 if dr.rank == nyf
+0044 disp('The rank condition is verified.' )
+0045 else
+0046 disp('The rank conditions ISN''T verified!' )
+0047 end
+0048 disp(' ' )
+0049 end
+0050 end
+0051
+0052
+0053 lambda_ = eigenvalues_;
+0054
+0055 options_ = temp_options;
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/check_mh.html b/matlab/doc/check_mh.html
new file mode 100644
index 000000000..dcf11f073
--- /dev/null
+++ b/matlab/doc/check_mh.html
@@ -0,0 +1,70 @@
+
+
+
+ Description of check_mh
+
+
+
+
+
+
+
+
+
+
+
+
+
+check_mh
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function check_mh(fname)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+my_subplot spreads subplots on several figures according to a maximum number of
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function check_mh(fname)
+0002 eval(['load ' fname]);
+0003 nb = size(x3,3);
+0004 np = size(x2,2);
+0005 nr = size(x2,1);
+0006
+0007 j1 = ceil(0.5*nr);
+0008 x = [j1:100:nr];
+0009 z = [];
+0010 for i=1:np
+0011 y1 = zeros(size(x),nb);
+0012 for k=1:nb
+0013 for j=1:length(x)
+0014 y1(j,k) = mean(x2(1:x(j),i,k));
+0015 end
+0016 end
+0017 my_subplot (i,np,4,5,'MH convergence' );
+0018 plot([y1])
+0019 xmin = min(min(x2(:,i,:)));
+0020 xmax = max(max(x2(:,i,:)));
+0021 z = [z; [i sum(sum(x3(:,i,:) < xmin))/nr sum(sum(x3(:,i) > xmax))/nr]];
+0022 end
+0023 disp(z)
+0024
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/check_model.html b/matlab/doc/check_model.html
new file mode 100644
index 000000000..c95ba0544
--- /dev/null
+++ b/matlab/doc/check_model.html
@@ -0,0 +1,64 @@
+
+
+
+ Description of check_model
+
+
+
+
+
+
+
+
+
+
+
+
+
+check_model
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function check_model()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function check_model()
+0002 global M_
+0003
+0004 xlen = M_.maximum_exo_lag+M_.maximum_exo_lead + 1;
+0005 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0006 error ('RESOL: Error in model specification: some variables don"t appear as current' ) ;
+0007 end
+0008
+0009 if xlen > 1
+0010 error (['RESOL: stochastic exogenous variables must appear only at the' ...
+0011 ' current period. Use additional endogenous variables' ]) ;
+0012 end
+0013
+0014 if (M_.exo_det_nbr > 0) & (M_.maximum_lag > 1 | M_.maximum_lead > 1)
+0015 error(['Exogenous deterministic variables are currently only allowed in' ...
+0016 ' models with leads and lags on only one period' ])
+0017 end
+0018
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/compDist.html b/matlab/doc/compDist.html
new file mode 100644
index 000000000..547c7632f
--- /dev/null
+++ b/matlab/doc/compDist.html
@@ -0,0 +1,217 @@
+
+
+
+ Description of compDist
+
+
+
+
+
+
+
+
+
+
+
+
+
+compDist
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function compdist(xparam1, x2, pltopt, figurename)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function compdist(xparam1, x2, pltopt, figurename)
+0002 global bayestopt_ estim_params_ M_ options_
+0003
+0004
+0005
+0006
+0007 number_of_grid_points = 2^9;
+0008 bandwidth = 0;
+0009 kernel_function = 'gaussian' ;
+0010
+0011 truncprior = 10^(-3);
+0012
+0013
+0014 npar=length(xparam1);
+0015 nruns=length(x2);
+0016 icol=ceil(sqrt(npar));
+0017 iraw=icol;
+0018 if (icol-1)*(icol-2)>=npar
+0019 iraw = icol-2;
+0020 icol=icol-1;
+0021 elseif (icol)*(icol-2)>=npar
+0022 iraw = icol-2;
+0023 elseif icol*(icol-1)>=npar
+0024 iraw=icol-1;
+0025 end
+0026
+0027 pmean=bayestopt_.pmean;
+0028 pshape=bayestopt_.pshape;
+0029 p1 = bayestopt_.p1;
+0030 p2 = bayestopt_.p2;
+0031 p3 = bayestopt_.p3;
+0032 p4 = bayestopt_.p4;
+0033
+0034 figure('Name' ,figurename)
+0035 for i=1:npar;
+0036 if i<=estim_params_.nvx
+0037 vname = deblank(M_.exo_name(estim_params_.var_exo(i,1),:));
+0038 nam=['SE_{' ,vname,'}' ];
+0039 elseif i<=(estim_params_.nvx+estim_params_.nvn)
+0040 deblank(options_.varobs(estim_params_.var_endo(i-estim_params_.nvx,1),:));
+0041 nam=['SE_{EOBS_' ,vname,'}' ];
+0042 elseif i<=(estim_params_.nvx+estim_params_.nvn+estim_params_.ncx)
+0043 j = i - (estim_params_.nvx+estim_params_.nvn);
+0044 k1 = estim_params_.corrx(j,1);
+0045 k2 = estim_params_.corrx(j,2);
+0046 vname = [deblank(M_.exo_name(k1,:)) ',' deblank(M_.exo_name(k2,:))];
+0047 nam=['CC_{' ,vname,'}' ];
+0048 elseif i<=(estim_params_.nvx+estim_params_.nvn+estim_params_.ncx+ ...
+0049 estim_params_.ncn)
+0050 j = i - (estim_params_.nvx+estim_params_.nvn+estim_params_.ncx);
+0051 k1 = estim_params_.corrn(j,1);
+0052 k2 = estim_params_.corrn(j,2);
+0053 vname = [deblank(M_.exo_name(k1,:)) ',' deblank(M_.exo_name(k2,:))];
+0054 nam=['CC_{EOBS_' ,vname,'}' ];
+0055 else
+0056 j = i - (estim_params_.nvx+estim_params_.nvn+estim_params_.ncx+ ...
+0057 estim_params_.ncn);
+0058 nam = deblank(estim_params_.param_names(j,:));
+0059 end
+0060 subplot(iraw, icol, i);
+0061 if strcmpi(pltopt,'all' );
+0062 [abscissa,ff,h] = posterior_density_estimate (x2(round(options_.mh_drop*nruns):end ,i),...
+0063 number_of_grid_points,bandwidth,kernel_function);
+0064 plot(abscissa,ff,'-k' ,'linewidth' ,2);
+0065 end ;
+0066 a = 0;
+0067 b = 0;
+0068 if pshape(i) == 1;
+0069 density = inline('((1-x).^(b-1)).*x.^(a-1)./beta(a,b)' ,'x' ,'a' ,'b' );
+0070 mu = (p1(i)-p3(i))/(p4(i)-p3(i));
+0071 stdd = p2(i)/(p4(i)-p3(i));
+0072 a = (1-mu)*mu^2/stdd^2 - mu;
+0073 b = a*(1/mu - 1);
+0074 infbound = qbeta (truncprior,a,b);
+0075 supbound = qbeta (1-truncprior,a,b);
+0076 stepsize = (supbound-infbound)/200;
+0077 abscissa = infbound:stepsize:supbound;
+0078 f = density(abscissa,a,b);
+0079 abscissa = abscissa*(p4(i)-p3(i))+p3(i);
+0080 if strcmp(pltopt,'all' );
+0081 top = max([max(ff);max(f)]);
+0082 end ;
+0083 elseif pshape(i) == 2;
+0084
+0085
+0086 mu = p1(i)-p3(i);
+0087 b = p2(i)^2/mu;
+0088 a = mu/b;
+0089 infbound = mj_qgamma (truncprior,a)*b;
+0090 supbound = mj_qgamma (1-truncprior,a)*b;
+0091 stepsize = (supbound-infbound)/200;
+0092 abscissa = infbound:stepsize:supbound;
+0093 f = exp(lpdfgam (abscissa,a,b));
+0094 abscissa = abscissa + p3(i);
+0095 if strcmp(pltopt,'all' );
+0096 top = max([max(ff);max(f)]);
+0097 end ;
+0098 elseif pshape(i) == 3;
+0099 density = inline('inv(sqrt(2*pi)*b)*exp(-0.5*((x-a)/b).^2)' ,'x' ,'a' ,'b' );
+0100 a = p1(i);
+0101 b = p2(i);
+0102 infbound = qnorm (truncprior,a,b);
+0103 supbound = qnorm (1-truncprior,a,b);
+0104 stepsize = (supbound-infbound)/200;
+0105 abscissa = infbound:stepsize:supbound;
+0106 f = density(abscissa,a,b);
+0107 if strcmp(pltopt,'all' );
+0108 top = max([max(ff);max(f)]);
+0109 end ;
+0110 elseif pshape(i) == 4;
+0111 density = inline('2*inv(gamma(nu/2))*(x.^(-nu-1))*((s/2)^(nu/2)).*exp(-s./(2*x.^2))' ,'x' ,'s' ,'nu' );
+0112 nu = p2(i);
+0113 s = p1(i);
+0114 a = nu/2;
+0115 b = 2/s;
+0116 infbound = 1/sqrt(mj_qgamma (1-10*truncprior,a)*b);
+0117 supbound = 1/sqrt(mj_qgamma (10*truncprior,a)*b);
+0118 stepsize = (supbound-infbound)/200;
+0119 abscissa = infbound:stepsize:supbound;
+0120 f = density(abscissa,s,nu);
+0121 if strcmp(pltopt,'all' );
+0122 top = max([max(ff);max(f)]);
+0123 end ;
+0124 elseif pshape(i) == 5;
+0125 density = inline('(x.^0)/(b-a)' ,'x' ,'a' ,'b' );
+0126 a = p1(i);
+0127 b = p2(i);
+0128 infbound = a;
+0129 supbound = b;
+0130 stepsize = (supbound-infbound)/200;
+0131 abscissa = infbound:stepsize:supbound;
+0132 f = density(abscissa,a,b);
+0133 if strcmp(pltopt,'all' );
+0134 top = max([max(ff);max(f)]);
+0135 end ;
+0136 elseif pshape(i) == 6;
+0137 density = inline('inv(gamma(nu/2))*(x.^(-.5(nu+2)))*((s/2)^(nu/2)).*exp(-s./(2*x))' ,'x' ,'s' ,'nu' );
+0138 nu = p2(i);
+0139 s = p1(i);
+0140 a = nu/2;
+0141 b = 2/s;
+0142 infbound = 1/(qgamma (1-truncprior,a)*b);
+0143 supbound = 1/(qgamma (truncprior,a)*b);
+0144 stepsize = (supbound-infbound)/200;
+0145 abscissa = infbound:stepsize:supbound;
+0146 f = density(abscissa,s,nu);
+0147 if strcmp(pltopt,'all' );
+0148 top = max([max(ff);max(f)]);
+0149 end ;
+0150 end ;
+0151 hold on;
+0152 k = [1:length(f)];
+0153 if pshape(i) ~= 5
+0154 [junk,k1] = max(f);
+0155 if k1 == 1 | k1 == length(f)
+0156 k = find(f < 10);
+0157 end
+0158 end
+0159 hh = plot(abscissa(k),f(k),'-k' ,'linewidth' ,2);
+0160 set(hh,'color' ,[0.7 0.7 0.7]);
+0161
+0162 if strcmp(pltopt,'all' );
+0163 plot( [xparam1(i) xparam1(i)], [0,top], '--g' , 'linewidth' , 2);
+0164 end ;
+0165 title(nam,'Interpreter' ,'none' );
+0166 hold off;
+0167 end ;
+0168 drawnow
+0169
+0170
+0171
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/csminit.html b/matlab/doc/csminit.html
new file mode 100644
index 000000000..dfae370fe
--- /dev/null
+++ b/matlab/doc/csminit.html
@@ -0,0 +1,257 @@
+
+
+
+ Description of csminit
+
+
+
+
+
+
+
+
+
+
+
+
+
+csminit
+
+
+ PURPOSE
+[fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...
+
+ SYNOPSIS
+function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+csminwel [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)mr_gstep Copyright (C) 2005 Marco Rattonewrat
+
+
+
+ SOURCE CODE
+0001 function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024 ANGLE = .005;
+0025
+0026 THETA = .3;
+0027 FCHANGE = 1000;
+0028 MINLAMB = 1e-9;
+0029
+0030
+0031
+0032 MINDFAC = .01;
+0033 fcount=0;
+0034 lambda=1;
+0035 xhat=x0;
+0036 f=f0;
+0037 fhat=f0;
+0038 g = g0;
+0039 gnorm = norm(g);
+0040
+0041 if (gnorm < 1.e-12) & ~badg
+0042 retcode =1;
+0043 dxnorm=0;
+0044
+0045 else
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065 dx = -H0*g;
+0066
+0067 dxnorm = norm(dx);
+0068 if dxnorm > 1e12
+0069 disp('Near-singular H problem.' )
+0070 dx = dx*FCHANGE/dxnorm;
+0071 end
+0072 dfhat = dx'*g0;
+0073
+0074
+0075
+0076 if ~badg
+0077
+0078 a = -dfhat/(gnorm*dxnorm);
+0079 if a<ANGLE
+0080 dx = dx - (ANGLE*dxnorm/gnorm+dfhat/(gnorm*gnorm))*g;
+0081 dfhat = dx'*g;
+0082 dxnorm = norm(dx);
+0083 disp(sprintf('Correct for low angle: %g' ,a))
+0084 end
+0085 end
+0086 disp(sprintf('Predicted improvement: %18.9f' ,-dfhat/2))
+0087
+0088
+0089
+0090 done=0;
+0091 factor=3;
+0092 shrink=1;
+0093 lambdaMin=0;
+0094 lambdaMax=inf;
+0095 lambdaPeak=0;
+0096 fPeak=f0;
+0097 lambdahat=0;
+0098 while ~done
+0099 if size(x0,2)>1
+0100 dxtest=x0+dx'*lambda;
+0101 else
+0102 dxtest=x0+dx*lambda;
+0103 end
+0104
+0105 f = eval([fcn '(dxtest,varargin{:})' ]);
+0106
+0107
+0108
+0109 disp(sprintf('lambda = %10.5g; f = %20.7f' ,lambda,f ))
+0110
+0111
+0112 if f<fhat
+0113 fhat=f;
+0114 xhat=dxtest;
+0115 lambdahat = lambda;
+0116 end
+0117 fcount=fcount+1;
+0118 shrinkSignal = (~badg & (f0-f < max([-THETA*dfhat*lambda 0]))) | (badg & (f0-f) < 0) ;
+0119 growSignal = ~badg & ( (lambda > 0) & (f0-f > -(1-THETA)*dfhat*lambda) );
+0120 if shrinkSignal & ( (lambda>lambdaPeak) | (lambda<0) )
+0121 if (lambda>0) & ((~shrink) | (lambda/factor <= lambdaPeak))
+0122 shrink=1;
+0123 factor=factor^.6;
+0124 while lambda/factor <= lambdaPeak
+0125 factor=factor^.6;
+0126 end
+0127
+0128 if abs(factor-1)<MINDFAC
+0129 if abs(lambda)<4
+0130 retcode=2;
+0131 else
+0132 retcode=7;
+0133 end
+0134 done=1;
+0135 end
+0136 end
+0137 if (lambda<lambdaMax) & (lambda>lambdaPeak)
+0138 lambdaMax=lambda;
+0139 end
+0140 lambda=lambda/factor;
+0141 if abs(lambda) < MINLAMB
+0142 if (lambda > 0) & (f0 <= fhat)
+0143
+0144 lambda = -lambda*factor^6
+0145 else
+0146 if lambda < 0
+0147 retcode = 6;
+0148 else
+0149 retcode = 3;
+0150 end
+0151 done = 1;
+0152 end
+0153 end
+0154 elseif (growSignal & lambda>0) | (shrinkSignal & ((lambda <= lambdaPeak) & (lambda>0)))
+0155 if shrink
+0156 shrink=0;
+0157 factor = factor^.6;
+0158
+0159 if abs(factor-1)<MINDFAC
+0160 if abs(lambda)<4
+0161 retcode=4;
+0162 else
+0163 retcode=7;
+0164 end
+0165 done=1;
+0166 end
+0167 end
+0168 if ( f<fPeak ) & (lambda>0)
+0169 fPeak=f;
+0170 lambdaPeak=lambda;
+0171 if lambdaMax<=lambdaPeak
+0172 lambdaMax=lambdaPeak*factor*factor;
+0173 end
+0174 end
+0175 lambda=lambda*factor;
+0176 if abs(lambda) > 1e20;
+0177 retcode = 5;
+0178 done =1;
+0179 end
+0180 else
+0181 done=1;
+0182 if factor < 1.2
+0183 retcode=7;
+0184 else
+0185 retcode=0;
+0186 end
+0187 end
+0188 end
+0189 end
+0190 disp(sprintf('Norm of dx %10.5g' , dxnorm))
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/csminwel.html b/matlab/doc/csminwel.html
new file mode 100644
index 000000000..08813a49f
--- /dev/null
+++ b/matlab/doc/csminwel.html
@@ -0,0 +1,337 @@
+
+
+
+ Description of csminwel
+
+
+
+
+
+
+
+
+
+
+
+
+
+csminwel
+
+
+ PURPOSE
+[fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)
+
+ SYNOPSIS
+function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+bfgsi H = bfgsi(H0,dg,dx)csminit [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...numgrad function [g badg] = numgrad(fcn,xvarargin)
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019 global bayestopt_
+0020 [nx,no]=size(x0);
+0021 nx=max(nx,no);
+0022 Verbose=1;
+0023 NumGrad= isempty(grad);
+0024 done=0;
+0025 itct=0;
+0026 fcount=0;
+0027 snit=100;
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038 f0 = feval(fcn,x0,varargin{:});
+0039
+0040
+0041
+0042 if f0 > 1e50, disp('Bad initial parameter.' ), return , end
+0043 if NumGrad
+0044 if length(grad)==0
+0045 [g badg] = numgrad (fcn,x0, varargin{:});
+0046
+0047
+0048 else
+0049 badg=any(find(grad==0));
+0050 g=grad;
+0051 end
+0052
+0053 else
+0054 [g badg] = feval(grad,x0,varargin{:});
+0055
+0056
+0057 end
+0058 retcode3=101;
+0059 x=x0;
+0060 f=f0;
+0061 H=H0;
+0062 cliff=0;
+0063 while ~done
+0064 bayestopt_.penalty = f;
+0065 g1=[]; g2=[]; g3=[];
+0066
+0067 disp('-----------------' )
+0068 disp('-----------------' )
+0069
+0070 disp(sprintf('f at the beginning of new iteration, %20.10f' ,f))
+0071
+0072
+0073
+0074 itct=itct+1;
+0075 [f1 x1 fc retcode1] = csminit (fcn,x,f,g,badg,H,varargin{:});
+0076
+0077
+0078
+0079
+0080 fcount = fcount+fc;
+0081
+0082
+0083
+0084
+0085
+0086
+0087
+0088
+0089 if retcode1 ~= 1
+0090 if retcode1==2 | retcode1==4
+0091 wall1=1; badg1=1;
+0092 else
+0093 if NumGrad
+0094 [g1 badg1] = numgrad (fcn, x1,varargin{:});
+0095
+0096
+0097
+0098 else
+0099 [g1 badg1] = feval(grad,x1,varargin{:});
+0100
+0101
+0102
+0103 end
+0104 wall1=badg1;
+0105
+0106 save g1 g1 x1 f1 varargin;
+0107
+0108
+0109 end
+0110 if wall1
+0111
+0112
+0113
+0114
+0115 Hcliff=H+diag(diag(H).*rand(nx,1));
+0116 disp('Cliff. Perturbing search direction.' )
+0117 [f2 x2 fc retcode2] = csminit (fcn,x,f,g,badg,Hcliff,varargin{:});
+0118
+0119
+0120
+0121 fcount = fcount+fc;
+0122 if f2 < f
+0123 if retcode2==2 | retcode2==4
+0124 wall2=1; badg2=1;
+0125 else
+0126 if NumGrad
+0127 [g2 badg2] = numgrad (fcn, x2,varargin{:});
+0128
+0129
+0130
+0131 else
+0132 [g2 badg2] = feval(grad,x2,varargin{:});
+0133
+0134
+0135
+0136 end
+0137 wall2=badg2;
+0138
+0139 badg2
+0140 save g2 g2 x2 f2 varargin
+0141
+0142
+0143 end
+0144 if wall2
+0145 disp('Cliff again. Try traversing' )
+0146 if norm(x2-x1) < 1e-13
+0147 f3=f; x3=x; badg3=1;retcode3=101;
+0148 else
+0149 gcliff=((f2-f1)/((norm(x2-x1))^2))*(x2-x1);
+0150 if (size(x0,2)>1), gcliff=gcliff', end
+0151 [f3 x3 fc retcode3] = csminit (fcn,x,f,gcliff,0,eye(nx),varargin{:});
+0152
+0153
+0154
+0155
+0156 fcount = fcount+fc;
+0157 if retcode3==2 | retcode3==4
+0158 wall3=1; badg3=1;
+0159 else
+0160 if NumGrad
+0161 [g3 badg3] = numgrad (fcn, x3,varargin{:});
+0162
+0163
+0164
+0165 else
+0166 [g3 badg3] = feval(grad,x3,varargin{:});
+0167
+0168
+0169
+0170 end
+0171 wall3=badg3;
+0172
+0173 badg3
+0174 save g3 g3 x3 f3 varargin;
+0175
+0176
+0177 end
+0178 end
+0179 else
+0180 f3=f; x3=x; badg3=1; retcode3=101;
+0181 end
+0182 else
+0183 f3=f; x3=x; badg3=1;retcode3=101;
+0184 end
+0185 else
+0186
+0187 f2=f; f3=f; badg2=1; badg3=1; retcode2=101; retcode3=101;
+0188 end
+0189 else
+0190 f2=f;f3=f;f1=f;retcode2=retcode1;retcode3=retcode1;
+0191 end
+0192
+0193 if f3 < f - crit & badg3==0
+0194 ih=3
+0195 fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3;
+0196 elseif f2 < f - crit & badg2==0
+0197 ih=2
+0198 fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2;
+0199 elseif f1 < f - crit & badg1==0
+0200 ih=1
+0201 fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1;
+0202 else
+0203 [fh,ih] = min([f1,f2,f3]);
+0204 disp(sprintf('ih = %d' ,ih))
+0205
+0206 switch ih
+0207 case 1
+0208 xh=x1;
+0209 case 2
+0210 xh=x2;
+0211 case 3
+0212 xh=x3;
+0213 end
+0214
+0215
+0216 retcodei=[retcode1,retcode2,retcode3];
+0217 retcodeh=retcodei(ih);
+0218 if exist('gh' )
+0219 nogh=isempty(gh);
+0220 else
+0221 nogh=1;
+0222 end
+0223 if nogh
+0224 if NumGrad
+0225 [gh badgh] = numgrad (fcn,xh,varargin{:});
+0226 else
+0227 [gh badgh] = feval(grad, xh,varargin{:});
+0228 end
+0229 end
+0230 badgh=1;
+0231 end
+0232
+0233
+0234
+0235
+0236
+0237
+0238 stuck = (abs(fh-f) < crit);
+0239 if (~badg)&(~badgh)&(~stuck)
+0240 H = bfgsi (H,gh-g,xh-x);
+0241 end
+0242 if Verbose
+0243 disp('----' )
+0244 disp(sprintf('Improvement on iteration %d = %18.9f' ,itct,f-fh))
+0245 end
+0246
+0247 if itct > nit
+0248 disp('iteration count termination' )
+0249 done = 1;
+0250 elseif stuck
+0251 disp('improvement < crit termination' )
+0252 done = 1;
+0253 end
+0254 rc=retcodeh;
+0255 if rc == 1
+0256 disp('zero gradient' )
+0257 elseif rc == 6
+0258 disp('smallest step still improving too slow, reversed gradient' )
+0259 elseif rc == 5
+0260 disp('largest step still improving too fast' )
+0261 elseif (rc == 4) | (rc==2)
+0262 disp('back and forth on step length never finished' )
+0263 elseif rc == 3
+0264 disp('smallest step still improving too slow' )
+0265 elseif rc == 7
+0266 disp('warning: possible inaccuracy in H matrix' )
+0267 end
+0268
+0269 f=fh;
+0270 x=xh;
+0271 g=gh;
+0272 badg=badgh;
+0273 end
+0274
+0275
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/cumplot.html b/matlab/doc/cumplot.html
new file mode 100644
index 000000000..80fd9cd55
--- /dev/null
+++ b/matlab/doc/cumplot.html
@@ -0,0 +1,61 @@
+
+
+
+ Description of cumplot
+
+
+
+
+
+
+
+
+
+
+
+
+
+cumplot
+
+
+ PURPOSE
+function h =cumplot(x)
+
+ SYNOPSIS
+function h = cumplot(x);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+filt_mc_ copyright Marco Ratto 2006stab_map_1 function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)
+
+
+
+ SOURCE CODE
+0001 function h = cumplot(x);
+0002
+0003
+0004
+0005
+0006 n=length(x);
+0007 x=[-inf; sort(x); Inf];
+0008 y=[0:n n]./n;
+0009 h0 = stairs(x,y);
+0010 grid on,
+0011
+0012 if nargout,
+0013 h=h0;
+0014 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/datatomfile.html b/matlab/doc/datatomfile.html
new file mode 100644
index 000000000..6c53041c0
--- /dev/null
+++ b/matlab/doc/datatomfile.html
@@ -0,0 +1,95 @@
+
+
+
+ Description of datatomfile
+
+
+
+
+
+
+
+
+
+
+
+
+
+datatomfile
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function datatomfile (s,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function datatomfile (s,var_list)
+0004
+0005
+0006
+0007
+0008
+0009
+0010 global M_ oo_
+0011
+0012
+0013 sm=[s,'.m' ];
+0014 fid=fopen(sm,'w' ) ;
+0015
+0016 n = size(var_list,1);
+0017 if n == 0
+0018 n = M_.endo_nbr;
+0019 ivar = [1:n]';
+0020 var_list = M_.endo_names;
+0021 else
+0022 ivar=zeros(n,1);
+0023 for i=1:n
+0024 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0025 if isempty(i_tmp)
+0026 error (['One of the specified variables does not exist' ]) ;
+0027 else
+0028 ivar(i) = i_tmp;
+0029 end
+0030 end
+0031 end
+0032
+0033
+0034 for i = 1:n
+0035 fprintf(fid,[M_.endo_names(ivar(i),:), '=[' ],'\n' ) ;
+0036 fprintf(fid,'\n' ) ;
+0037 fprintf(fid,'%15.8g\n' ,oo_.endo_simul(ivar(i),:)') ;
+0038 fprintf(fid,'\n' ) ;
+0039 fprintf(fid,'];\n' ) ;
+0040 fprintf(fid,'\n' ) ;
+0041 end
+0042 fclose(fid) ;
+0043
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dbeta.html b/matlab/doc/dbeta.html
new file mode 100644
index 000000000..e8985fa57
--- /dev/null
+++ b/matlab/doc/dbeta.html
@@ -0,0 +1,64 @@
+
+
+
+ Description of dbeta
+
+
+
+
+
+
+
+
+
+
+
+
+
+dbeta
+
+
+ PURPOSE
+DBETA The beta density function
+
+ SYNOPSIS
+function d = dbeta(x,a,b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+qbeta QBETA The beta inverse distribution function
+
+
+
+ SOURCE CODE
+0001 function d = dbeta(x,a,b)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if any(any((a<=0)|(b<=0)))
+0010 error('Parameter a or b is nonpositive' )
+0011 end
+0012
+0013 I = find((x<0)|(x>1));
+0014
+0015 d = x.^(a-1) .* (1-x).^(b-1) ./ beta(a,b);
+0016 d(I) = 0*I;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dcompare.html b/matlab/doc/dcompare.html
new file mode 100644
index 000000000..834197703
--- /dev/null
+++ b/matlab/doc/dcompare.html
@@ -0,0 +1,87 @@
+
+
+
+ Description of dcompare
+
+
+
+
+
+
+
+
+
+
+
+
+
+dcompare
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dcompare(s1)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+bseastr Copyright (C) 2001 Michel Juillardftest Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dcompare(s1)
+0004
+0005 global options_ nvx nvy x y lag1
+0006
+0007 ftest (s1,0) ;
+0008
+0009 i = [lag1(1):size(x,2)-lag1(2)+1]' ;
+0010
+0011 if size(options_.smpl,1) == 1
+0012 error(['DSAMPLE not specified.' ]) ;
+0013 end
+0014
+0015 if options_.smpl(3) > 0
+0016 if options_.smpl(3) == 2
+0017 if options_.smpl(1)<0 | options_.smpl(2)>size(x,2)-lag1(2)
+0018 error ('Wrong sample.' ) ;
+0019 end
+0020 i = [options_.smpl(1)+lag1(1):options_.smpl(2)+lag1(1)]' ;
+0021 elseif options_.smpl(3) == 1
+0022 if options_.smpl(1)>size(x,2)-lag1(2)
+0023 error ('Wrong sample.' ) ;
+0024 end
+0025 i = [lag1(1):options_.smpl(1)+lag1(1)]' ;
+0026 end
+0027 end
+0028
+0029 j = bseastr (nvx,nvy) ;
+0030
+0031 if stop
+0032 return ;
+0033 end
+0034
+0035 z = mean(mean(abs(x(j,i)-y(j,i)))) ;
+0036
+0037 disp (['The mean absolute difference between set ' s1(1,:) 'and set ' s1(2,:)]) ;
+0038 disp (['is : ' num2str(z)]) ;
+0039 return ;
+0040
+0041
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/demoicon.gif b/matlab/doc/demoicon.gif
new file mode 100644
index 000000000..c89e7acbc
Binary files /dev/null and b/matlab/doc/demoicon.gif differ
diff --git a/matlab/doc/dgamma.html b/matlab/doc/dgamma.html
new file mode 100644
index 000000000..394445ee3
--- /dev/null
+++ b/matlab/doc/dgamma.html
@@ -0,0 +1,63 @@
+
+
+
+ Description of dgamma
+
+
+
+
+
+
+
+
+
+
+
+
+
+dgamma
+
+
+ PURPOSE
+DGAMMA The gamma density function
+
+ SYNOPSIS
+function f = dgamma(x,a,b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+qgamma QGAMMA The gamma inverse distribution function
+
+
+
+ SOURCE CODE
+0001 function f = dgamma(x,a,b)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if any(any(a<=0))
+0010 error('Parameter a is wrong' )
+0011 end
+0012
+0013 f = (x./b) .^ (a-1) .* exp(-x./b) ./ (b.*gamma(a));
+0014 I0 = find(x<0);
+0015 f(I0) = zeros(size(I0));
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/disp_dr.html b/matlab/doc/disp_dr.html
new file mode 100644
index 000000000..0ea59297e
--- /dev/null
+++ b/matlab/doc/disp_dr.html
@@ -0,0 +1,246 @@
+
+
+
+ Description of disp_dr
+
+
+
+
+
+
+
+
+
+
+
+
+
+disp_dr
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function disp_dr(dr,order,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function disp_dr(dr,order,var_list)
+0004 global M_
+0005
+0006 nx =size(dr.ghx,2);
+0007 nu =size(dr.ghu,2);
+0008 k = find(dr.kstate(:,2) <= M_.maximum_lag+1);
+0009 klag = dr.kstate(k,[1 2]);
+0010
+0011 k1 = dr.order_var;
+0012
+0013 nvar = size(var_list,1);
+0014 if nvar == 0
+0015 nvar = length(k1);
+0016 ivar = [1:nvar];
+0017 else
+0018 ivar=zeros(nvar,1);
+0019 for i=1:nvar
+0020 i_tmp = strmatch(var_list(i,:),M_.endo_names(k1,:),'exact' );
+0021 if isempty(i_tmp)
+0022 disp(var_list(i,:));
+0023 error (['One of the variable specified does not exist' ]) ;
+0024 else
+0025 ivar(i) = i_tmp;
+0026 end
+0027 end
+0028 end
+0029 disp('POLICY AND TRANSITION FUNCTIONS' )
+0030
+0031 str = ' ' ;
+0032 for i=1:nvar
+0033 str = [str sprintf('%16s' ,M_.endo_names(k1(ivar(i)),:))];
+0034 end
+0035 disp(str);
+0036
+0037
+0038
+0039 str = 'Constant ' ;
+0040 flag = 0;
+0041 for i=1:nvar
+0042 x = dr.ys(k1(ivar(i)));
+0043 if order > 1
+0044 x = x + dr.ghs2(ivar(i))/2;
+0045 end
+0046 if abs(x) > 1e-6
+0047 flag = 1;
+0048 str = [str sprintf('%16.6f' ,x)];
+0049 else
+0050 str = [str ' 0' ];
+0051 end
+0052 end
+0053 if flag
+0054 disp(str)
+0055 end
+0056 if order > 1
+0057 str = '(correction) ' ;
+0058 flag = 0;
+0059 for i=1:nvar
+0060 x = dr.ghs2(ivar(i))/2;
+0061 if abs(x) > 1e-6
+0062 flag = 1;
+0063 str = [str sprintf('%16.6f' ,x)];
+0064 else
+0065 str = [str ' 0' ];
+0066 end
+0067 end
+0068 if flag
+0069 disp(str)
+0070 end
+0071 end
+0072
+0073
+0074
+0075 for k=1:nx
+0076 flag = 0;
+0077 str1 = sprintf('%s(%d)' ,M_.endo_names(k1(klag(k,1)),:),klag(k,2)-M_.maximum_lag-2);
+0078 str = sprintf('%-20s' ,str1);
+0079 for i=1:nvar
+0080 x = dr.ghx(ivar(i),k);
+0081 if abs(x) > 1e-6
+0082 flag = 1;
+0083 str = [str sprintf('%16.6f' ,x)];
+0084 else
+0085 str = [str ' 0' ];
+0086 end
+0087 end
+0088 if flag
+0089 disp(str)
+0090 end
+0091 end
+0092
+0093
+0094
+0095 for k=1:nu
+0096 flag = 0;
+0097 str = sprintf('%-20s' ,M_.exo_names(k,:));
+0098 for i=1:nvar
+0099 x = dr.ghu(ivar(i),k);
+0100 if abs(x) > 1e-6
+0101 flag = 1;
+0102 str = [str sprintf('%16.6f' ,x)];
+0103 else
+0104 str = [str ' 0' ];
+0105 end
+0106 end
+0107 if flag
+0108 disp(str)
+0109 end
+0110 end
+0111
+0112 if order > 1
+0113
+0114 for k = 1:nx
+0115 for j = 1:k
+0116 flag = 0;
+0117 str1 = sprintf('%s(%d),%s(%d)' ,M_.endo_names(k1(klag(k,1)),:),klag(k,2)-M_.maximum_lag-2, ...
+0118 M_.endo_names(k1(klag(j,1)),:),klag(j,2)-M_.maximum_lag-2);
+0119 str = sprintf('%-20s' ,str1);
+0120 for i=1:nvar
+0121 if k == j
+0122 x = dr.ghxx(ivar(i),(k-1)*nx+j)/2;
+0123 else
+0124 x = dr.ghxx(ivar(i),(k-1)*nx+j);
+0125 end
+0126 if abs(x) > 1e-6
+0127 flag = 1;
+0128 str = [str sprintf('%16.6f' ,x)];
+0129 else
+0130 str = [str ' 0' ];
+0131 end
+0132 end
+0133 if flag
+0134 disp(str)
+0135 end
+0136 end
+0137 end
+0138
+0139
+0140
+0141 for k = 1:nu
+0142 for j = 1:k
+0143 flag = 0;
+0144 str = sprintf('%-20s' ,[M_.exo_names(k,:) ',' M_.exo_names(j,:)] );
+0145 for i=1:nvar
+0146 if k == j
+0147 x = dr.ghuu(ivar(i),(k-1)*nu+j)/2;
+0148 else
+0149 x = dr.ghuu(ivar(i),(k-1)*nu+j);
+0150 end
+0151 if abs(x) > 1e-6
+0152 flag = 1;
+0153 str = [str sprintf('%16.6f' ,x)];
+0154 else
+0155 str = [str ' 0' ];
+0156 end
+0157 end
+0158 if flag
+0159 disp(str)
+0160 end
+0161 end
+0162 end
+0163
+0164
+0165
+0166 for k = 1:nx
+0167 for j = 1:nu
+0168 flag = 0;
+0169 str1 = sprintf('%s(%d),%s' ,M_.endo_names(k1(klag(k,1)),:),klag(k,2)-M_.maximum_lag-2, ...
+0170 M_.exo_names(j,:));
+0171 str = sprintf('%-20s' ,str1);
+0172 for i=1:nvar
+0173 x = dr.ghxu(ivar(i),(k-1)*nu+j);
+0174 if abs(x) > 1e-6
+0175 flag = 1;
+0176 str = [str sprintf('%16.6f' ,x)];
+0177 else
+0178 str = [str ' 0' ];
+0179 end
+0180 end
+0181 if flag
+0182 disp(str)
+0183 end
+0184 end
+0185 end
+0186 end
+0187
+0188
+0189
+0190
+0191
+0192
+0193
+0194
+0195
+0196
+0197
+0198
+0199
+0200
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/disp_moments.html b/matlab/doc/disp_moments.html
new file mode 100644
index 000000000..c59b4e617
--- /dev/null
+++ b/matlab/doc/disp_moments.html
@@ -0,0 +1,128 @@
+
+
+
+ Description of disp_moments
+
+
+
+
+
+
+
+
+
+Home >
. > disp_moments.m
+
+
+
+disp_moments
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function disp_moments(y,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function disp_moments(y,var_list)
+0004 global M_ options_ oo_
+0005
+0006 warning off
+0007 nvar = size(var_list,1);
+0008 if nvar == 0
+0009 nvar = M_.endo_nbr;
+0010 ivar = [1:nvar]';
+0011 else
+0012 ivar=zeros(nvar,1);
+0013 for i=1:nvar
+0014 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0015 if isempty(i_tmp)
+0016 error (['One of the variable specified does not exist' ]) ;
+0017 else
+0018 ivar(i) = i_tmp;
+0019 end
+0020 end
+0021 end
+0022 y = y(ivar,options_.drop+M_.maximum_lag+1:end)';
+0023
+0024 m = mean(y);
+0025 y = y - repmat(m,size(y,1),1);
+0026 s2 = mean(y.*y);
+0027 s = sqrt(s2);
+0028 oo_.mean = m;
+0029 oo_.var = y'*y/size(y,1);
+0030
+0031 labels = deblank(M_.endo_names(ivar,:));
+0032
+0033 if options_.nomoments == 0
+0034 z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
+0035
+0036 title='MOMENTS OF SIMULATED VARIABLES' ;
+0037 if options_.hp_filter > 1
+0038 title = [title ' (HP filter, lambda = ' ...
+0039 int2str(options_.hp_filter) ')' ];
+0040 end
+0041 headers=strvcat('VARIABLE' ,'MEAN' ,'STD. DEV.' ,'VARIANCE' ,'SKEWNESS' , ...
+0042 'KURTOSIS' );
+0043 table (title,headers,labels,z,size(labels,2)+2,16,6);
+0044 end
+0045
+0046 if options_.nocorr == 0
+0047 corr = (y'*y/size(y,1))./(s'*s);
+0048 title = 'CORRELATION OF SIMULATED VARIABLES' ;
+0049 if options_.hp_filter > 1
+0050 title = [title ' (HP filter, lambda = ' ...
+0051 int2str(options_.hp_filter) ')' ];
+0052 end
+0053 headers = strvcat('VARIABLE' ,M_.endo_names(ivar,:));
+0054 table (title,headers,labels,corr,size(labels,2)+2,8,4);
+0055 end
+0056
+0057 ar = options_.ar;
+0058 options_ = set_default_option (options_,'ar' ,5);
+0059 ar = options_.ar;
+0060 if ar > 0
+0061 autocorr = [];
+0062 for i=1:ar
+0063 oo_.autocorr{i} = y(ar+1:end ,:)'*y(ar+1-i:end-i,:)./((size(y,1)-ar)*s'*s);
+0064 autocorr = [ autocorr diag(oo_.autocorr{i}) ];
+0065 end
+0066 title = 'AUTOCORRELATION OF SIMULATED VARIABLES' ;
+0067 if options_.hp_filter > 1
+0068 title = [title ' (HP filter, lambda = ' ...
+0069 int2str(options_.hp_filter) ')' ];
+0070 end
+0071 headers = strvcat('VARIABLE' ,int2str([1:ar]'));
+0072 table (title,headers,labels,autocorr,size(labels,2)+2,8,4);
+0073 end
+0074
+0075 warning on
+0076
+0077
+0078
+0079
+0080
+0081
+0082
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/disp_th_moments.html b/matlab/doc/disp_th_moments.html
new file mode 100644
index 000000000..f4807f8a5
--- /dev/null
+++ b/matlab/doc/disp_th_moments.html
@@ -0,0 +1,142 @@
+
+
+
+ Description of disp_th_moments
+
+
+
+
+
+
+
+
+
+Home >
. > disp_th_moments.m
+
+
+
+disp_th_moments
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function disp_th_moments(dr,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function disp_th_moments(dr,var_list)
+0004 global M_ oo_ options_
+0005
+0006 nvar = size(var_list,1);
+0007 if nvar == 0
+0008 nvar = length(dr.order_var);
+0009 ivar = [1:nvar]';
+0010 else
+0011 ivar=zeros(nvar,1);
+0012 for i=1:nvar
+0013 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0014 if isempty(i_tmp)
+0015 error (['One of the variable specified does not exist' ]) ;
+0016 else
+0017 ivar(i) = i_tmp;
+0018 end
+0019 end
+0020 end
+0021
+0022 m = dr.ys(ivar);
+0023
+0024 oo_.gamma_y = th_autocovariances (dr,ivar);
+0025
+0026 i1 = find(abs(diag(oo_.gamma_y{1})) > 1e-12);
+0027 s2 = diag(oo_.gamma_y{1});
+0028 sd = sqrt(s2);
+0029 if options_.order == 2
+0030 m = m+oo_.gamma_y{options_.ar+3};
+0031 end
+0032
+0033 z = [ m sd s2 ];
+0034 oo_.mean = m;
+0035 oo_.var = oo_.gamma_y{1};
+0036
+0037 lh = size(deblank(M_.endo_names(ivar,:)),2)+2;
+0038 if options_.nomoments == 0
+0039 title='THEORETICAL MOMENTS' ;
+0040 if options_.hp_filter == 1
+0041 title = [title ' (HP filter, lambda = ' int2str(options_.hp_filter) ')' ];
+0042 end
+0043 headers=strvcat('VARIABLE' ,'MEAN' ,'STD. DEV.' ,'VARIANCE' );
+0044 table (title,headers,deblank(M_.endo_names(ivar,:)),z,lh,11,4);
+0045 if M_.exo_nbr > 1
+0046 disp(' ' )
+0047 title='VARIANCE DECOMPOSITION (in percent)' ;
+0048 if options_.hp_filter == 1
+0049 title = [title ' (HP filter, lambda = ' ...
+0050 int2str(options_.hp_filter) ')' ];
+0051 end
+0052 headers = M_.exo_names;
+0053 headers(M_.exo_names_orig_ord,:) = headers;
+0054 headers = strvcat(' ' ,headers);
+0055 table (title,headers,deblank(M_.endo_names(ivar(i1),:)),100*oo_.gamma_y{options_.ar+2}(i1,:), ...
+0056 lh,8,2);
+0057 end
+0058 end
+0059
+0060 if options_.nocorr == 0
+0061 disp(' ' )
+0062 title='MATRIX OF CORRELATIONS' ;
+0063 if options_.hp_filter == 1
+0064 title = [title ' (HP filter, lambda = ' int2str(options_.hp_filter) ')' ];
+0065 end
+0066 labels = deblank(M_.endo_names(ivar,:));
+0067 headers = strvcat('Variables' ,labels(i1,:));
+0068 corr = oo_.gamma_y{1}(i1,i1)./(sd(i1)*sd(i1)');
+0069 table (title,headers,labels(i1,:),corr,lh,8,4);
+0070 end
+0071
+0072 if options_.ar > 0
+0073 disp(' ' )
+0074 title='COEFFICIENTS OF AUTOCORRELATION' ;
+0075 if options_.hp_filter == 1
+0076 title = [title ' (HP filter, lambda = ' int2str(options_.hp_filter) ')' ];
+0077 end
+0078 labels = deblank(M_.endo_names(ivar(i1),:));
+0079 headers = strvcat('Order ' ,int2str([1:options_.ar]'));
+0080 z=[];
+0081 for i=1:options_.ar
+0082 oo_.autocorr{i} = oo_.gamma_y{i+1};
+0083 z(:,i) = diag(oo_.gamma_y{i+1}(i1,i1));
+0084 end
+0085 table (title,headers,labels,z,0,8,4);
+0086 end
+0087
+0088
+0089
+0090
+0091
+0092
+0093
+0094
+0095
+0096
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dlognorm.html b/matlab/doc/dlognorm.html
new file mode 100644
index 000000000..1f0ac3055
--- /dev/null
+++ b/matlab/doc/dlognorm.html
@@ -0,0 +1,64 @@
+
+
+
+ Description of dlognorm
+
+
+
+
+
+
+
+
+
+
+
+
+
+dlognorm
+
+
+ PURPOSE
+DLOGNORM The log-normal density function
+
+ SYNOPSIS
+function f = dlognorm(x,lambda,zeta)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+dnorm DNORM The normal density function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function f = dlognorm(x,lambda,zeta)
+0002
+0003
+0004
+0005
+0006
+0007
+0008 if any(any(zeta<=0))
+0009 error('Parameter zeta is wrong' )
+0010 end
+0011
+0012 neg = find(x <= 0);
+0013 [n1,n2] = size(neg);
+0014 x(neg) = ones(n1,n2);
+0015 f = dnorm (log(x),lambda,zeta)./x;
+0016 f(neg) = zeros(n1,n2);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dnorm.html b/matlab/doc/dnorm.html
new file mode 100644
index 000000000..ea49ac2bb
--- /dev/null
+++ b/matlab/doc/dnorm.html
@@ -0,0 +1,59 @@
+
+
+
+ Description of dnorm
+
+
+
+
+
+
+
+
+
+
+
+
+
+dnorm
+
+
+ PURPOSE
+DNORM The normal density function
+
+ SYNOPSIS
+function f = dnorm(x,m,s)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dlognorm DLOGNORM The log-normal density function
+
+
+
+ SOURCE CODE
+0001 function f = dnorm(x,m,s)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if nargin<3, s=1; end
+0010 if nargin<2, m=0; end
+0011 f = exp(-0.5*((x-m)./s).^2)./(sqrt(2*pi)*s);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/down.png b/matlab/doc/down.png
new file mode 100644
index 000000000..d41104a26
Binary files /dev/null and b/matlab/doc/down.png differ
diff --git a/matlab/doc/dr1.html b/matlab/doc/dr1.html
new file mode 100644
index 000000000..0548bcbe3
--- /dev/null
+++ b/matlab/doc/dr1.html
@@ -0,0 +1,698 @@
+
+
+
+ Description of dr1
+
+
+
+
+
+
+
+
+
+
+
+
+
+dr1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [dr,info]=dr1(dr,task)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dr2 Copyright (C) 2001 Michel Juillardresol Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [dr,info]=dr1(dr,task)
+0004 global M_ options_ oo_
+0005
+0006 global olr_state
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017 info = 0;
+0018
+0019 options_ = set_default_option (options_,'loglinear' ,0);
+0020 options_ = set_default_option (options_,'noprint' ,0);
+0021 options_ = set_default_option (options_,'olr' ,0);
+0022 options_ = set_default_option (options_,'olr_beta' ,1);
+0023 options_ = set_default_option (options_,'qz_criterium' ,1.000001);
+0024
+0025 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0026 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0027 iyv = M_.lead_lag_incidence';
+0028 iyv = iyv(:);
+0029 iyr0 = find(iyv) ;
+0030 it_ = M_.maximum_lag + 1 ;
+0031
+0032 if M_.exo_nbr == 0
+0033 oo_.exo_steady_state = [] ;
+0034 end
+0035
+0036 tempex = oo_.exo_simul;
+0037
+0038 it_ = M_.maximum_lag + 1;
+0039 if options_.olr
+0040 z = repmat(zeros(M_.endo_nbr,1),1,klen);
+0041 else
+0042 z = repmat(dr.ys,1,klen);
+0043 end
+0044 z = z(iyr0) ;
+0045 if options_.order == 1
+0046 [junk,jacobia_] = feval([M_.fname '_dynamic' ],z,tempex);
+0047 elseif options_.order == 2
+0048 [junk,jacobia_,hessian ] = feval([M_.fname '_dynamic' ],z,...
+0049 [oo_.exo_simul ...
+0050 oo_.exo_det_simul]);
+0051 end
+0052
+0053 oo_.exo_simul = tempex ;
+0054 tempex = [];
+0055
+0056
+0057 if options_.olr
+0058 bet = options_.olr_beta;
+0059 jacobia1 = [];
+0060 n_inst = size(options_.olr_inst,1);
+0061
+0062 if ~isfield(olr_state_,'done' )
+0063 olr_state_.done = 1;
+0064 olr_state_.old_M_.maximum_lag = M_.maximum_lag;
+0065 olr_state_.old_M_.maximum_lead = M_.maximum_lead;
+0066 olr_state_.old_M_.endo_nbr = M_.endo_nbr;
+0067 olr_state_.old_M_.lead_lag_incidence = M_.lead_lag_incidence;
+0068
+0069 for i=1:M_.endo_nbr
+0070 temp = ['mult_' int2str(i)];
+0071 lgoo_.endo_simul = strvcat(lgoo_.endo_simul,temp);
+0072 end
+0073 M_.endo_nbr = 2*M_.endo_nbr-n_inst;
+0074 M_.maximum_lag = max(M_.maximum_lag,M_.maximum_lead);
+0075 M_.maximum_lead = M_.maximum_lag;
+0076 end
+0077 nj = olr_state_.old_M_.endo_nbr-n_inst;
+0078 offset_min = M_.maximum_lag - olr_state_.old_M_.maximum_lag;
+0079 offset_max = M_.maximum_lead - olr_state_.old_M_.maximum_lead;
+0080 newiy = zeros(2*M_.maximum_lag+1,nj+olr_state_.old_M_.endo_nbr);
+0081 jacobia_ = jacobia_(1:nj,:);
+0082 for i=1:2*M_.maximum_lag+1
+0083 if i > offset_min & i <= 2*M_.maximum_lag+1-offset_max
+0084 [junk,k1,k2] = find(olr_state_.old_M_.lead_lag_incidence(i-offset_min,:));
+0085 if i == M_.maximum_lag+1
+0086 jacobia1 = [jacobia1 [jacobia_(:,k2); 2*options_.olr_w]];
+0087 else
+0088 jacobia1 = [jacobia1 [jacobia_(:,k2); ...
+0089 zeros(olr_state_.old_M_.endo_nbr,length(k1))]];
+0090 end
+0091 newiy(i,k1) = ones(1,length(k1));
+0092 end
+0093 i1 = 2*M_.maximum_lag+2-i;
+0094 if i1 <= 2*M_.maximum_lag+1-offset_max & i1 > offset_min
+0095 [junk,k1,k2] = find(olr_state_.old_M_.lead_lag_incidence(i1-offset_min,:));
+0096 k3 = find(any(jacobia_(:,k2),2));
+0097 x = zeros(olr_state_.old_M_.endo_nbr,length(k3));
+0098 x(k1,:) = bet^(-i1+M_.maximum_lag+1)*jacobia_(k3,k2)';
+0099 jacobia1 = [jacobia1 [zeros(nj,length(k3)); x]];
+0100 newiy(i,k3+olr_state_.old_M_.endo_nbr) = ones(1,length(k3));
+0101 end
+0102 end
+0103 jacobia1 = [jacobia1 [jacobia_(:,end-M_.exo_nbr+1:end); ...
+0104 zeros(olr_state_.old_M_.endo_nbr, M_.exo_nbr)]];
+0105 newiy = newiy';
+0106 newiy = find(newiy(:));
+0107 M_.lead_lag_incidence = zeros(M_.endo_nbr*(M_.maximum_lag+M_.maximum_lead+1),1);
+0108 M_.lead_lag_incidence(newiy) = [1:length(newiy)]';
+0109 M_.lead_lag_incidence =reshape(M_.lead_lag_incidence,M_.endo_nbr,M_.maximum_lag+M_.maximum_lead+1)';
+0110 jacobia_ = jacobia1;
+0111 clear jacobia1
+0112
+0113 resid = feval([M_.fname '_steady' ],zeros(olr_state_.old_M_.endo_nbr,1));
+0114 if resid '*resid < 1e-12
+0115 dr.ys =[dr.ys; zeros(nj,1)];
+0116 else
+0117 AA = zeros(M_.endo_nbr,M_.endo_nbr);
+0118 for i=1:M_.maximum_lag+M_.maximum_lead+1
+0119 [junk,k1,k2] = find(M_.lead_lag_incidence(i,:));
+0120 AA(:,k1) = AA(:,k1)+jacobia_(:,k2);
+0121 end
+0122 dr.ys = -AA\[resid ; zeros(nj,1)];
+0123 end
+0124 end
+0125
+0126
+0127 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0128 dr=set_state_space (dr);
+0129 kstate = dr.kstate;
+0130 kad = dr.kad;
+0131 kae = dr.kae;
+0132 nstatic = dr.nstatic;
+0133 nfwrd = dr.nfwrd;
+0134 npred = dr.npred;
+0135 nboth = dr.nboth;
+0136 order_var = dr.order_var;
+0137 nd = size(kstate,1);
+0138 nz = nnz(M_.lead_lag_incidence);
+0139
+0140 sdyn = M_.endo_nbr - nstatic;
+0141
+0142 k0 = M_.lead_lag_incidence(M_.maximum_lag+1,order_var);
+0143 k1 = M_.lead_lag_incidence(find([1:klen] ~= M_.maximum_lag+1),:);
+0144 b = jacobia_(:,k0);
+0145
+0146 if M_.maximum_lead == 0;
+0147 a = jacobia_(:,nonzeros(k1'));
+0148 dr.ghx = zeros(size(a));
+0149 m = 0;
+0150 for i=M_.maximum_lag:-1:1
+0151 k = nonzeros(M_.lead_lag_incidence(i,order_var));
+0152 dr.ghx(:,m+[1:length(k)]) = -b\a(:,k);
+0153 m = m+length(k);
+0154 end
+0155 if M_.exo_nbr
+0156 dr.ghu = -b\jacobia_(:,nz+1:end);
+0157 end
+0158 dr.eigval = eig(transition_matrix (dr));
+0159 dr.rank = 0;
+0160 if any(abs(dr.eigval) > options_.qz_criterium)
+0161 temp = sort(abs(dr.eigval));
+0162 nba = nnz(abs(dr.eigval) > options_.qz_criterium);
+0163 temp = temp(nd-nba+1:nd)-1-options_.qz_criterium;
+0164 info(1) = 3;
+0165 info(2) = temp'*temp;
+0166 end
+0167 return ;
+0168 end
+0169
+0170
+0171 if nstatic > 0
+0172 [Q,R] = qr(b(:,1:nstatic));
+0173 aa = Q'*jacobia_;
+0174 else
+0175 aa = jacobia_;
+0176 end
+0177 a = aa(:,nonzeros(k1'));
+0178 b = aa(:,k0);
+0179 b10 = b(1:nstatic,1:nstatic);
+0180 b11 = b(1:nstatic,nstatic+1:end);
+0181 b2 = b(nstatic+1:end ,nstatic+1:end);
+0182 if any(isinf(a(:)))
+0183 info = 1;
+0184 return
+0185 end
+0186 if M_.exo_nbr
+0187 fu = aa(:,nz+(1:M_.exo_nbr));
+0188 end
+0189 clear aa;
+0190
+0191
+0192 d = zeros(nd,nd) ;
+0193 e = d ;
+0194
+0195 k = find(kstate(:,2) >= M_.maximum_lag+2 & kstate(:,3));
+0196 d(1:sdyn,k) = a(nstatic+1:end ,kstate(k,3)) ;
+0197 k1 = find(kstate(:,2) == M_.maximum_lag+2);
+0198 e(1:sdyn,k1) = -b2(:,kstate(k1,1)-nstatic);
+0199 k = find(kstate(:,2) <= M_.maximum_lag+1 & kstate(:,4));
+0200 e(1:sdyn,k) = -a(nstatic+1:end ,kstate(k,4)) ;
+0201 k2 = find(kstate(:,2) == M_.maximum_lag+1);
+0202 k2 = k2(~ismember(kstate(k2,1),kstate(k1,1)));
+0203 d(1:sdyn,k2) = b2(:,kstate(k2,1)-nstatic);
+0204
+0205 if ~isempty(kad)
+0206 for j = 1:size(kad,1)
+0207 d(sdyn+j,kad(j)) = 1 ;
+0208 e(sdyn+j,kae(j)) = 1 ;
+0209 end
+0210 end
+0211
+0212 if ~exist('mjdgges' )
+0213
+0214 use_qzdiv = 1;
+0215 [ss,tt,qq,w] = qz(e,d);
+0216 [tt,ss,qq,w] = qzdiv (options_.qz_criterium,tt,ss,qq,w);
+0217 ss1=diag(ss);
+0218 tt1=diag(tt);
+0219 warning_state = warning;
+0220 warning off;
+0221 dr.eigval = ss1./tt1 ;
+0222 warning warning_state;
+0223 nba = nnz(abs(dr.eigval) > options_.qz_criterium);
+0224 else
+0225 use_qzdiv = 0;
+0226 [ss,tt,w,sdim,dr.eigval,info1] = mjdgges(e,d,options_.qz_criterium);
+0227 if info1
+0228 info(1) = 2;
+0229 info(2) = info1;
+0230 return
+0231 end
+0232 nba = nd-sdim;
+0233 end
+0234
+0235 nyf = sum(kstate(:,2) > M_.maximum_lag+1);
+0236
+0237 if task == 1
+0238 dr.rank = rank(w(1:nyf,nd-nyf+1:end));
+0239 dr.eigval = eig(e,d);
+0240 return
+0241 end
+0242
+0243 if nba ~= nyf
+0244 temp = sort(abs(dr.eigval));
+0245 if nba > nyf
+0246 temp = temp(nd-nba+1:nd-nyf)-1-options_.qz_criterium;
+0247 info(1) = 3;
+0248 elseif nba < nyf;
+0249 temp = temp(nd-nyf+1:nd-nba)-1-options_.qz_criterium;
+0250 info(1) = 4;
+0251 end
+0252 info(2) = temp'*temp;
+0253 return
+0254 end
+0255
+0256 np = nd - nyf;
+0257 n2 = np + 1;
+0258 n3 = nyf;
+0259 n4 = n3 + 1;
+0260
+0261
+0262 w1 =w(1:n3,n2:nd);
+0263 if condest(w1) > 1e9;
+0264 info(1) = 5;
+0265 info(2) = condest(w1);
+0266 return ;
+0267 else
+0268 gx = -w1'\w(n4:nd,n2:nd)';
+0269 end
+0270
+0271
+0272 hx = w(1:n3,1:np)'*gx+w(n4:nd,1:np)';
+0273 hx = (tt(1:np,1:np)*hx)\(ss(1:np,1:np)*hx);
+0274
+0275 k1 = find(kstate(n4:nd,2) == M_.maximum_lag+1);
+0276 k2 = find(kstate(1:n3,2) == M_.maximum_lag+2);
+0277 dr.ghx = [hx(k1,:); gx(k2(nboth+1:end),:)];
+0278
+0279
+0280 j3 = nonzeros(kstate(:,3));
+0281 j4 = find(kstate(:,3));
+0282
+0283 if M_.exo_nbr
+0284 a1 = b;
+0285 aa1 = [];
+0286 if nstatic > 0
+0287 aa1 = a1(:,1:nstatic);
+0288 end
+0289 dr.ghu = -[aa1 a(:,j3)*gx(j4,1:npred)+a1(:,nstatic+1:nstatic+ ...
+0290 npred) a1(:,nstatic+npred+1:end)]\fu;
+0291 end
+0292
+0293
+0294 if nstatic > 0
+0295 temp = -a(1:nstatic,j3)*gx(j4,:)*hx;
+0296 j5 = find(kstate(n4:nd,4));
+0297 temp(:,j5) = temp(:,j5)-a(1:nstatic,nonzeros(kstate(:,4)));
+0298 temp = b10\(temp-b11*dr.ghx);
+0299 dr.ghx = [temp; dr.ghx];
+0300 temp = [];
+0301 end
+0302
+0303 if options_.loglinear == 1
+0304 k = find(dr.kstate(:,2) <= M_.maximum_lag+1);
+0305 klag = dr.kstate(k,[1 2]);
+0306 k1 = dr.order_var;
+0307
+0308 dr.ghx = repmat(1./dr.ys(k1),1,size(dr.ghx,2)).*dr.ghx.* ...
+0309 repmat(dr.ys(k1(klag(:,1)))',size(dr.ghx,1),1);
+0310 dr.ghu = repmat(1./dr.ys(k1),1,size(dr.ghu,2)).*dr.ghu;
+0311 end
+0312
+0313
+0314 if use_qzdiv
+0315 gx = real(gx);
+0316 hx = real(hx);
+0317 dr.ghx = real(dr.ghx);
+0318 dr.ghu = real(dr.ghu);
+0319 end
+0320
+0321
+0322 if M_.exo_det_nbr > 0
+0323 f1 = sparse(jacobia_(:,nonzeros(M_.lead_lag_incidence(M_.maximum_lag+2:end ,order_var))));
+0324 f0 = sparse(jacobia_(:,nonzeros(M_.lead_lag_incidence(M_.maximum_lag+1,order_var))));
+0325 fudet = sparse(jacobia_(:,nz+M_.exo_nbr+1:end));
+0326 M1 = inv(f0+[zeros(M_.endo_nbr,nstatic) f1*gx zeros(M_.endo_nbr,nyf-nboth)]);
+0327 M2 = M1*f1;
+0328 dr.ghud = cell(M_.exo_det_length,1);
+0329 dr.ghud{1} = -M1*fudet;
+0330 for i = 2:M_.exo_det_length
+0331 dr.ghud{i} = -M2*dr.ghud{i-1}(end-nyf+1:end ,:);
+0332 end
+0333 end
+0334
+0335 if options_.order == 1
+0336 return
+0337 end
+0338
+0339
+0340
+0341
+0342
+0343 kk = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+1:end ,order_var)),1));
+0344 if M_.maximum_lag > 0
+0345 kk = [cumsum(M_.lead_lag_incidence(1:M_.maximum_lag,order_var),1); kk];
+0346 end
+0347 kk = kk';
+0348 kk = find(kk(:));
+0349 nk = size(kk,1) + M_.exo_nbr + M_.exo_det_nbr;
+0350 k1 = M_.lead_lag_incidence(:,order_var);
+0351 k1 = k1';
+0352 k1 = k1(:);
+0353 k1 = k1(kk);
+0354 k2 = find(k1);
+0355 kk1(k1(k2)) = k2;
+0356 kk1 = [kk1 length(k1)+1:length(k1)+M_.exo_nbr+M_.exo_det_nbr];
+0357 kk = reshape([1:nk^2],nk,nk);
+0358 kk1 = kk(kk1,kk1);
+0359
+0360 hessian (:,kk1(:)) = hessian ;
+0361
+0362
+0363
+0364
+0365 n1 = 0;
+0366 n2 = np;
+0367 zx = zeros(np,np);
+0368 zu=zeros(np,M_.exo_nbr);
+0369 for i=2:M_.maximum_lag+1
+0370 k1 = sum(kstate(:,2) == i);
+0371 zx(n1+1:n1+k1,n2-k1+1:n2)=eye(k1);
+0372 n1 = n1+k1;
+0373 n2 = n2-k1;
+0374 end
+0375 kk = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+1:end ,order_var)),1));
+0376 k0 = [1:M_.endo_nbr];
+0377 gx1 = dr.ghx;
+0378 hu = dr.ghu(nstatic+[1:npred],:);
+0379 zx = [zx; gx1];
+0380 zu = [zu; dr.ghu];
+0381 for i=1:M_.maximum_lead
+0382 k1 = find(kk(i+1,k0) > 0);
+0383 zu = [zu; gx1(k1,1:npred)*hu];
+0384 gx1 = gx1(k1,:)*hx;
+0385 zx = [zx; gx1];
+0386 kk = kk(:,k0);
+0387 k0 = k1;
+0388 end
+0389 zx=[zx; zeros(M_.exo_nbr,np);zeros(M_.exo_det_nbr,np)];
+0390 zu=[zu; eye(M_.exo_nbr);zeros(M_.exo_det_nbr,M_.exo_nbr)];
+0391 [n1,n2] = size(zx);
+0392 if n1*n1*n2*n2 > 1e7
+0393 rhs = zeros(M_.endo_nbr,n2*n2);
+0394 k1 = 1;
+0395 for i1 = 1:n2
+0396 for i2 = 1:n2
+0397 rhs(:,k1) = hessian *kron(zx(:,i1),zx(:,i2));
+0398 k1 = k1 + 1;
+0399 end
+0400 end
+0401 else
+0402 rhs = hessian *kron(zx,zx);
+0403 end
+0404 rhs = -rhs;
+0405
+0406
+0407 n = M_.endo_nbr+sum(kstate(:,2) > M_.maximum_lag+1 & kstate(:,2) < M_.maximum_lag+M_.maximum_lead+1);
+0408 A = zeros(n,n);
+0409 B = zeros(n,n);
+0410 A(1:M_.endo_nbr,1:M_.endo_nbr) = jacobia_(:,M_.lead_lag_incidence(M_.maximum_lag+1,order_var));
+0411
+0412 k1 = find(kstate(:,2) == M_.maximum_lag+M_.maximum_lead+1);
+0413 if M_.maximum_lead > 1
+0414 k2 = find(kstate(:,2) == M_.maximum_lag+M_.maximum_lead);
+0415 [junk,junk,k3] = intersect(kstate(k1,1),kstate(k2,1));
+0416 else
+0417 k2 = [1:M_.endo_nbr];
+0418 k3 = kstate(k1,1);
+0419 end
+0420
+0421 B(1:M_.endo_nbr,end-length(k2)+k3) = jacobia_(:,kstate(k1,3)+M_.endo_nbr);
+0422 offset = M_.endo_nbr;
+0423 k0 = [1:M_.endo_nbr];
+0424 gx1 = dr.ghx;
+0425 for i=1:M_.maximum_lead-1
+0426 k1 = find(kstate(:,2) == M_.maximum_lag+i+1);
+0427 [k2,junk,k3] = find(kstate(k1,3));
+0428 A(1:M_.endo_nbr,offset+k2) = jacobia_(:,k3+M_.endo_nbr);
+0429 n1 = length(k1);
+0430 A(offset+[1:n1],nstatic+[1:npred]) = -gx1(kstate(k1,1),1:npred);
+0431 gx1 = gx1*hx;
+0432 A(offset+[1:n1],offset+[1:n1]) = eye(n1);
+0433 n0 = length(k0);
+0434 E = eye(n0);
+0435 if i == 1
+0436 [junk,junk,k4]=intersect(kstate(k1,1),[1:M_.endo_nbr]);
+0437 else
+0438 [junk,junk,k4]=intersect(kstate(k1,1),kstate(k0,1));
+0439 end
+0440 i1 = offset-n0+n1;
+0441 B(offset+[1:n1],offset-n0+[1:n0]) = -E(k4,:);
+0442 k0 = k1;
+0443 offset = offset + n1;
+0444 end
+0445 [junk,k1,k2] = find(M_.lead_lag_incidence(M_.maximum_lag+M_.maximum_lead+1,order_var));
+0446 A(1:M_.endo_nbr,nstatic+1:nstatic+npred)=...
+0447 A(1:M_.endo_nbr,nstatic+[1:npred])+jacobia_(:,k2)*gx1(k1,1:npred);
+0448 C = hx;
+0449 D = [rhs; zeros(n-M_.endo_nbr,size(rhs,2))];
+0450 dr.ghxx = gensylv(2,A,B,C,D);
+0451 if exist('gensylv' )
+0452 dr.ghxx = gensylv(2,A,B,C,D);
+0453 else
+0454 C = kron(hx,hx);
+0455 x0 = sylvester3 (A,B,C,D);
+0456 dr.ghxx = sylvester3a (x0,A,B,C,D);
+0457 end
+0458
+0459
+0460
+0461 hu = dr.ghu(nstatic+1:nstatic+npred,:);
+0462
+0463
+0464
+0465 if n1*n1*n2*M_.exo_nbr > 1e7
+0466 rhs = zeros(M_.endo_nbr,n2*M_.exo_nbr);
+0467 k1 = 1;
+0468 for i1 = 1:n2
+0469 for i2 = 1:M_.exo_nbr
+0470 rhs(:,k1) = hessian *kron(zx(:,i1),zu(:,i2));
+0471 k1 = k1 + 1;
+0472 end
+0473 end
+0474 else
+0475 rhs = hessian *kron(zx,zu);
+0476 end
+0477 nyf1 = sum(kstate(:,2) == M_.maximum_lag+2);
+0478 hu1 = [hu;zeros(np-npred,M_.exo_nbr)];
+0479
+0480 rhs = -[rhs; zeros(n-M_.endo_nbr,size(rhs,2))]-B*dr.ghxx*kron(hx,hu1);
+0481
+0482
+0483
+0484 dr.ghxu = A\rhs;
+0485
+0486
+0487
+0488 kk = reshape([1:np*np],np,np);
+0489 kk = kk(1:npred,1:npred);
+0490 if n1*n1*M_.exo_nbr*M_.exo_nbr > 1e7
+0491 rhs = zeros(M_.endo_nbr,M_.exo_nbr*M_.exo_nbr);
+0492 k1 = 1;
+0493 for i1 = 1:M_.exo_nbr
+0494 for i2 = 1:M_.exo_nbr
+0495 rhs(:,k1) = hessian *kron(zu(:,i1),zu(:,i2));
+0496 k1 = k1 + 1;
+0497 end
+0498 end
+0499 else
+0500 rhs = hessian *kron(zu,zu);
+0501 end
+0502
+0503 rhs = -[rhs; zeros(n-M_.endo_nbr,size(rhs,2))]-B*dr.ghxx*kron(hu1,hu1);
+0504
+0505
+0506 dr.ghuu = A\rhs;
+0507
+0508 dr.ghxx = dr.ghxx(1:M_.endo_nbr,:);
+0509 dr.ghxu = dr.ghxu(1:M_.endo_nbr,:);
+0510 dr.ghuu = dr.ghuu(1:M_.endo_nbr,:);
+0511
+0512
+0513
+0514
+0515
+0516 O1 = zeros(M_.endo_nbr,nstatic);
+0517 O2 = zeros(M_.endo_nbr,M_.endo_nbr-nstatic-npred);
+0518 LHS = jacobia_(:,M_.lead_lag_incidence(M_.maximum_lag+1,order_var));
+0519 RHS = zeros(M_.endo_nbr,M_.exo_nbr^2);
+0520 kk = find(kstate(:,2) == M_.maximum_lag+2);
+0521 gu = dr.ghu;
+0522 guu = dr.ghuu;
+0523 Gu = [dr.ghu(nstatic+[1:npred],:); zeros(np-npred,M_.exo_nbr)];
+0524 Guu = [dr.ghuu(nstatic+[1:npred],:); zeros(np-npred,M_.exo_nbr*M_.exo_nbr)];
+0525 E = eye(M_.endo_nbr);
+0526 M_.lead_lag_incidenceordered = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+1:end ,order_var)),1));
+0527 if M_.maximum_lag > 0
+0528 M_.lead_lag_incidenceordered = [cumsum(M_.lead_lag_incidence(1:M_.maximum_lag,order_var),1); M_.lead_lag_incidenceordered];
+0529 end
+0530 M_.lead_lag_incidenceordered = M_.lead_lag_incidenceordered';
+0531 M_.lead_lag_incidenceordered = M_.lead_lag_incidenceordered(:);
+0532 k1 = find(M_.lead_lag_incidenceordered);
+0533 M_.lead_lag_incidenceordered(k1) = [1:length(k1)]';
+0534 M_.lead_lag_incidenceordered =reshape(M_.lead_lag_incidenceordered,M_.endo_nbr,M_.maximum_lag+M_.maximum_lead+1)';
+0535 kh = reshape([1:nk^2],nk,nk);
+0536 kp = sum(kstate(:,2) <= M_.maximum_lag+1);
+0537 E1 = [eye(npred); zeros(kp-npred,npred)];
+0538 H = E1;
+0539 hxx = dr.ghxx(nstatic+[1:npred],:);
+0540 for i=1:M_.maximum_lead
+0541 for j=i:M_.maximum_lead
+0542 [junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_lag+j+1,order_var));
+0543 [junk,k3a,k3] = find(M_.lead_lag_incidenceordered(M_.maximum_lag+j+1,:));
+0544 RHS = RHS + jacobia_(:,k2)*guu(k2a,:)+hessian (:,kh(k3,k3))* ...
+0545 kron(gu(k3a,:),gu(k3a,:));
+0546 end
+0547
+0548
+0549 [junk,k2a,k2] = find(M_.lead_lag_incidence(M_.maximum_lag+i+1,order_var));
+0550 LHS = LHS + jacobia_(:,k2)*(E(k2a,:)+[O1(k2a,:) dr.ghx(k2a,:)*H O2(k2a,:)]);
+0551
+0552 if i == M_.maximum_lead
+0553 break
+0554 end
+0555
+0556 kk = find(kstate(:,2) == M_.maximum_lag+i+1);
+0557 gu = dr.ghx*Gu;
+0558 GuGu = kron(Gu,Gu);
+0559 guu = dr.ghx*Guu+dr.ghxx*GuGu;
+0560 Gu = hx*Gu;
+0561 Guu = hx*Guu;
+0562 Guu(end-npred+1:end ,:) = Guu(end-npred+1:end ,:) + hxx*GuGu;
+0563
+0564 H = E1 + hx*H;
+0565 end
+0566 RHS = RHS*M_.Sigma_e(:);
+0567 dr.fuu = RHS;
+0568 RHS = -RHS-dr.fbias;
+0569 dr.ghs2 = LHS\RHS;
+0570
+0571
+0572 if M_.exo_det_nbr > 0
+0573 hud = dr.ghud{1}(nstatic+1:nstatic+npred,:);
+0574 zud=[zeros(np,M_.exo_det_nbr);dr.ghud{1};gx(:,1:npred)*hud;zeros(M_.exo_nbr,M_.exo_det_nbr);eye(M_.exo_det_nbr)];
+0575 R1 = hessian *kron(zx,zud);
+0576 dr.ghxud = cell(M_.exo_det_length,1);
+0577 kf = [M_.endo_nbr-nyf+1:M_.endo_nbr];
+0578 kp = nstatic+[1:npred];
+0579 dr.ghxud{1} = -M1*(R1+f1*dr.ghxx(kf,:)*kron(dr.ghx(kp,:),dr.ghud{1}(kp,:)));
+0580 Eud = eye(M_.exo_det_nbr);
+0581 for i = 2:M_.exo_det_length
+0582 hudi = dr.ghud{i}(kp,:);
+0583 zudi=[zeros(np,M_.exo_det_nbr);dr.ghud{i};gx(:,1:npred)*hudi;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
+0584 R2 = hessian *kron(zx,zudi);
+0585 dr.ghxud{i} = -M2*(dr.ghxud{i-1}(kf,:)*kron(hx,Eud)+dr.ghxx(kf,:)*kron(dr.ghx(kp,:),dr.ghud{i}(kp,:)))-M1*R2;
+0586 end
+0587 R1 = hessian *kron(zu,zud);
+0588 dr.ghudud = cell(M_.exo_det_length,1);
+0589 kf = [M_.endo_nbr-nyf+1:M_.endo_nbr];
+0590
+0591 dr.ghuud{1} = -M1*(R1+f1*dr.ghxx(kf,:)*kron(dr.ghu(kp,:),dr.ghud{1}(kp,:)));
+0592 Eud = eye(M_.exo_det_nbr);
+0593 for i = 2:M_.exo_det_length
+0594 hudi = dr.ghud{i}(kp,:);
+0595 zudi=[zeros(np,M_.exo_det_nbr);dr.ghud{i};gx(:,1:npred)*hudi;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
+0596 R2 = hessian *kron(zu,zudi);
+0597 dr.ghuud{i} = -M2*dr.ghxud{i-1}(kf,:)*kron(hu,Eud)-M1*R2;
+0598 end
+0599 R1 = hessian *kron(zud,zud);
+0600 dr.ghudud = cell(M_.exo_det_length,M_.exo_det_length);
+0601 dr.ghudud{1,1} = -M1*R1-M2*dr.ghxx(kf,:)*kron(hud,hud);
+0602 for i = 2:M_.exo_det_length
+0603 hudi = dr.ghud{i}(nstatic+1:nstatic+npred,:);
+0604 zudi=[zeros(np,M_.exo_det_nbr);dr.ghud{i};gx(:,1:npred)*hudi+dr.ghud{i-1}(kf,:);zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
+0605 R2 = hessian *kron(zudi,zudi);
+0606 dr.ghudud{i,i} = -M2*(dr.ghudud{i-1,i-1}(kf,:)+...
+0607 2*dr.ghxud{i-1}(kf,:)*kron(hudi,Eud) ...
+0608 +dr.ghxx(kf,:)*kron(hudi,hudi))-M1*R2;
+0609 R2 = hessian *kron(zud,zudi);
+0610 dr.ghudud{1,i} = -M2*(dr.ghxud{i-1}(kf,:)*kron(hud,Eud)+...
+0611 dr.ghxx(kf,:)*kron(hud,hudi))...
+0612 -M1*R2;
+0613 for j=2:i-1
+0614 hudj = dr.ghud{j}(kp,:);
+0615 zudj=[zeros(np,M_.exo_det_nbr);dr.ghud{j};gx(:,1:npred)*hudj;zeros(M_.exo_nbr+M_.exo_det_nbr,M_.exo_det_nbr)];
+0616 R2 = hessian *kron(zudj,zudi);
+0617 dr.ghudud{j,i} = -M2*(dr.ghudud{j-1,i-1}(kf,:)+dr.ghxud{j-1}(kf,:)* ...
+0618 kron(hudi,Eud)+dr.ghxud{i-1}(kf,:)* ...
+0619 kron(hudj,Eud)+dr.ghxx(kf,:)*kron(hudj,hudi))-M1*R2;
+0620 end
+0621
+0622 end
+0623 end
+0624
+0625
+0626
+0627
+0628
+0629
+0630
+0631
+0632
+0633
+0634
+0635
+0636
+0637
+0638
+0639
+0640
+0641
+0642
+0643
+0644
+0645
+0646
+0647
+0648
+0649
+0650
+0651
+0652
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dr11.html b/matlab/doc/dr11.html
new file mode 100644
index 000000000..7645f1560
--- /dev/null
+++ b/matlab/doc/dr11.html
@@ -0,0 +1,301 @@
+
+
+
+ Description of dr11
+
+
+
+
+
+
+
+
+
+
+
+
+
+dr11
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dr=dr11(iorder,dr,cheik)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+resol1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dr=dr11(iorder,dr,cheik)
+0004
+0005 global M_ options_ oo_
+0006 global it_ stdexo_ means_ dr1_test_ bayestopt_
+0007
+0008
+0009 global dr1_test_ bayestopt_
+0010
+0011 options_ = set_default_option (options_,'loglinear' ,0);
+0012
+0013 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0014 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0015 iyv = transpose(M_.lead_lag_incidence);
+0016 iyv = iyv(:);
+0017 iyr0 = find(iyv) ;
+0018 it_ = M_.maximum_lag + 1 ;
+0019
+0020
+0021 if M_.exo_nbr == 0
+0022 oo_.exo_steady_state = [] ;
+0023 end
+0024
+0025 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0026 error ('Error in model specification: some variables don"t appear as current' ) ;
+0027 end
+0028
+0029 if ~cheik
+0030
+0031
+0032
+0033
+0034 end
+0035
+0036 if M_.maximum_lead > 1 & iorder > 1
+0037 error (['Models with leads on more than one period can only be solved' ...
+0038 ' at order 1' ])
+0039 end
+0040
+0041 dr=set_state_space (dr);
+0042 kstate = dr.kstate;
+0043 kad = dr.kad;
+0044 kae = dr.kae;
+0045 nstatic = dr.nstatic;
+0046 nfwrd = dr.nfwrd;
+0047 npred = dr.npred;
+0048 nboth = dr.nboth;
+0049 order_var = dr.order_var;
+0050 nd = size(kstate,1);
+0051
+0052 sdyn = M_.endo_nbr - nstatic;
+0053
+0054
+0055 tempex = oo_.exo_simul;
+0056
+0057 it_ = M_.maximum_lag + 1;
+0058 z = repmat(dr.ys,1,klen);
+0059 z = z(iyr0) ;
+0060
+0061
+0062 [junk,M_.jacobia] = feval([M_.fname '_dynamic' ],z,oo_.exo_simul);
+0063 oo_.exo_simul = tempex ;
+0064 tempex = [];
+0065
+0066 nz = size(z,1);
+0067 k1 = M_.lead_lag_incidence(find([1:klen] ~= M_.maximum_lag+1),:);
+0068 b = M_.jacobia(:,M_.lead_lag_incidence(M_.maximum_lag+1,order_var));
+0069 a = b\M_.jacobia(:,nonzeros(k1'));
+0070 if any(isinf(a(:)))
+0071 dr1_test_(1) = 5;
+0072 dr1_test_(2) = bayestopt_.penalty;
+0073 end
+0074 if M_.exo_nbr
+0075 fu = b\M_.jacobia(:,nz+1:end);
+0076 end
+0077
+0078 if M_.maximum_lead == 0 & M_.maximum_lag == 1;
+0079 dr.ghx = -a;
+0080 dr.ghu = -fu;
+0081 return ;
+0082 elseif M_.maximum_lead == 0 & M_.maximum_lag > 1
+0083
+0084 e = zeros(endo_nbr,nd);
+0085 k = find(kstate(:,2) <= M_.maximum_lag+1 & kstate(:,4));
+0086 e(:,k) = -a(:,kstate(k,4)) ;
+0087 dr.ghx = e;
+0088 dr.ghu = -fu;
+0089 end
+0090
+0091
+0092 d = zeros(nd,nd) ;
+0093 e = d ;
+0094
+0095 k = find(kstate(:,2) >= M_.maximum_lag+2 & kstate(:,3));
+0096 d(1:sdyn,k) = a(nstatic+1:end ,kstate(k,3)) ;
+0097 k1 = find(kstate(:,2) == M_.maximum_lag+2);
+0098 a1 = eye(sdyn);
+0099 e(1:sdyn,k1) = -a1(:,kstate(k1,1)-nstatic);
+0100 k = find(kstate(:,2) <= M_.maximum_lag+1 & kstate(:,4));
+0101 e(1:sdyn,k) = -a(nstatic+1:end ,kstate(k,4)) ;
+0102 k2 = find(kstate(:,2) == M_.maximum_lag+1);
+0103 k2 = k2(~ismember(kstate(k2,1),kstate(k1,1)));
+0104 d(1:sdyn,k2) = a1(:,kstate(k2,1)-nstatic);
+0105
+0106 if ~isempty(kad)
+0107 for j = 1:size(kad,1)
+0108 d(sdyn+j,kad(j)) = 1 ;
+0109 e(sdyn+j,kae(j)) = 1 ;
+0110 end
+0111 end
+0112 options_ = set_default_option (options_,'qz_criterium' ,1.000001);
+0113
+0114 if ~exist('mjdgges' )
+0115
+0116 use_qzdiv = 1;
+0117 [ss,tt,qq,w] = qz(e,d);
+0118 [tt,ss,qq,w] = qzdiv (options_.qz_criterium,tt,ss,qq,w);
+0119 ss1=diag(ss);
+0120 tt1=diag(tt);
+0121 warning_state = warning;
+0122 warning off;
+0123 oo_.eigenvalues = ss1./tt1 ;
+0124 warning warning_state;
+0125 nba = nnz(abs(eigval) > options_.qz_criterium);
+0126 else
+0127 use_qzdiv = 0;
+0128 [ss,tt,w,sdim,oo_.eigenvalues,info] = mjdgges(e,d,options_.qz_criterium);
+0129 if info & info ~= nd+2;
+0130 error(['ERROR' info ' in MJDGGES.DLL' ]);
+0131 end
+0132 nba = nd-sdim;
+0133 end
+0134
+0135 nyf = sum(kstate(:,2) > M_.maximum_lag+1);
+0136
+0137 if cheik
+0138 dr.rank = rank(w(1:nyf,nd-nyf+1:end));
+0139
+0140 return
+0141 end
+0142
+0143 eigenvalues = sort(oo_.eigenvalues);
+0144
+0145 if nba > nyf;
+0146
+0147 dr1_test_(1) = 3;
+0148 dr1_test_(2) = (abs(eigenvalues(nd-nba+1:nd-nyf))-1-1e-5)'*...
+0149 (abs(eigenvalues(nd-nba+1:nd-nyf))-1-1e-5);
+0150 return
+0151 elseif nba < nyf;
+0152
+0153 dr1_test_(1) = 2;
+0154 dr1_test_(2) = (abs(eigenvalues(nd-nyf+1:nd-nba))-1-1e-5)'*...
+0155 (abs(eigenvalues(nd-nyf+1:nd-nba))-1-1e-5);
+0156
+0157 return
+0158 end
+0159
+0160 np = nd - nyf;
+0161 n2 = np + 1;
+0162 n3 = nyf;
+0163 n4 = n3 + 1;
+0164
+0165
+0166
+0167 if condest(w(1:n3,n2:nd)) > 1e9
+0168
+0169 dr1_test_(1) = 2;
+0170 dr1_test_(2) = 1;
+0171 return
+0172 end
+0173
+0174 warning_state = warning;
+0175 lastwarn('' );
+0176 warning off;
+0177 gx = -w(1:n3,n2:nd)'\w(n4:nd,n2:nd)';
+0178
+0179 if length(lastwarn) > 0;
+0180
+0181 dr1_test_(1) = 2;
+0182 dr1_test_(2) = 1;
+0183 warning(warning_state);
+0184 return
+0185 end
+0186
+0187
+0188 hx = w(1:n3,1:np)'*gx+w(n4:nd,1:np)';
+0189 hx = (tt(1:np,1:np)*hx)\(ss(1:np,1:np)*hx);
+0190
+0191 lastwarn('' );
+0192 if length(lastwarn) > 0;
+0193
+0194 dr1_test_(1) = 2;
+0195 dr1_test_(2) = 1;
+0196 warning(warning_state);
+0197 return
+0198 end
+0199
+0200 k1 = find(kstate(n4:nd,2) == M_.maximum_lag+1);
+0201 k2 = find(kstate(1:n3,2) == M_.maximum_lag+2);
+0202 dr.ghx = [hx(k1,:); gx(k2(nboth+1:end),:)];
+0203
+0204
+0205 j3 = nonzeros(kstate(:,3));
+0206 j4 = find(kstate(:,3));
+0207
+0208 if M_.exo_nbr
+0209 a1 = eye(M_.endo_nbr);
+0210 aa1 = [];
+0211 if nstatic > 0
+0212 aa1 = a1(:,1:nstatic);
+0213 end
+0214 dr.ghu = -[aa1 a(:,j3)*gx(j4,1:npred)+a1(:,nstatic+1:nstatic+ ...
+0215 npred) a1(:,nstatic+npred+1:end)]\fu;
+0216
+0217
+0218 lastwarn('' );
+0219 if length(lastwarn) > 0;
+0220
+0221 dr1_test_(1) = 2;
+0222 dr1_test_(2) = 1;
+0223 return
+0224 end
+0225 end
+0226 warning(warning_state);
+0227
+0228
+0229 if nstatic > 0
+0230 temp = -a(1:nstatic,j3)*gx(j4,:)*hx;
+0231 j5 = find(kstate(n4:nd,4));
+0232 temp(:,j5) = temp(:,j5)-a(1:nstatic,nonzeros(kstate(:,4)));
+0233 dr.ghx = [temp; dr.ghx];
+0234 temp = [];
+0235 end
+0236
+0237 if options_.loglinear == 1
+0238 k = find(dr.kstate(:,2) <= M_.maximum_lag+1);
+0239 klag = dr.kstate(k,[1 2]);
+0240 k1 = dr.order_var;
+0241
+0242 dr.ghx = repmat(1./dr.ys(k1),1,size(dr.ghx,2)).*dr.ghx.* ...
+0243 repmat(dr.ys(k1(klag(:,1)))',size(dr.ghx,1),1);
+0244 dr.ghu = repmat(1./dr.ys(k1),1,size(dr.ghu,2)).*dr.ghu;
+0245 end
+0246
+0247
+0248 if use_qzdiv
+0249 gx = real(gx);
+0250 hx = real(hx);
+0251 dr.ghx = real(dr.ghx);
+0252 dr.ghu = real(dr.ghu);
+0253 end
+0254
+0255
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dr2.html b/matlab/doc/dr2.html
new file mode 100644
index 000000000..8f4e9b867
--- /dev/null
+++ b/matlab/doc/dr2.html
@@ -0,0 +1,59 @@
+
+
+
+ Description of dr2
+
+
+
+
+
+
+
+
+
+
+
+
+
+dr2
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function ghs2=dr2(ys,dr)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+dr1 Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004 function ghs2=dr2(ys,dr)
+0005 global M_
+0006
+0007 dr.ys = ys;
+0008 fh = str2func([M_.fname '_static' ]);
+0009 dr.fbias = 2*feval(fh,dr.ys);
+0010 dr=dr1 (dr,0);
+0011 ghs2 = dr.ghs2;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/draw_prior_density.html b/matlab/doc/draw_prior_density.html
new file mode 100644
index 000000000..cb68a8883
--- /dev/null
+++ b/matlab/doc/draw_prior_density.html
@@ -0,0 +1,136 @@
+
+
+
+ Description of draw_prior_density
+
+
+
+
+
+
+
+
+
+Home >
. > draw_prior_density.m
+
+
+
+draw_prior_density
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [07-15-2004]
+
+ SYNOPSIS
+function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+lpdfgam log GAMMA PDFmj_qgamma MJ_QGAMMA The gamma inverse distribution functionqbeta QBETA The beta inverse distribution functionqgamma QGAMMA The gamma inverse distribution functionqnorm QNORM The normal inverse distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);
+0002
+0003
+0004 global bayestopt_
+0005
+0006 pmean = bayestopt_.pmean;
+0007 pshape = bayestopt_.pshape;
+0008 p1 = bayestopt_.p1;
+0009 p2 = bayestopt_.p2;
+0010 p3 = bayestopt_.p3;
+0011 p4 = bayestopt_.p4;
+0012
+0013 truncprior = 10^(-3);
+0014
+0015 if pshape(indx) == 1
+0016 density = inline('((bb-x).^(b-1)).*(x-aa).^(a-1)./(beta(a,b)*(bb-aa)^(a+b-1))' ,'x' ,'a' ,'b' ,'aa' ,'bb' );
+0017 mu = (p1(indx)-p3(indx))/(p4(indx)-p3(indx));
+0018 stdd = p2(indx)/(p4(indx)-p3(indx));
+0019 a = (1-mu)*mu^2/stdd^2 - mu;
+0020 b = a*(1/mu-1);
+0021 aa = p3(indx);
+0022 bb = p4(indx);
+0023 infbound = qbeta (truncprior,a,b)*(bb-aa)+aa;
+0024 supbound = qbeta (1-truncprior,a,b)*(bb-aa)+aa;
+0025 stepsize = (supbound-infbound)/200;
+0026 abscissa = infbound:stepsize:supbound;
+0027 dens = density(abscissa,a,b,aa,bb);
+0028 elseif pshape(indx) == 2
+0029 mu = p1(indx)-p3(indx);
+0030 b = p2(indx)^2/mu;
+0031 a = mu/b;
+0032 infbound = mj_qgamma (truncprior,a)*b;
+0033 supbound = mj_qgamma (1-truncprior,a)*b;
+0034 stepsize = (supbound-infbound)/200;
+0035 abscissa = infbound:stepsize:supbound;
+0036 dens = exp(lpdfgam (abscissa,a,b));
+0037 abscissa = abscissa + p3(indx);
+0038 elseif pshape(indx) == 3
+0039 density = inline('inv(sqrt(2*pi)*b)*exp(-0.5*((x-a)/b).^2)' ,'x' ,'a' ,'b' );
+0040 a = p1(indx);
+0041 b = p2(indx);
+0042 infbound = qnorm (truncprior,a,b);
+0043 supbound = qnorm (1-truncprior,a,b);
+0044 stepsize = (supbound-infbound)/200;
+0045 abscissa = infbound:stepsize:supbound;
+0046 dens = density(abscissa,a,b);
+0047 elseif pshape(indx) == 4
+0048 density = inline('2*inv(gamma(nu/2))*(x.^(-nu-1))*((s/2)^(nu/2)).*exp(-s./(2*x.^2))' ,'x' ,'s' ,'nu' );
+0049 nu = p2(indx);
+0050 s = p1(indx);
+0051 a = nu/2;
+0052 b = 2/s;
+0053 infbound = 1/sqrt(mj_qgamma (1-10*truncprior,a)*b);
+0054 supbound = 1/sqrt(mj_qgamma (10*truncprior,a)*b);
+0055 stepsize = (supbound-infbound)/200;
+0056 abscissa = infbound:stepsize:supbound;
+0057 dens = density(abscissa,s,nu);
+0058 elseif pshape(indx) == 5
+0059 density = inline('(x.^0)/(b-a)' ,'x' ,'a' ,'b' );
+0060 a = p1(indx);
+0061 b = p2(indx);
+0062 infbound = a;
+0063 supbound = b;
+0064 stepsize = (supbound-infbound)/200;
+0065 abscissa = infbound:stepsize:supbound;
+0066 dens = density(abscissa,a,b);
+0067 elseif pshape(indx) == 6
+0068 density = inline('inv(gamma(nu/2))*(x.^(-.5(nu+2)))*((s/2)^(nu/2)).*exp(-s./(2*x))' ,'x' ,'s' ,'nu' );
+0069 nu = p2(indx);
+0070 s = p1(indx);
+0071 a = nu/2;
+0072 b = 2/s;
+0073 infbound = 1/(qgamma (1-truncprior,a)*b);
+0074 supbound = 1/(qgamma (truncprior,a)*b);
+0075 stepsize = (supbound-infbound)/200;
+0076 abscissa = infbound:stepsize:supbound;
+0077 dens = density(abscissa,s,nu);
+0078 end
+0079
+0080 k = [1:length(dens)];
+0081 if pshape(indx) ~= 5
+0082 [junk,k1] = max(dens);
+0083 if k1 == 1 | k1 == length(dens)
+0084 k = find(dens < 10);
+0085 end
+0086 end
+0087 binf = abscissa(k(1));
+0088 bsup = abscissa(k(length(k)));
+0089 x = abscissa(k);
+0090 f = dens(k);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dsample.html b/matlab/doc/dsample.html
new file mode 100644
index 000000000..0e6eaa84d
--- /dev/null
+++ b/matlab/doc/dsample.html
@@ -0,0 +1,93 @@
+
+
+
+ Description of dsample
+
+
+
+
+
+
+
+
+
+
+
+
+
+dsample
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dsample(s1,s2)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dsample(s1,s2)
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015 global options_
+0016
+0017 options_.smpl = zeros(2,1) ;
+0018
+0019 if s1 > options_.periods | s2 > options_.periods
+0020 t = ['DYNARE dsample error: one of the arguments is larger than the one' ...
+0021 ' specified in PERIODS' ];
+0022 error(t);
+0023 end
+0024
+0025 if nargin == 0
+0026 options_.smpl(1) = 1 ;
+0027 options_.smpl(2) = options_.periods ;
+0028 elseif nargin == 1
+0029 options_.smpl(1) = 1 ;
+0030 options_.smpl(2) = s1 ;
+0031 else
+0032 options_.smpl(1) = s1 ;
+0033 options_.smpl(2) = s2 ;
+0034 end
+0035
+0036
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dy_date.html b/matlab/doc/dy_date.html
new file mode 100644
index 000000000..6a7f3b71c
--- /dev/null
+++ b/matlab/doc/dy_date.html
@@ -0,0 +1,52 @@
+
+
+
+ Description of dy_date
+
+
+
+
+
+
+
+
+
+
+
+
+
+dy_date
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function y=dy_date(year,period)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dyn2vec.html b/matlab/doc/dyn2vec.html
new file mode 100644
index 000000000..3360054cc
--- /dev/null
+++ b/matlab/doc/dyn2vec.html
@@ -0,0 +1,105 @@
+
+
+
+ Description of dyn2vec
+
+
+
+
+
+
+
+
+
+
+
+
+
+dyn2vec
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [z,zss]=dyn2vec(s1,s2);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardsimul Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [z,zss]=dyn2vec(s1,s2);
+0004
+0005 global M_ oo_ options_
+0006
+0007 if options_.smpl == 0
+0008 k = [1:size(oo_.y_simul,2)];
+0009 else
+0010 k = [M_.maximum_lag+options_.smpl(1):M_.maximum_lag+options_.smpl(2)];
+0011 end
+0012
+0013 if nargin == 0
+0014 if nargout > 0
+0015 t = ['DYNARE dyn2vec error: the function doesn''t return values when' ...
+0016 ' used without input argument' ];
+0017 error(t);
+0018 end
+0019 for i=1:size(oo_.y_simul,1)
+0020 assignin('base' ,deblank(M_.endo_names(i,:)),oo_.y_simul(i,k)');
+0021 end
+0022 return
+0023 else
+0024 j = strmatch(s1,M_.endo_names,'exact' );
+0025 if ~ isempty(j)
+0026 z = oo_.y_simul(j,k)';
+0027 else
+0028 j = strmatch(s1,M_.exo_names,'exact' );
+0029 if ~ isempty(j)
+0030 if options_.smpl == 0
+0031 z = oo_.exo_simul(:,j);
+0032 else
+0033 z = oo_.exo_simul(M_.maximum_lag+options_.smpl(1):M_.maximum_lag+options_.smpl(2));
+0034 end
+0035 else
+0036 t = ['DYNARE dyn2vec error: variable ' deblank(s1(i,:)) ' doesn''t' ...
+0037 ' exist.' ] ;
+0038 error (t) ;
+0039 end
+0040 end
+0041 end
+0042
+0043 if nargout == 0
+0044 if nargin == 1
+0045 assignin('base' ,s1,z);
+0046 elseif nargin == 2
+0047 assignin('base' ,s2,z);
+0048 end
+0049 else
+0050 zss=oo_.steady_state(j);
+0051 end
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynare.html b/matlab/doc/dynare.html
new file mode 100644
index 000000000..03bdc19e5
--- /dev/null
+++ b/matlab/doc/dynare.html
@@ -0,0 +1,109 @@
+
+
+
+ Description of dynare
+
+
+
+
+
+
+
+
+
+
+
+
+
+dynare
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dynare(fname, varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dynare(fname, varargin)
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012 if ~isstr(fname)
+0013 error ('The argument in DYNARE must be a text string.' ) ;
+0014 end
+0015
+0016
+0017 if isempty(strfind(fname,'.' ))
+0018 fname1 = [fname '.dyn' ];
+0019 d = dir(fname1);
+0020 if length(d) == 0
+0021 fname1 = [fname '.mod' ];
+0022 end
+0023 fname = fname1;
+0024
+0025 else
+0026 if ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.MOD' ) ...
+0027 && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),'.DYN' )
+0028 error ('Argument is a file name with .mod or .dyn extension' );
+0029 end ;
+0030 end ;
+0031 d = dir(fname);
+0032 if length(d) == 0
+0033 disp(['DYNARE: can''t open ' fname])
+0034 return
+0035 end
+0036 dynareroot = strrep(which('dynare.m' ),'dynare.m' ,'' );
+0037 command = [dynareroot 'dynare_m ' fname] ;
+0038 for i=2:nargin
+0039 command = [command ' ' varargin{i-1}];
+0040 end
+0041 [status, result] = system(command);
+0042 if status
+0043 error(result)
+0044 end
+0045
+0046 if ~ isempty(find(abs(fname) == 46))
+0047 fname = fname(:,1:find(abs(fname) == 46)-1) ;
+0048 end
+0049 evalin('base' ,fname) ;
+0050
+0051
+0052
+0053
+0054
+0055
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynare_MC.html b/matlab/doc/dynare_MC.html
new file mode 100644
index 000000000..a5d460670
--- /dev/null
+++ b/matlab/doc/dynare_MC.html
@@ -0,0 +1,302 @@
+
+
+
+ Description of dynare_MC
+
+
+
+
+
+
+
+
+
+
+
+
+
+dynare_MC
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function dynare_MC(var_list_)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function dynare_MC(var_list_)
+0002
+0003 global M_ options_ oo_ estim_params_
+0004 global bayestopt_
+0005
+0006 options_.varlist = var_list_;
+0007 options_.lgyidx2varobs = zeros(size(M_.endo_names,1),1);
+0008 for i = 1:size(M_.endo_names,1)
+0009 tmp = strmatch(deblank(M_.endo_names(i,:)),options_.varobs,'exact' );
+0010 if ~isempty(tmp)
+0011 options_.lgyidx2varobs(i,1) = tmp;
+0012 end
+0013 end
+0014
+0015 options_ = set_default_option (options_,'first_obs' ,1);
+0016 options_ = set_default_option (options_,'prefilter' ,0);
+0017 options_ = set_default_option (options_,'presample' ,0);
+0018 options_ = set_default_option (options_,'lik_algo' ,1);
+0019 options_ = set_default_option (options_,'lik_init' ,1);
+0020 options_ = set_default_option (options_,'nograph' ,0);
+0021 options_ = set_default_option (options_,'mh_conf_sig' ,0.90);
+0022 options_ = set_default_option (options_,'mh_replic' ,20000);
+0023 options_ = set_default_option (options_,'mh_drop' ,0.5);
+0024 options_ = set_default_option (options_,'mh_jscale' ,0.2);
+0025 options_ = set_default_option (options_,'mh_init_scale' ,2*options_.mh_jscale);
+0026 options_ = set_default_option (options_,'mode_file' ,'' );
+0027 options_ = set_default_option (options_,'mode_compute' ,4);
+0028 options_ = set_default_option (options_,'mode_check' ,0);
+0029 options_ = set_default_option (options_,'prior_trunc' ,1e-10);
+0030 options_ = set_default_option (options_,'mh_mode' ,1);
+0031 options_ = set_default_option (options_,'mh_nblck' ,2);
+0032 options_ = set_default_option (options_,'load_mh_file' ,0);
+0033 options_ = set_default_option (options_,'nodiagnostic' ,0);
+0034 options_ = set_default_option (options_,'loglinear' ,0);
+0035 options_ = set_default_option (options_,'unit_root_vars' ,[]);
+0036 options_ = set_default_option (options_,'XTick' ,[]);
+0037 options_ = set_default_option (options_,'XTickLabel' ,[]);
+0038 options_ = set_default_option (options_,'bayesian_irf' ,0);
+0039 options_ = set_default_option (options_,'bayesian_th_moments' ,0);
+0040 options_ = set_default_option (options_,'TeX' ,0);
+0041 options_ = set_default_option (options_,'irf' ,0);
+0042 options_ = set_default_option (options_,'relative_irf' ,0);
+0043 options_ = set_default_option (options_,'order' ,1);
+0044 options_ = set_default_option (options_,'ar' ,5);
+0045 options_ = set_default_option (options_,'dr_algo' ,0);
+0046 options_ = set_default_option (options_,'linear' ,0);
+0047 options_ = set_default_option (options_,'drop' ,0);
+0048 options_ = set_default_option (options_,'replic' ,1);
+0049 options_ = set_default_option (options_,'hp_filter' ,0);
+0050 options_ = set_default_option (options_,'forecast' ,0);
+0051 options_ = set_default_option (options_,'smoother' ,0);
+0052 options_ = set_default_option (options_,'moments_varendo' ,0);
+0053 options_ = set_default_option (options_,'filtered_vars' ,0);
+0054 options_ = set_default_option (options_,'kalman_algo' ,1);
+0055 options_ = set_default_option (options_,'kalman_tol' ,10^(-12));
+0056 options_ = set_default_option (options_,'posterior_mode_estimation' ,1);
+0057 options_ = set_default_option (options_,'MaxNumberOfBytes' ,1e6);
+0058 options_ = set_default_option (options_,'xls_sheet' ,'' );
+0059 options_ = set_default_option (options_,'xls_range' ,'' );
+0060
+0061
+0062 M_.dname = M_.fname;
+0063
+0064
+0065
+0066 pnames = [' ' ;'beta ' ;'gamm ' ;'norm ' ;'invg ' ;'unif ' ;'invg2' ];
+0067 n_varobs = size(options_.varobs,1);
+0068
+0069 [xparam1,estim_params_,bayestopt_,lb,ub] = set_prior (estim_params_);
+0070
+0071 options_.mh_replic = 0;
+0072
+0073 bounds = prior_bounds (bayestopt_);
+0074 bounds(:,1)=max(bounds(:,1),lb);
+0075 bounds(:,2)=min(bounds(:,2),ub);
+0076
+0077 if any(xparam1 < bounds(:,1)) | any(xparam1 > bounds(:,2))
+0078 find(xparam1 < bounds(:,1))
+0079 find(xparam1 > bounds(:,2))
+0080 error('Initial parameter values are outside parameter bounds' )
+0081 end
+0082 lb = bounds(:,1);
+0083 ub = bounds(:,2);
+0084 bayestopt_.lb = lb;
+0085 bayestopt_.ub = ub;
+0086
+0087 if ~isfield(options_,'trend_coeffs' )
+0088 bayestopt_.with_trend = 0;
+0089 else
+0090 bayestopt_.with_trend = 1;
+0091 bayestopt_.trend_coeff = {};
+0092 trend_coeffs = options_.trend_coeffs;
+0093 nt = length(trend_coeffs);
+0094 for i=1:n_varobs
+0095 if i > length(trend_coeffs)
+0096 bayestopt_.trend_coeff{i} = '0' ;
+0097 else
+0098 bayestopt_.trend_coeff{i} = trend_coeffs{i};
+0099 end
+0100 end
+0101 end
+0102
+0103 bayestopt_.penalty = 1e8;
+0104
+0105 nvx = estim_params_.nvx;
+0106 nvn = estim_params_.nvn;
+0107 ncx = estim_params_.ncx;
+0108 ncn = estim_params_.ncn;
+0109 np = estim_params_.np ;
+0110 nx = nvx+nvn+ncx+ncn+np;
+0111
+0112
+0113 if exist([M_.fname '_steadystate' ])
+0114 bayestopt_.static_solve = [M_.fname '_steadystate' ];
+0115 else
+0116 bayestopt_.static_solve = 'dynare_solve' ;
+0117 end
+0118
+0119 dr = set_state_space ([]);
+0120
+0121
+0122 if ~isempty(options_.unit_root_vars)
+0123 n_ur = size(options_.unit_root_vars,1);
+0124 i_ur = zeros(n_ur,1);
+0125 for i=1:n_ur
+0126 i1 = strmatch(deblank(options_.unit_root_vars(i,:)),M_.endo_names(dr.order_var,:),'exact' );
+0127 if isempty(i1)
+0128 error('Undeclared variable in unit_root_vars statement' )
+0129 end
+0130 i_ur(i) = i1;
+0131 end
+0132 if M_.maximum_lag > 1
+0133 l1 = flipud([cumsum(M_.lead_lag_incidence(1:M_.maximum_lag-1,dr.order_var),1);ones(1,M_.endo_nbr)]);
+0134 n1 = nnz(l1);
+0135 bayestopt_.Pinf = zeros(n1,n1);
+0136 l2 = find(l1');
+0137 l3 = zeros(M_.endo_nbr,M_.maximum_lag);
+0138 l3(i_ur,:) = l1(:,i_ur)';
+0139 l3 = l3(:);
+0140 i_ur1 = find(l3(l2));
+0141 i_stable = ones(M_.endo_nbr,1);
+0142 i_stable(i_ur) = zeros(n_ur,1);
+0143 i_stable = find(i_stable);
+0144 bayestopt_.Pinf(i_ur1,i_ur1) = diag(ones(1,length(i_ur1)));
+0145 bayestopt_.i_var_stable = i_stable;
+0146 l3 = zeros(M_.endo_nbr,M_.maximum_lag);
+0147 l3(i_stable,:) = l1(:,i_stable)';
+0148 l3 = l3(:);
+0149 bayestopt_.i_T_var_stable = find(l3(l2));
+0150 else
+0151 n1 = M_.endo_nbr;
+0152 bayestopt_.Pinf = zeros(n1,n1);
+0153 bayestopt_.Pinf(i_ur,i_ur) = diag(ones(1,length(i_ur)));
+0154 l1 = ones(M_.endo_nbr,1);
+0155 l1(i_ur,:) = zeros(length(i_ur),1);
+0156 bayestopt_.i_T_var_stable = find(l1);
+0157 end
+0158 options_.lik_init = 3;
+0159 end
+0160
+0161 if isempty(options_.datafile)
+0162 error('ESTIMATION: datafile option is missing' )
+0163 end
+0164
+0165 if isempty(options_.varobs)
+0166 error('ESTIMATION: VAROBS is missing' )
+0167 end
+0168
+0169
+0170
+0171
+0172 k = find(isnan(bayestopt_.jscale));
+0173 bayestopt_.jscale(k) = options_.mh_jscale;
+0174
+0175
+0176 rawdata = read_variables (options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
+0177
+0178 k = [];
+0179 k1 = [];
+0180 for i=1:n_varobs
+0181 k = [k strmatch(deblank(options_.varobs(i,:)),M_.endo_names(dr.order_var,:), ...
+0182 'exact' )];
+0183 k1 = [k1 strmatch(deblank(options_.varobs(i,:)),M_.endo_names, 'exact' )];
+0184 end
+0185
+0186 bayestopt_.mf = k;
+0187 bayestopt_.mfys = k1;
+0188 options_ = set_default_option (options_,'nobs' ,size(rawdata,1)-options_.first_obs+1);
+0189 gend = options_.nobs;
+0190
+0191 rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
+0192 if options_.loglinear == 1
+0193 rawdata = log(rawdata);
+0194 end
+0195 if options_.prefilter == 1
+0196 bayestopt_.mean_varobs = mean(rawdata,1);
+0197 data = transpose(rawdata-ones(gend,1)*bayestopt_.mean_varobs);
+0198 else
+0199 data = transpose(rawdata);
+0200 end
+0201
+0202 if ~isreal(rawdata)
+0203 error(['There are complex values in the data. Probably a wrong' ...
+0204 ' transformation' ])
+0205 end
+0206
+0207 nvx = estim_params_.nvx;
+0208 nvn = estim_params_.nvn;
+0209 ncx = estim_params_.ncx;
+0210 ncn = estim_params_.ncn;
+0211 np = estim_params_.np ;
+0212 npar = nvx+nvn+ncx+ncn+np;
+0213 offset = npar-np;
+0214 fname_=M_.fname;
+0215
+0216 options_ = set_default_option (options_,'opt_gsa' ,1);
+0217 options_gsa_ = options_.opt_gsa;
+0218
+0219 if options_gsa_.pprior,
+0220 load([fname_,'_prior' ])
+0221 namfile=[fname_,'_prior' ];
+0222 else
+0223 load([fname_,'_mc' ])
+0224 namfile=[fname_,'_mc' ];
+0225 end
+0226 load(options_.mode_file)
+0227
+0228
+0229
+0230 x=[lpmat0(istable,:) lpmat(istable,:)];
+0231 clear lpmat lpmat0 istable iunstable egg yys T
+0232 B = size(x,1);
+0233 if M_.maximum_lag > 1
+0234 l1 = flipud([cumsum(M_.lead_lag_incidence(1:M_.maximum_lag-1,dr.order_var),1);ones(1,M_.endo_nbr)]);
+0235 n1 = nnz(l1);
+0236 else
+0237 n1 = M_.endo_nbr;
+0238 end
+0239 stock_smooth = zeros(gend,n1,B);
+0240 stock_filter = zeros(gend+1,n1,B);
+0241 stock_ys = zeros(M_.endo_nbr,B);
+0242
+0243 h = waitbar(0,'MC smoother ...' );
+0244 for b=1:B
+0245 deep = x(b,:);
+0246
+0247 logpo2(b) = DsgeLikelihood (deep',gend,data);
+0248 [atT,innov,measurement_error,filtered_state_vector,ys,trend_coeff] = DsgeSmoother (deep,gend,data);
+0249 stock_smooth(:,:,b)=atT';
+0250 stock_filter(:,:,b)=filtered_state_vector';
+0251 stock_ys(:,b)=ys;
+0252 waitbar(b/B,h,['MC smoother ...' ,num2str(b),'/' ,num2str(B)]);
+0253 end
+0254 close(h)
+0255
+0256 save(namfile,'x' ,'logpo2' ,'stock_smooth' ,'stock_filter' ,'stock_ys' ,'-append' )
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynare_estimation.html b/matlab/doc/dynare_estimation.html
new file mode 100644
index 000000000..2819bcc8d
--- /dev/null
+++ b/matlab/doc/dynare_estimation.html
@@ -0,0 +1,1242 @@
+
+
+
+ Description of dynare_estimation
+
+
+
+
+
+
+
+
+
+Home >
. > dynare_estimation.m
+
+
+
+dynare_estimation
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function dynare_estimation(var_list_)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+CheckPath 06-03-2005CutSample stephane.adjemian@ens.fr [09-09-2005]DsgeLikelihood stephane.adjemian@cepremap.cnrs.fr [09-07-2004]DsgeSmoother stephane.adjemian@cepremap.cnrs.fr [09-07-2004]GetPosteriorParametersStatistics stephane.adjemian@ens.fr [09-09-2005]McMCDiagnostics stephane.adjemian@ens.fr [06-04-2005]PlotPosteriorDistributions stephane.adjemian@ens.fr [09-09-2005]PosteriorIRF stephane.adjemian@ens.fr [09-25-2005]asamin ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)csminwel [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)generalized_cholesky proc gmchol(A);hessian Copyright (C) 2001 Michel Juillardinitial_estimation_checks marginal_density stephane.adjemian@ens.fr [09-09-2005]metropolis stephane.adjemian@ens.fr [09-02-2005]metropolis_draw mode_check newrat plot_priors stephane.adjemian@cepremap.cnrs.fr [07-31-2004]pltorg stephane.adjemian@cepremap.cnrs.fr [06-07-2004]prior_bounds read_variables Copyright (C) 2005 Michel Juillardset_default_option set_prior set_state_space Copyright (C) 2001 Michel Juillardunion
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function dynare_estimation(var_list_)
+0002
+0003 global M_ options_ oo_ estim_params_
+0004 global bayestopt_
+0005
+0006
+0007 M_.H = [];
+0008
+0009 options_.varlist = var_list_;
+0010 options_.lgyidx2varobs = zeros(size(M_.endo_names,1),1);
+0011 for i = 1:size(M_.endo_names,1)
+0012 tmp = strmatch(deblank(M_.endo_names(i,:)),options_.varobs,'exact' );
+0013 if ~isempty(tmp)
+0014 options_.lgyidx2varobs(i,1) = tmp;
+0015 end
+0016 end
+0017
+0018 options_ = set_default_option (options_,'first_obs' ,1);
+0019 options_ = set_default_option (options_,'prefilter' ,0);
+0020 options_ = set_default_option (options_,'presample' ,0);
+0021 options_ = set_default_option (options_,'lik_algo' ,1);
+0022 options_ = set_default_option (options_,'lik_init' ,1);
+0023 options_ = set_default_option (options_,'nograph' ,0);
+0024 options_ = set_default_option (options_,'mh_conf_sig' ,0.90);
+0025 options_ = set_default_option (options_,'mh_replic' ,20000);
+0026 options_ = set_default_option (options_,'mh_drop' ,0.5);
+0027 options_ = set_default_option (options_,'mh_jscale' ,0.2);
+0028 options_ = set_default_option (options_,'mh_init_scale' ,2*options_.mh_jscale);
+0029 options_ = set_default_option (options_,'mode_file' ,'' );
+0030 options_ = set_default_option (options_,'mode_compute' ,4);
+0031 options_ = set_default_option (options_,'mode_check' ,0);
+0032 options_ = set_default_option (options_,'prior_trunc' ,1e-10);
+0033 options_ = set_default_option (options_,'mh_mode' ,1);
+0034 options_ = set_default_option (options_,'mh_nblck' ,2);
+0035 options_ = set_default_option (options_,'load_mh_file' ,0);
+0036 options_ = set_default_option (options_,'nodiagnostic' ,0);
+0037 options_ = set_default_option (options_,'loglinear' ,0);
+0038 options_ = set_default_option (options_,'unit_root_vars' ,[]);
+0039 options_ = set_default_option (options_,'XTick' ,[]);
+0040 options_ = set_default_option (options_,'XTickLabel' ,[]);
+0041 options_ = set_default_option (options_,'bayesian_irf' ,0);
+0042 options_ = set_default_option (options_,'bayesian_th_moments' ,0);
+0043 options_ = set_default_option (options_,'TeX' ,0);
+0044 options_ = set_default_option (options_,'irf' ,40);
+0045 options_ = set_default_option (options_,'relative_irf' ,0);
+0046 options_ = set_default_option (options_,'order' ,1);
+0047 options_ = set_default_option (options_,'ar' ,5);
+0048 options_ = set_default_option (options_,'dr_algo' ,0);
+0049 options_ = set_default_option (options_,'linear' ,0);
+0050 options_ = set_default_option (options_,'drop' ,0);
+0051 options_ = set_default_option (options_,'replic' ,1);
+0052 options_ = set_default_option (options_,'hp_filter' ,0);
+0053 options_ = set_default_option (options_,'forecast' ,0);
+0054 options_ = set_default_option (options_,'smoother' ,0);
+0055 options_ = set_default_option (options_,'moments_varendo' ,0);
+0056 options_ = set_default_option (options_,'filtered_vars' ,0);
+0057 options_ = set_default_option (options_,'kalman_algo' ,1);
+0058 options_ = set_default_option (options_,'kalman_tol' ,10^(-12));
+0059 options_ = set_default_option (options_,'posterior_mode_estimation' ,1);
+0060 options_ = set_default_option (options_,'MaxNumberOfBytes' ,1e6);
+0061 options_ = set_default_option (options_,'xls_sheet' ,'' );
+0062 options_ = set_default_option (options_,'xls_range' ,'' );
+0063 options_ = set_default_option (options_,'filter_step_ahead' ,0);
+0064 options_ = set_default_option (options_,'diffuse_d' ,[]);
+0065 if options_.filtered_vars ~= 0 & options_.filter_step_ahead == 0
+0066 options_.filter_step_ahead = 1;
+0067 end
+0068 if options_.filter_step_ahead ~= 0
+0069 options_.nk = max(options_.filter_step_ahead);
+0070 else
+0071 options_.nk = 0;
+0072 end
+0073
+0074
+0075 M_.dname = M_.fname;
+0076
+0077
+0078
+0079 pnames = [' ' ;'beta ' ;'gamm ' ;'norm ' ;'invg ' ;'unif ' ;'invg2' ];
+0080 n_varobs = size(options_.varobs,1);
+0081
+0082 [xparam1,estim_params_,bayestopt_,lb,ub] = set_prior (estim_params_);
+0083
+0084 if any(bayestopt_.pshape > 0)
+0085 if options_.mode_compute
+0086 plot_priors
+0087 end
+0088 else
+0089 options_.mh_replic = 0;
+0090 end
+0091
+0092 bounds = prior_bounds (bayestopt_);
+0093 bounds(:,1)=max(bounds(:,1),lb);
+0094 bounds(:,2)=min(bounds(:,2),ub);
+0095
+0096 if any(xparam1 < bounds(:,1)) | any(xparam1 > bounds(:,2))
+0097 find(xparam1 < bounds(:,1))
+0098 find(xparam1 > bounds(:,2))
+0099 error('Initial parameter values are outside parameter bounds' )
+0100 end
+0101 lb = bounds(:,1);
+0102 ub = bounds(:,2);
+0103 bayestopt_.lb = lb;
+0104 bayestopt_.ub = ub;
+0105
+0106 if ~isfield(options_,'trend_coeffs' )
+0107 bayestopt_.with_trend = 0;
+0108 else
+0109 bayestopt_.with_trend = 1;
+0110 bayestopt_.trend_coeff = {};
+0111 trend_coeffs = options_.trend_coeffs;
+0112 nt = length(trend_coeffs);
+0113 for i=1:n_varobs
+0114 if i > length(trend_coeffs)
+0115 bayestopt_.trend_coeff{i} = '0' ;
+0116 else
+0117 bayestopt_.trend_coeff{i} = trend_coeffs{i};
+0118 end
+0119 end
+0120 end
+0121
+0122 bayestopt_.penalty = 1e8;
+0123
+0124 nvx = estim_params_.nvx;
+0125 nvn = estim_params_.nvn;
+0126 ncx = estim_params_.ncx;
+0127 ncn = estim_params_.ncn;
+0128 np = estim_params_.np ;
+0129 nx = nvx+nvn+ncx+ncn+np;
+0130
+0131
+0132 if exist([M_.fname '_steadystate' ])
+0133 bayestopt_.static_solve = [M_.fname '_steadystate' ];
+0134 else
+0135 bayestopt_.static_solve = 'dynare_solve' ;
+0136 end
+0137
+0138 dr = set_state_space ([]);
+0139
+0140
+0141 if ~isempty(options_.unit_root_vars)
+0142 n_ur = size(options_.unit_root_vars,1);
+0143 i_ur = zeros(n_ur,1);
+0144 for i=1:n_ur
+0145 i1 = strmatch(deblank(options_.unit_root_vars(i,:)),M_.endo_names(dr.order_var,:),'exact' );
+0146 if isempty(i1)
+0147 error('Undeclared variable in unit_root_vars statement' )
+0148 end
+0149 i_ur(i) = i1;
+0150 end
+0151 if M_.maximum_lag > 1
+0152 l1 = flipud([cumsum(M_.lead_lag_incidence(1:M_.maximum_lag-1,dr.order_var),1);ones(1,M_.endo_nbr)]);
+0153 n1 = nnz(l1);
+0154 bayestopt_.Pinf = zeros(n1,n1);
+0155 l2 = find(l1');
+0156 l3 = zeros(M_.endo_nbr,M_.maximum_lag);
+0157 l3(i_ur,:) = l1(:,i_ur)';
+0158 l3 = l3(:);
+0159 i_ur1 = find(l3(l2));
+0160 i_stable = ones(M_.endo_nbr,1);
+0161 i_stable(i_ur) = zeros(n_ur,1);
+0162 i_stable = find(i_stable);
+0163 bayestopt_.Pinf(i_ur1,i_ur1) = diag(ones(1,length(i_ur1)));
+0164 bayestopt_.i_var_stable = i_stable;
+0165 l3 = zeros(M_.endo_nbr,M_.maximum_lag);
+0166 l3(i_stable,:) = l1(:,i_stable)';
+0167 l3 = l3(:);
+0168 bayestopt_.i_T_var_stable = find(l3(l2));
+0169 else
+0170 n1 = M_.endo_nbr;
+0171 bayestopt_.Pinf = zeros(n1,n1);
+0172 bayestopt_.Pinf(i_ur,i_ur) = diag(ones(1,length(i_ur)));
+0173 l1 = ones(M_.endo_nbr,1);
+0174 l1(i_ur,:) = zeros(length(i_ur),1);
+0175 bayestopt_.i_T_var_stable = find(l1);
+0176 end
+0177 options_.lik_init = 3;
+0178 end
+0179
+0180 if isempty(options_.datafile)
+0181 error('ESTIMATION: datafile option is missing' )
+0182 end
+0183
+0184 if isempty(options_.varobs)
+0185 error('ESTIMATION: VAROBS is missing' )
+0186 end
+0187
+0188
+0189
+0190
+0191 k = find(isnan(bayestopt_.jscale));
+0192 bayestopt_.jscale(k) = options_.mh_jscale;
+0193
+0194
+0195 rawdata = read_variables (options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
+0196
+0197 k = [];
+0198 k1 = [];
+0199 for i=1:n_varobs
+0200 k = [k strmatch(deblank(options_.varobs(i,:)),M_.endo_names(dr.order_var,:),'exact' )];
+0201 k1 = [k1 strmatch(deblank(options_.varobs(i,:)),M_.endo_names, 'exact' )];
+0202 end
+0203
+0204 k2 = union (k',[dr.nstatic+1:dr.nstatic+dr.npred]');
+0205
+0206 k2 = [k2;[M_.endo_nbr+(1:dr.nspred-dr.npred)]'];
+0207
+0208
+0209
+0210 bayestopt_.restrict_state = k2;
+0211
+0212
+0213 [junk,bayestopt_.mf1] = ismember(k,k2);
+0214
+0215
+0216 bayestopt_.mf2 = k;
+0217 bayestopt_.mfys = k1;
+0218 bayestopt_.Z = zeros(n_varobs,length(k2));
+0219 for i=1:n_varobs
+0220 bayestopt_.Z(i,bayestopt_.mf1(i)) = 1;
+0221 end
+0222
+0223 options_ = set_default_option (options_,'nobs' ,size(rawdata,1)-options_.first_obs+1);
+0224 gend = options_.nobs;
+0225
+0226 rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
+0227 if options_.loglinear == 1
+0228 rawdata = log(rawdata);
+0229 end
+0230 if options_.prefilter == 1
+0231 bayestopt_.mean_varobs = mean(rawdata,1);
+0232 data = transpose(rawdata-ones(gend,1)*bayestopt_.mean_varobs);
+0233 else
+0234 data = transpose(rawdata);
+0235 end
+0236
+0237 if ~isreal(rawdata)
+0238 error(['There are complex values in the data. Probably a wrong' ...
+0239 ' transformation' ])
+0240 end
+0241
+0242 if length(options_.mode_file) > 0 & options_.posterior_mode_estimation
+0243 eval(['load ' options_.mode_file ';' ]');
+0244 end
+0245
+0246 initial_estimation_checks (xparam1,gend,data);
+0247
+0248
+0249 if options_.mode_compute > 0 & options_.posterior_mode_estimation
+0250 fh=str2func('DsgeLikelihood' );
+0251 if options_.mode_compute == 1
+0252 optim_options = optimset('display' ,'iter' ,'LargeScale' ,'off' , ...
+0253 'MaxFunEvals' ,100000,'TolFun' ,1e-8,'TolX' ,1e-6);
+0254 if isfield(options_,'optim_opt' )
+0255 eval(['optim_options = optimset(optim_options,' options_.optim_opt ');' ]);
+0256 end
+0257 [xparam1,fval,exitflag,output,lamdba,grad,hessian_fmincon] = ...
+0258 fmincon(fh,xparam1,[],[],[],[],lb,ub,[],optim_options,gend,data);
+0259 elseif options_.mode_compute == 2
+0260
+0261 [fval,xparam1,grad,hessian_asamin,exitflag] = ...
+0262 asamin ('minimize' ,'DsgeLikelihood' ,xparam1,lb,ub,- ...
+0263 ones(size(xparam1)),gend,data);
+0264 elseif options_.mode_compute == 3
+0265 optim_options = optimset('display' ,'iter' ,...
+0266 'MaxFunEvals' ,100000,'TolFun' ,1e-8,'TolX' ,1e-6);
+0267 if isfield(options_,'optim_opt' )
+0268 eval(['optim_options = optimset(optim_options,' options_.optim_opt ');' ]);
+0269 end
+0270 [xparam1,fval,exitflag] = fminunc(fh,xparam1,optim_options,gend, ...
+0271 data);
+0272 elseif options_.mode_compute == 4
+0273 H0 = 1e-4*eye(nx);
+0274 crit = 1e-7;
+0275 nit = 1000;
+0276 verbose = 2;
+0277 [fval,xparam1,grad,hessian_csminwel,itct,fcount,retcodehat] = ...
+0278 csminwel ('DsgeLikelihood' ,xparam1,H0,[],crit,nit,gend,data);
+0279 disp(sprintf('Objective function at mode: %f' ,fval))
+0280 disp(sprintf('Objective function at mode: %f' ,DsgeLikelihood (xparam1,gend,data)))
+0281 elseif options_.mode_compute == 5
+0282 if isfield(options_,'hess' )
+0283 flag = options_.hess;
+0284 else
+0285 flag = 1;
+0286 end
+0287 if ~exist('igg' ),
+0288 hh=[];
+0289 gg=[];
+0290 igg=[];
+0291 end
+0292 if isfield(options_,'ftol' )
+0293 crit = options_.ftol;
+0294 else
+0295 crit = 1.e-7;
+0296 end
+0297 if isfield(options_,'nit' )
+0298 nit = options_.nit;
+0299 else
+0300 nit=1000;
+0301 end
+0302
+0303 [xparam1, hh, gg, fval, invhess] = newrat ('DsgeLikelihood' ,xparam1,hh,gg,igg,crit,nit,flag,gend,data);
+0304 eval(['save ' M_.fname '_mode xparam1 hh gg fval invhess;' ]);
+0305 end
+0306 if options_.mode_compute ~= 5
+0307 hh = reshape(hessian ('DsgeLikelihood' ,xparam1,gend,data),nx,nx);
+0308 eval(['save ' M_.fname '_mode xparam1 hh fval;' ]);
+0309 end
+0310 eval(['save ' M_.fname '_mode xparam1 hh;' ]);
+0311 end
+0312
+0313 if options_.mode_check == 1 & options_.posterior_mode_estimation
+0314 mode_check (xparam1,0,hh,gend,data,lb,ub);
+0315 end
+0316
+0317 if options_.posterior_mode_estimation
+0318 hh = generalized_cholesky (hh);
+0319 invhess = inv(hh);
+0320 stdh = sqrt(diag(invhess));
+0321 else
+0322 invhess = eye(length(xparam1));
+0323 end
+0324
+0325 if any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
+0326 disp(' ' )
+0327 disp('RESULTS FROM POSTERIOR MAXIMIZATION' )
+0328 tstath = zeros(nx,1);
+0329 for i = 1:nx
+0330 tstath(i) = abs(xparam1(i))/stdh(i);
+0331 end
+0332 tit1 = sprintf('%10s %7s %8s %7s %6s %4s %6s\n' ,' ' ,'prior mean' , ...
+0333 'mode' ,'s.d.' ,'t-stat' ,'prior' ,'pstdev' );
+0334 if np
+0335 ip = nvx+nvn+ncx+ncn+1;
+0336 disp('parameters' )
+0337 disp(tit1)
+0338 for i=1:np
+0339 name = bayestopt_.name{ip};
+0340 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , ...
+0341 name, ...
+0342 bayestopt_.pmean(ip),xparam1(ip),stdh(ip),tstath(ip), ...
+0343 pnames(bayestopt_.pshape(ip)+1,:), ...
+0344 bayestopt_.pstdev(ip)));
+0345 eval(['oo_.posterior_mode.parameters.' name ' = xparam1(ip);' ]);
+0346 eval(['oo_.posterior_std.parameters.' name ' = stdh(ip);' ]);
+0347 ip = ip+1;
+0348 end
+0349 end
+0350 if nvx
+0351 ip = 1;
+0352 disp('standard deviation of shocks' )
+0353 disp(tit1)
+0354 for i=1:nvx
+0355 k = estim_params_.var_exo(i,1);
+0356 name = deblank(M_.exo_names(k,:));
+0357 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , ...
+0358 name,bayestopt_.pmean(ip),xparam1(ip), ...
+0359 stdh(ip),tstath(ip),pnames(bayestopt_.pshape(ip)+1,:), ...
+0360 bayestopt_.pstdev(ip)));
+0361 M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
+0362 eval(['oo_.posterior_mode.shocks_std.' name ' = xparam1(ip);' ]);
+0363 eval(['oo_.posterior_std.shocks_std.' name ' = stdh(ip);' ]);
+0364 ip = ip+1;
+0365 end
+0366 end
+0367 if nvn
+0368 disp('standard deviation of measurement errors' )
+0369 disp(tit1)
+0370 ip = nvx+1;
+0371 for i=1:nvn
+0372 name = deblank(options_.varobs(estim_params_.var_endo(i,1),:));
+0373 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , ...
+0374 name,bayestopt_.pmean(ip), ...
+0375 xparam1(ip),stdh(ip),tstath(ip), ...
+0376 pnames(bayestopt_.pshape(ip)+1,:), ...
+0377 bayestopt_.pstdev(ip)));
+0378 eval(['oo_.posterior_mode.measurement_errors_std.' name ' = xparam1(ip);' ]);
+0379 eval(['oo_.posterior_std.measurement_errors_std.' name ' = stdh(ip);' ]);
+0380 ip = ip+1;
+0381 end
+0382 end
+0383 if ncx
+0384 disp('correlation of shocks' )
+0385 disp(tit1)
+0386 ip = nvx+nvn+1;
+0387 for i=1:ncx
+0388 k1 = estim_params_.corrx(i,1);
+0389 k2 = estim_params_.corrx(i,2);
+0390 name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
+0391 NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
+0392 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , name, ...
+0393 bayestopt_.pmean(ip),xparam1(ip),stdh(ip),tstath(ip), ...
+0394 pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.pstdev(ip)));
+0395 M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
+0396 M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
+0397 eval(['oo_.posterior_mode.shocks_corr.' NAME ' = xparam1(ip);' ]);
+0398 eval(['oo_.posterior_std.shocks_corr.' NAME ' = stdh(ip);' ]);
+0399 ip = ip+1;
+0400 end
+0401 end
+0402 if ncn
+0403 disp('correlation of measurement errors' )
+0404 disp(tit1)
+0405 ip = nvx+nvn+ncx+1;
+0406 for i=1:ncn
+0407 k1 = estim_params_.corrn(i,1);
+0408 k2 = estim_params_.corrn(i,2);
+0409 name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
+0410 NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
+0411 disp(sprintf('%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f' , name, ...
+0412 bayestopt_.pmean(ip),xparam1(ip),stdh(ip),tstath(ip), ...
+0413 pnames(bayestopt_.pshape(ip)+1,:), bayestopt_.pstdev(ip)));
+0414 eval(['oo_.posterior_mode.measurement_errors_corr.' NAME ' = xparam1(ip);' ]);
+0415 eval(['oo_.posterior_std.measurement_errors_corr.' NAME ' = stdh(ip);' ]);
+0416 ip = ip+1;
+0417 end
+0418 end
+0419
+0420 md_Laplace = .5*size(xparam1,1)*log(2*pi) + .5*log(det(invhess)) ...
+0421 - DsgeLikelihood (xparam1,gend,data);
+0422 oo_.MarginalDensity.LaplaceApproximation = md_Laplace;
+0423 disp(' ' )
+0424 disp(sprintf('Log data density [Laplace approximation] is %f.' ,md_Laplace))
+0425 disp(' ' )
+0426 elseif ~any(bayestopt_.pshape > 0) & options_.posterior_mode_estimation
+0427 disp(' ' )
+0428 disp('RESULTS FROM MAXIMUM LIKELIHOOD' )
+0429 tstath = zeros(nx,1);
+0430 for i = 1:nx
+0431 tstath(i) = abs(xparam1(i))/stdh(i);
+0432 end
+0433 tit1 = sprintf('%10s %10s %7s %6s\n' ,' ' ,'Estimate' ,'s.d.' ,'t-stat' );
+0434 if np
+0435 ip = nvx+nvn+ncx+ncn+1;
+0436 disp('parameters' )
+0437 disp(tit1)
+0438 for i=1:np
+0439 name = bayestopt_.name{ip};
+0440 disp(sprintf('%12s %8.4f %7.4f %7.4f' , ...
+0441 name,xparam1(ip),stdh(ip),tstath(ip)));
+0442 eval(['oo_.mle_mode.parameters.' name ' = xparam1(ip);' ]);
+0443 eval(['oo_.mle_std.parameters.' name ' = stdh(ip);' ]);
+0444 ip = ip+1;
+0445 end
+0446 end
+0447 if nvx
+0448 ip = 1;
+0449 disp('standard deviation of shocks' )
+0450 disp(tit1)
+0451 for i=1:nvx
+0452 k = estim_params_.var_exo(i,1);
+0453 name = deblank(M_.exo_names(k,:));
+0454 disp(sprintf('%12s %8.4f %7.4f %7.4f' ,name,xparam1(ip),stdh(ip),tstath(ip)));
+0455 M_.Sigma_e(k,k) = xparam1(ip)*xparam1(ip);
+0456 eval(['oo_.mle_mode.shocks_std.' name ' = xparam1(ip);' ]);
+0457 eval(['oo_.mle_std.shocks_std.' name ' = stdh(ip);' ]);
+0458 ip = ip+1;
+0459 end
+0460 end
+0461 if nvn
+0462 disp('standard deviation of measurement errors' )
+0463 disp(tit1)
+0464 ip = nvx+1;
+0465 for i=1:nvn
+0466 name = deblank(options_.varobs(estim_params_.var_endo(i,1),:));
+0467 disp(sprintf('%12s %8.4f %7.4f %7.4f' ,name,xparam1(ip),stdh(ip),tstath(ip)))
+0468 eval(['oo_.mle_mode.measurement_errors_std.' name ' = xparam1(ip);' ]);
+0469 eval(['oo_.mle_std.measurement_errors_std.' name ' = stdh(ip);' ]);
+0470 ip = ip+1;
+0471 end
+0472 end
+0473 if ncx
+0474 disp('correlation of shocks' )
+0475 disp(tit1)
+0476 ip = nvx+nvn+1;
+0477 for i=1:ncx
+0478 k1 = estim_params_.corrx(i,1);
+0479 k2 = estim_params_.corrx(i,2);
+0480 name = [deblank(M_.exo_names(k1,:)) ',' deblank(M_.exo_names(k2,:))];
+0481 NAME = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
+0482 disp(sprintf('%12s %8.4f %7.4f %7.4f' , name,xparam1(ip),stdh(ip),tstath(ip)));
+0483 M_.Sigma_e(k1,k2) = xparam1(ip)*sqrt(M_.Sigma_e(k1,k1)*M_.Sigma_e(k2,k2));
+0484 M_.Sigma_e(k2,k1) = M_.Sigma_e(k1,k2);
+0485 eval(['oo_.mle_mode.shocks_corr.' NAME ' = xparam1(ip);' ]);
+0486 eval(['oo_.mle_std.shocks_corr.' NAME ' = stdh(ip);' ]);
+0487 ip = ip+1;
+0488 end
+0489 end
+0490 if ncn
+0491 disp('correlation of measurement errors' )
+0492 disp(tit1)
+0493 ip = nvx+nvn+ncx+1;
+0494 for i=1:ncn
+0495 k1 = estim_params_.corrn(i,1);
+0496 k2 = estim_params_.corrn(i,2);
+0497 name = [deblank(M_.endo_names(k1,:)) ',' deblank(M_.endo_names(k2,:))];
+0498 NAME = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
+0499 disp(sprintf('%12s %8.4f %7.4f %7.4f' ,name,xparam1(ip),stdh(ip),tstath(ip)));
+0500 eval(['oo_.mle_mode.measurement_error_corr.' NAME ' = xparam1(ip);' ]);
+0501 eval(['oo_.mle_std.measurement_error_corr.' NAME ' = stdh(ip);' ]);
+0502 ip = ip+1;
+0503 end
+0504 end
+0505 end
+0506
+0507
+0508 OutputDirectoryName = CheckPath ('Output' );
+0509
+0510 if any(bayestopt_.pshape > 0) & options_.TeX
+0511 if np
+0512 filename = [OutputDirectoryName '\' M_.fname '_Posterior_Mode_1.TeX' ];
+0513 fidTeX = fopen(filename,'w' );
+0514 fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n' );
+0515 fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (parameters)\n' );
+0516 fprintf(fidTeX,['%% ' datestr(now,0)]);
+0517 fprintf(fidTeX,' \n' );
+0518 fprintf(fidTeX,' \n' );
+0519 fprintf(fidTeX,'{\\tiny \n' )
+0520 fprintf(fidTeX,'\\begin{table}\n' );
+0521 fprintf(fidTeX,'\\centering\n' );
+0522 fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n' );
+0523 fprintf(fidTeX,'\\hline\\hline \\\\ \n' );
+0524 fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n' );
+0525 fprintf(fidTeX,'\\hline \\\\ \n' );
+0526 ip = nvx+nvn+ncx+ncn+1;
+0527 for i=1:np
+0528 fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n' ,...
+0529 M_.param_names_tex(estim_params_.param_vals(i,1),:),...
+0530 deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
+0531 bayestopt_.pmean(ip),...
+0532 estim_params_.param_vals(i,6),...
+0533 xparam1(ip),...
+0534 stdh(ip));
+0535 ip = ip + 1;
+0536 end
+0537 fprintf(fidTeX,'\\hline\\hline \n' );
+0538 fprintf(fidTeX,'\\end{tabular}\n ' );
+0539 fprintf(fidTeX,'\\caption{Results from posterior parameters (parameters)}\n ' );
+0540 fprintf(fidTeX,'\\label{Table:Posterior:1}\n' );
+0541 fprintf(fidTeX,'\\end{table}\n' );
+0542 fprintf(fidTeX,'} \n' )
+0543 fprintf(fidTeX,'%% End of TeX file.\n' );
+0544 fclose(fidTeX);
+0545 end
+0546 if nvx
+0547 TeXfile = [OutputDirectoryName '\' M_.fname '_Posterior_Mode_2.TeX' ];
+0548 fidTeX = fopen(TeXfile,'w' );
+0549 fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n' );
+0550 fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of structural shocks)\n' );
+0551 fprintf(fidTeX,['%% ' datestr(now,0)]);
+0552 fprintf(fidTeX,' \n' );
+0553 fprintf(fidTeX,' \n' );
+0554 fprintf(fidTeX,'{\\tiny \n' );
+0555 fprintf(fidTeX,'\\begin{table}\n' );
+0556 fprintf(fidTeX,'\\centering\n' );
+0557 fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n' );
+0558 fprintf(fidTeX,'\\hline\\hline \\\\ \n' );
+0559 fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n' )
+0560 fprintf(fidTeX,'\\hline \\\\ \n' );
+0561 ip = 1;
+0562 for i=1:nvx
+0563 k = estim_params_.var_exo(i,1);
+0564 fprintf(fidTeX,[ '$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n' ],...
+0565 deblank(M_.exo_names_tex(k,:)),...
+0566 deblank(pnames(bayestopt_.pshape(ip)+1,:)),...
+0567 bayestopt_.pmean(ip),...
+0568 estim_params_.var_exo(i,7),...
+0569 xparam1(ip), ...
+0570 stdh(ip));
+0571 ip = ip+1;
+0572 end
+0573 fprintf(fidTeX,'\\hline\\hline \n' );
+0574 fprintf(fidTeX,'\\end{tabular}\n ' );
+0575 fprintf(fidTeX,'\\caption{Results from posterior parameters (standard deviation of structural shocks)}\n ' );
+0576 fprintf(fidTeX,'\\label{Table:Posterior:2}\n' );
+0577 fprintf(fidTeX,'\\end{table}\n' );
+0578 fprintf(fidTeX,'} \n' )
+0579 fprintf(fidTeX,'%% End of TeX file.\n' );
+0580 fclose(fidTeX);
+0581 end
+0582 if nvn
+0583 TeXfile = [OutputDirectoryName '\' M_.fname '_Posterior_Mode_3.TeX' ];
+0584 fidTeX = fopen(TeXfile,'w' );
+0585 fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n' );
+0586 fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (standard deviation of measurement errors)\n' );
+0587 fprintf(fidTeX,['%% ' datestr(now,0)]);
+0588 fprintf(fidTeX,' \n' );
+0589 fprintf(fidTeX,' \n' );
+0590 fprintf(fidTeX,'\\begin{table}\n' );
+0591 fprintf(fidTeX,'\\centering\n' );
+0592 fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n' );
+0593 fprintf(fidTeX,'\\hline\\hline \\\\ \n' );
+0594 fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n' )
+0595 fprintf(fidTeX,'\\hline \\\\ \n' );
+0596 ip = nvx+1;
+0597 for i=1:nvn
+0598 idx = strmatch(options_.varobs(estim_params_.var_endo(i,1),:),M_.endo_names);
+0599 fprintf(fidTeX,'$%s$ & %4s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n' ,...
+0600 deblank(M_.endo_names_tex(idx,:)), ...
+0601 deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
+0602 bayestopt_.pmean(ip), ...
+0603 estim_params_.var_endo(i,7),...
+0604 xparam1(ip),...
+0605 stdh(ip));
+0606 ip = ip+1;
+0607 end
+0608 fprintf(fidTeX,'\\hline\\hline \n' );
+0609 fprintf(fidTeX,'\\end{tabular}\n ' );
+0610 fprintf(fidTeX,'\\caption{Results from posterior parameters (standard deviation of measurement errors)}\n ' );
+0611 fprintf(fidTeX,'\\label{Table:Posterior:3}\n' );
+0612 fprintf(fidTeX,'\\end{table}\n' );
+0613 fprintf(fidTeX,'%% End of TeX file.\n' );
+0614 fclose(fidTeX);
+0615 end
+0616 if ncx
+0617 TeXfile = [OutputDirectoryName '\' M_.fname '_Posterior_Mode_4.TeX' ];
+0618 fidTeX = fopen(TeXfile,'w' );
+0619 fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n' );
+0620 fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of structural shocks)\n' );
+0621 fprintf(fidTeX,['%% ' datestr(now,0)]);
+0622 fprintf(fidTeX,' \n' );
+0623 fprintf(fidTeX,' \n' );
+0624 fprintf(fidTeX,'\\begin{table}\n' );
+0625 fprintf(fidTeX,'\\centering\n' );
+0626 fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n' );
+0627 fprintf(fidTeX,'\\hline\\hline \\\\ \n' );
+0628 fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n' )
+0629 fprintf(fidTeX,'\\hline \\\\ \n' );
+0630 ip = nvx+nvn+1;
+0631 for i=1:ncx
+0632 k1 = estim_params_.corrx(i,1);
+0633 k2 = estim_params_.corrx(i,2);
+0634 fprintf(fidTeX,[ '$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n' ],...
+0635 [deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))], ...
+0636 deblank(pnames(bayestopt_.pshape(ip)+1,:)), ...
+0637 bayestopt_.pmean(ip), ...
+0638 estim_params_.corrx(i,8), ...
+0639 xparam1(ip), ...
+0640 stdh(ip));
+0641 ip = ip+1;
+0642 end
+0643 fprintf(fidTeX,'\\hline\\hline \n' );
+0644 fprintf(fidTeX,'\\end{tabular}\n ' );
+0645 fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of structural shocks)}\n ' );
+0646 fprintf(fidTeX,'\\label{Table:Posterior:4}\n' );
+0647 fprintf(fidTeX,'\\end{table}\n' );
+0648 fprintf(fidTeX,'%% End of TeX file.\n' );
+0649 fclose(fidTeX);
+0650 end
+0651 if ncn
+0652 TeXfile = [OutputDirectoryName '\' M_.fname '_Posterior_Mode_5.TeX' ];
+0653 fidTeX = fopen(TeXfile,'w' );
+0654 fprintf(fidTeX,'%% TeX-table generated by dynare_estimation (Dynare).\n' );
+0655 fprintf(fidTeX,'%% RESULTS FROM POSTERIOR MAXIMIZATION (correlation of measurement errors)\n' );
+0656 fprintf(fidTeX,['%% ' datestr(now,0)]);
+0657 fprintf(fidTeX,' \n' );
+0658 fprintf(fidTeX,' \n' );
+0659 fprintf(fidTeX,'\\begin{table}\n' );
+0660 fprintf(fidTeX,'\\centering\n' );
+0661 fprintf(fidTeX,'\\begin{tabular}{l|lcccc} \n' );
+0662 fprintf(fidTeX,'\\hline\\hline \\\\ \n' );
+0663 fprintf(fidTeX,' & Prior distribution & Prior mean & Prior s.d. & Posterior mode & s.d. \\\\ \n' )
+0664 fprintf(fidTeX,'\\hline \\\\ \n' );
+0665 ip = nvx+nvn+ncx+1;
+0666 for i=1:ncn
+0667 k1 = estim_params_.corrn(i,1);
+0668 k2 = estim_params_.corrn(i,2);
+0669 fprintf(fidTeX,'$%s$ & %s & %7.3f & %6.4f & %8.4f & %7.4f \\\\ \n' ,...
+0670 [deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))], ...
+0671 pnames(bayestopt_.pshape(ip)+1,:), ...
+0672 bayestopt_.pmean(ip), ...
+0673 estim_params_.corrn(i,8), ...
+0674 xparam1(ip), ...
+0675 stdh(ip));
+0676 ip = ip+1;
+0677 end
+0678 fprintf(fidTeX,'\\hline\\hline \n' );
+0679 fprintf(fidTeX,'\\end{tabular}\n ' );
+0680 fprintf(fidTeX,'\\caption{Results from posterior parameters (correlation of measurement errors)}\n ' );
+0681 fprintf(fidTeX,'\\label{Table:Posterior:5}\n' );
+0682 fprintf(fidTeX,'\\end{table}\n' );
+0683 fprintf(fidTeX,'%% End of TeX file.\n' );
+0684 fclose(fidTeX);
+0685 end
+0686 end
+0687
+0688 if (any(bayestopt_.pshape >0 ) & options_.mh_replic) | ...
+0689 (any(bayestopt_.pshape >0 ) & options_.load_mh_file)
+0690 bounds = prior_bounds (bayestopt_);
+0691 bayestopt_.lb = bounds(:,1);
+0692 bayestopt_.ub = bounds(:,2);
+0693 if any(xparam1 < bounds(:,1)) | any(xparam1 > bounds(:,2))
+0694 find(xparam1 < bounds(:,1))
+0695 find(xparam1 > bounds(:,2))
+0696 error('Mode values are outside prior bounds. Reduce prior_trunc.' )
+0697 end
+0698 if options_.mh_replic
+0699 metropolis (xparam1,invhess,gend,data,rawdata,bounds);
+0700 end
+0701 if ~options_.nodiagnostic & options_.mh_replic > 1000 & options_.mh_nblck > 1
+0702 McMCDiagnostics ;
+0703 end
+0704
+0705 CutSample ;
+0706
+0707 marginal = marginal_density ;
+0708
+0709 GetPosteriorParametersStatistics ;
+0710 PlotPosteriorDistributions ;
+0711 metropolis_draw (1);
+0712 if options_.bayesian_irf
+0713 PosteriorIRF ('posterior' );
+0714 end
+0715 return
+0716
+0717 end
+0718
+0719 if ~((any(bayestopt_.pshape > 0) & options_.mh_replic) | (any(bayestopt_.pshape ...
+0720 > 0) & options_.load_mh_file)) | ~options_.smoother
+0721
+0722 options_.lik_algo = 2;
+0723 [atT,innov,measurement_error,filtered_state_vector,ys,trend_coeff] = DsgeSmoother (xparam1,gend,data);
+0724 for i=1:M_.endo_nbr
+0725 eval(['oo_.SmoothedVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = atT(i,:)'';' ]);
+0726 eval(['oo_.FilteredVariables.' deblank(M_.endo_names(dr.order_var(i),:)) ' = filtered_state_vector(i,:)'';' ]);
+0727 end
+0728 [nbplt,nr,nc,lr,lc,nstar] = pltorg (M_.exo_nbr);
+0729 if options_.TeX
+0730 fidTeX = fopen([M_.fname '_SmoothedShocks.TeX' ],'w' );
+0731 fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation.m (Dynare).\n' );
+0732 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0733 fprintf(fidTeX,' \n' );
+0734 end
+0735 if nbplt == 1
+0736 hh = figure('Name' ,'Smoothed shocks' );
+0737 NAMES = [];
+0738 if options_.TeX, TeXNAMES = [], end
+0739 for i=1:M_.exo_nbr
+0740 subplot(nr,nc,i);
+0741 plot(1:gend,innov(i,:),'-k' ,'linewidth' ,1)
+0742 hold on
+0743 plot([1 gend],[0 0],'-r' ,'linewidth' ,.5)
+0744 hold off
+0745 xlim([1 gend])
+0746 name = deblank(M_.exo_names(i,:));
+0747 NAMES = strvcat(NAMES,name);
+0748 if ~isempty(options_.XTick)
+0749 set(gca,'XTick' ,options_.XTick)
+0750 set(gca,'XTickLabel' ,options_.XTickLabel)
+0751 end
+0752 if options_.TeX
+0753 texname = M_.exo_names_tex(i,1);
+0754 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+0755 end
+0756 title(name,'Interpreter' ,'none' )
+0757 eval(['oo_.SmoothedShocks.' deblank(M_.exo_names(i,:)) ' = innov(i,:)'';' ]);
+0758 end
+0759 eval(['print -depsc2 ' M_.fname '_SmoothedShocks' int2str(1)]);
+0760 eval(['print -dpdf ' M_.fname '_SmoothedShocks' int2str(1)]);
+0761 saveas(hh,[M_.fname '_SmoothedShocks' int2str(1) '.fig' ]);
+0762 if options_.nograph, close(hh), end
+0763 if options_.TeX
+0764 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0765 for jj = 1:M_.exo_nbr
+0766 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0767 end
+0768 fprintf(fidTeX,'\\centering \n' );
+0769 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_SmoothedShocks%s}\n' ,M_.fname,int2str(1));
+0770 fprintf(fidTeX,'\\caption{Smoothed shocks.}' );
+0771 fprintf(fidTeX,'\\label{Fig:SmoothedShocks:%s}\n' ,int2str(1));
+0772 fprintf(fidTeX,'\\end{figure}\n' );
+0773 fprintf(fidTeX,'\n' );
+0774 fprintf(fidTeX,'%% End of TeX file.\n' );
+0775 fclose(fidTeX);
+0776 end
+0777 else
+0778 for plt = 1:nbplt-1
+0779 hh = figure('Name' ,'Smoothed shocks' );
+0780 set(0,'CurrentFigure' ,hh)
+0781 NAMES = [];
+0782 if options_.TeX, TeXNAMES = [], end
+0783 for i=1:nstar
+0784 k = (plt-1)*nstar+i;
+0785 subplot(nr,nc,i);
+0786 plot([1 gend],[0 0],'-r' ,'linewidth' ,.5)
+0787 hold on
+0788 plot(1:gend,innov(k,:),'-k' ,'linewidth' ,1)
+0789 hold off
+0790 name = deblank(M_.exo_names(k,:));
+0791 NAMES = strvcat(NAMES,name);
+0792 if ~isempty(options_.XTick)
+0793 set(gca,'XTick' ,options_.XTick)
+0794 set(gca,'XTickLabel' ,options_.XTickLabel)
+0795 end
+0796 xlim([1 gend])
+0797 if options_.TeX
+0798 texname = M_.exo_names_tex(k,:);
+0799 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+0800 end
+0801 title(name,'Interpreter' ,'none' )
+0802 eval(['oo_.SmoothedShocks.' deblank(name) ' = innov(k,:)'';' ]);
+0803 end
+0804 eval(['print -depsc2 ' M_.fname '_SmoothedShocks' int2str(plt)]);
+0805 eval(['print -dpdf ' M_.fname '_SmoothedShocks' int2str(plt)]);
+0806 saveas(hh,[M_.fname '_SmoothedShocks' int2str(plt) '.fig' ]);
+0807 if options_.nograph, close(hh), end
+0808 if options_.TeX
+0809 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0810 for jj = 1:nstar
+0811 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0812 end
+0813 fprintf(fidTeX,'\\centering \n' );
+0814 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_SmoothedShocks%s}\n' ,M_.fname,int2str(plt));
+0815 fprintf(fidTeX,'\\caption{Smoothed shocks.}' );
+0816 fprintf(fidTeX,'\\label{Fig:SmoothedShocks:%s}\n' ,int2str(plt));
+0817 fprintf(fidTeX,'\\end{figure}\n' );
+0818 fprintf(fidTeX,'\n' );
+0819 end
+0820 end
+0821 hh = figure('Name' ,'Smoothed shocks' );
+0822 set(0,'CurrentFigure' ,hh)
+0823 NAMES = [];
+0824 if options_.TeX, TeXNAMES = [], end
+0825 for i=1:M_.exo_nbr-(nbplt-1)*nstar
+0826 k = (nbplt-1)*nstar+i;
+0827 if lr ~= 0
+0828 subplot(lr,lc,i);
+0829 else
+0830 subplot(nr,nc,i);
+0831 end
+0832 plot([1 gend],[0 0],'-r' ,'linewidth' ,0.5)
+0833 hold on
+0834 plot(1:gend,innov(k,:),'-k' ,'linewidth' ,1)
+0835 hold off
+0836 name = deblank(M_.exo_names(k,:));
+0837 NAMES = strvcat(NAMES,name);
+0838 if ~isempty(options_.XTick)
+0839 set(gca,'XTick' ,options_.XTick)
+0840 set(gca,'XTickLabel' ,options_.XTickLabel)
+0841 end
+0842 xlim([1 gend])
+0843 if options_.TeX
+0844 texname = M_.exo_names_tex(k,:);
+0845 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+0846 end
+0847 title(name,'Interpreter' ,'none' )
+0848 eval(['oo_.SmoothedShocks.' deblank(name) ' = innov(k,:)'';' ]);
+0849 end
+0850 eval(['print -depsc2 ' M_.fname '_SmoothedShocks' int2str(nbplt)]);
+0851 eval(['print -dpdf ' M_.fname '_SmoothedShocks' int2str(nbplt)]);
+0852 saveas(hh,[M_.fname '_SmoothedShocks' int2str(nbplt) '.fig' ]);
+0853 if options_.nograph, close(hh), end
+0854 if options_.TeX
+0855 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0856 for jj = 1:size(NAMES,1);
+0857 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0858 end
+0859 fprintf(fidTeX,'\\centering \n' );
+0860 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_SmoothedShocks%s}\n' ,M_.fname,int2str(nbplt));
+0861 fprintf(fidTeX,'\\caption{Smoothed shocks.}' );
+0862 fprintf(fidTeX,'\\label{Fig:SmoothedShocks:%s}\n' ,int2str(nbplt));
+0863 fprintf(fidTeX,'\\end{figure}\n' );
+0864 fprintf(fidTeX,'\n' );
+0865 fprintf(fidTeX,'%% End of TeX file.\n' );
+0866 fclose(fidTeX);
+0867 end
+0868 end
+0869
+0870
+0871
+0872 yf = zeros(gend,n_varobs);
+0873 if options_.prefilter == 1
+0874 yf = atT(bayestopt_.mf,:)+repmat(transpose(bayestopt_.mean_varobs),1,gend);
+0875 elseif options_.loglinear == 1
+0876 yf = atT(bayestopt_.mf,:)+repmat(log(ys(bayestopt_.mfys)),1,gend)+...
+0877 trend_coeff*[1:gend];
+0878 else
+0879 yf = atT(bayestopt_.mf,:)+repmat(ys(bayestopt_.mfys),1,gend)+...
+0880 trend_coeff*[1:gend];
+0881 end
+0882 if nvn
+0883 number_of_plots_to_draw = 0;
+0884 index = [];
+0885 for i=1:n_varobs
+0886 if max(abs(measurement_error(10:end))) > 0.000000001
+0887 number_of_plots_to_draw = number_of_plots_to_draw + 1;
+0888 index = cat(1,index,i);
+0889 end
+0890 eval(['oo_.SmoothedMeasurementErrors.' deblank(options_.varobs(i,:)) ...
+0891 ' = measurement_error(i,:)'';' ]);
+0892 end
+0893 [nbplt,nr,nc,lr,lc,nstar] = pltorg (number_of_plots_to_draw);
+0894 if options_.TeX
+0895 fidTeX = fopen([M_.fname '_SmoothedObservationErrors.TeX' ],'w' );
+0896 fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation.m (Dynare).\n' );
+0897 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0898 fprintf(fidTeX,' \n' );
+0899 end
+0900 if nbplt == 1
+0901 hh = figure('Name' ,'Smoothed observation errors' );
+0902 set(0,'CurrentFigure' ,hh)
+0903 NAMES = [];
+0904 if options_.TeX, TeXNAMES = [], end
+0905 for i=1:number_of_plots_to_draw
+0906 subplot(nr,nc,i);
+0907 plot(1:gend,measurement_error(index(i),:),'-k' ,'linewidth' ,1)
+0908 hold on
+0909 plot([1 gend],[0 0],'-r' ,'linewidth' ,.5)
+0910 hold off
+0911 name = deblank(options_.varobs(index(i),:));
+0912 NAMES = strvcat(NAMES,name);
+0913 if ~isempty(options_.XTick)
+0914 set(gca,'XTick' ,options_.XTick)
+0915 set(gca,'XTickLabel' ,options_.XTickLabel)
+0916 end
+0917 if options_.TeX
+0918 idx = strmatch(options_.varobs(indx(i),:),M_.endo_names,'exact' );
+0919 texname = M_.endo_names_tex(idx,:);
+0920 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+0921 end
+0922 title(name,'Interpreter' ,'none' )
+0923 end
+0924 eval(['print -depsc2 ' M_.fname '_SmoothedObservationErrors' int2str(1)]);
+0925 eval(['print -dpdf ' M_.fname '_SmoothedObservationErrors' int2str(1)]);
+0926 saveas(hh,[M_.fname '_SmoothedObservationErrors' int2str(1) '.fig' ]);
+0927 if options_.nograph, close(hh), end
+0928 if options_.TeX
+0929 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0930 for jj = 1:number_of_plots_to_draw
+0931 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0932 end
+0933 fprintf(fidTeX,'\\centering \n' );
+0934 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_SmoothedObservationErrors%s}\n' ,M_.fname,int2str(1));
+0935 fprintf(fidTeX,'\\caption{Smoothed observation errors.}' );
+0936 fprintf(fidTeX,'\\label{Fig:SmoothedObservationErrors:%s' ,int2str(1));
+0937 fprintf(fidTeX,'\\end{figure}\n' );
+0938 fprintf(fidTeX,'\n' );
+0939 fprintf(fidTeX,'%% End of TeX file.\n' );
+0940 fclose(fidTeX);
+0941 end
+0942 else
+0943 for plt = 1:nbplt-1
+0944 hh = figure('Name' ,'Smoothed observation errors' );
+0945 set(0,'CurrentFigure' ,hh)
+0946 NAMES = [];
+0947 if options_.TeX, TeXNAMES = [], end
+0948 for i=1:nstar
+0949 k = (plt-1)*nstar+i;
+0950 subplot(nr,nc,i);
+0951 plot([1 gend],[0 0],'-r' ,'linewidth' ,.5)
+0952 hold on
+0953 plot(1:gend,measurement_error(index(k),:),'-k' ,'linewidth' ,1)
+0954 hold off
+0955 name = deblank(options_.varobs(index(k),:));
+0956 NAMES = strvcat(NAMES,name);
+0957 if ~isempty(options_.XTick)
+0958 set(gca,'XTick' ,options_.XTick)
+0959 set(gca,'XTickLabel' ,options_.XTickLabel)
+0960 end
+0961 if options_.TeX
+0962 idx = strmatch(options_.varobs(k),M_.endo_names,'exact' );
+0963 texname = M_.endo_names_tex(idx,:);
+0964 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+0965 end
+0966 title(name,'Interpreter' ,'none' )
+0967 end
+0968 eval(['print -depsc2 ' M_.fname '_SmoothedObservationErrors' int2str(plt)]);
+0969 eval(['print -dpdf ' M_.fname '_SmoothedObservationErrors' int2str(plt)]);
+0970 saveas(hh,[M_.fname '_SmoothedObservationErrors' int2str(plt) '.fig' ]);
+0971 if options_.nograph, close(hh), end
+0972 if options_.TeX
+0973 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0974 for jj = 1:nstar
+0975 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0976 end
+0977 fprintf(fidTeX,'\\centering \n' );
+0978 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_SmoothedObservationErrors%s}\n' ,M_.fname,int2str(plt));
+0979 fprintf(fidTeX,'\\caption{Smoothed observation errors.}' );
+0980 fprintf(fidTeX,'\\label{Fig:SmoothedObservationErrors:%s}\n' ,int2str(plt));
+0981 fprintf(fidTeX,'\\end{figure}\n' );
+0982 fprintf(fidTeX,'\n' );
+0983 end
+0984 end
+0985 hh = figure('Name' ,'Smoothed observation errors' );
+0986 set(0,'CurrentFigure' ,hh)
+0987 NAMES = [];
+0988 if options_.TeX, TeXNAMES = [], end
+0989 for i=1:number_of_plots_to_draw-(nbplt-1)*nstar
+0990 k = (nbplt-1)*nstar+i;
+0991 if lr ~= 0
+0992 subplot(lr,lc,i);
+0993 else
+0994 subplot(nr,nc,i);
+0995 end
+0996 plot([1 gend],[0 0],'-r' ,'linewidth' ,0.5)
+0997 hold on
+0998 plot(1:gend,measurement_error(index(k),:),'-k' ,'linewidth' ,1)
+0999 hold off
+1000 name = deblank(options_.varobs(index(k),:));
+1001 NAMES = strvcat(NAMES,name);
+1002 if ~isempty(options_.XTick)
+1003 set(gca,'XTick' ,options_.XTick)
+1004 set(gca,'XTickLabel' ,options_.XTickLabel)
+1005 end
+1006 if options_.TeX
+1007 idx = strmatch(options_.varobs(index(k)),M_.endo_names,'exact' );
+1008 texname = M_.endo_names_tex(idx,:);
+1009 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+1010 end
+1011 title(name,'Interpreter' ,'none' );
+1012 end
+1013 eval(['print -depsc2 ' M_.fname '_SmoothedObservationErrors' int2str(nbplt)]);
+1014 eval(['print -dpdf ' M_.fname '_SmoothedObservationErrors' int2str(nbplt)]);
+1015 saveas(hh,[M_.fname '_SmoothedObservationErrors' int2str(nbplt) '.fig' ]);
+1016 if options_.nograph, close(hh), end
+1017 if options_.TeX
+1018 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+1019 for jj = 1:size(NAMES,1);
+1020 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+1021 end
+1022 fprintf(fidTeX,'\\centering \n' );
+1023 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_SmoothedObservedErrors%s}\n' ,M_.fname,int2str(nbplt));
+1024 fprintf(fidTeX,'\\caption{Smoothed observed errors.}' );
+1025 fprintf(fidTeX,'\\label{Fig:SmoothedObservedErrors:%s}\n' ,int2str(nbplt));
+1026 fprintf(fidTeX,'\\end{figure}\n' );
+1027 fprintf(fidTeX,'\n' );
+1028 fprintf(fidTeX,'%% End of TeX file.\n' );
+1029 fclose(fidTeX);
+1030 end
+1031 end
+1032 end
+1033
+1034
+1035
+1036 [nbplt,nr,nc,lr,lc,nstar] = pltorg (n_varobs);
+1037 if options_.TeX
+1038 fidTeX = fopen([M_.fname '_HistoricalAndSmoothedVariables.TeX' ],'w' );
+1039 fprintf(fidTeX,'%% TeX eps-loader file generated by dynare_estimation.m (Dynare).\n' );
+1040 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+1041 fprintf(fidTeX,' \n' );
+1042 end
+1043 if nbplt == 1
+1044 hh = figure('Name' ,'Historical and smoothed variables' );
+1045 NAMES = [];
+1046 if options_.TeX, TeXNAMES = [], end
+1047 for i=1:n_varobs
+1048 subplot(nr,nc,i);
+1049 plot(1:gend,yf(i,:),'-r' ,'linewidth' ,1)
+1050 hold on
+1051 plot(1:gend,rawdata(:,i),'-k' ,'linewidth' ,1)
+1052 hold off
+1053 name = deblank(options_.varobs(i,:));
+1054 NAMES = strvcat(NAMES,name);
+1055 if ~isempty(options_.XTick)
+1056 set(gca,'XTick' ,options_.XTick)
+1057 set(gca,'XTickLabel' ,options_.XTickLabel)
+1058 end
+1059 xlim([1 gend])
+1060 if options_.TeX
+1061 idx = strmatch(options_.varobs(i),M_.endo_names,'exact' );
+1062 texname = M_.endo_names_tex(idx,:);
+1063 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+1064 end
+1065 title(name,'Interpreter' ,'none' )
+1066 end
+1067 eval(['print -depsc2 ' M_.fname '_HistoricalAndSmoothedVariables' int2str(1)]);
+1068 eval(['print -dpdf ' M_.fname '_HistoricalAndSmoothedVariables' int2str(1)]);
+1069 saveas(hh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(1) '.fig' ]);
+1070 if options_.nograph, close(hh), end
+1071 if options_.TeX
+1072 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+1073 for jj = 1:n_varobs
+1074 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+1075 end
+1076 fprintf(fidTeX,'\\centering \n' );
+1077 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_HistoricalAndSmoothedVariables%s}\n' ,M_.fname,int2str(1));
+1078 fprintf(fidTeX,'\\caption{Historical and smoothed variables.}' );
+1079 fprintf(fidTeX,'\\label{Fig:HistoricalAndSmoothedVariables:%s}\n' ,int2str(1));
+1080 fprintf(fidTeX,'\\end{figure}\n' );
+1081 fprintf(fidTeX,'\n' );
+1082 fprintf(fidTeX,'%% End of TeX file.\n' );
+1083 fclose(fidTeX);
+1084 end
+1085 else
+1086 for plt = 1:nbplt-1
+1087 hh = figure('Name' ,'Historical and smoothed variables' );
+1088 set(0,'CurrentFigure' ,hh)
+1089 NAMES = [];
+1090 if options_.TeX, TeXNAMES = [], end
+1091 for i=1:nstar
+1092 k = (plt-1)*nstar+i;
+1093 subplot(nr,nc,i);
+1094 plot(1:gend,yf(k,:),'-r' ,'linewidth' ,1)
+1095 hold on
+1096 plot(1:gend,rawdata(:,k),'-k' ,'linewidth' ,1)
+1097 hold off
+1098 name = deblank(options_.varobs(k,:));
+1099 NAMES = strvcat(NAMES,name);
+1100 if ~isempty(options_.XTick)
+1101 set(gca,'XTick' ,options_.XTick)
+1102 set(gca,'XTickLabel' ,options_.XTickLabel)
+1103 end
+1104 xlim([1 gend])
+1105 if options_.TeX
+1106 idx = strmatch(options_.varobs(k),M_.endo_names,'exact' );
+1107 texname = M_.endo_names_tex(idx,:);
+1108 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+1109 end
+1110 title(name,'Interpreter' ,'none' )
+1111 end
+1112 eval(['print -depsc2 ' M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)]);
+1113 eval(['print -dpdf ' M_.fname '_HistoricalAndSmoothedVariables' int2str(plt)]);
+1114 saveas(hh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(plt) '.fig' ]);
+1115 if options_.nograph, close(hh), end
+1116 if options_.TeX
+1117 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+1118 for jj = 1:nstar
+1119 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+1120 end
+1121 fprintf(fidTeX,'\\centering \n' );
+1122 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_HistoricalAndSmoothedVariables%s}\n' ,M_.fname,int2str(plt));
+1123 fprintf(fidTeX,'\\caption{Historical and smoothed variables.}' );
+1124 fprintf(fidTeX,'\\label{Fig:HistoricalAndSmoothedVariables:%s}\n' ,int2str(plt));
+1125 fprintf(fidTeX,'\\end{figure}\n' );
+1126 fprintf(fidTeX,'\n' );
+1127 end
+1128 end
+1129 hh = figure('Name' ,'Historical and smoothed variables' );
+1130 set(0,'CurrentFigure' ,hh)
+1131 NAMES = [];
+1132 if options_.TeX, TeXNAMES = [], end
+1133 for i=1:n_varobs-(nbplt-1)*nstar
+1134 k = (nbplt-1)*nstar+i;
+1135 if lr ~= 0
+1136 subplot(lr,lc,i);
+1137 else
+1138 subplot(nr,nc,i);
+1139 end
+1140 plot(1:gend,yf(k,:),'-r' ,'linewidth' ,1)
+1141 hold on
+1142 plot(1:gend,rawdata(:,k),'-k' ,'linewidth' ,1)
+1143 hold off
+1144 name = deblank(options_.varobs(k,:));
+1145 NAMES = strvcat(NAMES,name);
+1146 if ~isempty(options_.XTick)
+1147 set(gca,'XTick' ,options_.XTick)
+1148 set(gca,'XTickLabel' ,options_.XTickLabel)
+1149 end
+1150 xlim([1 gend])
+1151 if options_.TeX
+1152 idx = strmatch(options_.varobs(i),M_.endo_names,'exact' );
+1153 texname = M_.endo_names_tex(idx,:);
+1154 TeXNAMES = strvcat(TeXNAMES,['$ ' deblank(texname) ' $' ]);
+1155 end
+1156 title(name,'Interpreter' ,'none' );
+1157 end
+1158 eval(['print -depsc2 ' M_.fname '_HistoricalAndSmoothedVariables' int2str(nbplt)]);
+1159 eval(['print -dpdf ' M_.fname '_HistoricalAndSmoothedVariables' int2str(nbplt)]);
+1160 saveas(hh,[M_.fname '_HistoricalAndSmoothedVariables' int2str(nbplt) '.fig' ]);
+1161 if options_.nograph, close(hh), end
+1162 if options_.TeX
+1163 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+1164 for jj = 1:size(NAMES,1);
+1165 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+1166 end
+1167 fprintf(fidTeX,'\\centering \n' );
+1168 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_HistoricalAndSmoothedVariables%s}\n' ,M_.fname,int2str(nbplt));
+1169 fprintf(fidTeX,'\\caption{Historical and smoothed variables.}' );
+1170 fprintf(fidTeX,'\\label{Fig:HistoricalAndSmoothedVariables:%s}\n' ,int2str(nbplt));
+1171 fprintf(fidTeX,'\\end{figure}\n' );
+1172 fprintf(fidTeX,'\n' );
+1173 fprintf(fidTeX,'%% End of TeX file.\n' );
+1174 fclose(fidTeX);
+1175 end
+1176 end
+1177 end
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynare_resolve.html b/matlab/doc/dynare_resolve.html
new file mode 100644
index 000000000..f379cb928
--- /dev/null
+++ b/matlab/doc/dynare_resolve.html
@@ -0,0 +1,60 @@
+
+
+
+ Description of dynare_resolve
+
+
+
+
+
+
+
+
+
+Home >
. > dynare_resolve.m
+
+
+
+dynare_resolve
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [A,B,ys,info] = dynare_resolve()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynare_sensitivity.html b/matlab/doc/dynare_sensitivity.html
new file mode 100644
index 000000000..1bd6eaff7
--- /dev/null
+++ b/matlab/doc/dynare_sensitivity.html
@@ -0,0 +1,241 @@
+
+
+
+ Description of dynare_sensitivity
+
+
+
+
+
+
+
+
+
+Home >
. > dynare_sensitivity.m
+
+
+
+dynare_sensitivity
+
+
+ PURPOSE
+copyright Marco Ratto 2006
+
+ SYNOPSIS
+function x0=dynare_sensitivity()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x0=dynare_sensitivity()
+0002
+0003
+0004 global M_ options_ oo_ bayestopt_
+0005
+0006 fname_ = M_.fname;
+0007 lgy_ = M_.endo_names;
+0008 x0=[];
+0009
+0010 options_ = set_default_option (options_,'opt_gsa' ,1);
+0011 options_gsa_ = options_.opt_gsa;
+0012
+0013
+0014 options_gsa_ = set_default_option (options_gsa_,'stab' ,1);
+0015 options_gsa_ = set_default_option (options_gsa_,'redform' ,0);
+0016 options_gsa_ = set_default_option (options_gsa_,'pprior' ,1);
+0017 options_gsa_ = set_default_option (options_gsa_,'ppost' ,0);
+0018 options_gsa_ = set_default_option (options_gsa_,'ilptau' ,1);
+0019 options_gsa_ = set_default_option (options_gsa_,'Nsam' ,2048);
+0020 options_gsa_ = set_default_option (options_gsa_,'load_stab' ,0);
+0021 options_gsa_ = set_default_option (options_gsa_,'alpha2_stab' ,0.3);
+0022 options_gsa_ = set_default_option (options_gsa_,'ksstat' ,0.1);
+0023 options_gsa_ = set_default_option (options_gsa_,'load_mh' ,0);
+0024
+0025 OutputDirectoryName = CheckPath ('GSA' );
+0026
+0027
+0028 if options_gsa_.stab & ~options_gsa_.load_mh,
+0029 x0 = stab_map_ (options_gsa_.Nsam, options_gsa_.load_stab, options_gsa_.ksstat, options_gsa_.alpha2_stab, ...
+0030 options_gsa_.redform, options_gsa_.pprior, options_gsa_.ilptau, OutputDirectoryName);
+0031 end
+0032
+0033
+0034
+0035 options_gsa_ = set_default_option (options_gsa_,'load_redform' ,0);
+0036 options_gsa_ = set_default_option (options_gsa_,'logtrans_redform' ,0);
+0037 options_gsa_ = set_default_option (options_gsa_,'threshold_redform' ,[]);
+0038 options_gsa_ = set_default_option (options_gsa_,'ksstat_redform' ,0.1);
+0039 options_gsa_ = set_default_option (options_gsa_,'alpha2_redform' ,0.3);
+0040 options_gsa_ = set_default_option (options_gsa_,'namendo' ,[]);
+0041 options_gsa_ = set_default_option (options_gsa_,'namlagendo' ,[]);
+0042 options_gsa_ = set_default_option (options_gsa_,'namexo' ,[]);
+0043
+0044 if options_gsa_.redform & ~isempty(options_gsa_.namendo) & ~options_gsa_.load_mh,
+0045 redform_map(options_gsa_.namendo, options_gsa_.namlagendo, options_gsa_.namexo, ...
+0046 options_gsa_.load_redform, options_gsa_.pprior, options_gsa_.logtrans_redform, ...
+0047 options_gsa_.threshold_redform, options_gsa_.ksstat_redform, ...
+0048 options_gsa_.alpha2_redform, OutputDirectoryName);
+0049 end
+0050
+0051
+0052 options_gsa_ = set_default_option (options_gsa_,'rmse' ,0);
+0053 options_gsa_ = set_default_option (options_gsa_,'var_rmse' ,options_.varobs);
+0054 options_gsa_ = set_default_option (options_gsa_,'load_rmse' ,0);
+0055 options_gsa_ = set_default_option (options_gsa_,'pfilt_rmse' ,0.1);
+0056 options_gsa_ = set_default_option (options_gsa_,'istart_rmse' ,1);
+0057 options_gsa_ = set_default_option (options_gsa_,'alpha_rmse' ,0.002);
+0058 options_gsa_ = set_default_option (options_gsa_,'alpha2_rmse' ,0.5);
+0059 options_.opt_gsa = options_gsa_;
+0060 if options_gsa_.rmse,
+0061 if options_gsa_.pprior
+0062 a=load([OutputDirectoryName,'\' ,fname_,'_prior' ]);
+0063 else
+0064 a=load([OutputDirectoryName,'\' ,fname_,'_mc' ]);
+0065 end
+0066 if ~isfield(a,'stock_filter' ),
+0067 dynare_MC ([],OutputDirectoryName);
+0068 options_gsa_.load_rmse=0;
+0069 end
+0070 filt_mc_ (options_gsa_.var_rmse, options_gsa_.load_rmse, options_gsa_.pfilt_rmse, ...
+0071 options_gsa_.alpha_rmse, options_gsa_.alpha2_rmse, OutputDirectoryName, ...
+0072 options_gsa_.istart_rmse);
+0073 end
+0074
+0075
+0076 options_gsa_ = set_default_option (options_gsa_,'glue' ,0);
+0077 if options_gsa_.glue,
+0078 dr_ = oo_.dr;
+0079 if options_gsa_.ppost
+0080 load([OutputDirectoryName,'\' ,fname_,'_post' ]);
+0081 DirectoryName = CheckPath ('metropolis' );
+0082 else
+0083 if options_gsa_.pprior
+0084 load([OutputDirectoryName,'\' ,fname_,'_prior' ]);
+0085 else
+0086 load([OutputDirectoryName,'\' ,fname_,'_mc' ]);
+0087 end
+0088 end
+0089 nruns=size(x,1);
+0090 gend = options_.nobs;
+0091 rawdata = read_variables (options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
+0092 rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
+0093 if options_.loglinear == 1
+0094 rawdata = log(rawdata);
+0095 end
+0096 if options_.prefilter == 1
+0097 data = transpose(rawdata-ones(gend,1)*bayestopt_.mean_varobs);
+0098 else
+0099 data = transpose(rawdata);
+0100 end
+0101
+0102 Obs.data = data;
+0103 Obs.time = [1:gend];
+0104 Obs.num = gend;
+0105 for j=1:size(options_.varobs,1)
+0106 Obs.name{j} = deblank(options_.varobs(j,:));
+0107 vj=deblank(options_.varobs(j,:));
+0108
+0109 jxj = strmatch(vj,lgy_(dr_.order_var,:),'exact' );
+0110 js = strmatch(vj,lgy_,'exact' );
+0111 if ~options_gsa_.ppost
+0112 y0=zeros(gend+1,nruns);
+0113 nb = size(stock_filter,3);
+0114 y0 = squeeze(stock_filter(:,jxj,:)) + ...
+0115 kron(stock_ys(js,:),ones(size(stock_filter,1),1));
+0116 Out(j).data = y0';
+0117 Out(j).time = [1:size(y0,1)];
+0118 else
+0119 Out(j).data = jxj;
+0120 Out(j).time = [pwd,'\' ,DirectoryName];
+0121 end
+0122 Out(j).name = vj;
+0123 Out(j).ini = 'yes' ;
+0124 Lik(j).name = ['rmse_' ,vj];
+0125 Lik(j).ini = 'yes' ;
+0126 Lik(j).isam = 1;
+0127 Lik(j).data = rmse_MC(:,j)';
+0128
+0129 if ~options_gsa_.ppost
+0130 y0 = squeeze(stock_smooth(:,jxj,:)) + ...
+0131 kron(stock_ys(js,:),ones(size(stock_smooth,1),1));
+0132 Out1(j).name = vj;
+0133 Out1(j).ini = 'yes' ;
+0134 Out1(j).time = [1:size(y0,1)];
+0135 Out1(j).data = y0';
+0136 else
+0137 Out1=Out;
+0138 end
+0139 ismoo(j)=jxj;
+0140
+0141 end
+0142 jsmoo = size(options_.varobs,1);
+0143 for j=1:M_.endo_nbr,
+0144 if ~ismember(j,ismoo),
+0145 jsmoo=jsmoo+1;
+0146 vj=deblank(M_.endo_names(dr_.order_var(j),:));
+0147 if ~options_gsa_.ppost
+0148 y0 = squeeze(stock_smooth(:,j,:)) + ...
+0149 kron(stock_ys(j,:),ones(size(stock_smooth,1),1));
+0150 Out1(jsmoo).time = [1:size(y0,1)];
+0151 Out1(jsmoo).data = y0';
+0152 else
+0153 Out1(jsmoo).data = j;
+0154 Out1(jsmoo).time = [pwd,'\' ,DirectoryName];
+0155 end
+0156 Out1(jsmoo).name = vj;
+0157 Out1(jsmoo).ini = 'yes' ;
+0158 end
+0159 end
+0160 tit(M_.exo_names_orig_ord,:) = M_.exo_names;
+0161 for j=1:M_.exo_nbr,
+0162 Exo(j).name = deblank(tit(j,:));
+0163 end
+0164 if ~options_gsa_.ppost
+0165 Lik(size(options_.varobs,1)+1).name = 'logpo' ;
+0166 Lik(size(options_.varobs,1)+1).ini = 'yes' ;
+0167 Lik(size(options_.varobs,1)+1).isam = 1;
+0168 Lik(size(options_.varobs,1)+1).data = -logpo2;
+0169 end
+0170 Sam.name = bayestopt_.name;
+0171 Sam.dim = [size(x) 0];
+0172 Sam.data = [x];
+0173
+0174 Rem.id = 'Original' ;
+0175 Rem.ind= [1:size(x,1)];
+0176
+0177 if options_gsa_.ppost
+0178 Info.dynare=M_.fname;
+0179 Out=Out1;
+0180 save([OutputDirectoryName,'\' ,fname_,'_post_glue' ], 'Out' , 'Sam' , 'Lik' , 'Obs' , 'Rem' ,'Info' , 'Exo' )
+0181
+0182
+0183 else
+0184 if options_gsa_.pprior
+0185 save([OutputDirectoryName,'\' ,fname_,'_prior_glue' ], 'Out' , 'Sam' , 'Lik' , 'Obs' , 'Rem' )
+0186 Out=Out1;
+0187 save([OutputDirectoryName,'\' ,fname_,'_prior_glue_smooth' ], 'Out' , 'Sam' , 'Lik' , 'Obs' , 'Rem' )
+0188 else
+0189 save([OutputDirectoryName,'\' ,fname_,'_mc_glue' ], 'Out' , 'Sam' , 'Lik' , 'Obs' , 'Rem' )
+0190 Out=Out1;
+0191 save([OutputDirectoryName,'\' ,fname_,'_mc_glue_smooth' ], 'Out' , 'Sam' , 'Lik' , 'Obs' , 'Rem' )
+0192 end
+0193 end
+0194
+0195 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynare_solve.html b/matlab/doc/dynare_solve.html
new file mode 100644
index 000000000..1c884ef2c
--- /dev/null
+++ b/matlab/doc/dynare_solve.html
@@ -0,0 +1,131 @@
+
+
+
+ Description of dynare_solve
+
+
+
+
+
+
+
+
+
+Home >
. > dynare_solve.m
+
+
+
+dynare_solve
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [x,cheik] = dynare_solve(func,x,jacobian_flag,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+olr1 Copyright (C) 2001 Michel Juillardosr1 resol Copyright (C) 2001 Michel Juillardresol1 Copyright (C) 2001 Michel Juillardsimult_ Copyright (C) 2001 Michel Juillardsteady_ Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [x,cheik] = dynare_solve(func,x,jacobian_flag,varargin)
+0004 global options_
+0005
+0006 options_ = set_default_option (options_,'solve_algo' ,2);
+0007 cheik = 0;
+0008 if options_.solve_algo == 0
+0009 if ~isempty(which('fsolve' )) & sscanf(version('-release' ),'%d' ) >= 13;
+0010 options=optimset('fsolve' );
+0011 options.MaxFunEvals = 20000;
+0012 options.TolFun=1e-8;
+0013 options.Display = 'off' ;
+0014 if jacobian_flag
+0015 options.Jacobian = 'on' ;
+0016 else
+0017 options.Jacobian = 'on' ;
+0018 end
+0019 [x,fval,exitval,output] = fsolve(func,x,options,varargin{:});
+0020 if exitval > 0
+0021 cheik = 0;
+0022 else
+0023 cheik = 1;
+0024 end
+0025 return
+0026 else
+0027 options_.solve_algo = 1;
+0028 end
+0029 end
+0030
+0031 if options_.solve_algo == 1
+0032 nn = size(x,1) ;
+0033 [x,cheik]=solve1 (func,x,1:nn,1:nn,jacobian_flag,varargin{:});
+0034 elseif options_.solve_algo == 2
+0035 nn = size(x,1) ;
+0036 tolf = eps^(2/3) ;
+0037
+0038 if jacobian_flag
+0039 [fvec,fjac] = feval(func,x,varargin{:});
+0040 else
+0041 fvec = feval(func,x,varargin{:});
+0042 fjac = zeros(nn,nn) ;
+0043 end
+0044
+0045 i = find(~isfinite(fvec));
+0046
+0047 if ~isempty(i)
+0048 disp(['STEADY: numerical initial values incompatible with the following' ...
+0049 ' equations' ])
+0050 disp(i')
+0051 error('exiting ...' )
+0052 end
+0053
+0054 f = 0.5*fvec'*fvec ;
+0055
+0056 if max(abs(fvec)) < 0.01*tolf
+0057 return ;
+0058 end
+0059
+0060 if ~jacobian_flag
+0061 fjac = zeros(nn,nn) ;
+0062 dh = max(abs(x),options_.gstep*ones(nn,1))*eps^(1/3);
+0063 for j = 1:nn
+0064 xdh = x ;
+0065 xdh(j) = xdh(j)+dh(j) ;
+0066 fjac(:,j) = (feval(func,xdh,varargin{:}) - fvec)./dh(j) ;
+0067 end
+0068 end
+0069
+0070 [j1,j2,r,s] = dmperm(fjac);
+0071
+0072 for i=length(r)-1:-1:1
+0073 [x,cheik]=solve1 (func,x,j1(r(i):r(i+1)-1),j2(r(i):r(i+1)-1),jacobian_flag,varargin{:});
+0074 if cheik
+0075 error(sprintf('Solve block = %d check = %d\n' ,i,cheik));
+0076 end
+0077 end
+0078 [x,cheik]=solve1 (func,x,1:nn,1:nn,jacobian_flag,varargin{:});
+0079
+0080 end
+0081
+0082
+0083
+0084
+0085
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynasave.html b/matlab/doc/dynasave.html
new file mode 100644
index 000000000..46006179b
--- /dev/null
+++ b/matlab/doc/dynasave.html
@@ -0,0 +1,87 @@
+
+
+
+ Description of dynasave
+
+
+
+
+
+
+
+
+
+
+
+
+
+dynasave
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dynasave(s,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dynasave(s,var_list)
+0004
+0005
+0006
+0007
+0008 global M_ oo_
+0009
+0010 n = size(var_list,1);
+0011 if n == 0
+0012 n = M_.endo_nbr;
+0013 ivar = [1:n]';
+0014 var_list = M_.endo_names;
+0015 else
+0016 ivar=zeros(n,1);
+0017 for i=1:n
+0018 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0019 if isempty(i_tmp)
+0020 error (['One of the specified variables does not exist' ]) ;
+0021 else
+0022 ivar(i) = i_tmp;
+0023 end
+0024 end
+0025 end
+0026
+0027
+0028
+0029 eval([var_list(1) '=oo_.y_simul(ivar(1),:)'';' ])
+0030 eval(['save ' s ' ' var_list(1) ' -mat' ])
+0031 for i = 2:n
+0032
+0033 eval([var_list(i) '=oo_.y_simul(ivar(i),:)'';' ])
+0034 eval(['save ' s ' ' var_list(i) ' -append -mat' ])
+0035 end
+0036
+0037
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/dynatype.html b/matlab/doc/dynatype.html
new file mode 100644
index 000000000..d2cf33a60
--- /dev/null
+++ b/matlab/doc/dynatype.html
@@ -0,0 +1,91 @@
+
+
+
+ Description of dynatype
+
+
+
+
+
+
+
+
+
+
+
+
+
+dynatype
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dynatype (s,var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dynatype (s,var_list)
+0004
+0005
+0006
+0007
+0008
+0009
+0010 global M_ oo_
+0011
+0012 fid=fopen(s,'w' ) ;
+0013
+0014 n = size(var_list,1);
+0015 if n == 0
+0016 n = M_.endo_nbr;
+0017 ivar = [1:n]';
+0018 var_list = M_.endo_names;
+0019 else
+0020 ivar=zeros(n,1);
+0021 for i=1:n
+0022 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0023 if isempty(i_tmp)
+0024 error (['One of the specified variables does not exist' ]) ;
+0025 else
+0026 ivar(i) = i_tmp;
+0027 end
+0028 end
+0029 end
+0030
+0031
+0032 for i = 1:n
+0033 fprintf(fid,M_.endo_names(ivar(i),:),'\n' ) ;
+0034 fprintf(fid,'\n' ) ;
+0035 fprintf(fid,'%15.8g\n' ,oo_.y_simul(ivar(i),:)') ;
+0036 end
+0037 fclose(fid) ;
+0038
+0039 return ;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/f_var.html b/matlab/doc/f_var.html
new file mode 100644
index 000000000..f22d6dcd4
--- /dev/null
+++ b/matlab/doc/f_var.html
@@ -0,0 +1,50 @@
+
+
+
+ Description of f_var
+
+
+
+
+
+
+
+
+
+
+
+
+
+f_var
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function b=f_var(x,a,nx)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+calib_obj targets and iy order: 1) variances 2) correlations
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/fbeta.html b/matlab/doc/fbeta.html
new file mode 100644
index 000000000..3279f46f6
--- /dev/null
+++ b/matlab/doc/fbeta.html
@@ -0,0 +1,52 @@
+
+
+
+ Description of fbeta
+
+
+
+
+
+
+
+
+
+
+
+
+
+fbeta
+
+
+ PURPOSE
+must restrict p2 such that a>0 and b>0 ....
+
+ SYNOPSIS
+function e = fbeta(p2,p,p1,perc)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/ff1_.html b/matlab/doc/ff1_.html
new file mode 100644
index 000000000..c59a28ed4
--- /dev/null
+++ b/matlab/doc/ff1_.html
@@ -0,0 +1,58 @@
+
+
+
+ Description of ff1_
+
+
+
+
+
+
+
+
+
+
+
+
+
+ff1_
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function y=ff1_(x)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function y=ff1_(x)
+0004 global it_ M_ oo_
+0005
+0006 n1 = size(x,1) - M_.exo_nbr;
+0007 oo_.exo_simul(it_+M_.maximum_lag-M_.maximum_lag,:) = x(n1+1:end)';
+0008 fh = str2func([M_.fname '_static' ]);
+0009 y=feval(fh,x(1:n1),oo_.exo_simul);
+0010
+0011
+0012
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/ffill.html b/matlab/doc/ffill.html
new file mode 100644
index 000000000..cd6cc2866
--- /dev/null
+++ b/matlab/doc/ffill.html
@@ -0,0 +1,70 @@
+
+
+
+ Description of ffill
+
+
+
+
+
+
+
+
+
+
+
+
+
+ffill
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [a,b] = ffill(x,ixc,y)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+simk Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [a,b] = ffill(x,ixc,y)
+0004
+0005 xc = size(x,1) ;
+0006
+0007 if isempty(y)
+0008 b = [ixc; 0];
+0009 a = [x zeros(size(x,1),1)];
+0010 else
+0011 yc = size(y,1) ;
+0012 b = [ixc;yc] ;
+0013
+0014 if xc > yc
+0015 a = [x [y;zeros(xc-yc,size(y,2))]] ;
+0016 elseif yc > xc
+0017 a = [[x;zeros(yc-xc,size(x,2))] y] ;
+0018 else
+0019 a = [x y] ;
+0020 end
+0021
+0022 end
+0023
+0024
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/fgamma.html b/matlab/doc/fgamma.html
new file mode 100644
index 000000000..a89e2e619
--- /dev/null
+++ b/matlab/doc/fgamma.html
@@ -0,0 +1,50 @@
+
+
+
+ Description of fgamma
+
+
+
+
+
+
+
+
+
+
+
+
+
+fgamma
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function e = fgamma(p2,p,p1,perc)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+pgamma PGAMMA The gamma distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/figamm.html b/matlab/doc/figamm.html
new file mode 100644
index 000000000..9b789f431
--- /dev/null
+++ b/matlab/doc/figamm.html
@@ -0,0 +1,48 @@
+
+
+
+ Description of figamm
+
+
+
+
+
+
+
+
+
+
+
+
+
+figamm
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function e = figamm(p2,p,p1,perc)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+pgamma PGAMMA The gamma distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/filt_mc_.html b/matlab/doc/filt_mc_.html
new file mode 100644
index 000000000..9a94b9539
--- /dev/null
+++ b/matlab/doc/filt_mc_.html
@@ -0,0 +1,647 @@
+
+
+
+ Description of filt_mc_
+
+
+
+
+
+
+
+
+
+
+
+
+
+filt_mc_
+
+
+ PURPOSE
+copyright Marco Ratto 2006
+
+ SYNOPSIS
+function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)
+0002
+0003 global bayestopt_ estim_params_ M_ options_ oo_
+0004
+0005 if nargin<1 | isempty(vvarvecm),
+0006 vvarvecm = options_.varobs;
+0007 end
+0008 if nargin<2,
+0009 loadSA=0;
+0010 end
+0011 if nargin<3 | isempty(pfilt),
+0012 pfilt=0.1;
+0013 end
+0014 if nargin<4 | isempty(alpha),
+0015 alpha=0.002;
+0016 end
+0017 if nargin<5 | isempty(alpha2),
+0018 alpha2=0.5;
+0019 end
+0020 if nargin<7 | isempty(istart),
+0021 istart=1;
+0022 end
+0023 if nargin<8,
+0024 alphaPC=0.5;
+0025 end
+0026
+0027 fname_ = M_.fname;
+0028 lgy_ = M_.endo_names;
+0029 dr_ = oo_.dr;
+0030
+0031 disp(' ' )
+0032 disp(' ' )
+0033 disp('Starting sensitivity analysis' )
+0034 disp('for the fit of EACH observed series ...' )
+0035 disp(' ' )
+0036 disp('Deleting old SA figures...' )
+0037 a=dir([OutDir,'\*.*' ]);
+0038 if options_.opt_gsa.ppost,
+0039 tmp=['_SA_fit_post' ];
+0040 else
+0041 if options_.opt_gsa.pprior
+0042 tmp=['_SA_fit_prior' ];
+0043 else
+0044 tmp=['_SA_fit_mc' ];
+0045 end
+0046 end
+0047 for j=1:length(a),
+0048 if strmatch([fname_,tmp],a(j).name),
+0049 disp(a(j).name)
+0050 delete([OutDir,'\' ,a(j).name])
+0051 end ,
+0052 end
+0053 disp('done !' )
+0054
+0055
+0056 nshock=estim_params_.nvx + estim_params_.nvn + estim_params_.ncx + estim_params_.ncn;
+0057 npar=estim_params_.np;
+0058 for j=1:npar+nshock,
+0059 if j>nshock
+0060 if isfield(oo_,'posterior_mode' ),
+0061 xparam1(j)=oo_.posterior_mode.parameters.(bayestopt_.name{j});
+0062 end
+0063 if isfield(oo_,'posterior_mean' ),
+0064 xparam1_mean(j)=oo_.posterior_mean.parameters.(bayestopt_.name{j});
+0065 end
+0066 else
+0067 if isfield(oo_,'posterior_mode' ),
+0068 xparam1(j)=oo_.posterior_mode.shocks_std.(bayestopt_.name{j});
+0069 end
+0070 if isfield(oo_,'posterior_mean' ),
+0071 xparam1_mean(j)=oo_.posterior_mean.shocks_std.(bayestopt_.name{j});
+0072 end
+0073 end
+0074 end
+0075
+0076 if options_.opt_gsa.ppost,
+0077 fnamtmp=[fname_,'_post' ];
+0078 DirectoryName = CheckPath ('metropolis' );
+0079 else
+0080 if options_.opt_gsa.pprior
+0081 fnamtmp=[fname_,'_prior' ];
+0082 else
+0083 fnamtmp=[fname_,'_mc' ];
+0084 end
+0085 end
+0086 if ~loadSA,
+0087 if exist('xparam1' ,'var' )
+0088 set_all_parameters (xparam1);
+0089 steady_ ;
+0090 ys_mode=oo_.steady_state;
+0091 end
+0092 if exist('xparam1_mean' ,'var' )
+0093 set_all_parameters (xparam1_mean);
+0094 steady_ ;
+0095 ys_mean=oo_.steady_state;
+0096 end
+0097 eval(options_.datafile)
+0098 if ~options_.opt_gsa.ppost
+0099 load([OutDir,'\' ,fnamtmp]);
+0100 else
+0101 load([DirectoryName '/' M_.fname '_data.mat' ]);
+0102 filfilt = dir([DirectoryName '/' M_.fname '_filter*.mat' ]);
+0103 filparam = dir([DirectoryName '/' M_.fname '_param*.mat' ]);
+0104 x=[];
+0105 logpo2=[];
+0106 sto_ys=[];
+0107 for j=1:length(filparam),
+0108
+0109 if isempty(strmatch([M_.fname '_param_irf' ],filparam(j).name))
+0110 load([DirectoryName '/' filparam(j).name]);
+0111 x=[x; stock];
+0112 logpo2=[logpo2; stock_logpo];
+0113 sto_ys=[sto_ys; stock_ys];
+0114 clear stock stock_logpo stock_ys;
+0115 end
+0116 end
+0117 logpo2=-logpo2;
+0118 end
+0119 nruns=size(x,1);
+0120 nfilt=floor(pfilt*nruns);
+0121 disp(' ' )
+0122 disp('Computing RMSE''s...' )
+0123 fobs = options_.first_obs;
+0124 nobs=options_.nobs;
+0125 for i=1:size(vvarvecm,1),
+0126 vj=deblank(vvarvecm(i,:));
+0127 if options_.prefilter == 1
+0128 eval([vj,'=' ,vj,'-bayestopt_.mean_varobs(i);' ])
+0129 end
+0130
+0131 jxj = strmatch(vj,lgy_(dr_.order_var,:),'exact' );
+0132 js = strmatch(vj,lgy_,'exact' );
+0133 if exist('xparam1' ,'var' )
+0134 eval(['rmse_mode(i) = sqrt(mean((' ,vj,'(fobs-1+istart:fobs-1+nobs)-oo_.steady_state(js)-oo_.FilteredVariables.' ,vj,'(istart:end-1)).^2));' ])
+0135 end
+0136 y0=zeros(nobs+1,nruns);
+0137 if options_.opt_gsa.ppost
+0138 nbb=0;
+0139 for j=1:length(filfilt),
+0140 load([DirectoryName '/' M_.fname '_filter' ,num2str(j),'.mat' ]);
+0141 nb = size(stock,4);
+0142 y0(:,nbb+1:nbb+nb)=squeeze(stock(1,jxj,:,:)); + ...
+0143 kron(sto_ys(nbb+1:nbb+nb,js)',ones(size(stock,3),1));
+0144
+0145 nbb=nbb+nb;
+0146 clear stock;
+0147 end
+0148 else
+0149 y0 = squeeze(stock_filter(:,jxj,:)) + ...
+0150 kron(stock_ys(js,:),ones(size(stock_filter,1),1));
+0151 end
+0152 y0M=mean(y0,2);
+0153 for j=1:nruns,
+0154 eval(['rmse_MC(j,i) = sqrt(mean((' ,vj,'(fobs-1+istart:fobs-1+nobs)-y0(istart:end-1,j)).^2));' ])
+0155 end
+0156 if exist('xparam1_mean' ,'var' )
+0157
+0158 [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother (xparam1_mean,stock_gend,stock_data);
+0159 y0 = ahat(jxj,:)' + ...
+0160 kron(ys_mean(js,:),ones(size(ahat,2),1));
+0161 eval(['rmse_pmean(i) = sqrt(mean((' ,vj,'(fobs-1+istart:fobs-1+nobs)-y0(istart:end-1)).^2));' ])
+0162 end
+0163 end
+0164 clear stock_filter;
+0165 for j=1:nruns,
+0166 lnprior(j,1) = priordens (x(j,:),bayestopt_.pshape,bayestopt_.p1,bayestopt_.p2,bayestopt_.p3,bayestopt_.p4);
+0167 end
+0168 likelihood=logpo2(:)+lnprior(:);
+0169 disp('... done!' )
+0170
+0171 if options_.opt_gsa.ppost
+0172 save([OutDir,'\' ,fnamtmp], 'x' , 'logpo2' , 'likelihood' , 'rmse_MC' , 'rmse_mode' ,'rmse_pmean' )
+0173 else
+0174 save([OutDir,'\' ,fnamtmp], 'likelihood' , 'rmse_MC' , 'rmse_mode' ,'rmse_pmean' ,'-append' )
+0175 end
+0176 else
+0177 load([OutDir,'\' ,fnamtmp],'x' ,'logpo2' ,'likelihood' ,'rmse_MC' ,'rmse_mode' ,'rmse_pmean' );
+0178 lnprior=likelihood(:)-logpo2(:);
+0179 nruns=size(x,1);
+0180 nfilt=floor(pfilt*nruns);
+0181 end
+0182
+0183 nfilt0=nfilt*ones(size(vvarvecm,1),1);
+0184 logpo2=logpo2(:);
+0185 if ~options_.opt_gsa.ppost
+0186 [dum, ipost]=sort(logpo2);
+0187 end
+0188 for i=1:size(vvarvecm,1),
+0189 [dum, ixx(:,i)]=sort(rmse_MC(:,i));
+0190 if options_.opt_gsa.ppost,
+0191
+0192 rmse_txt=rmse_pmean;
+0193 else
+0194 if options_.opt_gsa.pprior,
+0195 rmse_txt=rmse_mode;
+0196 else
+0197
+0198 rmse_txt=rmse_pmean;
+0199 end
+0200 end
+0201 for j=1:npar+nshock,
+0202 [H,P,KSSTAT] = smirnov (x(ixx(nfilt0(i)+1:end ,i),j),x(ixx(1:nfilt0(i),i),j), alpha);
+0203 [H1,P1,KSSTAT1] = smirnov (x(ixx(nfilt0(i)+1:end ,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1);
+0204 [H2,P2,KSSTAT2] = smirnov (x(ixx(nfilt0(i)+1:end ,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1);
+0205 if H1 & H2==0,
+0206 SS(j,i)=1;
+0207 elseif H1==0,
+0208 SS(j,i)=-1;
+0209 else
+0210 SS(j,i)=0;
+0211 end
+0212 PP(j,i)=P;
+0213 end
+0214 end
+0215 figure('name' ,'prior' )
+0216 for i=1:size(vvarvecm,1),
+0217 subplot(3,3,i)
+0218 h=cumplot (lnprior(ixx(1:nfilt0(i),i)));
+0219 set(h,'color' ,'red' )
+0220 hold on, cumplot (lnprior)
+0221 h=cumplot (lnprior(ixx(nfilt0(i)+1:end ,i)));
+0222 set(h,'color' ,'green' )
+0223 title(vvarvecm(i,:))
+0224 end
+0225 if options_.opt_gsa.ppost
+0226 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_post_lnprior' ])
+0227 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_post_lnprior' ]);
+0228 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_post_lnprior' ]);
+0229 else
+0230 if options_.opt_gsa.pprior
+0231 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_prior_lnprior' ])
+0232 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_prior_lnprior' ]);
+0233 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_prior_lnprior' ]);
+0234 else
+0235 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_mc_lnprior' ])
+0236 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_mc_lnprior' ]);
+0237 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_mc_lnprior' ]);
+0238 end
+0239 end
+0240 close(gcf)
+0241 figure('name' ,'likelihood' )
+0242 for i=1:size(vvarvecm,1),
+0243 subplot(3,3,i)
+0244 h=cumplot (likelihood(ixx(1:nfilt0(i),i)));
+0245 set(h,'color' ,'red' )
+0246 hold on, h=cumplot (likelihood);
+0247 h=cumplot (likelihood(ixx(nfilt0(i)+1:end ,i)));
+0248 set(h,'color' ,'green' )
+0249 title(vvarvecm(i,:))
+0250 end
+0251 if options_.opt_gsa.ppost
+0252 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_post_lnlik' ])
+0253 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_post_lnlik' ]);
+0254 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_post_lnlik' ]);
+0255 else
+0256 if options_.opt_gsa.pprior
+0257 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_prior_lnlik' ])
+0258 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_prior_lnlik' ]);
+0259 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_prior_lnlik' ]);
+0260 else
+0261 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_mc_lnlik' ])
+0262 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_mc_lnlik' ]);
+0263 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_mc_lnlik' ]);
+0264 end
+0265 end
+0266 close(gcf)
+0267 figure('name' ,'posterior' )
+0268 for i=1:size(vvarvecm,1),
+0269 subplot(3,3,i)
+0270 h=cumplot (logpo2(ixx(1:nfilt0(i),i)));
+0271 set(h,'color' ,'red' )
+0272 hold on, h=cumplot (logpo2);
+0273 h=cumplot (logpo2(ixx(nfilt0(i)+1:end ,i)));
+0274 set(h,'color' ,'green' )
+0275 title(vvarvecm(i,:))
+0276 end
+0277 if options_.opt_gsa.ppost
+0278 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_post_lnpost' ])
+0279 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_post_lnpost' ]);
+0280 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_post_lnpost' ]);
+0281 else
+0282 if options_.opt_gsa.pprior
+0283 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_prior_lnpost' ])
+0284 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_prior_lnpost' ]);
+0285 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_prior_lnpost' ]);
+0286 else
+0287 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_mc_lnpost' ])
+0288 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_mc_lnpost' ]);
+0289 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_mc_lnpost' ]);
+0290 end
+0291 end
+0292 close(gcf)
+0293
+0294 param_names='' ;
+0295 for j=1:npar+nshock,
+0296 param_names=str2mat(param_names, bayestopt_.name{j});
+0297 end
+0298 param_names=param_names(2:end ,:);
+0299
+0300 disp(' ' )
+0301 disp('RMSE over the MC sample:' )
+0302 disp(' min yr RMSE max yr RMSE' )
+0303 for j=1:size(vvarvecm,1),
+0304 disp([vvarvecm(j,:), sprintf('%15.5g' ,[(min(rmse_MC(:,j))) [(max(rmse_MC(:,j)))]])])
+0305 end
+0306 invar = find( std(rmse_MC)./mean(rmse_MC)<=0.0001 );
+0307 if ~isempty(invar)
+0308 disp(' ' )
+0309 disp(' ' )
+0310 disp('RMSE is not varying significantly over the MC sample for the following variables:' )
+0311 disp(vvarvecm(invar,:))
+0312 disp('These variables are excluded from SA' )
+0313 disp('[Unless you treat these series as exogenous, there is something wrong in your estimation !]' )
+0314 end
+0315 ivar = find( std(rmse_MC)./mean(rmse_MC)>0.0001 );
+0316 vvarvecm=vvarvecm(ivar,:);
+0317 rmse_MC=rmse_MC(:,ivar);
+0318
+0319 disp(' ' )
+0320 if options_.opt_gsa.ppost==0 & options_.opt_gsa.pprior,
+0321 disp(['Sample filtered the ' ,num2str(pfilt*100),'% best RMSE''s for each observed series ...' ])
+0322 else
+0323 disp(['Sample filtered the best RMSE''s smaller than RMSE at the posterior mean ...' ])
+0324 end
+0325
+0326
+0327
+0328
+0329 disp(' ' )
+0330 disp(' ' )
+0331 disp('RMSE ranges after filtering:' )
+0332 if options_.opt_gsa.ppost==0 & options_.opt_gsa.pprior,
+0333 disp([' best ' ,num2str(pfilt*100),'% filtered remaining 90%' ])
+0334 disp([' min max min max posterior mode' ])
+0335 else
+0336 disp([' best filtered remaining ' ])
+0337 disp([' min max min max posterior mean' ])
+0338 end
+0339 for j=1:size(vvarvecm,1),
+0340 disp([vvarvecm(j,:), sprintf('%15.5g' ,[min(rmse_MC(ixx(1:nfilt0(j),j),j)) ...
+0341 max(rmse_MC(ixx(1:nfilt0(j),j),j)) ...
+0342 min(rmse_MC(ixx(nfilt0(j)+1:end ,j),j)) ...
+0343 max(rmse_MC(ixx(nfilt0(j)+1:end ,j),j)) ...
+0344 rmse_txt(j)])])
+0345
+0346
+0347
+0348
+0349 end
+0350
+0351
+0352
+0353
+0354
+0355
+0356
+0357
+0358
+0359 SP=zeros(npar+nshock,size(vvarvecm,1));
+0360 for j=1:size(vvarvecm,1),
+0361 ns=find(PP(:,j)<alpha);
+0362 SP(ns,j)=ones(size(ns));
+0363 SS(:,j)=SS(:,j).*SP(:,j);
+0364 end
+0365
+0366 for j=1:npar+nshock,
+0367 nsp(j)=length(find(SP(j,:)));
+0368 end
+0369 snam0=param_names(find(nsp==0),:);
+0370 snam1=param_names(find(nsp==1),:);
+0371 snam2=param_names(find(nsp>1),:);
+0372 snam=param_names(find(nsp>0),:);
+0373
+0374
+0375
+0376
+0377 nsnam=(find(nsp>1));
+0378
+0379 disp(' ' )
+0380 disp(' ' )
+0381 disp('These parameters do not affect significantly the fit of ANY observed series:' )
+0382 disp(snam0)
+0383 disp(' ' )
+0384 disp('These parameters affect ONE single observed series:' )
+0385 disp(snam1)
+0386 disp(' ' )
+0387 disp('These parameters affect MORE THAN ONE observed series: trade off exists!' )
+0388 disp(snam2)
+0389
+0390
+0391
+0392 pnam=bayestopt_.name;
+0393
+0394
+0395 a00=jet(size(vvarvecm,1));
+0396 for ix=1:ceil(length(nsnam)/6),
+0397 figure,
+0398 for j=1+6*(ix-1):min(size(snam2,1),6*ix),
+0399 subplot(2,3,j-6*(ix-1))
+0400
+0401 h0=cumplot (x(:,nsnam(j)));
+0402
+0403 hold on,
+0404 np=find(SP(nsnam(j),:));
+0405
+0406 a0=a00(np,:);
+0407 for i=1:nsp(nsnam(j)),
+0408
+0409 h0=cumplot (x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)));
+0410 set(h0,'color' ,a0(i,:))
+0411 end
+0412 ydum=get(gca,'ylim' );
+0413
+0414 xdum=xparam1(nsnam(j));
+0415 h1=plot([xdum xdum],ydum);
+0416 set(h1,'color' ,[0.85 0.85 0.85],'linewidth' ,2)
+0417 h0=legend(str2mat('base' ,vvarvecm(np,:)),0);
+0418 set(h0,'fontsize' ,6)
+0419
+0420 xlabel('' )
+0421 set(findobj(get(h0,'children' ),'type' ,'text' ),'interpreter' ,'none' )
+0422 title([pnam{nsnam(j)}],'interpreter' ,'none' )
+0423 if options_.opt_gsa.ppost
+0424 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_post_' ,num2str(ix)])
+0425 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_post_' int2str(ix)]);
+0426 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_post_' int2str(ix)]);
+0427 else
+0428 if options_.opt_gsa.pprior
+0429 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_prior_' ,num2str(ix)])
+0430 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_prior_' int2str(ix)]);
+0431 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_prior_' int2str(ix)]);
+0432 else
+0433 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_mc_' ,num2str(ix)])
+0434 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_mc_' int2str(ix)]);
+0435 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_mc_' int2str(ix)]);
+0436 end
+0437 end
+0438 end
+0439 end
+0440 close all
+0441
+0442 for j=1:size(SP,2),
+0443 nsx(j)=length(find(SP(:,j)));
+0444 end
+0445
+0446 number_of_grid_points = 2^9;
+0447 bandwidth = 0;
+0448 kernel_function = 'gaussian' ;
+0449
+0450
+0451 for ix=1:ceil(length(nsnam)/6),
+0452 figure,
+0453 for j=1+6*(ix-1):min(size(snam2,1),6*ix),
+0454 subplot(2,3,j-6*(ix-1))
+0455 optimal_bandwidth = mh_optimal_bandwidth (x(:,nsnam(j)),size(x,1),bandwidth,kernel_function);
+0456 [x1,f1] = kernel_density_estimate (x(:,nsnam(j)),number_of_grid_points,...
+0457 optimal_bandwidth,kernel_function);
+0458 h0 = plot(x1, f1);
+0459 hold on,
+0460 np=find(SP(nsnam(j),:));
+0461
+0462 a0=a00(np,:);
+0463 for i=1:nsp(nsnam(j)),
+0464 optimal_bandwidth = mh_optimal_bandwidth (x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)),nfilt,bandwidth,kernel_function);
+0465 [x1,f1] = kernel_density_estimate (x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)),number_of_grid_points,...
+0466 optimal_bandwidth,kernel_function);
+0467 h0 = plot(x1, f1);
+0468 set(h0,'color' ,a0(i,:))
+0469 end
+0470 ydum=get(gca,'ylim' );
+0471 set(gca,'ylim' ,[0 ydum(2)]);
+0472
+0473 xdum=xparam1(nsnam(j));
+0474 h1=plot([xdum xdum],[0 ydum(2)]);
+0475 set(h1,'color' ,[0.85 0.85 0.85],'linewidth' ,2)
+0476 h0=legend(str2mat('base' ,vvarvecm(np,:)),0);
+0477 set(h0,'fontsize' ,6)
+0478
+0479 xlabel('' )
+0480 set(findobj(get(h0,'children' ),'type' ,'text' ),'interpreter' ,'none' )
+0481 title([pnam{nsnam(j)}],'interpreter' ,'none' )
+0482 if options_.opt_gsa.ppost
+0483 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_post_dens_' ,num2str(ix)])
+0484 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_post_dens_' int2str(ix)]);
+0485 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_post_dens_' int2str(ix)]);
+0486 else
+0487 if options_.opt_gsa.pprior
+0488 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_prior_dens_' ,num2str(ix)])
+0489 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_prior_dens_' int2str(ix)]);
+0490 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_prior_dens_' int2str(ix)]);
+0491 else
+0492 saveas(gcf,[OutDir,'\' ,fname_,'_SA_fit_mc_dens_' ,num2str(ix)])
+0493 eval(['print -depsc2 ' OutDir '\' fname_ '_SA_fit_mc_dens_' int2str(ix)]);
+0494 eval(['print -dpdf ' OutDir '\' fname_ '_SA_fit_mc_dens_' int2str(ix)]);
+0495 end
+0496 end
+0497 end
+0498 end
+0499 close all
+0500
+0501
+0502
+0503
+0504
+0505
+0506
+0507
+0508
+0509
+0510
+0511
+0512
+0513
+0514
+0515
+0516
+0517
+0518
+0519
+0520
+0521
+0522
+0523
+0524
+0525
+0526
+0527
+0528
+0529
+0530
+0531
+0532
+0533
+0534
+0535
+0536
+0537
+0538
+0539
+0540
+0541
+0542
+0543
+0544
+0545 disp(' ' )
+0546 disp(' ' )
+0547 disp('Sensitivity table (significance and direction):' )
+0548 vav=char(zeros(1, size(param_names,2)+3 ));
+0549 ibl = 12-size(vvarvecm,2);
+0550 for j=1:size(vvarvecm,1),
+0551 vav = [vav, char(zeros(1,ibl)),vvarvecm(j,:)];
+0552 end
+0553 disp(vav)
+0554 for j=1:npar+nshock,
+0555
+0556 disp([param_names(j,:),' ' , sprintf('%12.3g' ,PP(j,:))])
+0557 disp([char(zeros(1, size(param_names,2)+3 )),sprintf(' (%6g)' ,SS(j,:))])
+0558 end
+0559
+0560
+0561 disp(' ' )
+0562 disp(' ' )
+0563 disp('Starting bivariate analysis:' )
+0564
+0565 for i=1:size(vvarvecm,1)
+0566 if options_.opt_gsa.ppost
+0567 fnam = ['SA_fit_post_' ,deblank(vvarvecm(i,:))];
+0568 else
+0569 if options_.opt_gsa.pprior
+0570 fnam = ['SA_fit_prior_' ,deblank(vvarvecm(i,:))];
+0571 else
+0572 fnam = ['SA_fit_mc_' ,deblank(vvarvecm(i,:))];
+0573 end
+0574 end
+0575 stab_map_2 (x(ixx(1:nfilt0(i),i),:),alpha2,fnam, OutDir);
+0576
+0577
+0578
+0579
+0580
+0581
+0582
+0583
+0584
+0585
+0586
+0587
+0588
+0589
+0590
+0591
+0592
+0593
+0594
+0595
+0596
+0597
+0598
+0599
+0600 end
+0601
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/fnorm.html b/matlab/doc/fnorm.html
new file mode 100644
index 000000000..c5f336e2b
--- /dev/null
+++ b/matlab/doc/fnorm.html
@@ -0,0 +1,48 @@
+
+
+
+ Description of fnorm
+
+
+
+
+
+
+
+
+
+
+
+
+
+fnorm
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function e = fnorm(p2,p,p1,perc)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+pnorm PNORM The normal distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/forcst.html b/matlab/doc/forcst.html
new file mode 100644
index 000000000..dce1748ba
--- /dev/null
+++ b/matlab/doc/forcst.html
@@ -0,0 +1,119 @@
+
+
+
+ Description of forcst
+
+
+
+
+
+
+
+
+
+
+
+
+
+forcst
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [yf,var_yf]=forcst(dr,y0,k,m)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+make_ex_ Copyright (C) 2001 Michel Juillardsimult_ Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [yf,var_yf]=forcst(dr,y0,k,m)
+0002 global M_ oo_ options_
+0003
+0004 options_.periods = k;
+0005 make_ex_ ;
+0006 yf = simult_ (y0,dr,oo_.exo_simul(1:k,:),1);
+0007
+0008 nstatic = dr.nstatic;
+0009 npred = dr.npred;
+0010 j = find(kstate(dr.kae,2) <= ykmin_+1);
+0011 kae = dr.kae(j);
+0012 nh = size(dr.ghx,2);
+0013 hx = dr.ghx(nstatic+1:nstatic+npred,:);
+0014 hu = dr.ghu(nstatic+1:nstatic+npred,:);
+0015 if ~isempty(kae)
+0016 n = length(kae);
+0017 tmp = sparse([1:n]',kae-sum(dr.kstate(:,2)>M_.maximum_lag+1),ones(n,1),n,nh);
+0018 hx = [hx; tmp];
+0019 hu = [hu; zeros(n,M_.exo_nbr)];
+0020 end
+0021 gx = [];
+0022 k2 = [];
+0023 if nstatic > 0
+0024 gx = dr.ghx(1:nstatic,:);
+0025 k2 = [1:nstatic]';
+0026 end
+0027 if size(dr.ghx,1) > nstatic+npred
+0028 gx = [gx; dr.ghx(nstatic+npred+1:end ,:)];
+0029 k2 = [k2; [nstatic+npred+1:size(dr.ghx,1)]'];
+0030 end
+0031
+0032 k1 = dr.order_var([nstatic+1:nstatic+npred]);
+0033 k2 = dr.order_var(k2);
+0034
+0035 sigma_u = hu*M_.Sigma_e*hu';
+0036 sigma_y1 = 0;
+0037 var_yf = zeros(k,M_.endo_nbr);
+0038
+0039
+0040 if isempty(k2)
+0041 for i=1:k
+0042 sigma_y1 = sigma_y1+sigma_u;
+0043 var_yf(i,k1) = diag(sigma_y1(1:npred,1:npred))';
+0044 if i == k
+0045 break
+0046 end
+0047 sigma_u = hx*sigma_u*hx';
+0048 end
+0049 else
+0050 for i=1:k
+0051 sigma_y1 = sigma_y1+sigma_u;
+0052 var_yf(i,k1) = diag(sigma_y1(1:npred,1:npred))';
+0053 sigma_y2 = gx*sigma_y1*gx';
+0054 var_yf(i,k2) = diag(sigma_y2)';
+0055 if i == k
+0056 break
+0057 end
+0058 sigma_u = hx*sigma_u*hx';
+0059 end
+0060 end
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/fortran.png b/matlab/doc/fortran.png
new file mode 100644
index 000000000..350c572ee
Binary files /dev/null and b/matlab/doc/fortran.png differ
diff --git a/matlab/doc/ftest.html b/matlab/doc/ftest.html
new file mode 100644
index 000000000..f8e27c9b2
--- /dev/null
+++ b/matlab/doc/ftest.html
@@ -0,0 +1,115 @@
+
+
+
+ Description of ftest
+
+
+
+
+
+
+
+
+
+
+
+
+
+ftest
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function ftest (s1,s2)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dcompare Copyright (C) 2001 Michel Juillardgcompare Copyright (C) 2001 Michel Juillardmcompare Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function ftest (s1,s2)
+0004
+0005 global nvx nvy x y lag1
+0006
+0007 if size(s1,1) ~= 2
+0008 error ('Spcifiez deux fichiers pour la comparaison.' ) ;
+0009 end
+0010
+0011 for i = 1:2
+0012 if ~ isempty(find(abs(s1(i,:)) == 46))
+0013 error ('Entrez les noms de fichiers sans extensions.' ) ;
+0014 end
+0015 end
+0016
+0017 s1 = [s1 [' ' ;' ' ]] ;
+0018 file1 = [s1(1,1:min(find(abs(s1(1,:)) == 32))-1) '.BIN' ] ;
+0019 file2 = [s1(2,1:min(find(abs(s1(2,:)) == 32))-1) '.BIN' ] ;
+0020
+0021 fid=fopen(file1,'r' ) ;
+0022 n1 = fread(fid,1,'int' ) ;
+0023 n2 = fread(fid,1,'int' ) ;
+0024 n3 = fread(fid,1,'int' ) ;
+0025 lag1 = fread(fid,4,'int' ) ;
+0026 nvx = fread(fid,[n1,n3],'int' ) ;
+0027 x = fread(fid,[n1,n2],'float64' ) ;
+0028 fclose(fid) ;
+0029 nvx = setstr(nvx) ;
+0030
+0031 fid=fopen(file2,'r' ) ;
+0032 n1 = fread(fid,1,'int' ) ;
+0033 n2 = fread(fid,1,'int' ) ;
+0034 n3 = fread(fid,1,'int' ) ;
+0035 lag2 = fread(fid,4,'int' ) ;
+0036 nvy = fread(fid,[n1,n3],'int' ) ;
+0037 y = fread(fid,[n1,n2],'float64' ) ;
+0038 fclose(fid) ;
+0039 nvy = setstr(nvy) ;
+0040
+0041 if size(x,1) ~= size(y,1)
+0042 error ('FTEST: The two files don''t have the same number of variables.' );
+0043 end
+0044
+0045 for i = 1:size(x,1)
+0046 if ~ strcmp(nvx(i,:),nvy(i,:))
+0047 error ('FTEST: The two files don''t have the same variables.' ) ;
+0048 end
+0049 end
+0050
+0051 if nnz(lag1 - lag2) > 0
+0052 error ('FTEST: Leads and lags aren''t the same in both files.' ) ;
+0053 end
+0054
+0055 j = zeros(size(s2,1),1);
+0056 for i=1:size(s2,1)
+0057 k = strmatch(s2(i,:),nvx,'exact' ) ;
+0058 if isempty(k)
+0059 t = ['FTEST: Variable ' s2(i) 'doesn''t exist' ] ;
+0060 error (t) ;
+0061 else
+0062 j(i) =k;
+0063 end
+0064 end
+0065
+0066 y = y(j,:) ;
+0067 x = x(j,:) ;
+0068
+0069
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/gamm_rnd.html b/matlab/doc/gamm_rnd.html
new file mode 100644
index 000000000..bee3e9790
--- /dev/null
+++ b/matlab/doc/gamm_rnd.html
@@ -0,0 +1,135 @@
+
+
+
+ Description of gamm_rnd
+
+
+
+
+
+
+
+
+
+
+
+
+
+gamm_rnd
+
+
+ PURPOSE
+PURPOSE: a matrix of random draws from the gamma distribution
+
+ SYNOPSIS
+function gb = gamm_rnd(nrow,m,k)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function gb = gamm_rnd(nrow,m,k)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021 if nargin ~= 3
+0022 error('Wrong # of arguments to gamm_rnd' );
+0023 end ;
+0024
+0025 ncol = 1;
+0026 gb=zeros(nrow,ncol);
+0027 if m<=1
+0028
+0029 c=1/m;
+0030 t=0.07+0.75*sqrt(1-m);
+0031 b=1+exp(-t)*m/t;
+0032 for i1=1:nrow
+0033 for i2=1:ncol
+0034 accept=0;
+0035 while accept==0
+0036 u=rand; w=rand; v=b*u;
+0037 if v<=1
+0038 x=t*(v^c);
+0039 accept=((w<=((2-x)/(2+x))) | (w<=exp(-x)));
+0040 else
+0041 x=-log(c*t*(b-v));
+0042 y=x/t;
+0043 accept=(((w*(m+y-m*y))<=1) | (w<=(y^(m-1))));
+0044 end
+0045 end
+0046 gb(i1,i2)=x;
+0047 end
+0048 end
+0049 else
+0050
+0051 b=m-1;
+0052 c=3*m-0.75;
+0053 for i1=1:nrow
+0054 for i2=1:ncol
+0055 accept=0;
+0056 while accept==0
+0057 u=rand; v=rand;
+0058 w=u*(1-u); y=sqrt(c/w)*(u-0.5);
+0059 x=b+y;
+0060 if x >= 0
+0061 z=64*(w^3)*v*v;
+0062 accept=(z<=(1-2*y*y/x)) ...
+0063 | (log(z)<=(2*(b*log(x/b)-y)));
+0064 end
+0065 end
+0066 gb(i1,i2)=x;
+0067 end
+0068 end
+0069 end
+0070 gb=gb/k;
+0071
+0072
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/gcompare.html b/matlab/doc/gcompare.html
new file mode 100644
index 000000000..30719e1eb
--- /dev/null
+++ b/matlab/doc/gcompare.html
@@ -0,0 +1,94 @@
+
+
+
+ Description of gcompare
+
+
+
+
+
+
+
+
+
+
+
+
+
+gcompare
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function gcompare(s1,s2)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+ftest Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function gcompare(s1,s2)
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012 global options_ M_
+0013 global nvx nvy x y lag1
+0014
+0015 ftest (s1,s2) ;
+0016
+0017 ix = [1-lag1(1):size(x,2)-lag1(1)]' ;
+0018 i = [lag1(1):size(ix,1)-lag1(2)+1]' ;
+0019
+0020 if options_.smpl == 0
+0021 i = [M_.maximum_lag:size(y,2)]' ;
+0022 else
+0023 i = [options_.smpl(1):options_.smpl(2)]' ;
+0024 end
+0025
+0026 for k = 1:size(x,1)
+0027 figure ;
+0028 plot (ix(i),x(k,i),ix(i),y(k,i)) ;
+0029 xlabel (['Periods' ]) ;
+0030 title (['Variable ' s2(k,:)]) ;
+0031 l = min(i) + 1;
+0032 ll = max(i) - 1 ;
+0033 text (l,x(k,l),s1(1,:)) ;
+0034 text (ll,y(k,ll),s1(2,:)) ;
+0035 end
+0036
+0037
+0038
+0039
+0040
+0041
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/gendata.html b/matlab/doc/gendata.html
new file mode 100644
index 000000000..7c33d4c32
--- /dev/null
+++ b/matlab/doc/gendata.html
@@ -0,0 +1,79 @@
+
+
+
+ Description of gendata
+
+
+
+
+
+
+
+
+
+
+
+
+
+gendata
+
+
+ PURPOSE
+[y,epsilon,alpha,eta] = gendata(T, ssf, a0)
+
+ SYNOPSIS
+function [y,epsilon,alpha,eta] = gendata(T, ssf, a0)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 function [y,epsilon,alpha,eta] = gendata(T, ssf, a0)
+0010
+0011 m = size(ssf.T, 1);
+0012 p = size(ssf.Z, 1);
+0013 r = size(ssf.R, 2);
+0014
+0015 cholH = chol(ssf.H);
+0016 cholQ = chol(ssf.Q);
+0017
+0018 epsilon = cholH*randn(p,T);
+0019 eta = cholQ*randn(r, T);
+0020
+0021 y = zeros(p, T);
+0022 alpha = zeros(m,T);
+0023 alpha(:,1) = a0;
+0024
+0025 for t = 1:T
+0026 y(:,t) = ssf.Z*alpha(:,t) + epsilon(:,t);
+0027 if t ~= T
+0028 alpha(:,t+1) = ssf.T*alpha(:,t) + ssf.R*eta(:,t);
+0029 end
+0030 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/generalized_cholesky.html b/matlab/doc/generalized_cholesky.html
new file mode 100644
index 000000000..46c14c997
--- /dev/null
+++ b/matlab/doc/generalized_cholesky.html
@@ -0,0 +1,101 @@
+
+
+
+ Description of generalized_cholesky
+
+
+
+
+
+
+
+
+
+Home >
. > generalized_cholesky.m
+
+
+
+generalized_cholesky
+
+
+ PURPOSE
+proc gmchol(A);
+
+ SYNOPSIS
+function AA = generalized_cholesky(A);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007 function AA = generalized_cholesky(A);
+0008
+0009 n = rows (A);
+0010 R = eye(n);
+0011 E = zeros(n,n);
+0012 norm_A = max(transpose(sum(abs(A))));
+0013 gamm = max(abs(diag(A)));
+0014 delta = max([eps*norm_A;eps]);
+0015
+0016 for j = 1:n;
+0017 theta_j = 0;
+0018 for i=1:n;
+0019 somme = 0;
+0020 for k=1:i-1;
+0021 somme = somme + R(k,i)*R(k,j);
+0022 end ;
+0023 R(i,j) = (A(i,j) - somme)/R(i,i);
+0024 if (A(i,j) -somme) > theta_j;
+0025 theta_j = A(i,j) - somme;
+0026 end ;
+0027 if i > j;
+0028 R(i,j) = 0;
+0029 end ;
+0030 end ;
+0031 somme = 0;
+0032 for k=1:j-1;
+0033 somme = somme + R(k,j)^2;
+0034 end ;
+0035 phi_j = A(j,j) - somme;
+0036 if j+1 <= n;
+0037 xi_j = max(abs(A((j+1):n,j)));
+0038 else ;
+0039 xi_j = abs(A(n,j));
+0040 end ;
+0041 beta_j = sqrt(max([gamm ; (xi_j/n) ; eps]));
+0042 if all(delta >= [abs(phi_j);((theta_j^2)/(beta_j^2))]);
+0043 E(j,j) = delta - phi_j;
+0044 elseif all(abs(phi_j) >= [((delta^2)/(beta_j^2));delta]);
+0045 E(j,j) = abs(phi_j) - phi_j;
+0046 elseif all(((theta_j^2)/(beta_j^2)) >= [delta;abs(phi_j)]);
+0047 E(j,j) = ((theta_j^2)/(beta_j^2)) - phi_j;
+0048 end ;
+0049 R(j,j) = sqrt(A(j,j) - somme + E(j,j));
+0050 end ;
+0051 AA = transpose(R)*R;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/generalized_cholesky2.html b/matlab/doc/generalized_cholesky2.html
new file mode 100644
index 000000000..3d969ee52
--- /dev/null
+++ b/matlab/doc/generalized_cholesky2.html
@@ -0,0 +1,189 @@
+
+
+
+ Description of generalized_cholesky2
+
+
+
+
+
+
+
+
+
+Home >
. > generalized_cholesky2.m
+
+
+
+generalized_cholesky2
+
+
+ PURPOSE
+/*
+
+ SYNOPSIS
+function AA = generalized_cholesky2(A)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023 function AA = generalized_cholesky2(A)
+0024
+0025 n = size(A,1);
+0026 L = zeros(n,n);
+0027 deltaprev = 0;
+0028 gamm = max(abs(diag(A)));
+0029 tau = eps^(1/3);
+0030
+0031 if min(eig(A)) > 0;
+0032 tau = -1000000;
+0033 end ;
+0034
+0035 norm_A = max(sum(abs(A))');
+0036 gamm = max(abs(diag(A)));
+0037 delta = max([eps*norm_A;eps]);
+0038 Pprod = eye(n);
+0039
+0040 if n > 2;
+0041 for k = 1,n-2;
+0042 if min((diag(A(k+1:n,k+1:n))' - A(k,k+1:n).^2/A(k,k))') < tau*gamm ...
+0043 & min(eig(A((k+1):n,(k+1):n))) < 0;
+0044 [tmp,dmax] = max(diag(A(k:n,k:n)));
+0045 if A(k+dmax-1,k+dmax-1) > A(k,k);
+0046 P = eye(n);
+0047 Ptemp = P(k,:);
+0048 P(k,:) = P(k+dmax-1,:);
+0049 P(k+dmax-1,:) = Ptemp;
+0050 A = P*A*P;
+0051 L = P*L*P;
+0052 Pprod = P*Pprod;
+0053 end ;
+0054 g = zeros(n-(k-1),1);
+0055 for i=k:n;
+0056 if i == 1;
+0057 sum1 = 0;
+0058 else ;
+0059 sum1 = sum(abs(A(i,k:(i-1)))');
+0060 end ;
+0061 if i == n;
+0062 sum2 = 0;
+0063 else ;
+0064 sum2 = sum(abs(A((i+1):n,i)));
+0065 end ;
+0066 g(i-k+1) = A(i,i) - sum1 - sum2;
+0067 end ;
+0068 [tmp,gmax] = max(g);
+0069 if gmax ~= k;
+0070 P = eye(n);
+0071 Ptemp = P(k,:);
+0072 P(k,:) = P(k+dmax-1,:);
+0073 P(k+dmax-1,:) = Ptemp;
+0074 A = P*A*P;
+0075 L = P*L*P;
+0076 Pprod = P*Pprod;
+0077 end ;
+0078 normj = sum(abs(A(k+1:n,k)));
+0079 delta = max([0;deltaprev;-A(k,k)+normj;-A(k,k)+tau*gamm]);
+0080 if delta > 0;
+0081 A(k,k) = A(k,k) + delta;
+0082 deltaprev = delta;
+0083 end ;
+0084 end ;
+0085 A(k,k) = sqrt(A(k,k));
+0086 L(k,k) = A(k,k);
+0087 for i=k+1:n;
+0088 if L(k,k) > eps;
+0089 A(i,k) = A(i,k)/L(k,k);
+0090 end ;
+0091 L(i,k) = A(i,k);
+0092 A(i,k+1:i) = A(i,k+1:i) - L(i,k)*L(k+1:i,k)';
+0093 if A(i,i) < 0;
+0094 A(i,i) = 0;
+0095 end ;
+0096 end ;
+0097 end ;
+0098 end ;
+0099 A(n-1,n) = A(n,n-1);
+0100 eigvals = eig(A(n-1:n,n-1:n));
+0101 dlist = [ 0 ; deltaprev ;...
+0102 -min(eigvals)+tau*max((inv(1-tau)*max(eigvals)-min(eigvals))|gamm) ];
+0103 if dlist(1) > dlist(2);
+0104 delta = dlist(1);
+0105 else ;
+0106 delta = dlist(2);
+0107 end ;
+0108 if delta < dlist(3);
+0109 delta = dlist(3);
+0110 end ;
+0111 if delta > 0;
+0112 A(n-1,n-1) = A(n-1,n-1) + delta;
+0113 A(n,n) = A(n,n) + delta;
+0114 deltaprev = delta;
+0115 end ;
+0116 A(n-1,n-1) = sqrt(A(n-1,n-1));
+0117 L(n-1,n-1) = A(n-1,n-1);
+0118 A(n,n-1) = A(n,n-1)/L(n-1,n-1);
+0119 L(n,n-1) = A(n,n-1);
+0120 A(n,n) = sqrt(A(n,n) - L(n,(n-1))^2);
+0121 L(n,n) = A(n,n);
+0122 AA = Pprod'*L'*Pprod';
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/get_the_name.html b/matlab/doc/get_the_name.html
new file mode 100644
index 000000000..d0b0c6a30
--- /dev/null
+++ b/matlab/doc/get_the_name.html
@@ -0,0 +1,105 @@
+
+
+
+ Description of get_the_name
+
+
+
+
+
+
+
+
+
+Home >
. > get_the_name.m
+
+
+
+get_the_name
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [07-13-2004]
+
+ SYNOPSIS
+function [nam,texnam] = get_the_name(k,TeX)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [nam,texnam] = get_the_name(k,TeX)
+0002
+0003 global M_ estim_params_ options_
+0004
+0005 nam = [];
+0006 texnam = [];
+0007
+0008 nvx = estim_params_.nvx;
+0009 nvn = estim_params_.nvn;
+0010 ncx = estim_params_.ncx;
+0011 ncn = estim_params_.ncn;
+0012
+0013 if k <= nvx
+0014 vname = deblank(M_.exo_names(estim_params_.var_exo(k,1),:));
+0015 nam = ['SE_' ,vname];
+0016 if TeX
+0017 tname = deblank(M_.exo_names_tex(estim_params_.var_exo(k,1),:));
+0018 texnam = ['$ SE_{' tname '} $' ];
+0019 end
+0020 elseif k <= (nvx+nvn)
+0021 vname = deblank(options_.varobs(estim_params_.var_endo(k-estim_params_.nvx,1),:));
+0022 nam=['SE_EOBS_' ,vname];
+0023 if TeX
+0024 tname = deblank(options_.TeX_varobs(estim_params_.var_endo(k-estim_params_.nvx,1),:));
+0025 texnam = ['$ SE_{' tname '} $' ];
+0026 end
+0027 elseif k <= (nvx+nvn+ncx)
+0028 jj = k - (nvx+nvn);
+0029 k1 = estim_params_.corrx(jj,1);
+0030 k2 = estim_params_.corrx(jj,2);
+0031 vname = [deblank(M_.exo_names(k1,:)) '_' deblank(M_.exo_names(k2,:))];
+0032 nam=['CC_' ,vname];
+0033 if TeX
+0034 tname = [deblank(M_.exo_names_tex(k1,:)) ',' deblank(M_.exo_names_tex(k2,:))];
+0035 texnam = ['$ CC_{' tname '} $' ];
+0036 end
+0037 elseif k <= (nvx+nvn+ncx+ncn)
+0038 jj = k - (nvx+nvn+ncx);
+0039 k1 = estim_params_.corrn(jj,1);
+0040 k2 = estim_params_.corrn(jj,2);
+0041 vname = [deblank(M_.endo_names(k1,:)) '_' deblank(M_.endo_names(k2,:))];
+0042 nam=['CC_EOBS_' vname];
+0043 if TeX
+0044 tname = [deblank(M_.endo_names_tex(k1,:)) ',' deblank(M_.endo_names_tex(k2,:))];
+0045 texnam =['$ CC_{' tname '} $' ];
+0046 end
+0047 else
+0048 jj = k - (nvx+nvn+ncx+ncn);
+0049 jj1 = estim_params_.param_vals(jj,1);
+0050 nam = deblank(M_.param_names(jj1,:));
+0051 if TeX
+0052 texnam = ['$ ' deblank(M_.param_names_tex(jj1,:)) ' $' ];
+0053 end
+0054 end
+0055
+0056
+0057
+0058
+0059
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/global_initialization.html b/matlab/doc/global_initialization.html
new file mode 100644
index 000000000..b067787b8
--- /dev/null
+++ b/matlab/doc/global_initialization.html
@@ -0,0 +1,67 @@
+
+
+
+ Description of global_initialization
+
+
+
+
+
+
+
+
+
+Home >
. > global_initialization.m
+
+
+
+global_initialization
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function global_initialization()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function global_initialization()
+0002 global oo_ M_ options_ ct_ endval_ rplottype_
+0003
+0004 ct_=0;
+0005 endval_=0;
+0006
+0007 options_.rplottype = 0;
+0008 options_.smpl = 0;
+0009 options_.dynatol = 0.00001;
+0010 options_.maxit_ = 10;
+0011 options_.slowc = 1;
+0012 options_.timing = 0;
+0013 options_.gstep = 1e-2;
+0014 options_.debug = 0
+0015 options_.initval_file = 0;
+0016
+0017 oo_.exo_simul = [];
+0018 oo_.y_simul = [];
+0019 oo_.dr = struct([]);
+0020 oo_.exo_det_steady_state = [];
+0021 oo_.exo_det_simul = [];
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/graph.dot b/matlab/doc/graph.dot
new file mode 100644
index 000000000..202b34fe5
--- /dev/null
+++ b/matlab/doc/graph.dot
@@ -0,0 +1,491 @@
+/* Created by mdot for Matlab */
+digraph m2html {
+ CutSample -> CheckPath;
+ DiffuseKalmanSmoother1 -> steady;
+ DiffuseKalmanSmoother3 -> steady;
+ DiffuseKalmanSmootherH1 -> steady;
+ DiffuseKalmanSmootherH3 -> steady;
+ DiffuseKalmanSmootherH3corr -> steady;
+ DsgeLikelihood -> DiffuseLikelihood3;
+ DsgeLikelihood -> DiffuseLikelihoodH1;
+ DsgeLikelihood -> DiffuseLikelihoodH3;
+ DsgeLikelihood -> DiffuseLikelihoodH3corr;
+ DsgeLikelihood -> dynare_resolve;
+ DsgeLikelihood -> kalman_filter;
+ DsgeLikelihood -> lyapunov_symm;
+ DsgeLikelihood -> priordens;
+ DsgeSmoother -> DiffuseKalmanSmoother1;
+ DsgeSmoother -> DiffuseKalmanSmoother3;
+ DsgeSmoother -> DiffuseKalmanSmootherH1;
+ DsgeSmoother -> DiffuseKalmanSmootherH3;
+ DsgeSmoother -> dynare_resolve;
+ DsgeSmoother -> lyapunov_symm;
+ DsgeSmoother -> set_all_parameters;
+ GetAllPosteriorDraws -> CheckPath;
+ GetOneDraw -> metropolis_draw;
+ GetPosteriorParametersStatistics -> CheckPath;
+ GetPosteriorParametersStatistics -> GetAllPosteriorDraws;
+ GetPosteriorParametersStatistics -> posterior_moments;
+ McMCDiagnostics -> CheckPath;
+ McMCDiagnostics -> get_the_name;
+ PlotPosteriorDistributions -> CheckPath;
+ PlotPosteriorDistributions -> draw_prior_density;
+ PlotPosteriorDistributions -> get_the_name;
+ PosteriorIRF -> CheckPath;
+ PosteriorIRF -> GetOneDraw;
+ PosteriorIRF -> ReshapeMatFiles;
+ PosteriorIRF -> irf;
+ PosteriorIRF -> posterior_moments;
+ PosteriorIRF -> resol;
+ PosteriorIRF -> set_parameters;
+ PosteriorSmoother -> CheckPath;
+ PosteriorSmoother -> DsgeSmoother;
+ PosteriorSmoother -> GetOneDraw;
+ PosteriorSmoother -> resol;
+ PosteriorSmoother -> set_all_parameters;
+ ReshapeMatFiles -> CheckPath;
+ UnivariateSpectralDensity -> kalman_transition_matrix;
+ UnivariateSpectralDensity -> lyapunov_symm;
+ beta_rnd -> gamm_rnd;
+ bksup -> irf;
+ bksup -> selif;
+ bksup1 -> irf;
+ bksupk -> irf;
+ bksupk -> selif;
+ calib -> calib_obj;
+ calib -> calib_obj2;
+ calib -> indnv;
+ calib -> resol;
+ calib -> union;
+ calib_obj -> bicgstab;
+ calib_obj -> f_var;
+ calib_obj -> lyapunov_symm;
+ calib_obj2 -> lyapunov_symm;
+ check -> print_info;
+ check -> resol;
+ check -> set_default_option;
+ check_mh -> my_subplot;
+ compDist -> lpdfgam;
+ compDist -> mj_qgamma;
+ compDist -> posterior_density_estimate;
+ compDist -> qbeta;
+ compDist -> qgamma;
+ compDist -> qnorm;
+ csminwel -> bfgsi;
+ csminwel -> csminit;
+ csminwel -> numgrad;
+ dcompare -> bseastr;
+ dcompare -> ftest;
+ disp_moments -> set_default_option;
+ disp_moments -> table;
+ disp_th_moments -> table;
+ disp_th_moments -> th_autocovariances;
+ dlognorm -> dnorm;
+ dr1 -> hessian;
+ dr1 -> qzdiv;
+ dr1 -> resid;
+ dr1 -> set_default_option;
+ dr1 -> set_state_space;
+ dr1 -> sylvester3;
+ dr1 -> sylvester3a;
+ dr1 -> transition_matrix;
+ dr11 -> qzdiv;
+ dr11 -> set_default_option;
+ dr11 -> set_state_space;
+ dr2 -> dr1;
+ draw_prior_density -> lpdfgam;
+ draw_prior_density -> mj_qgamma;
+ draw_prior_density -> qbeta;
+ draw_prior_density -> qgamma;
+ draw_prior_density -> qnorm;
+ dynare_MC -> DsgeLikelihood;
+ dynare_MC -> DsgeSmoother;
+ dynare_MC -> prior_bounds;
+ dynare_MC -> read_variables;
+ dynare_MC -> set_default_option;
+ dynare_MC -> set_prior;
+ dynare_MC -> set_state_space;
+ dynare_estimation -> CheckPath;
+ dynare_estimation -> CutSample;
+ dynare_estimation -> DsgeLikelihood;
+ dynare_estimation -> DsgeSmoother;
+ dynare_estimation -> GetPosteriorParametersStatistics;
+ dynare_estimation -> McMCDiagnostics;
+ dynare_estimation -> PlotPosteriorDistributions;
+ dynare_estimation -> PosteriorIRF;
+ dynare_estimation -> asamin;
+ dynare_estimation -> csminwel;
+ dynare_estimation -> generalized_cholesky;
+ dynare_estimation -> hessian;
+ dynare_estimation -> initial_estimation_checks;
+ dynare_estimation -> marginal_density;
+ dynare_estimation -> metropolis;
+ dynare_estimation -> metropolis_draw;
+ dynare_estimation -> mode_check;
+ dynare_estimation -> newrat;
+ dynare_estimation -> plot_priors;
+ dynare_estimation -> pltorg;
+ dynare_estimation -> prior_bounds;
+ dynare_estimation -> read_variables;
+ dynare_estimation -> set_default_option;
+ dynare_estimation -> set_prior;
+ dynare_estimation -> set_state_space;
+ dynare_estimation -> union;
+ dynare_resolve -> kalman_transition_matrix;
+ dynare_resolve -> resol;
+ dynare_sensitivity -> CheckPath;
+ dynare_sensitivity -> dynare_MC;
+ dynare_sensitivity -> filt_mc_;
+ dynare_sensitivity -> read_variables;
+ dynare_sensitivity -> set_default_option;
+ dynare_sensitivity -> stab_map_;
+ dynare_solve -> set_default_option;
+ dynare_solve -> solve1;
+ fgamma -> pgamma;
+ figamm -> pgamma;
+ filt_mc_ -> CheckPath;
+ filt_mc_ -> DsgeSmoother;
+ filt_mc_ -> cumplot;
+ filt_mc_ -> kernel_density_estimate;
+ filt_mc_ -> mh_optimal_bandwidth;
+ filt_mc_ -> priordens;
+ filt_mc_ -> set_all_parameters;
+ filt_mc_ -> smirnov;
+ filt_mc_ -> stab_map_2;
+ filt_mc_ -> steady_;
+ fnorm -> pnorm;
+ forcst -> make_ex_;
+ forcst -> simult_;
+ gcompare -> ftest;
+ generalized_cholesky -> rows;
+ initial_estimation_checks -> DsgeLikelihood;
+ initvalf_ -> dy_date;
+ irf -> simult_;
+ lnsrch -> check;
+ lnsrch1 -> check;
+ lptauSEQ -> LPTAU;
+ lyapunov_symm -> my_ordeig;
+ make_ex_ -> set_default_option;
+ make_y_ -> set_default_option;
+ marginal_density -> CheckPath;
+ marginal_density -> qchisq;
+ mcompare -> ftest;
+ metropolis -> CheckPath;
+ metropolis -> DsgeLikelihood;
+ metropolis_draw -> CheckPath;
+ mgnldnsty -> matrictint;
+ mgnldnsty -> rfvar3;
+ mgnldnsty -> varprior;
+ mj_qgamma -> lpdfgam;
+ mj_qgamma -> pgamma;
+ mode_check -> DsgeLikelihood;
+ mode_check -> get_the_name;
+ mode_check -> hessian;
+ mode_check -> pltorg;
+ mr_gstep -> csminit;
+ newrat -> check;
+ newrat -> csminit;
+ newrat -> mr_gstep;
+ newrat -> mr_hessian;
+ olr -> disp_dr;
+ olr -> disp_moments;
+ olr -> disp_th_moments;
+ olr -> dyn2vec;
+ olr -> irf;
+ olr -> make_ex_;
+ olr -> olr1;
+ olr -> set_default_option;
+ olr -> simult;
+ olr -> table;
+ olr1 -> check;
+ olr1 -> dynare_solve;
+ olr1 -> olr2;
+ olr2 -> union;
+ osr -> disp_dr;
+ osr -> disp_moments;
+ osr -> disp_th_moments;
+ osr -> dyn2vec;
+ osr -> irf;
+ osr -> make_ex_;
+ osr -> osr1;
+ osr -> set_default_option;
+ osr -> simult;
+ osr -> table;
+ osr1 -> check;
+ osr1 -> dynare_solve;
+ osr1 -> osr_obj;
+ osr1 -> resol;
+ osr_obj -> resol;
+ p2toperc -> fbeta;
+ p2toperc -> fgamma;
+ p2toperc -> figamm;
+ p2toperc -> qnorm;
+ plot_priors -> draw_prior_density;
+ plot_priors -> get_the_name;
+ plot_priors -> pltorg;
+ posterior_distribution -> draw_prior_density;
+ posterior_distribution -> get_the_name;
+ posterior_distribution -> kernel_density_estimate;
+ posterior_distribution -> mh_optimal_bandwidth;
+ posterior_moments -> kernel_density_estimate;
+ posterior_moments -> mh_optimal_bandwidth;
+ print_info -> set_default_option;
+ prior_bounds -> mj_qgamma;
+ prior_bounds -> qbeta;
+ prior_bounds -> qnorm;
+ priordens -> lpdfgam;
+ priordens -> lpdfgbeta;
+ priordens -> lpdfig1;
+ priordens -> lpdfig2;
+ priordens -> lpdfnorm;
+ qbeta -> dbeta;
+ qchisq -> qgamma;
+ qgamma -> dgamma;
+ qgamma -> pgamma;
+ qzdiv -> qzswitch;
+ resol -> dr1;
+ resol -> dynare_solve;
+ resol -> resid;
+ resol -> set_default_option;
+ resol1 -> dr11;
+ resol1 -> dynare_solve;
+ resol1 -> resid;
+ rndprior -> beta_rnd;
+ rndprior -> gamm_rnd;
+ set_prior -> inverse_gamma_specification;
+ set_prior -> uniform_specification;
+ set_state_space -> union;
+ sim1 -> bksup1;
+ simk -> bksupk;
+ simk -> ffill;
+ simk -> indnv;
+ simk -> selif;
+ simk -> union;
+ simul -> dyn2vec;
+ simul -> make_ex_;
+ simul -> make_y_;
+ simul -> set_default_option;
+ simul -> sim1;
+ simul -> simk;
+ simul -> simult;
+ simult -> simult_;
+ simult_ -> check;
+ simult_ -> dynare_solve;
+ simult_ -> set_default_option;
+ solve1 -> check;
+ solve1 -> lnsrch1;
+ stab_map_ -> lptauSEQ;
+ stab_map_ -> stab_map_1;
+ stab_map_ -> stab_map_2;
+ stab_map_ -> stoch_simul;
+ stab_map_1 -> cumplot;
+ stab_map_1 -> smirnov;
+ stab_map_marginal -> kernel_density_estimate;
+ stab_map_marginal -> mh_optimal_bandwidth;
+ steady -> set_default_option;
+ steady -> steady_;
+ steady_ -> check;
+ steady_ -> dynare_solve;
+ stoch_simul -> UnivariateSpectralDensity;
+ stoch_simul -> check_model;
+ stoch_simul -> disp_dr;
+ stoch_simul -> disp_moments;
+ stoch_simul -> disp_th_moments;
+ stoch_simul -> dyn2vec;
+ stoch_simul -> irf;
+ stoch_simul -> pltorg;
+ stoch_simul -> print_info;
+ stoch_simul -> resol;
+ stoch_simul -> set_default_option;
+ stoch_simul -> simult;
+ stoch_simul -> table;
+ th_autocovariances -> kalman_transition_matrix;
+ th_autocovariances -> lyapunov_symm;
+
+ CheckPath [URL="CheckPath.html"];
+ CreateBenchmark [URL="CreateBenchmark.html"];
+ CutSample [URL="CutSample.html"];
+ DiffuseKalmanSmoother1 [URL="DiffuseKalmanSmoother1.html"];
+ DiffuseKalmanSmoother3 [URL="DiffuseKalmanSmoother3.html"];
+ DiffuseKalmanSmootherH1 [URL="DiffuseKalmanSmootherH1.html"];
+ DiffuseKalmanSmootherH3 [URL="DiffuseKalmanSmootherH3.html"];
+ DiffuseKalmanSmootherH3corr [URL="DiffuseKalmanSmootherH3corr.html"];
+ DiffuseLikelihood1 [URL="DiffuseLikelihood1.html"];
+ DiffuseLikelihood3 [URL="DiffuseLikelihood3.html"];
+ DiffuseLikelihoodH1 [URL="DiffuseLikelihoodH1.html"];
+ DiffuseLikelihoodH3 [URL="DiffuseLikelihoodH3.html"];
+ DiffuseLikelihoodH3corr [URL="DiffuseLikelihoodH3corr.html"];
+ DsgeLikelihood [URL="DsgeLikelihood.html"];
+ DsgeSmoother [URL="DsgeSmoother.html"];
+ GetAllPosteriorDraws [URL="GetAllPosteriorDraws.html"];
+ GetOneDraw [URL="GetOneDraw.html"];
+ GetPosteriorParametersStatistics [URL="GetPosteriorParametersStatistics.html"];
+ InitSeed [URL="InitSeed.html"];
+ LPTAU [URL="LPTAU.html"];
+ MakeAllFigures [URL="MakeAllFigures.html"];
+ McMCDiagnostics [URL="McMCDiagnostics.html"];
+ PlotPosteriorDistributions [URL="PlotPosteriorDistributions.html"];
+ PosteriorIRF [URL="PosteriorIRF.html"];
+ PosteriorSmoother [URL="PosteriorSmoother.html"];
+ ReshapeMatFiles [URL="ReshapeMatFiles.html"];
+ UnivariateSpectralDensity [URL="UnivariateSpectralDensity.html"];
+ asamin [URL="asamin.html"];
+ beta_rnd [URL="beta_rnd.html"];
+ bfgsi [URL="bfgsi.html"];
+ bicgstab [URL="bicgstab.html"];
+ bksup [URL="bksup.html"];
+ bksup1 [URL="bksup1.html"];
+ bksupk [URL="bksupk.html"];
+ bseastr [URL="bseastr.html"];
+ calib [URL="calib.html"];
+ calib_obj [URL="calib_obj.html"];
+ calib_obj2 [URL="calib_obj2.html"];
+ check [URL="check.html"];
+ check_mh [URL="check_mh.html"];
+ check_model [URL="check_model.html"];
+ compDist [URL="compDist.html"];
+ csminit [URL="csminit.html"];
+ csminwel [URL="csminwel.html"];
+ cumplot [URL="cumplot.html"];
+ datatomfile [URL="datatomfile.html"];
+ dbeta [URL="dbeta.html"];
+ dcompare [URL="dcompare.html"];
+ dgamma [URL="dgamma.html"];
+ disp_dr [URL="disp_dr.html"];
+ disp_moments [URL="disp_moments.html"];
+ disp_th_moments [URL="disp_th_moments.html"];
+ dlognorm [URL="dlognorm.html"];
+ dnorm [URL="dnorm.html"];
+ dr1 [URL="dr1.html"];
+ dr11 [URL="dr11.html"];
+ dr2 [URL="dr2.html"];
+ draw_prior_density [URL="draw_prior_density.html"];
+ dsample [URL="dsample.html"];
+ dy_date [URL="dy_date.html"];
+ dyn2vec [URL="dyn2vec.html"];
+ dynare [URL="dynare.html"];
+ dynare_MC [URL="dynare_MC.html"];
+ dynare_estimation [URL="dynare_estimation.html"];
+ dynare_resolve [URL="dynare_resolve.html"];
+ dynare_sensitivity [URL="dynare_sensitivity.html"];
+ dynare_solve [URL="dynare_solve.html"];
+ dynasave [URL="dynasave.html"];
+ dynatype [URL="dynatype.html"];
+ f_var [URL="f_var.html"];
+ fbeta [URL="fbeta.html"];
+ ff1_ [URL="ff1_.html"];
+ ffill [URL="ffill.html"];
+ fgamma [URL="fgamma.html"];
+ figamm [URL="figamm.html"];
+ filt_mc_ [URL="filt_mc_.html"];
+ fnorm [URL="fnorm.html"];
+ forcst [URL="forcst.html"];
+ ftest [URL="ftest.html"];
+ gamm_rnd [URL="gamm_rnd.html"];
+ gcompare [URL="gcompare.html"];
+ gendata [URL="gendata.html"];
+ generalized_cholesky [URL="generalized_cholesky.html"];
+ generalized_cholesky2 [URL="generalized_cholesky2.html"];
+ get_the_name [URL="get_the_name.html"];
+ global_initialization [URL="global_initialization.html"];
+ hessian [URL="hessian.html"];
+ hessian_sparse [URL="hessian_sparse.html"];
+ indnv [URL="indnv.html"];
+ initial_estimation_checks [URL="initial_estimation_checks.html"];
+ initvalf_ [URL="initvalf_.html"];
+ inverse_gamma_specification [URL="inverse_gamma_specification.html"];
+ irf [URL="irf.html"];
+ kalman_filter [URL="kalman_filter.html"];
+ kalman_smoother [URL="kalman_smoother.html"];
+ kalman_transition_matrix [URL="kalman_transition_matrix.html"];
+ kernel_density_estimate [URL="kernel_density_estimate.html"];
+ lnsrch [URL="lnsrch.html"];
+ lnsrch1 [URL="lnsrch1.html"];
+ lpdfbeta [URL="lpdfbeta.html"];
+ lpdfgam [URL="lpdfgam.html"];
+ lpdfgbeta [URL="lpdfgbeta.html"];
+ lpdfig1 [URL="lpdfig1.html"];
+ lpdfig2 [URL="lpdfig2.html"];
+ lpdfnorm [URL="lpdfnorm.html"];
+ lptauSEQ [URL="lptauSEQ.html"];
+ lyapunov_symm [URL="lyapunov_symm.html"];
+ make_ex_ [URL="make_ex_.html"];
+ make_y_ [URL="make_y_.html"];
+ marginal_density [URL="marginal_density.html"];
+ matrictint [URL="matrictint.html"];
+ mcompare [URL="mcompare.html"];
+ metropolis [URL="metropolis.html"];
+ metropolis_draw [URL="metropolis_draw.html"];
+ mgnldnsty [URL="mgnldnsty.html"];
+ mh_optimal_bandwidth [URL="mh_optimal_bandwidth.html"];
+ mj_qgamma [URL="mj_qgamma.html"];
+ mode_check [URL="mode_check.html"];
+ mr_gstep [URL="mr_gstep.html"];
+ mr_hessian [URL="mr_hessian.html"];
+ my_ordeig [URL="my_ordeig.html"];
+ my_subplot [URL="my_subplot.html"];
+ newrat [URL="newrat.html"];
+ numgrad [URL="numgrad.html"];
+ olr [URL="olr.html"];
+ olr1 [URL="olr1.html"];
+ olr2 [URL="olr2.html"];
+ osr [URL="osr.html"];
+ osr1 [URL="osr1.html"];
+ osr_obj [URL="osr_obj.html"];
+ p2toperc [URL="p2toperc.html"];
+ pgamma [URL="pgamma.html"];
+ plot_priors [URL="plot_priors.html"];
+ pltorg [URL="pltorg.html"];
+ pnorm [URL="pnorm.html"];
+ posterior_density_estimate [URL="posterior_density_estimate.html"];
+ posterior_distribution [URL="posterior_distribution.html"];
+ posterior_moments [URL="posterior_moments.html"];
+ print_info [URL="print_info.html"];
+ prior_bounds [URL="prior_bounds.html"];
+ priordens [URL="priordens.html"];
+ qbeta [URL="qbeta.html"];
+ qchisq [URL="qchisq.html"];
+ qgamma [URL="qgamma.html"];
+ qnorm [URL="qnorm.html"];
+ qzdiv [URL="qzdiv.html"];
+ qzswitch [URL="qzswitch.html"];
+ read_variables [URL="read_variables.html"];
+ recursive_moments [URL="recursive_moments.html"];
+ resid [URL="resid.html"];
+ resol [URL="resol.html"];
+ resol1 [URL="resol1.html"];
+ rfvar3 [URL="rfvar3.html"];
+ rndprior [URL="rndprior.html"];
+ rows [URL="rows.html"];
+ rplot [URL="rplot.html"];
+ sec2hms [URL="sec2hms.html"];
+ selif [URL="selif.html"];
+ set_all_parameters [URL="set_all_parameters.html"];
+ set_default_option [URL="set_default_option.html"];
+ set_parameters [URL="set_parameters.html"];
+ set_prior [URL="set_prior.html"];
+ set_shocks [URL="set_shocks.html"];
+ set_state_space [URL="set_state_space.html"];
+ sim1 [URL="sim1.html"];
+ simk [URL="simk.html"];
+ simul [URL="simul.html"];
+ simult [URL="simult.html"];
+ simult_ [URL="simult_.html"];
+ smirnov [URL="smirnov.html"];
+ solve1 [URL="solve1.html"];
+ stab_map_ [URL="stab_map_.html"];
+ stab_map_1 [URL="stab_map_1.html"];
+ stab_map_2 [URL="stab_map_2.html"];
+ stab_map_marginal [URL="stab_map_marginal.html"];
+ steady [URL="steady.html"];
+ steady_ [URL="steady_.html"];
+ stoch_simul [URL="stoch_simul.html"];
+ sylvester3 [URL="sylvester3.html"];
+ sylvester3a [URL="sylvester3a.html"];
+ table [URL="table.html"];
+ th_autocovariances [URL="th_autocovariances.html"];
+ transition_matrix [URL="transition_matrix.html"];
+ uniform_specification [URL="uniform_specification.html"];
+ union [URL="union.html"];
+ varprior [URL="varprior.html"];
+}
\ No newline at end of file
diff --git a/matlab/doc/graph.html b/matlab/doc/graph.html
new file mode 100644
index 000000000..738a398d0
--- /dev/null
+++ b/matlab/doc/graph.html
@@ -0,0 +1,213 @@
+
+
+
+ Dependency Graph for .
+
+
+
+
+
+
+
+
+
+
+Dependency Graph for .
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Generated on Fri 16-Jun-2006 09:09:02 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/graph.map b/matlab/doc/graph.map
new file mode 100644
index 000000000..812eb28b8
--- /dev/null
+++ b/matlab/doc/graph.map
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/matlab/doc/graph.png b/matlab/doc/graph.png
new file mode 100644
index 000000000..f365ad15b
Binary files /dev/null and b/matlab/doc/graph.png differ
diff --git a/matlab/doc/hessian.html b/matlab/doc/hessian.html
new file mode 100644
index 000000000..56c2f7bca
--- /dev/null
+++ b/matlab/doc/hessian.html
@@ -0,0 +1,99 @@
+
+
+
+ Description of hessian
+
+
+
+
+
+
+
+
+
+
+
+
+
+hessian
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function hessian_mat = hessian(func,x,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005 function hessian_mat = hessian(func,x,varargin)
+0006 global options_
+0007 func = str2func(func);
+0008 n=size(x,1);
+0009
+0010 h1=max(abs(x),sqrt(options_.gstep)*ones(n,1))*eps^(1/6);
+0011 h_1=h1;
+0012 xh1=x+h1;
+0013 h1=xh1-x;
+0014 xh1=x-h_1;
+0015 h_1=x-xh1;
+0016 xh1=x;
+0017 f0=feval(func,x,varargin{:});
+0018 f1=zeros(size(f0,1),n);
+0019 f_1=f1;
+0020 for i=1:n
+0021 xh1(i)=x(i)+h1(i);
+0022 f1(:,i)=feval(func,xh1,varargin{:});
+0023 xh1(i)=x(i)-h_1(i);
+0024 f_1(:,i)=feval(func,xh1,varargin{:});
+0025 xh1(i)=x(i);
+0026 i=i+1;
+0027 end
+0028 xh_1=xh1;
+0029 hessian_mat = zeros(size(f0,1),n*n);
+0030 for i=1:n
+0031 if i > 1
+0032 k=[i:n:n*(i-1)];
+0033 hessian_mat(:,(i-1)*n+1:(i-1)*n+i-1)=hessian_mat(:,k);
+0034 end
+0035 hessian_mat(:,(i-1)*n+i)=(f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i));
+0036 temp=f1+f_1-f0*ones(1,n);
+0037 for j=i+1:n
+0038 xh1(i)=x(i)+h1(i);
+0039 xh1(j)=x(j)+h_1(j);
+0040 xh_1(i)=x(i)-h1(i);
+0041 xh_1(j)=x(j)-h_1(j);
+0042 hessian_mat(:,(i-1)*n+j)=-(-feval(func,xh1,varargin{:})-feval(func,xh_1,varargin{:})+temp(:,i)+temp(:,j))./(2*h1(i)*h_1(j));
+0043 xh1(i)=x(i);
+0044 xh1(j)=x(j);
+0045 xh_1(i)=x(i);
+0046 xh_1(j)=x(j);
+0047 j=j+1;
+0048 end
+0049 i=i+1;
+0050 end
+0051
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/hessian_sparse.html b/matlab/doc/hessian_sparse.html
new file mode 100644
index 000000000..a84122569
--- /dev/null
+++ b/matlab/doc/hessian_sparse.html
@@ -0,0 +1,47 @@
+
+
+
+ Description of hessian_sparse
+
+
+
+
+
+
+
+
+
+Home >
. > hessian_sparse.m
+
+
+
+hessian_sparse
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard%% computes second order partial derivatives% uses Abramowitz and Stegun (1965) formulas 25.3.24 and 25.3.27 p. 884function hessian_mat = hessian_sparse(func,x,varargin)global options_func = str2func(func);n=size(x,1);%h1=max(abs(x),options_.gstep*ones(n,1))*eps^(1/3);h1=max(abs(x),sqrt(options_.gstep)*ones(n,1))*eps^(1/6);h_1=h1;xh1=x+h1;h1=xh1-x;xh1=x-h_1;h_1=x-xh1;xh1=x;f0=feval(func,x,varargin{:});nf = size(f0,1);f1=zeros(nf,n);f_1=f1;for i=1:n xh1(i)=x(i)+h1(i); f1(:,i)=feval(func,xh1,varargin{:}); xh1(i)=x(i)-h_1(i); f_1(:,i)=feval(func,xh1,varargin{:}); xh1(i)=x(i); i=i+1;endxh_1=xh1;hessian_mat = spalloc(nf,n*n,3*nf*n);for i=1:n if i > 1 k=[i:n:n*(i-1)]; hessian_mat(:,(i-1)*n+1:(i-1)*n+i-1)=hessian_mat(:,k); end hessian_mat(:,(i-1)*n+i)=sparse((f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i))); temp=f1+f_1-f0*ones(1,n); for j=i+1:n xh1(i)=x(i)+h1(i); xh1(j)=x(j)+h_1(j); xh_1(i)=x(i)-h1(i); xh_1(j)=x(j)-h_1(j); hessian_mat(:,(i-1)*n+j)=sparse(-(-feval(func,xh1,varargin{:})-feval(func,xh_1,varargin{:})+temp(:,i)+temp(:,j))./(2*h1(i)*h_1(j))); xh1(i)=x(i); xh1(j)=x(j); xh_1(i)=x(i); xh_1(j)=x(j); j=j+1; end i=i+1;end% 10/03/02 MJ used the 7 points formula
+
+ SYNOPSIS
+This is a script file.
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/hp.png b/matlab/doc/hp.png
new file mode 100644
index 000000000..d09f988fb
Binary files /dev/null and b/matlab/doc/hp.png differ
diff --git a/matlab/doc/index.html b/matlab/doc/index.html
new file mode 100644
index 000000000..cb8edca8a
--- /dev/null
+++ b/matlab/doc/index.html
@@ -0,0 +1,34 @@
+
+
+
+ Index for Directory .
+
+
+
+
+
+
+
+
+
+
+
+Index for .
+
+Matlab files in this directory:
+
+ CheckPath 06-03-2005 CreateBenchmark stephane.adjemian@cepremap.cnrs.fr [12-06-2004] CutSample stephane.adjemian@ens.fr [09-09-2005] DiffuseKalmanSmoother1 modified by M. Ratto: DiffuseKalmanSmoother3 function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf) DiffuseKalmanSmootherH1 modified by M. Ratto: DiffuseKalmanSmootherH3 Modified by M. Ratto DiffuseKalmanSmootherH3corr stephane.adjemian@cepremap.cnrs.fr [09-16-2004] DiffuseLikelihood1 M. Ratto added lik in output DiffuseLikelihood3 M. Ratto added lik in output [October 2005] DiffuseLikelihoodH1 M. Ratto added lik in output DiffuseLikelihoodH3 M. Ratto added lik in output [October 2005] DiffuseLikelihoodH3corr stephane.adjemian@cepremap.cnrs.fr [12-13-2004] DsgeLikelihood stephane.adjemian@cepremap.cnrs.fr [09-07-2004] DsgeSmoother stephane.adjemian@cepremap.cnrs.fr [09-07-2004] GetAllPosteriorDraws stephane.adjemian@ens.fr [09-09-2005] GetOneDraw stephane.adjemian@ens.fr [09-25-2005] GetPosteriorParametersStatistics stephane.adjemian@ens.fr [09-09-2005] InitSeed stephane.adjemian@cepremap.cnrs.fr [12-02-2004] LPTAU MakeAllFigures stephane.adjemian@cepremap.cnrs.fr [02-04-2005] McMCDiagnostics stephane.adjemian@ens.fr [06-04-2005] PlotPosteriorDistributions stephane.adjemian@ens.fr [09-09-2005] PosteriorIRF stephane.adjemian@ens.fr [09-25-2005] PosteriorSmoother stephane.adjemian@ens.fr [09-25-2005] ReshapeMatFiles Reshape and sort (along the mcmc simulations) the mat files generated UnivariateSpectralDensity stephane.adjemian@ens.fr asamin ASAMIN A gateway function to Adaptive Simulated Annealing (ASA) beta_rnd PURPOSE: random draws from the beta(a,b) distribution bfgsi H = bfgsi(H0,dg,dx) bicgstab bksup Copyright (C) 2001 Michel Juillard bksup1 Copyright (C) 2001 Michel Juillard bksupk bseastr Copyright (C) 2001 Michel Juillard calib calib_obj targets and iy order: 1) variances 2) correlations calib_obj2 targets and iy order: 1) variances 2) correlations check Copyright (C) 2001 Michel Juillard check_mh check_model compDist csminit [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,... csminwel [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin) cumplot function h =cumplot(x) datatomfile Copyright (C) 2001 Michel Juillard dbeta DBETA The beta density function dcompare Copyright (C) 2001 Michel Juillard dgamma DGAMMA The gamma density function disp_dr Copyright (C) 2001 Michel Juillard disp_moments Copyright (C) 2001 Michel Juillard disp_th_moments Copyright (C) 2001 Michel Juillard dlognorm DLOGNORM The log-normal density function dnorm DNORM The normal density function dr1 Copyright (C) 2001 Michel Juillard dr11 Copyright (C) 2001 Michel Juillard dr2 Copyright (C) 2001 Michel Juillard draw_prior_density stephane.adjemian@ens.fr [07-15-2004] dsample Copyright (C) 2001 Michel Juillard dy_date dyn2vec Copyright (C) 2001 Michel Juillard dynare Copyright (C) 2001 Michel Juillard dynare_MC dynare_estimation dynare_resolve dynare_sensitivity copyright Marco Ratto 2006 dynare_solve Copyright (C) 2001 Michel Juillard dynasave Copyright (C) 2001 Michel Juillard dynatype Copyright (C) 2001 Michel Juillard f_var fbeta must restrict p2 such that a>0 and b>0 .... ff1_ Copyright (C) 2001 Michel Juillard ffill Copyright (C) 2001 Michel Juillard fgamma figamm filt_mc_ copyright Marco Ratto 2006 fnorm forcst ftest Copyright (C) 2001 Michel Juillard gamm_rnd PURPOSE: a matrix of random draws from the gamma distribution gcompare Copyright (C) 2001 Michel Juillard gendata [y,epsilon,alpha,eta] = gendata(T, ssf, a0) generalized_cholesky proc gmchol(A); generalized_cholesky2 /* get_the_name stephane.adjemian@cepremap.cnrs.fr [07-13-2004] global_initialization hessian Copyright (C) 2001 Michel Juillard hessian_sparse Copyright (C) 2001 Michel Juillard%% computes second order partial derivatives% uses Abramowitz and Stegun (1965) formulas 25.3.24 and 25.3.27 p. 884function hessian_mat = hessian_sparse(func,x,varargin)global options_func = str2func(func);n=size(x,1);%h1=max(abs(x),options_.gstep*ones(n,1))*eps^(1/3);h1=max(abs(x),sqrt(options_.gstep)*ones(n,1))*eps^(1/6);h_1=h1;xh1=x+h1;h1=xh1-x;xh1=x-h_1;h_1=x-xh1;xh1=x;f0=feval(func,x,varargin{:});nf = size(f0,1);f1=zeros(nf,n);f_1=f1;for i=1:n xh1(i)=x(i)+h1(i); f1(:,i)=feval(func,xh1,varargin{:}); xh1(i)=x(i)-h_1(i); f_1(:,i)=feval(func,xh1,varargin{:}); xh1(i)=x(i); i=i+1;endxh_1=xh1;hessian_mat = spalloc(nf,n*n,3*nf*n);for i=1:n if i > 1 k=[i:n:n*(i-1)]; hessian_mat(:,(i-1)*n+1:(i-1)*n+i-1)=hessian_mat(:,k); end hessian_mat(:,(i-1)*n+i)=sparse((f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i))); temp=f1+f_1-f0*ones(1,n); for j=i+1:n xh1(i)=x(i)+h1(i); xh1(j)=x(j)+h_1(j); xh_1(i)=x(i)-h1(i); xh_1(j)=x(j)-h_1(j); hessian_mat(:,(i-1)*n+j)=sparse(-(-feval(func,xh1,varargin{:})-feval(func,xh_1,varargin{:})+temp(:,i)+temp(:,j))./(2*h1(i)*h_1(j))); xh1(i)=x(i); xh1(j)=x(j); xh_1(i)=x(i); xh_1(j)=x(j); j=j+1; end i=i+1;end% 10/03/02 MJ used the 7 points formula indnv Copyright (C) 2001 Michel Juillard initial_estimation_checks initvalf_ inverse_gamma_specification irf kalman_filter SYNOPSIS kalman_smoother SYNOPSIS kalman_transition_matrix makes transition matrices out of ghx and ghu for Kalman filter kernel_density_estimate % This function aims at estimating a continuous density. A kernel density lnsrch Copyright (C) 2001 Michel Juillard lnsrch1 Copyright (C) 2001 Michel Juillard lpdfbeta log BETA PDF lpdfgam log GAMMA PDF lpdfgbeta log (generalized) BETA PDF lpdfig1 log INVERSE GAMMA (type 1) lpdfig2 log INVERSE GAMMA (type 2) lpdfnorm LPDFNORM The log of the normal density function lptauSEQ [lpmat] = lptauSEQ(Nsam,Nvar) lyapunov_symm solves x-a*x*a'=b for b (and then x) symmetrical make_ex_ Copyright (C) 2001 Michel Juillard make_y_ Copyright (C) 2001 Michel Juillard marginal_density stephane.adjemian@ens.fr [09-09-2005] matrictint function w=matrictint(S,XXi,T) mcompare Copyright (C) 2001 Michel Juillard metropolis stephane.adjemian@ens.fr [09-02-2005] metropolis_draw mgnldnsty function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat) mh_optimal_bandwidth % This function gives the optimal bandwidth parameter of a kernel estimator mj_qgamma MJ_QGAMMA The gamma inverse distribution function mode_check mr_gstep Copyright (C) 2005 Marco Ratto mr_hessian Copyright (C) 2004 Marco Ratto my_ordeig my_subplot spreads subplots on several figures according to a maximum number of newrat numgrad function [g badg] = numgrad(fcn,xvarargin) olr Copyright (C) 2001 Michel Juillard olr1 Copyright (C) 2001 Michel Juillard olr2 Copyright (C) 2003 Michel Juillard osr Copyright (C) 2001 Michel Juillard osr1 osr_obj the beginning and the end of this function may be adapted by the userx p2toperc pgamma PGAMMA The gamma distribution function plot_priors stephane.adjemian@cepremap.cnrs.fr [07-31-2004] pltorg stephane.adjemian@cepremap.cnrs.fr [06-07-2004] pnorm PNORM The normal distribution function posterior_density_estimate % posterior_distribution stephane.adjemian@cepremap.cnrs.fr [07-15-2004] posterior_moments stephane.adjemian@ens.fr [09-09-2005] print_info Copyright (C) 2005 Michel Juillard prior_bounds priordens This procedure computes a prior density for qbeta QBETA The beta inverse distribution function qchisq QCHISQ The chisquare inverse distribution function qgamma QGAMMA The gamma inverse distribution function qnorm QNORM The normal inverse distribution function qzdiv from Chris Sims web site qzswitch from Chris Sims web site read_variables Copyright (C) 2005 Michel Juillard recursive_moments stephane.adjemian@cepremap.cnrs.fr [02-03-2005] resid Copyright (C) 2001 Michel Juillard resol Copyright (C) 2001 Michel Juillard resol1 Copyright (C) 2001 Michel Juillard rfvar3 function var=rfvar3(ydata,lags,xdata,breaks,lambda,mu) rndprior rows rplot Copyright (C) 2001 Michel Juillard sec2hms function [hour, minute, second] = sec2hms(sec) selif Copyright (C) 2001 Michel Juillard set_all_parameters set_default_option set_parameters set_prior set_shocks Copyright (C) 2003 Michel Juillard set_state_space Copyright (C) 2001 Michel Juillard sim1 Copyright (C) 2001 Michel Juillard simk Copyright (C) 2001 Michel Juillard simul Copyright (C) 2001 Michel Juillard simult Copyright (C) 2001 Michel Juillard simult_ Copyright (C) 2001 Michel Juillard smirnov Smirnov test for 2 distributions solve1 Copyright (C) 2001 Michel Juillard stab_map_ stab_map_1 function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname) stab_map_2 function stab_map_2(x,alpha2,istab,fnam) stab_map_marginal function stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, ipar, dirname) steady Copyright (C) 2001 Michel Juillard steady_ Copyright (C) 2001 Michel Juillard stoch_simul Copyright (C) 2001 Michel Juillard sylvester3 solves a*x+b*x*c=d sylvester3a solves iteratively ax+bxc=d table Copyright (C) 2002 Michel Juillard th_autocovariances Copyright (C) 2001 Michel Juillard transition_matrix makes transition matrices out of ghx and ghu uniform_specification Copyright (C) 2004 Michel Juillard union varprior function [ydum,xdum,breaks]=varprior(nv,nx,lags,mnprior,vprior)
+
+
+Subsequent directories:
+
+Dependency Graph
+
+Generated on Fri 16-Jun-2006 09:08:58 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/indnv.html b/matlab/doc/indnv.html
new file mode 100644
index 000000000..2b4d2adc1
--- /dev/null
+++ b/matlab/doc/indnv.html
@@ -0,0 +1,63 @@
+
+
+
+ Description of indnv
+
+
+
+
+
+
+
+
+
+
+
+
+
+indnv
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function a=indnv(x,y)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+calib simk Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function a=indnv(x,y)
+0004
+0005 a = zeros(size(x)) ;
+0006
+0007 for i = 1:size(x,1)
+0008 j = find( x(i) == y );
+0009 if isempty(j)
+0010 a(i) = NaN;
+0011 else
+0012 a(i) = j;
+0013 end
+0014 end
+0015
+0016
+0017
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/initial_estimation_checks.html b/matlab/doc/initial_estimation_checks.html
new file mode 100644
index 000000000..f9e01e575
--- /dev/null
+++ b/matlab/doc/initial_estimation_checks.html
@@ -0,0 +1,86 @@
+
+
+
+ Description of initial_estimation_checks
+
+
+
+
+
+
+
+
+
+Home >
. > initial_estimation_checks.m
+
+
+
+initial_estimation_checks
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function initial_estimation_checks(xparam1,gend,data)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function initial_estimation_checks(xparam1,gend,data)
+0002 global dr1_test bayestopt_ estim_params_ options_ oo_ M_
+0003
+0004 nv = size(data,1);
+0005 if nv-size(options_.varobs,1)
+0006 disp(' ' )
+0007 disp(['Declared number of observed variables = ' int2str(size(options_.varobs,1))])
+0008 disp(['Number of variables in the database = ' int2str(nv)])
+0009 disp(' ' )
+0010 error(['Estimation can''t take place because the declared number of observed' ...
+0011 'variables doesn''t match the number of variables in the database.' ])
+0012 end
+0013 if nv > M_.exo_nbr+estim_params_.nvn
+0014 error(['Estimation can''t take place because there are less shocks than' ...
+0015 'observed variables' ])
+0016 end
+0017 r = rank(data);
+0018 if r < nv
+0019 error(['Estimation can''t take place because the data are perfectly' ...
+0020 ' correlated' ]);
+0021 end
+0022
+0023 fval = DsgeLikelihood (xparam1,gend,data);
+0024 if exist(dr1_test)
+0025 disp(dr1_test)
+0026 switch (dr1_test(1))
+0027 case 1
+0028 error('The steady state can''t be found' );
+0029 case 2
+0030 error(['Estimation can''t take place because there are an infinity of' ...
+0031 ' stable solutions' ]);
+0032 case 3
+0033 error(['Estimation can''t take place because there is no stable' ...
+0034 ' solution' ]);
+0035 case 4
+0036 error(['Estimation can''t take place because of singularity in Kalman' ...
+0037 ' filter' ]);
+0038 otherwise
+0039 end
+0040 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/initvalf_.html b/matlab/doc/initvalf_.html
new file mode 100644
index 000000000..1b20adb88
--- /dev/null
+++ b/matlab/doc/initvalf_.html
@@ -0,0 +1,149 @@
+
+
+
+ Description of initvalf_
+
+
+
+
+
+
+
+
+
+
+
+
+
+initvalf_
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function initvalf_(fname,period,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function initvalf_(fname,period,varargin)
+0002 global M_ oo_ options_
+0003 global y_start_date ex_start_date
+0004
+0005 if ~isempty(strfind(upper(fname),'.XLS' ))
+0006 [data,names_v]=xlsread(fname);
+0007 else
+0008 load(fname);
+0009 end
+0010
+0011 if length(period) == 2
+0012 period = dy_date (period(1),period(2));
+0013 end
+0014
+0015 if period - max(M_.maximum_lag,M_.maximum_lag) < 0
+0016 error(['INITVALF_: not enough data points in database for number of' ...
+0017 ' lags. Start later!' ])
+0018 end
+0019
+0020 if nargin > 2
+0021 if strcmp(upper(varargin{1}),'SERIES' )
+0022 series = 1 ;
+0023 elseif strcmp(upper(varargin{1}),'MAT' )
+0024 series = 0 ;
+0025 else
+0026 error(['INITVALF: unknown option ' varargin{1}])
+0027 end
+0028 else
+0029 series = 0 ;
+0030 end
+0031
+0032 y1 = floor((period-M_.maximum_lag)/M_.freq);
+0033 p1 = period-M_.maximum_lag-M_.freq*y1;
+0034 y_start_date(2) = M_.start_date(2) + p1-1;
+0035 if y_start_date(2) > M_.freq
+0036 y_start_date(2) = y_start_date(2) - M_.freq;
+0037 y1 = y1 + 1;
+0038 end
+0039 y_start_date(1) = M_.start_date(1)+y1;
+0040
+0041 y1 = floor((period-M_.maximum_lag)/M_.freq);
+0042 p1 = period-M_.maximum_lag-M_.freq*y1;
+0043 ex_start_date(2) = M_.start_date(2) + p1-1;
+0044 if y_start_date(2) > M_.freq
+0045 ex_start_date(2) = ex_start_date(2) - M_.freq;
+0046 y1 = y1 + 1;
+0047 end
+0048 ex_start_date(1) = M_.start_date(1)+y1;
+0049
+0050 clear y1, p1;
+0051
+0052 options_.initval_file = 1;
+0053 oo_.y_simul = [];
+0054 oo_.exo_simul = [];
+0055
+0056 for i=1:size(M_.endo_names,1)
+0057 if series == 1
+0058 x = eval([M_.endo_names(i,:) '(period-M_.maximum_lag:period+options_.periods+M_.maximum_lead-1);' ]);
+0059 oo_.y_simul = [oo_.y_simul; x'];
+0060 else
+0061 k = strmatch(upper(M_.endo_names(i,:)),names_v,'exact' );
+0062 if isempty(k)
+0063 error(['INITVALF: ' M_.endo_names(i,:) ' not found' ])
+0064 end
+0065 x = data(:,k);
+0066 oo_.y_simul = [oo_.y_simul; x(period-M_.maximum_lag:period+options_.periods+M_.maximum_lead-1)'];
+0067 end
+0068 end
+0069
+0070 for i=1:size(M_.exo_name,1)
+0071 if series == 1
+0072 x = eval([M_.exo_name(i,:) '(period-M_.maximum_lag:period+options_.periods+M_.maximum_lead-1);' ]);
+0073 oo_.exo_simul = [oo_.exo_simul x];
+0074 else
+0075 k = strmatch(upper(M_.exo_name(i,:)),names_v,'exact' );
+0076 if isempty(k)
+0077 error(['INITVALF: ' M_.exo_name(i,:) ' not found' ])
+0078 end
+0079 x = data(:,k);
+0080 oo_.exo_simul = [oo_.exo_simul x(period-M_.maximum_lag:period+options_.periods+M_.maximum_lead-1)];
+0081 end
+0082 end
+0083
+0084
+0085
+0086
+0087
+0088
+0089
+0090
+0091
+0092
+0093
+0094
+0095
+0096
+0097
+0098
+0099
+0100
+0101
+0102
+0103
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/inverse_gamma_specification.html b/matlab/doc/inverse_gamma_specification.html
new file mode 100644
index 000000000..4aba2a9ec
--- /dev/null
+++ b/matlab/doc/inverse_gamma_specification.html
@@ -0,0 +1,102 @@
+
+
+
+ Description of inverse_gamma_specification
+
+
+
+
+
+
+
+
+
+Home >
. > inverse_gamma_specification.m
+
+
+
+inverse_gamma_specification
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [s,nu] = inverse_gamma_specification(mu,sigma,type)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [s,nu] = inverse_gamma_specification(mu,sigma,type)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011 sigma2 = sigma^2;
+0012 mu2 = mu^2;
+0013
+0014 if type == 2;
+0015 nu = 2*(2+mu2/sigma2);
+0016 s = 2*mu*(1+mu2/sigma2);
+0017 elseif type == 1;
+0018 if sigma2 < Inf;
+0019 nu = sqrt(2*(2+mu2/sigma2));
+0020 nu2 = 2*nu;
+0021 nu1 = 2;
+0022 err = 2*mu2*gamma(nu/2)^2-(sigma2+mu2)*(nu-2)*gamma((nu-1)/2)^2;
+0023 while abs(nu2-nu1) > 1e-12
+0024 if err > 0
+0025 nu1 = nu;
+0026 if nu < nu2
+0027 nu = nu2;
+0028 else
+0029 nu = 2*nu;
+0030 nu2 = nu;
+0031 end
+0032 else
+0033 nu2 = nu;
+0034 end
+0035 nu = (nu1+nu2)/2;
+0036 err = 2*mu2*gamma(nu/2)^2-(sigma2+mu2)*(nu-2)*gamma((nu-1)/2)^2;
+0037 end
+0038 s = (sigma2+mu2)*(nu-2);
+0039 else ;
+0040 nu = 2;
+0041 s = 2*mu2/pi;
+0042 end ;
+0043 else ;
+0044 s = -1;
+0045 nu = -1;
+0046 end ;
+0047
+0048
+0049
+0050
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/irf.html b/matlab/doc/irf.html
new file mode 100644
index 000000000..1ca1a72cf
--- /dev/null
+++ b/matlab/doc/irf.html
@@ -0,0 +1,76 @@
+
+
+
+ Description of irf
+
+
+
+
+
+
+
+
+
+
+
+
+
+irf
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function y = irf(dr, e1, long, drop, replic, iorder)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+simult_ Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+PosteriorIRF stephane.adjemian@ens.fr [09-25-2005]bksup Copyright (C) 2001 Michel Juillardbksup1 Copyright (C) 2001 Michel Juillardbksupk olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001 function y = irf(dr, e1, long, drop, replic, iorder)
+0002 global M_ oo_ options_
+0003
+0004 temps = repmat(dr.ys,1,M_.maximum_lag);
+0005 y = 0;
+0006
+0007 if iorder == 1
+0008 y1 = repmat(dr.ys,1,long);
+0009 ex2 = zeros(long,M_.exo_nbr);
+0010 ex2(1,:) = e1';
+0011 y2 = simult_ (temps,dr,ex2,iorder);
+0012 y = y2(:,M_.maximum_lag+1:end)-y1;
+0013 else
+0014
+0015 i_exo_var = setdiff([1:M_.exo_nbr],find(diag(M_.Sigma_e) == 0 ));
+0016 nxs = length(i_exo_var);
+0017 ex1 = zeros(long+drop,M_.exo_nbr);
+0018 ex2 = ex1;
+0019 chol_S = chol(M_.Sigma_e(i_exo_var,i_exo_var));
+0020 for j = 1: replic
+0021 randn('seed' ,j);
+0022 ex1(:,i_exo_var) = randn(long+drop,nxs)*chol_S;
+0023 ex2 = ex1;
+0024 ex2(drop+1,:) = ex2(drop+1,:)+e1';
+0025 y1 = simult_ (temps,dr,ex1,iorder);
+0026 y2 = simult_ (temps,dr,ex2,iorder);
+0027 y = y+(y2(:,M_.maximum_lag+drop+1:end)-y1(:,M_.maximum_lag+drop+1:end));
+0028 end
+0029 y=y/replic;
+0030 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/kalman_filter.html b/matlab/doc/kalman_filter.html
new file mode 100644
index 000000000..816377611
--- /dev/null
+++ b/matlab/doc/kalman_filter.html
@@ -0,0 +1,114 @@
+
+
+
+ Description of kalman_filter
+
+
+
+
+
+
+
+
+
+Home >
. > kalman_filter.m
+
+
+
+kalman_filter
+
+
+ PURPOSE
+SYNOPSIS
+
+ SYNOPSIS
+function [loglik, per, d] = kalman_filter(varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035 function [loglik, per, d] = kalman_filter(varargin)
+0036
+0037 [loglik, per, d] = kalman_filter_(varargin{:});
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/kalman_smoother.html b/matlab/doc/kalman_smoother.html
new file mode 100644
index 000000000..f53bab74a
--- /dev/null
+++ b/matlab/doc/kalman_smoother.html
@@ -0,0 +1,122 @@
+
+
+
+ Description of kalman_smoother
+
+
+
+
+
+
+
+
+
+Home >
. > kalman_smoother.m
+
+
+
+kalman_smoother
+
+
+ PURPOSE
+SYNOPSIS
+
+ SYNOPSIS
+function [loglik,per,d,alpha,eta,V] = kalman_smoother(varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039 function [loglik,per,d,alpha,eta,V] = kalman_smoother(varargin)
+0040
+0041 [loglik,per,d,alpha,eta,V] = kalman_smoother_(varargin{:});
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/kalman_transition_matrix.html b/matlab/doc/kalman_transition_matrix.html
new file mode 100644
index 000000000..28490474e
--- /dev/null
+++ b/matlab/doc/kalman_transition_matrix.html
@@ -0,0 +1,80 @@
+
+
+
+ Description of kalman_transition_matrix
+
+
+
+
+
+
+
+
+
+Home >
. > kalman_transition_matrix.m
+
+
+
+kalman_transition_matrix
+
+
+ PURPOSE
+makes transition matrices out of ghx and ghu for Kalman filter
+
+ SYNOPSIS
+function [A,B] = kalman_transition_matrix(dr)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005 function [A,B] = kalman_transition_matrix(dr)
+0006 global M_
+0007 nx = size(dr.ghx,2)+dr.nfwrd+dr.nstatic;
+0008 kstate = dr.kstate;
+0009 ikx = [dr.nstatic+1:dr.nstatic+dr.npred];
+0010
+0011 A = zeros(nx,nx);
+0012 k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
+0013 i0 = find(k0(:,2) == M_.maximum_lag+1);
+0014 n0 = size(dr.ghx,1);
+0015 A(1:n0,dr.nstatic+1:dr.nstatic+dr.npred) = dr.ghx(:,1:dr.npred);
+0016 A(1:n0,dr.nstatic+dr.npred+dr.nfwrd+1:end) = dr.ghx(:,dr.npred+1:end);
+0017 B = zeros(nx,M_.exo_nbr);
+0018 B(1:n0,:) = dr.ghu;
+0019 offset_col = dr.nstatic;
+0020 for i=M_.maximum_lag:-1:2
+0021 i1 = find(k0(:,2) == i);
+0022 n1 = size(i1,1);
+0023 j = zeros(n1,1);
+0024 for j1 = 1:n1
+0025 j(j1) = find(k0(i0,1)==k0(i1(j1),1));
+0026 end
+0027 if i == M_.maximum_lag-1
+0028 offset_col = dr.nstatic+dr.nfwrd;
+0029 end
+0030 A(n0+i1-dr.npred,offset_col+i0(j))=eye(n1);
+0031 i0 = i1;
+0032 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/kernel_density_estimate.html b/matlab/doc/kernel_density_estimate.html
new file mode 100644
index 000000000..69c1e1d23
--- /dev/null
+++ b/matlab/doc/kernel_density_estimate.html
@@ -0,0 +1,108 @@
+
+
+
+ Description of kernel_density_estimate
+
+
+
+
+
+
+
+
+
+Home >
. > kernel_density_estimate.m
+
+
+
+kernel_density_estimate
+
+
+ PURPOSE
+% This function aims at estimating a continuous density. A kernel density
+
+ SYNOPSIS
+function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010 if size(data,2) > 1 & size(data,1) == 1
+0011 data = transpose(data);
+0012 elseif size(data,2)>1 & size(data,1)>1
+0013 error('kernel_density_estimate :: data must be a one dimensional array.' );
+0014 end
+0015 test = log(number_of_grid_points)/log(2);
+0016 if (abs(test-round(test)) > 10^(-12))
+0017 error('kernel_density_estimate :: The number of grid points must be a power of 2.' );
+0018 end
+0019
+0020 n = size(data,1);
+0021
+0022
+0023 if strcmpi(kernel_function,'gaussian' )
+0024 k = inline('inv(sqrt(2*pi))*exp(-0.5*x.^2)' );
+0025 elseif strcmpi(kernel_function,'uniform' )
+0026 k = inline('0.5*(abs(x) <= 1)' );
+0027 elseif strcmpi(kernel_function,'triangle' )
+0028 k = inline('(1-abs(x)).*(abs(x) <= 1)' );
+0029 elseif strcmpi(kernel_function,'epanechnikov' )
+0030 k = inline('0.75*(1-x.^2).*(abs(x) <= 1)' );
+0031 elseif strcmpi(kernel_function,'quartic' )
+0032 k = inline('0.9375*((1-x.^2).^2).*(abs(x) <= 1)' );
+0033 elseif strcmpi(kernel_function,'triweight' )
+0034 k = inline('1.09375*((1-x.^2).^3).*(abs(x) <= 1)' );
+0035 elseif strcmpi(kernel_function,'cosinus' )
+0036 k = inline('(pi/4)*cos((pi/2)*x).*(abs(x) <= 1)' );
+0037 end
+0038
+0039
+0040 a = min(data) - (max(data)-min(data))/3;
+0041 b = max(data) + (max(data)-min(data))/3;
+0042 abscissa = linspace(a,b,number_of_grid_points)';
+0043 d = abscissa(2)-abscissa(1);
+0044 xi = zeros(number_of_grid_points,1);
+0045 xa = (data-a)/(b-a)*number_of_grid_points;
+0046 for i = 1:n;
+0047 indx = floor(xa(i));
+0048 temp = xa(i)-indx;
+0049 xi(indx+[1 2]) = xi(indx+[1 2]) + [1-temp,temp]';
+0050 end ;
+0051 xk = [-number_of_grid_points:number_of_grid_points-1]'*d;
+0052 kk = k(xk/bandwidth);
+0053 kk = kk / (sum(kk)*d*n);
+0054 f = ifft(fft(fftshift(kk)).*fft([xi ;zeros(size(xi))]));
+0055 f = real(f(1:number_of_grid_points));
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/left.png b/matlab/doc/left.png
new file mode 100644
index 000000000..404df045f
Binary files /dev/null and b/matlab/doc/left.png differ
diff --git a/matlab/doc/linux.png b/matlab/doc/linux.png
new file mode 100644
index 000000000..42c0c328e
Binary files /dev/null and b/matlab/doc/linux.png differ
diff --git a/matlab/doc/lnsrch.html b/matlab/doc/lnsrch.html
new file mode 100644
index 000000000..80c2e3652
--- /dev/null
+++ b/matlab/doc/lnsrch.html
@@ -0,0 +1,132 @@
+
+
+
+ Description of lnsrch
+
+
+
+
+
+
+
+
+
+
+
+
+
+lnsrch
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [x,f,fvec,check]=lnsrch(xold,fold,g,p,stpmax,func,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [x,f,fvec,check]=lnsrch(xold,fold,g,p,stpmax,func,varargin)
+0004
+0005 alf = 1e-4 ;
+0006 tolx = 3.7e-11 ;
+0007 alam = 1;
+0008
+0009 nn = size(xold,1) ;
+0010 summ = sqrt(sum(p.*p)) ;
+0011 if ~isfinite(summ)
+0012 error(['Some element of Newton direction isn''t finite. Jacobian maybe' ...
+0013 ' singular or there is a problem with initial values' ])
+0014 end
+0015
+0016 if summ > stpmax
+0017 p=p.*stpmax/summ ;
+0018 end
+0019
+0020 slope = g'*p ;
+0021
+0022 test = max(abs(p)'./max([abs(xold)';ones(1,nn)])) ;
+0023 alamin = tolx/test ;
+0024
+0025 if alamin > 0.1
+0026 alamin = 0.1;
+0027 end
+0028
+0029 while 1
+0030 if alam < alamin
+0031 check = 1 ;
+0032 return
+0033 end
+0034
+0035 x = xold + (alam*p) ;
+0036 fvec = feval(func,x,varargin{:}) ;
+0037 f = 0.5*fvec'*fvec ;
+0038
+0039 if any(isnan(fvec))
+0040 alam = alam/2 ;
+0041 alam2 = alam ;
+0042 f2 = f ;
+0043 fold2 = fold ;
+0044 else
+0045
+0046 if f <= fold+alf*alam*slope
+0047 check = 0;
+0048 break ;
+0049 else
+0050 if alam == 1
+0051 tmplam = -slope/(2*(f-fold-slope)) ;
+0052 else
+0053 rhs1 = f-fold-alam*slope ;
+0054 rhs2 = f2-fold2-alam2*slope ;
+0055 a = (rhs1/(alam^2)-rhs2/(alam2^2))/(alam-alam2) ;
+0056 b = (-alam2*rhs1/(alam^2)+alam*rhs2/(alam2^2))/(alam-alam2) ;
+0057 if a == 0
+0058 tmplam = -slope/(2*b) ;
+0059 else
+0060 disc = (b^2)-3*a*slope ;
+0061
+0062 if disc < 0
+0063 error ('Roundoff problem in nlsearch' ) ;
+0064 else
+0065 tmplam = (-b+sqrt(disc))/(3*a) ;
+0066 end
+0067
+0068 end
+0069
+0070 if tmplam > 0.5*alam
+0071 tmplam = 0.5*alam;
+0072 end
+0073
+0074 end
+0075
+0076 alam2 = alam ;
+0077 f2 = f ;
+0078 fold2 = fold ;
+0079 alam = max([tmplam;(0.1*alam)]) ;
+0080 end
+0081 end
+0082 end
+0083
+0084
+0085
+0086
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lnsrch1.html b/matlab/doc/lnsrch1.html
new file mode 100644
index 000000000..39f9773b9
--- /dev/null
+++ b/matlab/doc/lnsrch1.html
@@ -0,0 +1,134 @@
+
+
+
+ Description of lnsrch1
+
+
+
+
+
+
+
+
+
+
+
+
+
+lnsrch1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [x,f,fvec,check]=lnsrch(xold,fold,g,p,stpmax,func,j1,j2,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+solve1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [x,f,fvec,check]=lnsrch(xold,fold,g,p,stpmax,func,j1,j2,varargin)
+0004
+0005 alf = 1e-4 ;
+0006 tolx = 3.7e-11 ;
+0007 alam = 1;
+0008
+0009 x = xold;
+0010 nn = length(j2);
+0011 summ = sqrt(sum(p.*p)) ;
+0012 if ~isfinite(summ)
+0013 error(['Some element of Newton direction isn''t finite. Jacobian maybe' ...
+0014 ' singular or there is a problem with initial values' ])
+0015 end
+0016
+0017 if summ > stpmax
+0018 p=p.*stpmax/summ ;
+0019 end
+0020
+0021 slope = g'*p ;
+0022
+0023 test = max(abs(p)'./max([abs(xold(j2))';ones(1,nn)])) ;
+0024 alamin = tolx/test ;
+0025
+0026 if alamin > 0.1
+0027 alamin = 0.1;
+0028 end
+0029
+0030 while 1
+0031 if alam < alamin
+0032 check = 1 ;
+0033 return
+0034 end
+0035
+0036 x(j2) = xold(j2) + (alam*p) ;
+0037 fvec = feval(func,x,varargin{:}) ;
+0038 fvec = fvec(j1);
+0039 f = 0.5*fvec'*fvec ;
+0040
+0041 if any(isnan(fvec))
+0042 alam = alam/2 ;
+0043 alam2 = alam ;
+0044 f2 = f ;
+0045 fold2 = fold ;
+0046 else
+0047
+0048 if f <= fold+alf*alam*slope
+0049 check = 0;
+0050 break ;
+0051 else
+0052 if alam == 1
+0053 tmplam = -slope/(2*(f-fold-slope)) ;
+0054 else
+0055 rhs1 = f-fold-alam*slope ;
+0056 rhs2 = f2-fold2-alam2*slope ;
+0057 a = (rhs1/(alam^2)-rhs2/(alam2^2))/(alam-alam2) ;
+0058 b = (-alam2*rhs1/(alam^2)+alam*rhs2/(alam2^2))/(alam-alam2) ;
+0059 if a == 0
+0060 tmplam = -slope/(2*b) ;
+0061 else
+0062 disc = (b^2)-3*a*slope ;
+0063
+0064 if disc < 0
+0065 error ('Roundoff problem in nlsearch' ) ;
+0066 else
+0067 tmplam = (-b+sqrt(disc))/(3*a) ;
+0068 end
+0069
+0070 end
+0071
+0072 if tmplam > 0.5*alam
+0073 tmplam = 0.5*alam;
+0074 end
+0075
+0076 end
+0077
+0078 alam2 = alam ;
+0079 f2 = f ;
+0080 fold2 = fold ;
+0081 alam = max([tmplam;(0.1*alam)]) ;
+0082 end
+0083 end
+0084 end
+0085
+0086
+0087
+0088
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lpdfbeta.html b/matlab/doc/lpdfbeta.html
new file mode 100644
index 000000000..b1a0af4b0
--- /dev/null
+++ b/matlab/doc/lpdfbeta.html
@@ -0,0 +1,53 @@
+
+
+
+ Description of lpdfbeta
+
+
+
+
+
+
+
+
+
+
+
+
+
+lpdfbeta
+
+
+ PURPOSE
+log BETA PDF
+
+ SYNOPSIS
+function ldens = lpdfbeta(x,a,b);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lpdfgam.html b/matlab/doc/lpdfgam.html
new file mode 100644
index 000000000..2d110947c
--- /dev/null
+++ b/matlab/doc/lpdfgam.html
@@ -0,0 +1,53 @@
+
+
+
+ Description of lpdfgam
+
+
+
+
+
+
+
+
+
+
+
+
+
+lpdfgam
+
+
+ PURPOSE
+log GAMMA PDF
+
+ SYNOPSIS
+function ldens = lpdfgam(x,a,b);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lpdfgbeta.html b/matlab/doc/lpdfgbeta.html
new file mode 100644
index 000000000..2ebe0e012
--- /dev/null
+++ b/matlab/doc/lpdfgbeta.html
@@ -0,0 +1,53 @@
+
+
+
+ Description of lpdfgbeta
+
+
+
+
+
+
+
+
+
+
+
+
+
+lpdfgbeta
+
+
+ PURPOSE
+log (generalized) BETA PDF
+
+ SYNOPSIS
+function ldens = lpdfgbeta(x,a,b,aa,bb);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+priordens This procedure computes a prior density for
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lpdfig1.html b/matlab/doc/lpdfig1.html
new file mode 100644
index 000000000..49158c989
--- /dev/null
+++ b/matlab/doc/lpdfig1.html
@@ -0,0 +1,66 @@
+
+
+
+ Description of lpdfig1
+
+
+
+
+
+
+
+
+
+
+
+
+
+lpdfig1
+
+
+ PURPOSE
+log INVERSE GAMMA (type 1)
+
+ SYNOPSIS
+function ldens = lpdfig1(x,s,nu)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+priordens This procedure computes a prior density for
+
+
+
+ SOURCE CODE
+0001 function ldens = lpdfig1(x,s,nu)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012 ldens = log(2) - gammaln(nu/2) - (nu/2).*log(2/s) - (nu+1)*log(x) - .5*s./(x.^2);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lpdfig2.html b/matlab/doc/lpdfig2.html
new file mode 100644
index 000000000..a45afb5ca
--- /dev/null
+++ b/matlab/doc/lpdfig2.html
@@ -0,0 +1,66 @@
+
+
+
+ Description of lpdfig2
+
+
+
+
+
+
+
+
+
+
+
+
+
+lpdfig2
+
+
+ PURPOSE
+log INVERSE GAMMA (type 2)
+
+ SYNOPSIS
+function ldens = lpdfig2(x,s,nu)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+priordens This procedure computes a prior density for
+
+
+
+ SOURCE CODE
+0001 function ldens = lpdfig2(x,s,nu)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012 ldens = - gammaln(nu/2) - (nu/2)*log(2/s) - .5*(nu+2)*log(x) -.5*s./x;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lpdfnorm.html b/matlab/doc/lpdfnorm.html
new file mode 100644
index 000000000..62d014a7d
--- /dev/null
+++ b/matlab/doc/lpdfnorm.html
@@ -0,0 +1,57 @@
+
+
+
+ Description of lpdfnorm
+
+
+
+
+
+
+
+
+
+
+
+
+
+lpdfnorm
+
+
+ PURPOSE
+LPDFNORM The log of the normal density function
+
+ SYNOPSIS
+function f = lpdfnorm(x,m,s)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+priordens This procedure computes a prior density for
+
+
+
+ SOURCE CODE
+0001 function f = lpdfnorm(x,m,s)
+0002
+0003
+0004
+0005
+0006 if nargin<3, s=1; end
+0007 if nargin<2, m=0; end
+0008 f = -log(s)-log(2*pi)/2-((x-m)./s).^2/2;
+0009
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lptauSEQ.html b/matlab/doc/lptauSEQ.html
new file mode 100644
index 000000000..ff652b841
--- /dev/null
+++ b/matlab/doc/lptauSEQ.html
@@ -0,0 +1,84 @@
+
+
+
+ Description of lptauSEQ
+
+
+
+
+
+
+
+
+
+
+
+
+
+lptauSEQ
+
+
+ PURPOSE
+[lpmat] = lptauSEQ(Nsam,Nvar)
+
+ SYNOPSIS
+function [lpmat] = lptauSEQ(Nsam,Nvar)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [lpmat] = lptauSEQ(Nsam,Nvar)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020 clear lptau
+0021 lpmat = zeros(Nsam, Nvar);
+0022 for j=1:Nsam,
+0023 lpmat(j,:)=LPTAU (j,Nvar);
+0024 end
+0025 return
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/lyapunov_symm.html b/matlab/doc/lyapunov_symm.html
new file mode 100644
index 000000000..e02c18700
--- /dev/null
+++ b/matlab/doc/lyapunov_symm.html
@@ -0,0 +1,118 @@
+
+
+
+ Description of lyapunov_symm
+
+
+
+
+
+
+
+
+
+Home >
. > lyapunov_symm.m
+
+
+
+lyapunov_symm
+
+
+ PURPOSE
+solves x-a*x*a'=b for b (and then x) symmetrical
+
+ SYNOPSIS
+function [x,ns_var]=lyapunov_symm(a,b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002 function [x,ns_var]=lyapunov_symm(a,b)
+0003 global options_
+0004
+0005 info = 0;
+0006 if size(a,1) == 1
+0007 x=b/(1-a*a);
+0008 return
+0009 end
+0010 [u,t] = schur(a);
+0011 if exist('ordeig' ,'builtin' )
+0012 e1 = abs(ordeig(t)) > 2-options_.qz_criterium;
+0013 else
+0014 e1 = abs(my_ordeig (t)) > 2-options_.qz_criterium;
+0015 end
+0016 k = sum(e1);
+0017 if exist('ordschur' ,'builtin' )
+0018
+0019 [u,t] = ordschur(u,t,e1);
+0020 n = length(e1)-k;
+0021 b=u(:,k+1:end)'*b*u(:,k+1:end);
+0022 t = t(k+1:end ,k+1:end);
+0023 elseif k > 0
+0024
+0025 error(['lyapunov_sym: you need a Matlab version > 6.5 to handle models' ...
+0026 ' with unit roots' ])
+0027 else
+0028
+0029 n = length(e1);
+0030 b=u'*b*u;
+0031 end
+0032 x=zeros(n,n);
+0033 for i=n:-1:2
+0034 if t(i,i-1) == 0
+0035 if i == n
+0036 c = zeros(n,1);
+0037 else
+0038 c = t(1:i,:)*(x(:,i+1:end)*t(i,i+1:end)')+...
+0039 t(i,i)*t(1:i,i+1:end)*x(i+1:end ,i);
+0040 end
+0041 q = eye(i)-t(1:i,1:i)*t(i,i);
+0042 x(1:i,i) = q\(b(1:i,i)+c);
+0043 x(i,1:i-1) = x(1:i-1,i)';
+0044 else
+0045 if i == n
+0046 c = zeros(n,1);
+0047 c1 = zeros(n,1);
+0048 else
+0049 c = t(1:i,:)*(x(:,i+1:end)*t(i,i+1:end)')+...
+0050 t(i,i)*t(1:i,i+1:end)*x(i+1:end ,i)+...
+0051 t(i,i-1)*t(1:i,i+1:end)*x(i+1:end ,i-1);
+0052 c1 = t(1:i,:)*(x(:,i+1:end)*t(i-1,i+1:end)')+...
+0053 t(i-1,i-1)*t(1:i,i+1:end)*x(i+1:end ,i-1)+...
+0054 t(i-1,i)*t(1:i,i+1:end)*x(i+1:end ,i);
+0055 end
+0056 q = [eye(i)-t(1:i,1:i)*t(i,i) -t(1:i,1:i)*t(i,i-1);...
+0057 -t(1:i,1:i)*t(i-1,i) eye(i)-t(1:i,1:i)*t(i-1,i-1)];
+0058 z = q\[b(1:i,i)+c;b(1:i,i-1)+c1];
+0059 x(1:i,i) = z(1:i);
+0060 x(1:i,i-1) = z(i+1:end);
+0061 x(i,1:i-1)=x(1:i-1,i)';
+0062 x(i-1,1:i-2)=x(1:i-2,i-1)';
+0063 i = i - 1;
+0064 end
+0065 end
+0066 if i == 2
+0067 c = t(1,:)*(x(:,2:end)*t(1,2:end)')+t(1,1)*t(1,2:end)*x(2:end ,1);
+0068 x(1,1)=(b(1,1)+c)/(1-t(1,1)*t(1,1));
+0069 end
+0070 x=u(:,k+1:end)*x*u(:,k+1:end)';
+0071 ns_var = [];
+0072 ns_var = find(any(abs(u(:,1:k)) > 1e-8,2));
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/m2html.css b/matlab/doc/m2html.css
new file mode 100644
index 000000000..9d88fb8cc
--- /dev/null
+++ b/matlab/doc/m2html.css
@@ -0,0 +1,75 @@
+body {
+ background: white;
+ color: black;
+ font-family: arial,sans-serif;
+ margin: 0;
+ padding: 1ex;
+}
+
+div.fragment {
+ width: 98%;
+ border: 1px solid #CCCCCC;
+ background-color: #f5f5f5;
+ padding-left: 4px;
+ margin: 4px;
+}
+
+div.box {
+ width: 98%;
+ background-color: #f5f5f5;
+ border: 1px solid #CCCCCC;
+ color: black;
+ padding: 4px;
+}
+
+.comment {
+ color: #228B22;
+}
+.string {
+ color: #B20000;
+}
+.keyword {
+ color: #0000FF;
+}
+
+.keywordtype { color: #604020; }
+.keywordflow { color: #e08000; }
+.preprocessor { color: #806020; }
+.stringliteral { color: #002080; }
+.charliteral { color: #008080; }
+
+a {
+ text-decoration: none;
+}
+
+a:hover {
+ background-color: #006699;
+ color:#FFFFFF;
+}
+
+a.code {
+ font-weight: normal;
+ color: #A020F0;
+}
+
+a.code:hover {
+ background-color: #FF0000;
+ color: #FFFFFF;
+}
+
+h1 {
+ background: transparent;
+ color: #006699;
+ font-size: x-large;
+ text-align: center;
+}
+
+h2 {
+ background: transparent;
+ color: #006699;
+ font-size: large;
+}
+
+address {
+ font-size:small;
+}
diff --git a/matlab/doc/make_ex_.html b/matlab/doc/make_ex_.html
new file mode 100644
index 000000000..788fc6e2a
--- /dev/null
+++ b/matlab/doc/make_ex_.html
@@ -0,0 +1,107 @@
+
+
+
+ Description of make_ex_
+
+
+
+
+
+
+
+
+
+
+
+
+
+make_ex_
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function make_ex_
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+forcst olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardsimul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function make_ex_
+0004 global M_ options_ oo_ ex0_ ex_det0_
+0005
+0006 options_ = set_default_option (options_,'periods' ,0);
+0007
+0008 if isempty(oo_.exo_steady_state)
+0009 oo_.exo_steady_state = zeros(M_.exo_nbr,1);
+0010 end
+0011 if M_.exo_det_nbr > 1 & isempty(oo_.exo_det_steady_state)
+0012 oo_.exo_det_steady_state = zeros(M_.exo_det_nbr,1);
+0013 end
+0014 if isempty(oo_.exo_simul)
+0015 if isempty(ex0_)
+0016 oo_.exo_simul = [ones(M_.maximum_lag+options_.periods+M_.maximum_lead,1)*oo_.exo_steady_state'];
+0017 else
+0018 oo_.exo_simul = [ones(M_.maximum_lag,1)*ex0_';ones(options_.periods+M_.maximum_lead,1)*oo_.exo_steady_state'];
+0019 end
+0020 elseif size(oo_.exo_simul,2) < length(oo_.exo_steady_state)
+0021 k = size(oo_.exo_simul,2)+1:length(oo_.exo_steady_state);
+0022 if isempty(ex0_)
+0023 oo_.exo_simul = [oo_.exo_simul ones(M_.maximum_lag+size(oo_.exo_simul,1)+M_.maximum_lead,1)*oo_.exo_steady_state(k)'];
+0024 else
+0025 oo_.exo_simul = [oo_.exo_simul [ones(M_.maximum_lag,1)*ex0_(k)'; ones(size(oo_.exo_simul,1)-M_.maximum_lag+M_.maximum_lead, ...
+0026 1)*oo_.exo_steady_state(k)']];
+0027 end
+0028 elseif size(oo_.exo_simul,1) < M_.maximum_lag+M_.maximum_lead+options_.periods
+0029 if isempty(ex0_)
+0030 oo_.exo_simul = [oo_.exo_simul; ones(M_.maximum_lag+options_.periods+M_.maximum_lead-size(oo_.exo_simul,1),1)*oo_.exo_steady_state'];
+0031 else
+0032 oo_.exo_simul = [ones(M_.maximum_lag,1)*ex0_'; oo_.exo_simul; ones(options_.periods+M_.maximum_lead-size(oo_.exo_simul, ...
+0033 1),1)*oo_.exo_steady_state'];
+0034 end
+0035 end
+0036 if M_.exo_det_nbr > 0
+0037 if isempty(oo_.exo_det_simul)
+0038 if isempty(ex_det0_)
+0039 oo_.exo_det_simul = [ones(M_.maximum_lag+options_.periods+M_.maximum_lead,1)*oo_.exo_det_steady_state'];
+0040 else
+0041 oo_.exo_det_simul = [ones(M_.maximum_lag,1)*ex_det0_';ones(options_.periods+M_.maximum_lead,1)*oo_.exo_det_steady_state'];
+0042 end
+0043 elseif size(oo_.exo_det_simul,2) < length(oo_.exo_det_steady_state)
+0044 k = size(oo_.exo_det_simul,2)+1:length(oo_.exo_det_steady_state);
+0045 if isempty(ex_det0_)
+0046 oo_.exo_det_simul = [oo_.exo_det_simul ones(M_.maximum_lag+size(oo_.exo_det_simul,1)+M_.maximum_lead,1)*oo_.exo_det_steady_state(k)'];
+0047 else
+0048 oo_.exo_det_simul = [oo_.exo_det_simul [ones(M_.maximum_lag,1)*ex_det0_(k)'; ones(size(oo_.exo_det_simul,1)-M_.maximum_lag+M_.maximum_lead, ...
+0049 1)*oo_.exo_det_steady_state(k)']];
+0050 end
+0051 elseif size(oo_.exo_det_simul,1) < M_.maximum_lag+M_.maximum_lead+options_.periods
+0052 if isempty(ex_det0_)
+0053 oo_.exo_det_simul = [oo_.exo_det_simul; ones(M_.maximum_lag+options_.periods+M_.maximum_lead-size(oo_.exo_det_simul,1),1)*oo_.exo_det_steady_state'];
+0054 else
+0055 oo_.exo_det_simul = [ones(M_.maximum_lag,1)*ex_det0_'; oo_.exo_det_simul; ones(options_.periods+M_.maximum_lead-size(oo_.exo_det_simul, ...
+0056 1),1)*oo_.exo_det_steady_state'];
+0057 end
+0058 end
+0059 end
+0060
+0061
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/make_y_.html b/matlab/doc/make_y_.html
new file mode 100644
index 000000000..c69b6edb5
--- /dev/null
+++ b/matlab/doc/make_y_.html
@@ -0,0 +1,82 @@
+
+
+
+ Description of make_y_
+
+
+
+
+
+
+
+
+
+
+
+
+
+make_y_
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function make_y_
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function make_y_
+0004 global M_ options_ oo_ ys0_
+0005
+0006 options_ = set_default_option (options_,'periods' ,0);
+0007
+0008 if isempty(oo_.steady_state)
+0009 oo_.steady_state = ones(M_.endo_nbr,1);
+0010 end
+0011
+0012
+0013 if isempty(oo_.y_simul)
+0014 if isempty(ys0_)
+0015 oo_.y_simul = [oo_.steady_state*ones(1,M_.maximum_lag+options_.periods+M_.maximum_lead)];
+0016 else
+0017 oo_.y_simul = [ys0_*ones(1,M_.maximum_lag);oo_.steady_state*ones(1,options_.periods+M_.maximum_lead)];
+0018 end
+0019 elseif size(oo_.y_simul,1) < length(oo_.steady_state)
+0020 k = size(oo_.y_simul,1)+1:length(oo_.steady_state)
+0021 if isempty(ys0_)
+0022 oo_.y_simul = [oo_.y_simul; oo_.steady_state(k)*ones(1,M_.maximum_lag+size(oo_.y_simul,1)+M_.maximum_lead)];
+0023 else
+0024 oo_.y_simul = [oo_.y_simul; [ys0_(k)*ones(1,M_.maximum_lag); oo_.steady_state(k)*ones(1,size(oo_.y_simul,2)-M_.maximum_lag+ ...
+0025 M_.maximum_lead)]];
+0026 end
+0027 elseif size(oo_.y_simul,2) < M_.maximum_lag+M_.maximum_lead+options_.periods
+0028 if isempty(ys0_)
+0029 oo_.y_simul = [oo_.y_simul oo_.steady_state*ones(1,M_.maximum_lag+options_.periods+M_.maximum_lead-size(oo_.y_simul,2),1)];
+0030 else
+0031 oo_.y_simul = [ys0_*ones(1,M_.maximum_lag) oo_.y_simul oo_.steady_state*ones(1,options_.periods+M_.maximum_lead-size(oo_.y_simul, ...
+0032 2))];
+0033 end
+0034 end
+0035
+0036
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/marginal_density.html b/matlab/doc/marginal_density.html
new file mode 100644
index 000000000..545a4611f
--- /dev/null
+++ b/matlab/doc/marginal_density.html
@@ -0,0 +1,152 @@
+
+
+
+ Description of marginal_density
+
+
+
+
+
+
+
+
+
+Home >
. > marginal_density.m
+
+
+
+marginal_density
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-09-2005]
+
+ SYNOPSIS
+function marginal = marginal_density()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+CheckPath 06-03-2005qchisq QCHISQ The chisquare inverse distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function marginal = marginal_density()
+0002
+0003 global M_ options_ estim_params_ oo_
+0004
+0005 npar = estim_params_.np+estim_params_.nvn+estim_params_.ncx+estim_params_.ncn+estim_params_.nvx;
+0006 nblck = options_.mh_nblck;
+0007
+0008 MhDirectoryName = CheckPath ('metropolis' );
+0009 load([ MhDirectoryName '/' M_.fname '_mh_history' ])
+0010
+0011 FirstMhFile = record.KeepedDraws.FirstMhFile;
+0012 FirstLine = record.KeepedDraws.FirstLine; ifil = FirstLine;
+0013 TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
+0014 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
+0015 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
+0016 TODROP = floor(options_.mh_drop*TotalNumberOfMhDraws);
+0017
+0018 MU = zeros(1,npar);
+0019 SIGMA = zeros(npar,npar);
+0020 lpost_mode = -Inf;
+0021
+0022 fprintf('MH: I''m computing the posterior mean... ' );
+0023 for n = FirstMhFile:TotalNumberOfMhFiles
+0024 for b = 1:nblck
+0025 load([ MhDirectoryName '/' M_.fname '_mh' int2str(n) '_blck' int2str(b)],'x2' ,'logpo2' );
+0026 MU = MU + sum(x2(ifil:end ,:));
+0027 lpost_mode = max(lpost_mode,max(logpo2));
+0028 end
+0029 ifil = 1;
+0030 end
+0031 MU = MU/((TotalNumberOfMhDraws-TODROP)*nblck);
+0032 MU1 = repmat(MU,MAX_nruns,1);
+0033
+0034 fprintf(' Done!\n' );
+0035 fprintf('MH: I''m computing the posterior covariance matrix... ' );
+0036 ifil = FirstLine;
+0037 for n = FirstMhFile:TotalNumberOfMhFiles
+0038 for b = 1:nblck
+0039 load([MhDirectoryName '/' M_.fname '_mh' int2str(n) '_blck' int2str(b)],'x2' );
+0040 x = x2(ifil:end ,:)-MU1(1:size(x2(ifil:end ,:),1),:);
+0041 SIGMA = SIGMA + x'*x;
+0042 end
+0043 ifil = 1;
+0044 end
+0045 SIGMA = SIGMA/((TotalNumberOfMhDraws-TODROP)*nblck);
+0046 fprintf(' Done!\n' );
+0047 disp(' ' );
+0048 disp('MH: I''m computing the posterior log marginale density (modified harmonic mean)... ' );
+0049 detSIGMA = det(SIGMA);
+0050 invSIGMA = inv(SIGMA);
+0051 marginal = zeros(9,2);
+0052 linee = 0;
+0053 check_coverage = 1;
+0054 increase = 1;
+0055 while check_coverage
+0056 for p = 0.1:0.1:0.9;
+0057 critval = qchisq (p,npar);
+0058 ifil = FirstLine;
+0059 tmp = 0;
+0060 for n = FirstMhFile:TotalNumberOfMhFiles
+0061 for b=1:nblck
+0062 load([ MhDirectoryName '/' M_.fname '_mh' int2str(n) '_blck' int2str(b)],'x2' ,'logpo2' );
+0063 EndOfFile = size(x2,1);
+0064 for i = ifil:EndOfFile
+0065 deviation = (x2(i,:)-MU)*invSIGMA*(x2(i,:)-MU)';
+0066 if deviation <= critval
+0067 lftheta = -log(p)-(npar*log(2*pi)+log(detSIGMA)+deviation)/2;
+0068 tmp = tmp + exp(lftheta - logpo2(i) + lpost_mode);
+0069 end
+0070 end
+0071 end
+0072 ifil = 1;
+0073 end
+0074 linee = linee + 1;
+0075 warning off all
+0076 marginal(linee,:) = [p, lpost_mode-log(tmp/((TotalNumberOfMhDraws-TODROP)*nblck))];
+0077 warning on all
+0078 end
+0079 if abs((marginal(9,2)-marginal(1,2))/marginal(9,2)) > 0.01 | isinf(marginal(1,2))
+0080 if increase == 1
+0081 disp('MH: The support of the weighting density function is not large enough...' )
+0082 disp('MH: I increase the variance of this distribution.' )
+0083 increase = 1.2*increase;
+0084 invSIGMA = inv(SIGMA*increase);
+0085 detSIGMA = det(SIGMA*increase);
+0086 linee = 0;
+0087 else
+0088 disp('MH: Let me try again.' )
+0089 increase = 1.2*increase;
+0090 invSIGMA = inv(SIGMA*increase);
+0091 detSIGMA = det(SIGMA*increase);
+0092 linee = 0;
+0093 if increase > 20
+0094 check_coverage = 0;
+0095 clear invSIGMA detSIGMA increase;
+0096 disp('MH: There''s probably a problem with the modified harmonic mean estimator.' )
+0097 end
+0098 end
+0099 else
+0100 check_coverage = 0;
+0101 clear invSIGMA detSIGMA increase;
+0102 disp('MH: Modified harmonic mean estimator, done!' )
+0103 end
+0104 end
+0105
+0106 oo_.MarginalDensity.ModifiedHarmonicMean = mean(marginal(:,2));
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/matlabicon.gif b/matlab/doc/matlabicon.gif
new file mode 100644
index 000000000..7c2b5e6e2
Binary files /dev/null and b/matlab/doc/matlabicon.gif differ
diff --git a/matlab/doc/matrictint.html b/matlab/doc/matrictint.html
new file mode 100644
index 000000000..af741c6fa
--- /dev/null
+++ b/matlab/doc/matrictint.html
@@ -0,0 +1,90 @@
+
+
+
+ Description of matrictint
+
+
+
+
+
+
+
+
+
+
+
+
+
+matrictint
+
+
+ PURPOSE
+function w=matrictint(S,XXi,T)
+
+ SYNOPSIS
+function w=matrictint(S,XXi,T)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+mgnldnsty function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat)
+
+
+ SUBFUNCTIONS
+
+ SOURCE CODE
+0001 function w=matrictint(S,XXi,T)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010 k=size(XXi,1);
+0011 m=size(S,1);
+0012 [cx,p]=chol(XXi);
+0013 [cs,q]=chol(S);
+0014
+0015
+0016 if any(diag(cx)<100*eps)
+0017 error('singular XXi' )
+0018 end
+0019 if any(diag(cs<100*eps))
+0020 error('singular S' )
+0021 end
+0022 w=(-T+k+(m-1)/2)*m*.5*log(pi)-(T-k)*sum(log(diag(cs)))+m*sum(log(diag(cx)))+ggammaln (m,(T-k)/2);
+0023
+0024 function lgg=ggammaln(m,ndf)
+0025
+0026
+0027
+0028 if ndf<=(m-1)/2
+0029 error('too few df in ggammaln' )
+0030 else
+0031
+0032 garg=ndf+.5*(0:-1:1-m);
+0033 lgg=sum(gammaln(garg));
+0034 end
+0035
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mcompare.html b/matlab/doc/mcompare.html
new file mode 100644
index 000000000..e12957de7
--- /dev/null
+++ b/matlab/doc/mcompare.html
@@ -0,0 +1,111 @@
+
+
+
+ Description of mcompare
+
+
+
+
+
+
+
+
+
+
+
+
+
+mcompare
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function mcompare(s1,s2)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+ftest Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function mcompare(s1,s2)
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015 global options_
+0016 global nvx nvy x y lag1
+0017
+0018 ftest (s1,s2) ;
+0019
+0020 ix = [1-lag1(1):size(x,2)-lag1(1)]' ;
+0021 i = [lag1(1):size(ix,1)-lag1(2)+1]' ;
+0022
+0023 if size(options_.smpl,1) == 1
+0024 error(['DSAMPLE not specified.' ]) ;
+0025 end
+0026
+0027 if options_.smpl(3) > 0
+0028 if options_.smpl(3) == 2
+0029 if options_.smpl(1)<0 | options_.smpl(2)>size(x,2)-lag1(2)
+0030 error ('Wrong sample.' ) ;
+0031 end
+0032 i = [options_.smpl(1)+lag1(1):options_.smpl(2)+lag1(1)]' ;
+0033 elseif options_.smpl(3) == 1
+0034 if options_.smpl(1)>size(x,2)-lag1(2)
+0035 error ('Wrong sample.' ) ;
+0036 end
+0037 i = [lag1(1):options_.smpl(1)+lag1(1)]' ;
+0038 end
+0039 end
+0040
+0041 for k = 1:size(x,1)
+0042 figure ;
+0043 x1 = x(k,i) ;
+0044 y1 = y(k,i) ;
+0045 if nnz(x1) < length(x1)
+0046 plot(ix(i),(y1-x1)) ;
+0047 else
+0048 plot(ix(i),(y1-x1)./x1) ;
+0049 end
+0050 xlabel(['Periods' ]) ;
+0051 title(['Variable ' s2(k)]) ;
+0052 end
+0053
+0054 return ;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/metropolis.html b/matlab/doc/metropolis.html
new file mode 100644
index 000000000..db2b75c6f
--- /dev/null
+++ b/matlab/doc/metropolis.html
@@ -0,0 +1,394 @@
+
+
+
+ Description of metropolis
+
+
+
+
+
+
+
+
+
+
+
+
+
+metropolis
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-02-2005]
+
+ SYNOPSIS
+function metropolis(xparam1,vv,gend,data,rawdata,mh_bounds)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function metropolis(xparam1,vv,gend,data,rawdata,mh_bounds)
+0002
+0003 global M_ oo_ options_ bayestopt_ estim_params_
+0004
+0005 bayestopt_.penalty = 1e8;
+0006
+0007 MhDirectoryName = CheckPath ('metropolis' );
+0008
+0009 nblck = options_.mh_nblck;
+0010 nruns = ones(nblck,1)*options_.mh_replic;
+0011 npar = length(xparam1);
+0012 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
+0013 d = chol(vv);
+0014 options_.lik_algo = 1;
+0015 OpenOldFile = ones(nblck,1);
+0016
+0017 if options_.load_mh_file == 0
+0018
+0019
+0020 if nblck > 1
+0021 disp('MH: Multiple chains mode.' )
+0022 else
+0023 disp('MH: One Chain mode.' )
+0024 end
+0025
+0026 files = dir([ MhDirectoryName '/' M_.fname '_mh*_blck*.mat' ]);
+0027 if length(files)
+0028 delete([ MhDirectoryName '/' M_.fname '_mh*_blck*.mat' ]);
+0029 disp('MH: Old _mh files succesfully erased!' )
+0030 end
+0031
+0032 if nblck > 1
+0033 disp('MH: Searching for initial values...' )
+0034 ix2 = zeros(nblck,npar);
+0035 ilogpo2 = zeros(nblck,1);
+0036 for j=1:nblck
+0037 validate = 0;
+0038 init_iter = 0;
+0039 trial = 1;
+0040 while validate == 0 & trial <= 10
+0041 candidate = options_.mh_init_scale*randn(1,npar)*d + transpose(xparam1);
+0042 if all(candidate' > mh_bounds(:,1)) & all(candidate' < mh_bounds(:,2))
+0043 ix2(j,:) = candidate;
+0044 ilogpo2(j) = -DsgeLikelihood (ix2(j,:)',gend,data);
+0045 j = j+1;
+0046 validate = 1;
+0047 end
+0048 init_iter = init_iter + 1;
+0049 if init_iter > 100 & validate == 0
+0050 disp(['MH: I couldn''t get a valid initial value in 100 trials.' ])
+0051 disp(['MH: You should Reduce mh_init_scale...' ])
+0052 disp(sprintf('MH: Parameter mh_init_scale is equal to %f.' ,options_.mh_init_scale))
+0053 options_.mh_init_scale = input('MH: Enter a new value... ' );
+0054 trial = trial+1;
+0055 end
+0056 end
+0057 if trial > 10 & ~validate
+0058 disp(['MH: I''m unable to find a starting value for block ' int2str(j)])
+0059 return
+0060 end
+0061 end
+0062 disp('MH: Initial values found!' )
+0063 disp(' ' )
+0064 else
+0065 candidate = transpose(xparam1);
+0066 if all(candidate' > mh_bounds(:,1)) & all(candidate' < mh_bounds(:,2))
+0067 ix2 = candidate;
+0068 ilogpo2 = -DsgeLikelihood (ix2',gend,data);
+0069 disp('MH: Initialization at the posterior mode.' )
+0070 disp(' ' )
+0071 else
+0072 disp('MH: Initialization failed...' )
+0073 disp('MH: The posterior mode lies outside the prior bounds.' )
+0074 return
+0075 end
+0076 end
+0077 fblck = 1;
+0078 fline = ones(nblck,1);
+0079 NewFile = ones(nblck,1);
+0080
+0081 file = dir([MhDirectoryName '/' M_.fname '_mh_history.mat' ]);
+0082 if length(files)
+0083 delete([ MhDirectoryName '/' M_.fname '_mh_history.mat' ]);
+0084 disp('MH: Old mh_history file succesfully erased!' )
+0085 end
+0086 AnticipatedNumberOfFiles = floor(nruns(1)/MAX_nruns);
+0087 AnticipatedNumberOfLinesInTheLastFile = nruns(1) - AnticipatedNumberOfFiles*MAX_nruns;
+0088 record.Nblck = nblck;
+0089 record.MhDraws = zeros(1,3);
+0090 record.MhDraws(1,1) = nruns(1);
+0091 record.MhDraws(1,2) = AnticipatedNumberOfFiles+1;
+0092 record.MhDraws(1,3) = AnticipatedNumberOfLinesInTheLastFile;
+0093 record.AcceptationRates = zeros(1,nblck);
+0094 record.Seeds.Normal = randn('state' );
+0095 record.Seeds.Unifor = rand('state' );
+0096 record.InitialParameters = ix2;
+0097 record.InitialLogLiK = ilogpo2;
+0098 record.LastParameters = zeros(nblck,npar);
+0099 record.LastLogLiK = zeros(nblck,1);
+0100 record.LastFileNumber = AnticipatedNumberOfFiles+1;
+0101 record.LastLineNumber = AnticipatedNumberOfLinesInTheLastFile;
+0102 save([MhDirectoryName '/' M_.fname '_mh_history' ],'record' );
+0103 elseif options_.load_mh_file == 1
+0104 disp('MH: I''m loading past metropolis-hastings simulations...' )
+0105 file = dir([ MhDirectoryName '/' M_.fname '_mh_history.mat' ]);
+0106 files = dir([ MhDirectoryName '/' M_.fname '_mh*.mat' ]);
+0107 if ~length(files)
+0108 disp('MH:: FAILURE! there is no MH file to load here!' )
+0109 return
+0110 end
+0111 if ~length(file)
+0112 disp('MH:: FAILURE! there is no MH-history file!' )
+0113 return
+0114 else
+0115 load([ MhDirectoryName '/' M_.fname '_mh_history' ])
+0116 end
+0117 past_number_of_blocks = record.Nblck;
+0118 if past_number_of_blocks ~= nblck
+0119 disp('MH:: The specified number of blocks doesn''t match with the previous number of blocks!' )
+0120 disp(['MH:: You declared ' int2str(nblck) ' blocks, but the previous number of blocks was ' int2str(past_number_of_blocks) '.' ])
+0121 disp(['MH:: I will run the Metropolis-Hastings with ' int2str(past_number_of_blocks) ' blocks.' ])
+0122 nblck = past_number_of_blocks;
+0123 options_.mh_nblck = nblck;
+0124 end
+0125
+0126
+0127 LastFileNumber = record.LastFileNumber;
+0128 LastLineNumber = record.LastLineNumber;
+0129 if LastLineNumber < MAX_nruns
+0130 NewFile = ones(nblck,1)*LastFileNumber;
+0131 else
+0132 NewFile = ones(nblck,1)*(LastFileNumber+1);
+0133 end
+0134 ilogpo2 = record.LastLogLiK;
+0135 ix2 = record.LastParameters;
+0136 fblck = 1;
+0137 fline = ones(nblck,1)*(LastLineNumber+1);
+0138 NumberOfPreviousSimulations = sum(record.MhDraws(:,1),1);
+0139 record.MhDraws = [record.MhDraws;zeros(1,3)];
+0140 NumberOfDrawsWrittenInThePastLastFile = MAX_nruns - LastLineNumber;
+0141 NumberOfDrawsToBeSaved = nruns(1) - NumberOfDrawsWrittenInThePastLastFile;
+0142 AnticipatedNumberOfFiles = floor(NumberOfDrawsToBeSaved/MAX_nruns);
+0143 AnticipatedNumberOfLinesInTheLastFile = NumberOfDrawsToBeSaved - AnticipatedNumberOfFiles*MAX_nruns;
+0144 record.LastFileNumber = LastFileNumber + AnticipatedNumberOfFiles + 1;
+0145 record.LastLineNumber = AnticipatedNumberOfLinesInTheLastFile;
+0146 record.MhDraws(end ,1) = nruns(1);
+0147 record.MhDraws(end ,2) = AnticipatedNumberOfFiles+1;
+0148 record.MhDraws(end ,3) = AnticipatedNumberOfLinesInTheLastFile;
+0149 randn('state' ,record.Seeds.Normal);
+0150 rand('state' ,record.Seeds.Unifor);
+0151 save([MhDirectoryName '/' M_.fname '_mh_history' ],'record' );
+0152 disp(['MH: ... It''s done. I''ve loaded ' int2str(NumberOfPreviousSimulations) ' simulations.' ])
+0153 disp(' ' )
+0154 elseif options_.load_mh_file == -1
+0155
+0156
+0157 disp('MH: Recover mode!' )
+0158 disp(' ' )
+0159 file = dir([MhDirectoryName '/' M_.fname '_mh_history.mat' ]);
+0160 if ~length(file)
+0161 disp('MH:: FAILURE! there is no MH-history file!' )
+0162 return
+0163 else
+0164 load([ MhDirectoryName '/' M_.fname '_mh_history' ])
+0165 end
+0166 nblck = record.Nblck;
+0167 options_.mh_nblck = nblck;
+0168 if size(record.MhDraws,1) == 1
+0169 OldMh = 0;
+0170 else
+0171 OldMh = 1;
+0172 end
+0173
+0174 if OldMh
+0175 ilogpo2 = record.LastLogLiK;
+0176 ix2 = record.LastParameters;
+0177 else
+0178 ilogpo2 = record.InitialLogLiK;
+0179 ix2 = record.InitialParameters;
+0180 end
+0181
+0182 if OldMh
+0183 LastLineNumberInThePreviousMh = record.MhDraws(end-1,3);
+0184 LastFileNumberInThePreviousMh = sum(record.MhDraws(1:end-1,2),1);
+0185 if LastLineNumberInThePreviousMh < MAX_nruns
+0186 NewFile = ones(nblck,1)*LastFileNumberInThePreviousMh;
+0187 else
+0188 NewFile = ones(nblck,1)*(LastFileNumberInThePreviousMh+1);
+0189 end
+0190 else
+0191 NewFile = ones(nblck,1);
+0192 end
+0193
+0194 if OldMh
+0195 fline = ones(nblck,1)*(record.MhDraws(end-1,3)+1);
+0196 else
+0197 fline = ones(nblck,1);
+0198 end
+0199
+0200 fblck = 1;
+0201
+0202 ExpectedNumberOfMhFilesPerBlock = sum(record.MhDraws(:,2),1);
+0203 ExpectedNumberOfMhFiles = ExpectedNumberOfMhFilesPerBlock*nblck;
+0204
+0205 AllMhFiles = dir([MhDirectoryName '/' M_.fname '_mh*_blck*.mat' ]);
+0206 TotalNumberOfMhFiles = length(AllMhFiles);
+0207
+0208 NumberOfMhFilesPerBlock = zeros(nblck,1);
+0209 for i = 1:nblck
+0210 BlckMhFiles = dir([ MhDirectoryName '/' M_.fname '_mh*_blck' int2str(i) '.mat' ]);
+0211 NumberOfMhFilesPerBlock(i) = length(BlckMhFiles);
+0212 end
+0213 tmp = NumberOfMhFilesPerBlock(1); b = 1;
+0214
+0215 CrashedBlck = 1;
+0216 while b <= nblck
+0217 if NumberOfMhFilesPerBlock(b) < ExpectedNumberOfMhFilesPerBlock
+0218 CrashedBlck = b;
+0219 break
+0220 end
+0221 b = b+1;
+0222 end
+0223
+0224 fblck = CrashedBlck;
+0225
+0226 NumberOfSavedMhFilesInTheCrashedBlck = ...
+0227 NumberOfMhFilesPerBlock(CrashedBlck);
+0228
+0229
+0230 if OldMh
+0231 ante = sum(record.MhDraws(1:end-1,2),1);
+0232 load([MhDirectoryName '/' M_.fname '_mh' int2str(ante) '_blck' int2str(CrashedBlck) '.mat' ],'logpo2' );
+0233 if length(logpo2) == MAX_nruns
+0234 IsTheLastFileOfThePreviousMhFull = 1;
+0235 else
+0236 IsTheLastFileOfThePreviousMhFull = 0;
+0237 end
+0238 else
+0239 ante = 0;
+0240 IsTheLastFileOfThePreviousMhFull = 1;
+0241 end
+0242 if ~IsTheLastFileOfThePreviousMhFull
+0243 MhFileExist = 1;
+0244 MhFileNumber = ante;
+0245 while MhFileExist
+0246 MhFileNumber = MhFileNumber + 1;
+0247 if ~exist([MhDirectoryName '/' M_.fname '_mh' int2str(MhFileNumber) '_blck' int2str(CrashedBlck) '.mat' ])
+0248 MhFileExist = 0;
+0249 end
+0250 end
+0251
+0252
+0253
+0254
+0255
+0256
+0257 NumberOfCompletedMhFiles = (MhFileNumber-1)-ante;
+0258
+0259 if OldMh
+0260 reste = MAX_nruns-record.MhDraws(end-1,3);
+0261 else
+0262 reste = 0
+0263 end
+0264 NumberOfSavedDraws = MAX_nruns*(NumberOfCompletedMhFiles) + reste;
+0265
+0266 nruns(CrashedBlck) = nruns(CrashedBlck)-NumberOfSavedDraws;
+0267
+0268
+0269 load([MhDirectoryName '/' M_.fname '_mh' int2str(MhFileNumber-1) '_blck' int2str(CrashedBlck) '.mat' ]);
+0270 ilogpo2(CrashedBlck) = logpo2(end);
+0271 ix2(CrashedBlck,:) = x2(end ,:);
+0272 NewFile(CrashedBlck) = MhFileNumber;
+0273 fline(CrashedBlck,1) = 1;
+0274 else
+0275
+0276 OpenOldFile(CrashedBlck) = 0;
+0277 disp('Ok' )
+0278 end
+0279 end
+0280
+0281
+0282
+0283 InitSizeArray = min([MAX_nruns*ones(nblck) nruns],[],2);
+0284 for b = fblck:nblck
+0285 if (options_.load_mh_file~=0) & (fline(b)>1) & OpenOldFile(b)
+0286 load(['./' MhDirectoryName '/' M_.fname '_mh' int2str(NewFile(b)) ...
+0287 '_blck' int2str(b) '.mat' ])
+0288 x2 = [x2;zeros(InitSizeArray(b)-fline(b)+1,npar)];
+0289 logpo2 = [logpo2;zeros(InitSizeArray(b)-fline(b)+1,1)];
+0290 OpenOldFile(b) = 0;
+0291 else
+0292 x2 = zeros(InitSizeArray(b),npar);
+0293 logpo2 = zeros(InitSizeArray(b),1);
+0294 end
+0295 hh = waitbar(0,['Please wait... Metropolis-Hastings (' int2str(b) '/' int2str(nblck) ')...' ]);
+0296 set(hh,'Name' ,'Metropolis-Hastings' )
+0297 isux = 0;
+0298 irun = fline(b);
+0299 j = 1;
+0300 while j <= nruns(b)
+0301 par = randn(1,npar)*d;
+0302 par = par.*bayestopt_.jscale' + ix2(b,:);
+0303 if all(par'>mh_bounds(:,1)) & all(par'<mh_bounds(:,2))
+0304 logpost = -DsgeLikelihood (par',gend,data);
+0305 else
+0306 logpost = -inf;
+0307 end
+0308 if (logpost > -inf) & (log(rand) < logpost-ilogpo2(b))
+0309 x2(irun,:) = par;
+0310 ix2(b,:) = par;
+0311 logpo2(irun) = logpost;
+0312 ilogpo2(b) = logpost;
+0313 isux = isux + 1;
+0314 else
+0315 x2(irun,:) = ix2(b,:);
+0316 logpo2(irun) = ilogpo2(b);
+0317 end
+0318 prtfrc = j/nruns(b);
+0319 waitbar(prtfrc,hh,[ '(' int2str(b) '/' int2str(nblck) ') ' sprintf('%f done, acceptation rate %f' ,prtfrc,isux/j)]);
+0320 if (irun == InitSizeArray(b)) | (j == nruns(b))
+0321 save([MhDirectoryName '/' M_.fname '_mh' int2str(NewFile(b)) '_blck' int2str(b)],'x2' ,'logpo2' );
+0322 InitSizeArray(b) = min(nruns(b)-j,MAX_nruns);
+0323 if j == nruns(b)
+0324 record.LastParameters(b,:) = x2(end ,:);
+0325 record.LastLogLiK(b) = logpo2(end);
+0326 end
+0327 if InitSizeArray(b)
+0328 x2 = zeros(InitSizeArray(b),npar);
+0329 logpo2 = zeros(InitSizeArray(b),1);
+0330 NewFile(b) = NewFile(b) + 1;
+0331 irun = 0;
+0332 else
+0333 InitSizeArray(b) = min(nruns(b),MAX_nruns);
+0334 end
+0335 end
+0336 j=j+1;
+0337 irun = irun + 1;
+0338 end
+0339 record.AcceptationRates(b) = isux/j;
+0340 close(hh);
+0341 end
+0342 record.Seeds.Normal = randn('state' );
+0343 record.Seeds.Unifor = rand('state' );
+0344 save([MhDirectoryName '/' M_.fname '_mh_history' ],'record' );
+0345 disp(['MH: Number of mh files : ' int2str(NewFile(1)) ' per block.' ])
+0346 disp(['MH: Total number of generated files : ' int2str(NewFile(1)*nblck) '.' ])
+0347 disp(['MH: Total number of iterations : ' int2str((NewFile(1)-1)*MAX_nruns+irun-1) '.' ])
+0348 disp(' ' )
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/metropolis_draw.html b/matlab/doc/metropolis_draw.html
new file mode 100644
index 000000000..16e3ecd03
--- /dev/null
+++ b/matlab/doc/metropolis_draw.html
@@ -0,0 +1,86 @@
+
+
+
+ Description of metropolis_draw
+
+
+
+
+
+
+
+
+
+Home >
. > metropolis_draw.m
+
+
+
+metropolis_draw
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [xparams, logpost]=metropolis_draw(init)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [xparams, logpost]=metropolis_draw(init)
+0002 global options_ estim_params_ M_
+0003 persistent mh_nblck NumberOfDraws fname FirstLine FirstMhFile MAX_nruns
+0004
+0005 if init
+0006 nvx = estim_params_.nvx;
+0007 nvn = estim_params_.nvn;
+0008 ncx = estim_params_.ncx;
+0009 ncn = estim_params_.ncn;
+0010 np = estim_params_.np ;
+0011 npar = nvx+nvn+ncx+ncn+np;
+0012 MhDirectoryName = CheckPath ('metropolis' );
+0013 fname = [ MhDirectoryName '/' M_.fname];
+0014 load([ fname '_mh_history' ]);
+0015 FirstMhFile = record.KeepedDraws.FirstMhFile;
+0016 FirstLine = record.KeepedDraws.FirstLine;
+0017 TotalNumberOfMhFiles = sum(record.MhDraws(:,2));
+0018 LastMhFile = TotalNumberOfMhFiles;
+0019 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
+0020 NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
+0021 MAX_nruns = ceil(options_.MaxNumberOfBytes/(npar+2)/8);
+0022 mh_nblck = options_.mh_nblck;
+0023 return
+0024 end
+0025
+0026 ChainNumber = ceil(rand*mh_nblck);
+0027 DrawNumber = ceil(rand*NumberOfDraws);
+0028
+0029 if DrawNumber <= MAX_nruns-FirstLine+1
+0030 MhFilNumber = FirstMhFile;
+0031 MhLine = FirstLine+DrawNumber-1;
+0032 else
+0033 DrawNumber = DrawNumber-(MAX_nruns-FirstLine+1);
+0034 MhFilNumber = FirstMhFile+ceil(DrawNumber/MAX_nruns);
+0035 MhLine = DrawNumber-(MhFilNumber-FirstMhFile-1)*MAX_nruns;
+0036 end
+0037
+0038 load( [ fname '_mh' int2str(MhFilNumber) '_blck' int2str(ChainNumber) '.mat' ],'x2' ,'logpo2' );
+0039 xparams = x2(MhLine,:);
+0040 logpost= logpo2(MhLine);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mex.png b/matlab/doc/mex.png
new file mode 100644
index 000000000..396f1bc94
Binary files /dev/null and b/matlab/doc/mex.png differ
diff --git a/matlab/doc/mgnldnsty.html b/matlab/doc/mgnldnsty.html
new file mode 100644
index 000000000..bfd04fa34
--- /dev/null
+++ b/matlab/doc/mgnldnsty.html
@@ -0,0 +1,117 @@
+
+
+
+ Description of mgnldnsty
+
+
+
+
+
+
+
+
+
+
+
+
+
+mgnldnsty
+
+
+ PURPOSE
+function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat)
+
+ SYNOPSIS
+function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+matrictint function w=matrictint(S,XXi,T)rfvar3 function var=rfvar3(ydata,lags,xdata,breaks,lambda,mu)varprior function [ydum,xdum,breaks]=varprior(nv,nx,lags,mnprior,vprior)
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024 if nargin<10,flat=0;end
+0025 [T,nv]=size(ydata);
+0026 [Tx,nx]=size(xdata);
+0027 if Tx ~= T, error('ydata and xdata length mismatch' ),end
+0028 [ydum,xdum,pbreaks]=varprior (nv,nx,lags,mnprior,vprior);
+0029 var=rfvar3 ([ydata;ydum],lags,[xdata;xdum],[breaks;T;T+pbreaks],lambda,mu);
+0030 Tu=size(var.u,1);
+0031 w=matrictint (var.u'*var.u,var.xxi,Tu-flat*(nv+1))-flat*.5*nv*(nv+1)*log(2*pi);
+0032 if nargin>8
+0033 if ~isempty(train) & train>0
+0034 if train <= lags
+0035 error('end of training sample <= # of lags' )
+0036 end
+0037 Tp=train;
+0038 tbreaks=breaks(find(breaks<train));
+0039 else
+0040 Tp=lags;
+0041 tbreaks=[];
+0042 end
+0043 else
+0044 Tp=lags;
+0045 tbreaks=[];
+0046 end
+0047 varp=rfvar3 ([ydata(1:Tp,:);ydum],lags,[xdata(1:Tp);xdum],[tbreaks;Tp;Tp+pbreaks],lambda,mu);
+0048 Tup=size(varp.u,1);
+0049 wp=matrictint (varp.u'*varp.u,varp.xxi,Tup-flat*(nv+1)/2)-flat*.5*nv*(nv+1)*log(2*pi);
+0050 w=w-wp;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mh_optimal_bandwidth.html b/matlab/doc/mh_optimal_bandwidth.html
new file mode 100644
index 000000000..f8494605d
--- /dev/null
+++ b/matlab/doc/mh_optimal_bandwidth.html
@@ -0,0 +1,209 @@
+
+
+
+ Description of mh_optimal_bandwidth
+
+
+
+
+
+
+
+
+
+Home >
. > mh_optimal_bandwidth.m
+
+
+
+mh_optimal_bandwidth
+
+
+ PURPOSE
+% This function gives the optimal bandwidth parameter of a kernel estimator
+
+ SYNOPSIS
+function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019 if strcmpi(kernel_function,'gaussian' )
+0020 k = inline('inv(sqrt(2*pi))*exp(-0.5*x.^2)' );
+0021 k2 = inline('inv(sqrt(2*pi))*(-exp(-0.5*x.^2)+(x.^2).*exp(-0.5*x.^2))' );
+0022 k4 = inline('inv(sqrt(2*pi))*(3*exp(-0.5*x.^2)-6*(x.^2).*exp(-0.5*x.^2)+(x.^4).*exp(-0.5*x.^2))' );
+0023 k6 = inline('inv(sqrt(2*pi))*(-15*exp(-0.5*x.^2)+45*(x.^2).*exp(-0.5*x.^2)-15*(x.^4).*exp(-0.5*x.^2)+(x.^6).*exp(-0.5*x.^2))' );
+0024 mu02 = inv(2*sqrt(pi));
+0025 mu21 = 1;
+0026 elseif strcmpi(kernel_function,'uniform' )
+0027 k = inline('0.5*(abs(x) <= 1)' );
+0028 mu02 = 0.5;
+0029 mu21 = 1/3;
+0030 elseif strcmpi(kernel_function,'triangle' )
+0031 k = inline('(1-abs(x)).*(abs(x) <= 1)' );
+0032 mu02 = 2/3;
+0033 mu21 = 1/6;
+0034 elseif strcmpi(kernel_function,'epanechnikov' )
+0035 k = inline('0.75*(1-x.^2).*(abs(x) <= 1)' );
+0036 mu02 = 3/5;
+0037 mu21 = 1/5;
+0038 elseif strcmpi(kernel_function,'quartic' )
+0039 k = inline('0.9375*((1-x.^2).^2).*(abs(x) <= 1)' );
+0040 mu02 = 15/21;
+0041 mu21 = 1/7;
+0042 elseif strcmpi(kernel_function,'triweight' )
+0043 k = inline('1.09375*((1-x.^2).^3).*(abs(x) <= 1)' );
+0044 k2 = inline('(105/4*(1-x.^2).*x.^2-105/16*(1-x.^2).^2).*(abs(x) <= 1)' );
+0045 k4 = inline('(-1575/4*x.^2+315/4).*(abs(x) <= 1)' );
+0046 k6 = inline('(-1575/2).*(abs(x) <= 1)' );
+0047 mu02 = 350/429;
+0048 mu21 = 1/9;
+0049 elseif strcmpi(kernel_function,'cosinus' )
+0050 k = inline('(pi/4)*cos((pi/2)*x).*(abs(x) <= 1)' );
+0051 k2 = inline('(-1/16*cos(pi*x/2)*pi^3).*(abs(x) <= 1)' );
+0052 k4 = inline('(1/64*cos(pi*x/2)*pi^5).*(abs(x) <= 1)' );
+0053 k6 = inline('(-1/256*cos(pi*x/2)*pi^7).*(abs(x) <= 1)' );
+0054 mu02 = (pi^2)/16;
+0055 mu21 = (pi^2-8)/pi^2;
+0056 else
+0057 disp('mh_optimal_bandwidth :: ' );
+0058 error('This kernel function is not yet implemented in Dynare!' );
+0059 end
+0060
+0061
+0062
+0063 if bandwidth == 0;
+0064
+0065 sigma = std(data);
+0066 h = 2*sigma*(sqrt(pi)*mu02/(12*(mu21^2)*n))^(1/5);
+0067 A = 0;
+0068 for i=1:n;
+0069 j = i;
+0070 while j<= n & data(j,1)==data(i,1);
+0071 j = j+1;
+0072 end ;
+0073 A = A + 2*(j-i) - 1;
+0074 end ;
+0075 A = A/n;
+0076 h = h*A^(1/5);
+0077 elseif bandwidth == -1;
+0078
+0079 if strcmp(kernel_function,'uniform' ) | ...
+0080 strcmp(kernel_function,'triangle' ) | ...
+0081 strcmp(kernel_function,'epanechnikov' ) | ...
+0082 strcmp(kernel_function,'quartic' );
+0083 error('I can''t compute the optimal bandwidth with this kernel... Try the gaussian, triweight or cosinus kernels.' );
+0084 end ;
+0085 sigma = std(data);
+0086 A = 0;
+0087 for i=1:n;
+0088 j = i;
+0089 while j<= n & data(j,1)==data(i,1);
+0090 j = j+1;
+0091 end ;
+0092 A = A + 2*(j-i) - 1;
+0093 end ;
+0094 A = A/n;
+0095 Itilda4 = 8*7*6*5/(((2*sigma)^9)*sqrt(pi));
+0096 g3 = abs(2*A*k6(0)/(mu21*Itilda4*n))^(1/9);
+0097 Ihat3 = 0;
+0098 for i=1:n;
+0099 Ihat3 = Ihat3 + sum(k6((data(i,1)-data)/g3));
+0100 end ;
+0101 Ihat3 = -Ihat3/((n^2)*g3^7);
+0102 g2 = abs(2*A*k4(0)/(mu21*Ihat3*n))^(1/7);
+0103 Ihat2 = 0;
+0104 for i=1:n;
+0105 Ihat2 = Ihat2 + sum(k4((data(i)-data)/g2));
+0106 end ;
+0107 Ihat2 = Ihat2/((n^2)*g2^5);
+0108 h = (A*mu02/(n*Ihat2*mu21^2))^(1/5);
+0109 elseif bandwidth == -2;
+0110
+0111 if strcmp(kernel_function,'uniform' ) | ...
+0112 strcmp(kernel_function,'triangle' ) | ...
+0113 strcmp(kernel_function,'epanechnikov' ) | ...
+0114 strcmp(kernel_function,'quartic' );
+0115 error('I can''t compute the optimal bandwidth with this kernel... Try the gaussian, triweight or cosinus kernels.' );
+0116 end ;
+0117 sigma = std(data);
+0118 A = 0;
+0119 T = zeros(n,1);
+0120 for i=1:n;
+0121 j = i;
+0122 while j<= n & data(j,1)==data(i,1);
+0123 j = j+1;
+0124 end ;
+0125 T(i) = (j-i);
+0126 A = A + 2*T(i) - 1;
+0127 end ;
+0128 A = A/n;
+0129 Itilda4 = 8*7*6*5/(((2*sigma)^9)*sqrt(pi));
+0130 g3 = abs(2*A*k6(0)/(mu21*Itilda4*n))^(1/9);
+0131 Ihat3 = 0;
+0132 for i=1:n;
+0133 Ihat3 = Ihat3 + sum(k6((data(i,1)-data)/g3));
+0134 end ;
+0135 Ihat3 = -Ihat3/((n^2)*g3^7);
+0136 g2 = abs(2*A*k4(0)/(mu21*Ihat3*n))^(1/7);
+0137 Ihat2 = 0;
+0138 for i=1:n;
+0139 Ihat2 = Ihat2 + sum(k4((data(i)-data)/g2));
+0140 end ;
+0141 Ihat2 = Ihat2/((n^2)*g2^5);
+0142 h = ((2*T-1)*mu02/(n*Ihat2*mu21^2)).^(1/5);
+0143 elseif bandwidth > 0
+0144 h = bandwidth;
+0145 else
+0146 disp('mh_optimal_bandwidth :: ' );
+0147 error('Parameter bandwidth must be a real parameter value or equal to 0,-1 or -2.' );
+0148 end
+0149
+0150 optimal_bandwidth = h;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mj_qgamma.html b/matlab/doc/mj_qgamma.html
new file mode 100644
index 000000000..82dd180cf
--- /dev/null
+++ b/matlab/doc/mj_qgamma.html
@@ -0,0 +1,78 @@
+
+
+
+ Description of mj_qgamma
+
+
+
+
+
+
+
+
+
+
+
+
+
+mj_qgamma
+
+
+ PURPOSE
+MJ_QGAMMA The gamma inverse distribution function
+
+ SYNOPSIS
+function x = mj_qgamma(p,a)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+lpdfgam log GAMMA PDFpgamma PGAMMA The gamma distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x = mj_qgamma(p,a)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011 if any(any(abs(2*p-1)>1))
+0012 error('A probability should be 0<=p<=1, please!' )
+0013 end
+0014 if any(any(a<=0))
+0015 error('Parameter a is wrong' )
+0016 end
+0017
+0018 x = max(a-1,0.1);
+0019 dx = 1;
+0020 while any(any(abs(dx)>256*eps*max(x,1)))
+0021
+0022 dx = (pgamma (x,a) - p) ./ exp(lpdfgam (x,a,1));
+0023 x = x - dx;
+0024 x = x + (dx - x) / 2 .* (x<0);
+0025 end
+0026
+0027 I0 = find(p==0);
+0028 x(I0) = zeros(size(I0));
+0029 I1 = find(p==1);
+0030 x(I1) = zeros(size(I1)) + Inf;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mode_check.html b/matlab/doc/mode_check.html
new file mode 100644
index 000000000..6b50003ea
--- /dev/null
+++ b/matlab/doc/mode_check.html
@@ -0,0 +1,227 @@
+
+
+
+ Description of mode_check
+
+
+
+
+
+
+
+
+
+
+
+
+
+mode_check
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function mode_check(x,fval,hessian,gend,data,lb,ub)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+DsgeLikelihood stephane.adjemian@cepremap.cnrs.fr [09-07-2004]get_the_name stephane.adjemian@cepremap.cnrs.fr [07-13-2004]hessian Copyright (C) 2001 Michel Juillardpltorg stephane.adjemian@cepremap.cnrs.fr [06-07-2004]
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function mode_check(x,fval,hessian,gend,data,lb,ub)
+0002 global bayestopt_ M_ options_
+0003
+0004 TeX = options_.TeX;
+0005 [s_min,k] = min(diag(hessian ))
+0006
+0007 disp('\nMODE CHECK\n' )
+0008 disp(sprintf('Fval obtained by fmincon: %f' , fval))
+0009 disp(bayestopt_.name)
+0010 cname = bayestopt_.name{k};
+0011 disp(sprintf('Most negative variance %f for parameter %d (%s = %f)' ,s_min,k,cname,x(k)))
+0012
+0013 [nbplt,nr,nc,lr,lc,nstar] = pltorg (length(x));
+0014
+0015 if TeX
+0016 fidTeX = fopen([M_.fname '_CheckPlots.TeX' ],'w' );
+0017 fprintf(fidTeX,'%% TeX eps-loader file generated by mode_check.m (Dynare).\n' );
+0018 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0019 fprintf(fidTeX,' \n' );
+0020 end
+0021
+0022
+0023 if nbplt == 1
+0024 if TeX
+0025 NAMES = [];
+0026 TeXNAMES = [];
+0027 end
+0028 hh = figure('Name' ,'Check plots' );
+0029 for k=1:length(x)
+0030 subplot(nr,nc,k)
+0031 [name,texname] = get_the_name (k,TeX);
+0032 if TeX
+0033 NAMES = strvcat(NAMES,name);
+0034 TeXNAMES = strvcat(TeXNAMES,texname);
+0035 end
+0036 xx = x;
+0037 l1 = max(lb(k),0.8*x(k));
+0038 l2 = min(ub(k),1.2*x(k));
+0039 z = [l1:(l2-l1)/20:l2];
+0040 y = zeros(length(z),1);
+0041 for i=1:length(z)
+0042 xx(k) = z(i);
+0043 y(i) = DsgeLikelihood (xx,gend,data);
+0044 end
+0045 plot(z,y)
+0046 hold on
+0047 yl=get(gca,'ylim' );
+0048 plot([x(k) x(k)],yl,'c' ,'LineWidth' , 1);
+0049 title(name,'interpreter' ,'none' );
+0050 hold off
+0051 drawnow
+0052 end
+0053 eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(1)]);
+0054 eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(1)]);
+0055 saveas(hh,[M_.fname '_CheckPlots' int2str(1) '.fig' ]);
+0056 if options_.nograph, close(hh), end
+0057
+0058 if TeX
+0059 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0060 for jj = 1:length(x)
+0061 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0062 end
+0063 fprintf(fidTeX,'\\centering \n' );
+0064 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_CheckPlots%s}\n' ,M_.fname,int2str(1));
+0065 fprintf(fidTeX,'\\caption{Priors.}' );
+0066 fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n' ,int2str(1));
+0067 fprintf(fidTeX,'\\end{figure}\n' );
+0068 fprintf(fidTeX,'\n' );
+0069 fprintf(fidTeX,'%% End of TeX file.\n' );
+0070 fclose(fidTeX);
+0071 end
+0072 else
+0073 for plt = 1:nbplt-1
+0074 if TeX
+0075 NAMES = [];
+0076 TeXNAMES = [];
+0077 end
+0078 hh = figure('Name' ,'Check plots' );
+0079 for k=1:nstar
+0080 subplot(nr,nc,k)
+0081 kk = (plt-1)*nstar+k;
+0082 [name,texname] = get_the_name (kk,TeX);
+0083 if TeX
+0084 NAMES = strvcat(NAMES,name);
+0085 TeXNAMES = strvcat(TeXNAMES,texname);
+0086 end
+0087 xx = x;
+0088 l1 = max(lb(kk),0.8*x(kk));
+0089 l2 = min(ub(kk),1.2*x(kk));
+0090 z = [l1:(l2-l1)/20:l2];
+0091 y = zeros(length(z),1);
+0092 for i=1:length(z)
+0093 xx(kk) = z(i);
+0094 y(i) = DsgeLikelihood (xx,gend,data);
+0095 end
+0096 plot(z,y);
+0097 hold on
+0098 yl=get(gca,'ylim' );
+0099 plot( [x(kk) x(kk)], yl, 'c' , 'LineWidth' , 1)
+0100 title(name,'interpreter' ,'none' )
+0101 hold off
+0102 drawnow
+0103 end
+0104 eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(plt)]);
+0105 eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(plt)]);
+0106 saveas(hh,[M_.fname '_CheckPlots' int2str(plt) '.fig' ]);
+0107 if options_.nograph, close(hh), end
+0108 if TeX
+0109
+0110 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0111 for jj = 1:nstar
+0112 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0113 end
+0114 fprintf(fidTeX,'\\centering \n' );
+0115 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_CheckPlots%s}\n' ,M_.fname,int2str(plt));
+0116 fprintf(fidTeX,'\\caption{Check plots.}' );
+0117 fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n' ,int2str(plt));
+0118 fprintf(fidTeX,'\\end{figure}\n' );
+0119 fprintf(fidTeX,' \n' );
+0120 end
+0121 end
+0122 hh = figure('Name' ,'Check plots' );
+0123 k = 1;
+0124 if TeX
+0125 NAMES = [];
+0126 TeXNAMES = [];
+0127 end
+0128 while (nbplt-1)*nstar+k <= length(x)
+0129 kk = (nbplt-1)*nstar+k;
+0130 [name,texname] = get_the_name (kk,TeX);
+0131 if TeX
+0132 NAMES = strvcat(NAMES,name);
+0133 TeXNAMES = strvcat(TeXNAMES,texname);
+0134 end
+0135 if lr ~= 0
+0136 subplot(lr,lc,k)
+0137 else
+0138 subplot(nr,nc,k)
+0139 end
+0140 xx = x;
+0141 l1 = max(lb(kk),0.8*x(kk));
+0142 l2 = min(ub(kk),1.2*x(kk));
+0143 z = [l1:(l2-l1)/20:l2];
+0144 y = zeros(length(z),1);
+0145 for i=1:length(z)
+0146 xx(kk) = z(i);
+0147 y(i) = DsgeLikelihood (xx,gend,data);
+0148 end
+0149 plot(z,y)
+0150 hold on
+0151 yl=get(gca,'ylim' );
+0152 plot( [x(kk) x(kk)], yl, 'c' , 'LineWidth' , 1)
+0153 title(name,'interpreter' ,'none' )
+0154 hold off
+0155 k = k + 1;
+0156 drawnow
+0157 end
+0158 eval(['print -depsc2 ' M_.fname '_CheckPlots' int2str(nbplt)]);
+0159 eval(['print -dpdf ' M_.fname '_CheckPlots' int2str(nbplt)]);
+0160 saveas(hh,[M_.fname '_CheckPlots' int2str(nbplt) '.fig' ]);
+0161 if options_.nograph, close(hh), end
+0162 if TeX
+0163 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0164 for jj = 1:lr*lc
+0165 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0166 end
+0167 fprintf(fidTeX,'\\centering \n' );
+0168 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_CheckPlots%s}\n' ,M_.fname,int2str(nbplt));
+0169 fprintf(fidTeX,'\\caption{Check plots.}' );
+0170 fprintf(fidTeX,'\\label{Fig:CheckPlots:%s}\n' ,int2str(nbplt));
+0171 fprintf(fidTeX,'\\end{figure}\n' );
+0172 fprintf(fidTeX,' \n' );
+0173 fprintf(fidTeX,'%% End of TeX file.\n' );
+0174 fclose(fidTeX);
+0175 end
+0176 end
+0177
+0178
+0179
+0180
+0181
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mr_gstep.html b/matlab/doc/mr_gstep.html
new file mode 100644
index 000000000..3f1be21a7
--- /dev/null
+++ b/matlab/doc/mr_gstep.html
@@ -0,0 +1,181 @@
+
+
+
+ Description of mr_gstep
+
+
+
+
+
+
+
+
+
+
+
+
+
+mr_gstep
+
+
+ PURPOSE
+Copyright (C) 2005 Marco Ratto
+
+ SYNOPSIS
+function [f0, x] = mr_gstep(func0,x,htol0,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+csminit [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [f0, x] = mr_gstep(func0,x,htol0,varargin)
+0002
+0003
+0004
+0005
+0006
+0007
+0008 global bayestopt_ options_
+0009 persistent h1
+0010
+0011 gstep_ = options_.gstep;
+0012 if nargin<3,
+0013 htol = 1.e-6;
+0014 else
+0015 htol = htol0;
+0016 end
+0017 func = str2func(func0);
+0018 f0=feval(func,x,varargin{:});
+0019 n=size(x,1);
+0020 h2=bayestopt_.ub-bayestopt_.lb;
+0021
+0022 if isempty(h1),
+0023 h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/4);
+0024 end
+0025
+0026 xh1=x;
+0027 f1=zeros(size(f0,1),n);
+0028 f_1=f1;
+0029
+0030 i=0;
+0031 while i<n,
+0032 i=i+1;
+0033 h10=h1(i);
+0034 hcheck=0;
+0035 dx=[];
+0036 xh1(i)=x(i)+h1(i);
+0037 fx = feval(func,xh1,varargin{:});
+0038 it=1;
+0039 dx=(fx-f0);
+0040 ic=0;
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055 icount = 0;
+0056 h0=h1(i);
+0057 while (abs(dx(it))<0.5*htol | abs(dx(it))>(2*htol)) & icount<10 & ic==0,
+0058
+0059 icount=icount+1;
+0060 if abs(dx(it)) ~= 0,
+0061 if abs(dx(it))<0.5*htol
+0062 h1(i)=min(0.3*abs(x(i)), 0.9*htol/abs(dx(it))*h1(i));
+0063 xh1(i)=x(i)+h1(i);
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071 end
+0072 if abs(dx(it))>(2*htol),
+0073 h1(i)= htol/abs(dx(it))*h1(i);
+0074 xh1(i)=x(i)+h1(i);
+0075 end
+0076 fx = feval(func,xh1,varargin{:});
+0077 it=it+1;
+0078 dx(it)=(fx-f0);
+0079 h0(it)=h1(i);
+0080 if h1(i)<1.e-12*min(1,h2(i)),
+0081 ic=1;
+0082 hcheck=1;
+0083 end
+0084 else
+0085 h1(i)=1;
+0086 ic=1;
+0087 end
+0088 end
+0089 f1(:,i)=fx;
+0090 xh1(i)=x(i)-h1(i);
+0091
+0092
+0093
+0094
+0095
+0096
+0097
+0098
+0099 fx = feval(func,xh1,varargin{:});
+0100 f_1(:,i)=fx;
+0101
+0102
+0103
+0104
+0105 if hcheck & htol<1,
+0106 htol=min(1,max(min(abs(dx))*2,htol*10));
+0107 h1(i)=h10;
+0108 xh1(i)=x(i);
+0109 i=i-1;
+0110 else
+0111 gg=zeros(size(x));
+0112 hh=gg;
+0113 gg(i)=(f1(i)'-f_1(i)')./(2.*h1(i));
+0114 if abs(f1(i)+f_1(i)-2*f0)>1.e-12,
+0115 hh(i) = abs(1/( (f1(i)+f_1(i)-2*f0)./(h1(i)*h1(i)) ));
+0116 else
+0117 hh(i) = 1;
+0118 end
+0119
+0120 if gg(i)*(hh(i)*gg(i))/2 > htol,
+0121 [f0 x fc retcode] = csminit (func0,x,f0,gg,0,diag(hh),varargin{:});
+0122 end
+0123 xh1=x;
+0124 end
+0125 save gstep
+0126 end
+0127
+0128 save gstep
+0129
+0130
+0131
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/mr_hessian.html b/matlab/doc/mr_hessian.html
new file mode 100644
index 000000000..10bdd9eee
--- /dev/null
+++ b/matlab/doc/mr_hessian.html
@@ -0,0 +1,358 @@
+
+
+
+ Description of mr_hessian
+
+
+
+
+
+
+
+
+
+
+
+
+
+mr_hessian
+
+
+ PURPOSE
+Copyright (C) 2004 Marco Ratto
+
+ SYNOPSIS
+function [hessian_mat, gg, htol1, ihh, hh_mat0] = mr_hessian(func,x,hflag,htol0,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028 function [hessian_mat, gg, htol1, ihh, hh_mat0] = mr_hessian(func,x,hflag,htol0,varargin)
+0029 global options_ bayestopt_
+0030 persistent h1 htol
+0031
+0032 gstep_=options_.gstep;
+0033 if isempty(htol), htol = 1.e-4; end
+0034 func = str2func(func);
+0035 [f0, ff0]=feval(func,x,varargin{:});
+0036 n=size(x,1);
+0037 h2=bayestopt_.ub-bayestopt_.lb;
+0038
+0039
+0040 if isempty(h1),
+0041 h1=max(abs(x),sqrt(gstep_)*ones(n,1))*eps^(1/4);
+0042 end
+0043
+0044 if htol0<htol,
+0045 htol=htol0;
+0046 end
+0047 xh1=x;
+0048 f1=zeros(size(f0,1),n);
+0049 f_1=f1;
+0050 ff1=zeros(size(ff0));
+0051 ff_1=ff1;
+0052
+0053
+0054 i=0;
+0055 while i<n,
+0056 i=i+1;
+0057 h10=h1(i);
+0058 hcheck=0;
+0059 dx=[];
+0060 xh1(i)=x(i)+h1(i);
+0061 [fx, ffx]=feval(func,xh1,varargin{:});
+0062 it=1;
+0063 dx=(fx-f0);
+0064 ic=0;
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077
+0078
+0079 icount = 0;
+0080 h0=h1(i);
+0081 while (abs(dx(it))<0.5*htol | abs(dx(it))>(2*htol)) & icount<10 & ic==0,
+0082
+0083 icount=icount+1;
+0084
+0085 if abs(dx(it))<0.5*htol
+0086 if abs(dx(it)) ~= 0,
+0087 h1(i)=min(0.3*abs(x(i)), 0.9*htol/abs(dx(it))*h1(i));
+0088 else
+0089 h1(i)=2.1*h1(i);
+0090 end
+0091 xh1(i)=x(i)+h1(i);
+0092
+0093
+0094
+0095
+0096
+0097
+0098
+0099 [fx, ffx]=feval(func,xh1,varargin{:});
+0100 end
+0101 if abs(dx(it))>(2*htol),
+0102 h1(i)= htol/abs(dx(it))*h1(i);
+0103 xh1(i)=x(i)+h1(i);
+0104 [fx, ffx]=feval(func,xh1,varargin{:});
+0105 while (fx-f0)==0,
+0106 h1(i)= h1(i)*2;
+0107 xh1(i)=x(i)+h1(i);
+0108 [fx, ffx]=feval(func,xh1,varargin{:});
+0109 ic=1;
+0110 end
+0111 end
+0112 it=it+1;
+0113 dx(it)=(fx-f0);
+0114 h0(it)=h1(i);
+0115 if h1(i)<1.e-12*min(1,h2(i)),
+0116 ic=1;
+0117 hcheck=1;
+0118 end
+0119
+0120
+0121
+0122
+0123 end
+0124
+0125
+0126
+0127
+0128
+0129
+0130
+0131
+0132
+0133
+0134
+0135 f1(:,i)=fx;
+0136 ff1=ffx;
+0137 if hflag,
+0138 xh1(i)=x(i)-h1(i);
+0139
+0140
+0141
+0142
+0143
+0144
+0145
+0146
+0147 [fx, ffx]=feval(func,xh1,varargin{:});
+0148 f_1(:,i)=fx;
+0149 ff_1=ffx;
+0150
+0151
+0152
+0153
+0154 ggh(:,i)=(ff1-ff_1)./(2.*h1(i));
+0155 else
+0156 ggh(:,i)=(ff1-ff0)./h1(i);
+0157 end
+0158 xh1(i)=x(i);
+0159 if hcheck & htol<1,
+0160 htol=min(1,max(min(abs(dx))*2,htol*10));
+0161 h1(i)=h10;
+0162 i=0;
+0163 end
+0164 save hess
+0165 end
+0166
+0167 h_1=h1;
+0168 xh1=x;
+0169 xh_1=xh1;
+0170
+0171 if hflag,
+0172 gg=(f1'-f_1')./(2.*h1);
+0173 else
+0174 gg=(f1'-f0)./h1;
+0175 end
+0176
+0177 if hflag==2,
+0178 gg=(f1'-f_1')./(2.*h1);
+0179 hessian_mat = zeros(size(f0,1),n*n);
+0180 for i=1:n
+0181 if i > 1
+0182 k=[i:n:n*(i-1)];
+0183 hessian_mat(:,(i-1)*n+1:(i-1)*n+i-1)=hessian_mat(:,k);
+0184 end
+0185 hessian_mat(:,(i-1)*n+i)=(f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i));
+0186 temp=f1+f_1-f0*ones(1,n);
+0187 for j=i+1:n
+0188 xh1(i)=x(i)+h1(i);
+0189 xh1(j)=x(j)+h_1(j);
+0190 xh_1(i)=x(i)-h1(i);
+0191 xh_1(j)=x(j)-h_1(j);
+0192
+0193
+0194
+0195
+0196
+0197
+0198
+0199
+0200
+0201
+0202
+0203
+0204 temp1 = feval(func,xh1,varargin{:});
+0205
+0206
+0207
+0208
+0209
+0210
+0211
+0212
+0213
+0214
+0215 temp2 = feval(func,xh_1,varargin{:});
+0216
+0217 hessian_mat(:,(i-1)*n+j)=-(-temp1 -temp2+temp(:,i)+temp(:,j))./(2*h1(i)*h_1(j));
+0218 xh1(i)=x(i);
+0219 xh1(j)=x(j);
+0220 xh_1(i)=x(i);
+0221 xh_1(j)=x(j);
+0222 j=j+1;
+0223 save hess
+0224 end
+0225 i=i+1;
+0226 end
+0227
+0228 elseif hflag==1,
+0229 hessian_mat = zeros(size(f0,1),n*n);
+0230 for i=1:n,
+0231 dum = (f1(:,i)+f_1(:,i)-2*f0)./(h1(i)*h_1(i));
+0232 if dum>eps,
+0233 hessian_mat(:,(i-1)*n+i)=dum;
+0234 else
+0235 hessian_mat(:,(i-1)*n+i)=max(eps, gg(i)^2);
+0236 end
+0237 end
+0238
+0239 end
+0240
+0241 gga=ggh.*kron(ones(size(ff1)),2.*h1');
+0242 hh_mat=gga'*gga;
+0243 hh_mat0=ggh'*ggh;
+0244 A=diag(2.*h1);
+0245 igg=inv(hh_mat);
+0246 ihh=A'*igg*A;
+0247 if hflag>0 & min(eig(reshape(hessian_mat,n,n)))>0,
+0248 hh0 = A*reshape(hessian_mat,n,n)*A';
+0249 hh = reshape(hessian_mat,n,n);
+0250 sd0=sqrt(diag(hh0));
+0251 sd=sqrt(diag(hh_mat));
+0252 hh_mat=hh_mat./(sd*sd').*(sd0*sd0');
+0253 igg=inv(hh_mat);
+0254 ihh=A'*igg*A;
+0255 hh_mat0=inv(A)'*hh_mat*inv(A);
+0256 sd=sqrt(diag(ihh));
+0257 sdh=sqrt(1./diag(hh));
+0258 for j=1:length(sd),
+0259 sd0(j,1)=min(bayestopt_.pstdev(j), sd(j));
+0260 sd0(j,1)=10^(0.5*(log10(sd0(j,1))+log10(sdh(j,1))));
+0261
+0262 end
+0263 ihh=ihh./(sd*sd').*(sd0*sd0');
+0264 igg=inv(A)'*ihh*inv(A);
+0265 hh_mat=inv(igg);
+0266 hh_mat0=inv(A)'*hh_mat*inv(A);
+0267
+0268
+0269
+0270
+0271
+0272
+0273 end
+0274 if hflag<2,
+0275 hessian_mat=hh_mat0(:);
+0276 end
+0277
+0278 if isnan(hessian_mat),
+0279 hh_mat0=eye(length(hh_mat0));
+0280 ihh=hh_mat0;
+0281 hessian_mat=hh_mat0(:);
+0282 end
+0283 hh1=h1;
+0284 htol1=htol;
+0285 save hess
+0286
+0287
+0288
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/my_ordeig.html b/matlab/doc/my_ordeig.html
new file mode 100644
index 000000000..f0756a33a
--- /dev/null
+++ b/matlab/doc/my_ordeig.html
@@ -0,0 +1,64 @@
+
+
+
+ Description of my_ordeig
+
+
+
+
+
+
+
+
+
+
+
+
+
+my_ordeig
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function eval = my_ordeig(t)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function eval = my_ordeig(t)
+0002
+0003 n = size(t,2);
+0004 eval = zeros(n,1);
+0005 for i=1:n-1
+0006 if t(i+1,i) == 0
+0007 eval(i) = t(i,i);
+0008 else
+0009 k = i:i+1;
+0010 eval(k) = eig(t(k,k));
+0011 i = i+1;
+0012 end
+0013 end
+0014 if i < n
+0015 t(n) = t(n,n);
+0016 end
+0017
+0018
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/my_subplot.html b/matlab/doc/my_subplot.html
new file mode 100644
index 000000000..f0a08bf52
--- /dev/null
+++ b/matlab/doc/my_subplot.html
@@ -0,0 +1,84 @@
+
+
+
+ Description of my_subplot
+
+
+
+
+
+
+
+
+
+
+
+
+
+my_subplot
+
+
+ PURPOSE
+spreads subplots on several figures according to a maximum number of
+
+ SYNOPSIS
+function my_subplot(i,imax,irow,icol,fig_title)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function my_subplot(i,imax,irow,icol,fig_title)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011 nfig_max = irow*icol;
+0012 if imax < nfig_max
+0013 icol = ceil(sqrt(imax));
+0014 irow=icol;
+0015 if (icol-1)*(icol-2) >= imax
+0016 irow = icol-2;
+0017 icol = icol-1;
+0018 elseif (icol)*(icol-2) >= imax
+0019 irow = icol-2;
+0020 elseif icol*(icol-1) >= imax
+0021 irow = icol-1;
+0022 end
+0023 end
+0024
+0025 i1 = mod(i-1,nfig_max);
+0026 if i1 == 0
+0027 figure('Name' ,fig_title);
+0028 end
+0029
+0030 subplot(irow,icol,i1+1);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/newrat.html b/matlab/doc/newrat.html
new file mode 100644
index 000000000..02275bb72
--- /dev/null
+++ b/matlab/doc/newrat.html
@@ -0,0 +1,321 @@
+
+
+
+ Description of newrat
+
+
+
+
+
+
+
+
+
+
+
+
+
+newrat
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillardcsminit [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...mr_gstep Copyright (C) 2005 Marco Rattomr_hessian Copyright (C) 2004 Marco Ratto
+This function is called by:
+
+
+
+ SUBFUNCTIONS
+
+ SOURCE CODE
+0001 function [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032 global bayestopt_
+0033 icount=0;
+0034 nx=length(x);
+0035 xparam1=x;
+0036
+0037 htol_base = max(1.e-5, ftol0);
+0038 flagit=0;
+0039 ftol=ftol0;
+0040 gtol=1.e-3;
+0041 htol=htol_base;
+0042 htol0=htol_base;
+0043 gibbstol=length(bayestopt_.pshape)/12;
+0044
+0045 func_hh = [func0,'_hh' ];
+0046 func = str2func(func0);
+0047 fval0=feval(func,x,varargin{:});
+0048 fval=fval0;
+0049 if isempty(hh)
+0050 [dum, gg, htol0, igg, hhg]=mr_hessian (func_hh,x,flagit,htol,varargin{:});
+0051 hh0 = reshape(dum,nx,nx);
+0052 hh=hhg;
+0053 if min(eig(hh0))<0,
+0054 hh0=hhg;
+0055 elseif flagit==2,
+0056 hh=hh0;
+0057 igg=inv(hh);
+0058 end
+0059 if htol0>htol,
+0060 htol=htol0;
+0061
+0062 end
+0063 else
+0064 hh0=hh;
+0065 hhg=hh;
+0066 igg=inv(hh);
+0067 end
+0068 disp(['Gradient norm ' ,num2str(norm(gg))])
+0069 ee=eig(hh);
+0070 disp(['Minimum Hessian eigenvalue ' ,num2str(min(ee))])
+0071 disp(['Maximum Hessian eigenvalue ' ,num2str(max(ee))])
+0072 g=gg;
+0073 check =0;
+0074 if max(eig(hh))<0, disp('Negative definite Hessian! Local maximum!' ), pause, end ,
+0075 save m1 x hh g hhg igg fval0
+0076
+0077 igrad=1;
+0078 igibbs=1;
+0079 inx=eye(nx);
+0080 jit=0;
+0081 while norm(gg)>gtol & check ==0 & jit<nit,
+0082 jit=jit+1;
+0083 tic
+0084 icount=icount+1;
+0085 bayestopt_.penalty = fval0(icount);
+0086 disp([' ' ])
+0087 disp(['Iteration ' ,num2str(icount)])
+0088 [fval x0 fc retcode] = csminit (func0,xparam1,fval0(icount),gg,0,igg,varargin{:});
+0089 if igrad,
+0090 [fval1 x01 fc retcode1] = csminit (func0,x0,fval,gg,0,inx,varargin{:});
+0091 if (fval-fval1)>1,
+0092 disp('Gradient step!!' )
+0093 else
+0094 igrad=0;
+0095 end
+0096 fval=fval1;
+0097 x0=x01;
+0098 end
+0099 if (fval0(icount)-fval)<1.e-2*(gg'*(igg*gg))/2 & igibbs,
+0100 [fvala, x0] = mr_gstep (func0,x0,htol,varargin{:});
+0101 if (fval-fvala)<gibbstol*(fval0(icount)-fval),
+0102 igibbs=0;
+0103 disp('Last Gibbs step, gain too small!!' )
+0104 else
+0105 disp('Gibbs step!!' )
+0106 end
+0107 fval=fvala;
+0108 end
+0109 if (fval0(icount)-fval)<ftol & flagit==0,
+0110 disp('Try diagonal Hessian' )
+0111 ihh=diag(1./(diag(hhg)));
+0112 [fval2 x0 fc retcode2] = csminit (func2str(func),x0,fval,gg,0,ihh,varargin{:});
+0113 if (fval-fval2)>=ftol ,
+0114
+0115 disp('Diagonal Hessian successful' )
+0116 end
+0117 fval=fval2;
+0118 end
+0119 if (fval0(icount)-fval)<ftol & flagit==0,
+0120 disp('Try gradient direction' )
+0121 ihh0=inx.*1.e-4;
+0122 [fval3 x0 fc retcode3] = csminit (func2str(func),x0,fval,gg,0,ihh0,varargin{:});
+0123 if (fval-fval3)>=ftol ,
+0124
+0125
+0126 disp('Gradient direction successful' )
+0127 end
+0128 fval=fval3;
+0129 end
+0130 xparam1=x0;
+0131 x(:,icount+1)=xparam1;
+0132 fval0(icount+1)=fval;
+0133
+0134 if (fval0(icount)-fval)<ftol,
+0135 disp('No further improvement is possible!' )
+0136 check =1;
+0137 if flagit==2,
+0138 hh=hh0;
+0139 elseif flagg>0,
+0140 [dum, gg, htol0, igg, hhg]=mr_hessian (func_hh,xparam1,flagg,ftol0,varargin{:});
+0141 if flagg==2,
+0142 hh = reshape(dum,nx,nx);
+0143 ee=eig(hh);
+0144 if min(ee)<0
+0145 hh=hhg;
+0146 end
+0147 else
+0148 hh=hhg;
+0149 end
+0150 end
+0151 disp(['Actual dxnorm ' ,num2str(norm(x(:,end)-x(:,end-1)))])
+0152 disp(['FVAL ' ,num2str(fval)])
+0153 disp(['Improvement ' ,num2str(fval0(icount)-fval)])
+0154 disp(['Ftol ' ,num2str(ftol)])
+0155 disp(['Htol ' ,num2str(htol0)])
+0156 disp(['Gradient norm ' ,num2str(norm(gg))])
+0157 ee=eig(hh);
+0158 disp(['Minimum Hessian eigenvalue ' ,num2str(min(ee))])
+0159 disp(['Maximum Hessian eigenvalue ' ,num2str(max(ee))])
+0160 g(:,icount+1)=gg;
+0161 else
+0162
+0163 df = fval0(icount)-fval;
+0164 disp(['Actual dxnorm ' ,num2str(norm(x(:,end)-x(:,end-1)))])
+0165 disp(['FVAL ' ,num2str(fval)])
+0166 disp(['Improvement ' ,num2str(df)])
+0167 disp(['Ftol ' ,num2str(ftol)])
+0168 disp(['Htol ' ,num2str(htol0)])
+0169
+0170 if df<htol0,
+0171 htol=max(htol_base,df/10);
+0172 end
+0173
+0174 if norm(x(:,icount)-xparam1)>1.e-12,
+0175 save m1 x fval0 -append
+0176 [dum, gg, htol0, igg, hhg]=mr_hessian (func_hh,xparam1,flagit,htol,varargin{:});
+0177 if htol0>htol,
+0178
+0179 htol=htol0;
+0180 disp(' ' )
+0181 disp('Numerical noise in the likelihood' )
+0182 disp('Tolerance has to be relaxed' )
+0183 disp(' ' )
+0184
+0185
+0186 end
+0187 hh0 = reshape(dum,nx,nx);
+0188 hh=hhg;
+0189 if flagit==2,
+0190 if min(eig(hh0))<=0,
+0191 hh0=hhg;
+0192 else
+0193 hh=hh0;
+0194 igg=inv(hh);
+0195 end
+0196 end
+0197 end
+0198 disp(['Gradient norm ' ,num2str(norm(gg))])
+0199 ee=eig(hh);
+0200 disp(['Minimum Hessian eigenvalue ' ,num2str(min(ee))])
+0201 disp(['Maximum Hessian eigenvalue ' ,num2str(max(ee))])
+0202 if max(eig(hh))<0, disp('Negative definite Hessian! Local maximum!' ), pause, end ,
+0203 t=toc;
+0204 disp(['Elapsed time for iteration ' ,num2str(t),' s.' ])
+0205
+0206 g(:,icount+1)=gg;
+0207 save m1 x hh g hhg igg fval0
+0208 end
+0209 end
+0210
+0211 save m1 x hh g hhg igg fval0
+0212 if ftol>ftol0,
+0213 disp(' ' )
+0214 disp('Numerical noise in the likelihood' )
+0215 disp('Tolerance had to be relaxed' )
+0216 disp(' ' )
+0217 end
+0218
+0219 if jit==nit,
+0220 disp(' ' )
+0221 disp('Maximum number of iterations reached' )
+0222 disp(' ' )
+0223 end
+0224
+0225 if norm(gg)<=gtol,
+0226 disp(['Estimation ended:' ])
+0227 disp(['Gradient norm < ' , num2str(gtol)])
+0228 end
+0229 if check ==1,
+0230 disp(['Estimation successful.' ])
+0231 end
+0232
+0233 return
+0234
+0235
+0236 function f00 = lsearch(lam,func,x,dx,varargin)
+0237
+0238
+0239 x0=x-dx*lam;
+0240 f00=feval(func,x0,varargin{:});
+0241
+0242
+0243
+0244
+0245
+0246
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/numgrad.html b/matlab/doc/numgrad.html
new file mode 100644
index 000000000..55f7a7c74
--- /dev/null
+++ b/matlab/doc/numgrad.html
@@ -0,0 +1,144 @@
+
+
+
+ Description of numgrad
+
+
+
+
+
+
+
+
+
+
+
+
+
+numgrad
+
+
+ PURPOSE
+function [g badg] = numgrad(fcn,xvarargin)
+
+ SYNOPSIS
+function [g, badg] = numgrad(fcn,x,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+csminwel [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)
+
+
+
+ SOURCE CODE
+0001 function [g, badg] = numgrad(fcn,x,varargin)
+0002
+0003
+0004 delta = 1e-6;
+0005
+0006 n=length(x);
+0007 tvec=delta*eye(n);
+0008 g=zeros(n,1);
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018 f0 = eval([fcn '(x,varargin{:})' ]);
+0019
+0020
+0021
+0022
+0023 badg=0;
+0024 for i=1:n
+0025 scale=1;
+0026
+0027 if size(x,1)>size(x,2)
+0028 tvecv=tvec(i,:);
+0029 else
+0030 tvecv=tvec(:,i);
+0031 end
+0032 g0 = (eval([fcn '(x+scale*tvecv'', varargin{:})' ]) - f0) ...
+0033 /(scale*delta);
+0034
+0035
+0036
+0037
+0038
+0039
+0040 if abs(g0)< 1e15
+0041 g(i)=g0;
+0042
+0043 else
+0044 disp('bad gradient ------------------------' )
+0045
+0046 g(i)=0;
+0047 badg=1;
+0048
+0049
+0050
+0051 end
+0052 end
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077
+0078
+0079
+0080
+0081
+0082
+0083
+0084
+0085
+0086
+0087
+0088
+0089
+0090
+0091
+0092
+0093
+0094
+0095
+0096
+0097
+0098
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/olr.html b/matlab/doc/olr.html
new file mode 100644
index 000000000..487844785
--- /dev/null
+++ b/matlab/doc/olr.html
@@ -0,0 +1,179 @@
+
+
+
+ Description of olr
+
+
+
+
+
+
+
+
+
+
+
+
+
+olr
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function olr(var_list,olr_inst,obj_var,W)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function olr(var_list,olr_inst,obj_var,W)
+0004 global M_ options_ oo_
+0005
+0006 options_.order = 1;
+0007 options_ = set_default_option (options_,'ar' ,5);
+0008 options_ = set_default_option (options_,'irf' ,40);
+0009 options_ = set_default_option (options_,'dr_algo' ,0);
+0010 options_ = set_default_option (options_,'simul_algo' ,0);
+0011 options_ = set_default_option (options_,'drop' ,100);
+0012 options_ = set_default_option (options_,'replic' ,1);
+0013 options_ = set_default_option (options_,'nomoments' ,0);
+0014 options_ = set_default_option (options_,'nocorr' ,0);
+0015 options_ = set_default_option (options_,'simul_seed' ,[]);
+0016 options_ = set_default_option (options_,'hp_filter' ,0);
+0017 options_ = set_default_option (options_,'hp_ngrid' ,512);
+0018 options_ = set_default_option (options_,'simul' ,0);
+0019 options_ = set_default_option (options_,'olr_beta' ,1);
+0020 options_ = set_default_option (options_,'periods' ,1);
+0021 if options_.simul & ~isempty(options_.periods) & options_.periods == 0
+0022 options_.periods = options_.periods;
+0023 end
+0024
+0025 options_.periods = max(options_.periods,1);
+0026
+0027 make_ex_ ;
+0028
+0029 oo_.dr=olr1 (oo_.steady_state,options_.dr_algo,olr_inst,options_.olr_beta,obj_var,W);
+0030
+0031 disp(' ' )
+0032 disp('OPTIMAL LINEAR REGULATOR' )
+0033 disp(' ' )
+0034 disp('MODEL SUMMARY' )
+0035 disp(' ' )
+0036 disp([' Number of variables: ' int2str(M_.endo_nbr-size(olr_inst,1))])
+0037 disp([' Number of stochastic shocks: ' int2str(M_.exo_nbr)])
+0038 disp([' Number of instruments ' int2str(size(olr_inst,1))])
+0039
+0040
+0041
+0042
+0043 disp([' Number of static variables: ' int2str(oo_.dr.nstatic)])
+0044 my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS' ;
+0045 labels = deblank(M_.exo_name);
+0046 headers = strvcat('Variables' ,labels);
+0047 lh = size(labels,2)+2;
+0048 table (my_title,headers,labels,M_.Sigma_e,lh,10,6);
+0049 disp(' ' )
+0050 disp_dr (oo_.dr,options_.order,var_list);
+0051 if options_.order == 1 & options_.simul == 0 & options_.nomoments == 0
+0052 disp_th_moments (oo_.dr,var_list);
+0053 elseif options_.simul == 1 | options_.nomoments == 0
+0054 if options_.periods == 0
+0055 error('OLR error: number of periods for the simulation isn''t specified' )
+0056 end
+0057 if options_.periods < options_.drop
+0058 disp(['OLR error: The horizon of simulation is shorter' ...
+0059 ' than the number of observations to be DROPed' ])
+0060 return
+0061 end
+0062
+0063 oo_.y_simul = simult (repmat(oo_.dr.ys,1,M_.maximum_lag),oo_.dr);
+0064 dyn2vec ;
+0065 if options_.nomoments == 0
+0066 disp_moments (oo_.y_simul,var_list);
+0067 end
+0068 end
+0069
+0070 n = size(var_list,1);
+0071 if n == 0
+0072 n = length(oo_.dr.order_var);
+0073 ivar = [1:n]';
+0074 var_list = M_.endo_names;
+0075 else
+0076 ivar=zeros(n,1);
+0077 for i=1:n
+0078 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0079 if isempty(i_tmp)
+0080 error (['One of the specified variables does not exist' ]) ;
+0081 else
+0082 ivar(i) = i_tmp;
+0083 end
+0084 end
+0085 end
+0086
+0087 if n < 13 & options_.irf > 0
+0088 if n == 1
+0089 nr = 1;
+0090 nc = 1;
+0091 elseif n == 2
+0092 nr = 1;
+0093 nc = 2;
+0094 elseif n <= 4
+0095 nr = 2;
+0096 nc = 2;
+0097 elseif n <= 6
+0098 nr = 2;
+0099 nc = 3;
+0100 elseif n <= 9
+0101 nr = 3;
+0102 nc = 3;
+0103 elseif n <= 12
+0104 nr = 3;
+0105 nc = 4;
+0106 end
+0107 olditer = options_.periods;
+0108 if options_.order == 1
+0109 options_.replic = 1;
+0110 else
+0111 if options_.replic == 0
+0112 options_.replic = 50;
+0113 end
+0114 end
+0115 for i = 1:M_.exo_nbr
+0116 figure('Name' ,['Shock to ' M_.exo_name(i,:)]);
+0117 y=irf (oo_.dr,M_.exo_name(i,:),sqrt(M_.Sigma_e(i,i)), options_.irf, options_.drop, options_.replic, options_.order);
+0118 m = 1;
+0119 for j = 1:n
+0120 if max(y(ivar(j),:))-min(y(ivar(j),:)) > 1e-10
+0121 subplot(nr,nc,m);
+0122 plot([y(ivar(j),:)']);
+0123 title(var_list(j,:),'Interpreter' ,'none' );
+0124 assignin('base' ,[deblank(var_list(j,:)) '_' deblank(M_.exo_name(i,:))],y(ivar(j),:)');
+0125 m = m + 1;
+0126 end
+0127 end
+0128
+0129 end
+0130 options_.periods = olditer;
+0131 end
+0132
+0133
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/olr1.html b/matlab/doc/olr1.html
new file mode 100644
index 000000000..8bf296b1e
--- /dev/null
+++ b/matlab/doc/olr1.html
@@ -0,0 +1,98 @@
+
+
+
+ Description of olr1
+
+
+
+
+
+
+
+
+
+
+
+
+
+olr1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dr = olr1(ys,algo,olr_inst,bet,obj_var,W)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillarddynare_solve Copyright (C) 2001 Michel Juillardolr2 Copyright (C) 2003 Michel Juillard
+This function is called by:
+
+olr Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dr = olr1(ys,algo,olr_inst,bet,obj_var,W)
+0004
+0005 global M_ options_ oo_
+0006 global it_ means_ stderrs_
+0007
+0008 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0009 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0010 iyv = M_.lead_lag_incidence';
+0011 iyv = iyv(:);
+0012 iyr0 = find(iyv) ;
+0013 it_ = M_.maximum_lag + 1 ;
+0014
+0015
+0016 if M_.exo_nbr == 0
+0017 oo_.exo_steady_state = [] ;
+0018 end
+0019
+0020 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0021 error ('OLR: Error in model specification: some variables don"t appear as current' ) ;
+0022 end
+0023
+0024 if M_.maximum_lead == 0
+0025 error ('Backward or static model: no point in using OLR' ) ;
+0026 end
+0027
+0028 if xlen > 1
+0029 error (['OLR: stochastic exogenous variables must appear only at the' ...
+0030 ' current period. Use additional endogenous variables' ]) ;
+0031 end
+0032
+0033
+0034 tempex = oo_.exo_simul;
+0035 oo_.exo_simul = oo_.exo_steady_state';
+0036 fh = str2func([M_.fname '_static' ]);
+0037 if max(abs(feval(fh,ys))) > options_.dynatol
+0038 [dr.ys, check ] = dynare_solve ([M_.fname '_static' ],ys);
+0039 if check
+0040 error('OLR: convergence problem in DYNARE_SOLVE' )
+0041 end
+0042 else
+0043 dr.ys = ys;
+0044 end
+0045 dr = olr2 (dr,olr_inst,bet,obj_var,W);
+0046 oo_.exo_simul = tempex;
+0047 tempex = [];
+0048
+0049
+0050
+0051
+0052
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/olr2.html b/matlab/doc/olr2.html
new file mode 100644
index 000000000..94ff690e6
--- /dev/null
+++ b/matlab/doc/olr2.html
@@ -0,0 +1,382 @@
+
+
+
+ Description of olr2
+
+
+
+
+
+
+
+
+
+
+
+
+
+olr2
+
+
+ PURPOSE
+Copyright (C) 2003 Michel Juillard
+
+ SYNOPSIS
+function dr=olr2(dr,olr_inst,bet,obj_var,W)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+olr1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005 function dr=olr2(dr,olr_inst,bet,obj_var,W)
+0006
+0007 global M_ options_ oo_
+0008 global it_ stdexo_
+0009
+0010 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0011 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0012 iyv = M_.lead_lag_incidence';
+0013 iyv = iyv(:);
+0014 iyr0 = find(iyv) ;
+0015 it_ = M_.maximum_lag + 1 ;
+0016
+0017 inst_nbr = size(olr_inst,1);
+0018 inst_i = zeros(inst_nbr,1);
+0019 for i=1:inst_nbr
+0020 k = strmatch(olr_inst(i,:),M_.endo_names,'exact' );
+0021 if isempty(k)
+0022 error(sprintf('OLR_INST %s isn''t a declared variable' ));
+0023 else
+0024 inst_i(i) = k;
+0025 end
+0026 end
+0027
+0028 if M_.maximum_lead == 0
+0029 error ('OLR : No forward variable: no point in using OLR' ) ;
+0030 end
+0031
+0032 if find(any(M_.lead_lag_incidence([1:M_.maximum_lag M_.maximum_lag+2:M_.maximum_lead],inst_i),2))
+0033 error('OLR: instruments can only appear at the current period' );
+0034 end
+0035
+0036 non_inst_i = setdiff([1:M_.endo_nbr],inst_i);
+0037 iy1_ = M_.lead_lag_incidence(:,non_inst_i);
+0038 endo_nbr_1 = M_.endo_nbr - inst_nbr;
+0039
+0040 if M_.exo_nbr == 0
+0041 oo_.exo_steady_state = [] ;
+0042 end
+0043
+0044 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0045 error ('Error in model specification: some variables don''t appear as current' ) ;
+0046 end
+0047
+0048 if xlen > 1
+0049 error (['SS: stochastic exogenous variables must appear only at the' ...
+0050 ' current period. Use additional endogenous variables' ]) ;
+0051 end
+0052
+0053 tempex = oo_.exo_simul;
+0054
+0055 it_ = M_.maximum_lag + 1;
+0056 dr.ys = oo_.steady_state;
+0057 z = repmat(dr.ys,1,klen);
+0058 z = z(iyr0) ;
+0059
+0060
+0061 [junk,M_.jacobia] = feval([M_.fname '_dynamic' ],z,oo_.exo_simul);
+0062
+0063 oo_.exo_simul = tempex ;
+0064 tempex = [];
+0065
+0066 nz = size(z,1);
+0067 fwrd_var = find(any(M_.lead_lag_incidence(M_.maximum_lag+2:end ,:),1))';
+0068 if M_.maximum_lag > 0
+0069 pred_var = find(any(M_.lead_lag_incidence(1:M_.maximum_lag,:),1))';
+0070 both_var = intersect(pred_var,fwrd_var);
+0071 pred_var = setdiff(pred_var,both_var);
+0072 fwrd_var = setdiff(fwrd_var,both_var);
+0073 stat_var = setdiff([1:M_.endo_nbr]',union (union (pred_var,both_var),fwrd_var));
+0074 else
+0075 pred_var = [];
+0076 both_var = [];
+0077 stat_var = setdiff([1:M_.endo_nbr]',fwrd_var);
+0078 end
+0079
+0080 stat_var = setdiff(stat_var,inst_i);
+0081
+0082 [stat_obj_var] = intersect(obj_var,stat_var);
+0083 n_stat_obj_var = length(stat_obj_var);
+0084 pred_var = [stat_obj_var; pred_var];
+0085 nboth = length(both_var);
+0086 npred = length(pred_var);
+0087 nfwrd = length(fwrd_var);
+0088 nstatic1 = length(stat_var);
+0089 nstatic = nstatic1-n_stat_obj_var;
+0090
+0091 order_var = [ setdiff(stat_var,obj_var); pred_var; both_var; fwrd_var];
+0092 k1 = M_.lead_lag_incidence(find([1:klen] ~= M_.maximum_lag+1),:);
+0093 b = M_.jacobia(1:endo_nbr_1,M_.lead_lag_incidence(M_.maximum_lag+1,order_var));
+0094 a = b\M_.jacobia(1:endo_nbr_1,nonzeros(k1'));
+0095 if M_.exo_nbr
+0096 fu = -b\M_.jacobia(1:endo_nbr_1,nz+1:end);
+0097 end
+0098
+0099 b = -b\M_.jacobia(1:endo_nbr_1,M_.lead_lag_incidence(M_.maximum_lag+1,inst_i));
+0100
+0101 if M_.maximum_lag > 0
+0102 if M_.maximum_lead > 0
+0103 kmask = [flipud(cumsum(M_.lead_lag_incidence(1:M_.maximum_lag,order_var),1))] ;
+0104 kmask = [kmask; flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+2:end ,order_var)),1))] ;
+0105 end
+0106 else
+0107 kmask = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+2:klen,order_var)),1));
+0108 end
+0109
+0110 kmask(1,nstatic+1:nstatic1) = 1;
+0111 kmask = kmask';
+0112
+0113
+0114
+0115 kmask = kmask(:);
+0116 i_kmask = find(kmask);
+0117 nd = size(i_kmask,1);
+0118 kmask(i_kmask) = [1:nd];
+0119
+0120
+0121
+0122
+0123 kad = [];
+0124 kae = [];
+0125 k1 = find([kmask(1:endo_nbr_1) & kmask(M_.maximum_lag*endo_nbr_1+1:(M_.maximum_lag+1)*endo_nbr_1)] );
+0126 if ~isempty(k1)
+0127 kad = kmask(k1);
+0128 kae = kmask(k1+M_.maximum_lag*endo_nbr_1);
+0129 end
+0130
+0131 if M_.maximum_lag > 1
+0132 k1 = find([kmask(endo_nbr_1+1:M_.maximum_lag*endo_nbr_1) & kmask(1:(M_.maximum_lag-1)*endo_nbr_1)] );
+0133 if ~isempty(k1)
+0134 kad = [kad; kmask(k1+endo_nbr_1)];
+0135 kae = [kae; kmask(k1)];
+0136 end
+0137 end
+0138 if M_.maximum_lead > 1
+0139 k1 = find([kmask((M_.maximum_lag+1)*endo_nbr_1+1:end) & kmask(M_.maximum_lag*endo_nbr_1+1:end-endo_nbr_1)] );
+0140 if ~isempty(k1)
+0141 kad = [kad; kmask(M_.maximum_lag*endo_nbr_1+k1)];
+0142 kae = [kae; kmask((M_.maximum_lag+1)*endo_nbr_1+k1)];
+0143 end
+0144 end
+0145
+0146
+0147
+0148
+0149 kstate = [ repmat([1:endo_nbr_1]',klen-1,1) ...
+0150 [kron([M_.maximum_lag+1:-1:2]',ones(endo_nbr_1,1)); ...
+0151 kron([M_.maximum_lag+2:klen]',ones(endo_nbr_1,1))] ...
+0152 zeros((klen-1)*endo_nbr_1,2)];
+0153 kiy = [flipud(M_.lead_lag_incidence(1:M_.maximum_lag+1,order_var)); M_.lead_lag_incidence(M_.maximum_lag+2:end ,order_var)]';
+0154 kiy = kiy(:);
+0155 i1 = find(kiy((M_.maximum_lag+1)*endo_nbr_1+1:end));
+0156 kstate(i1+M_.maximum_lag*endo_nbr_1,3) = kiy(i1+(M_.maximum_lag+1)*endo_nbr_1)-M_.endo_nbr;
+0157 kstate(1:M_.maximum_lag*endo_nbr_1,4) = kiy(endo_nbr_1+1:(M_.maximum_lag+1)*endo_nbr_1);
+0158
+0159 kstate = kstate(i_kmask,:);
+0160
+0161 sdyn = M_.endo_nbr-nstatic-inst_nbr;
+0162
+0163
+0164 d = zeros(nd,nd) ;
+0165 e = d ;
+0166
+0167
+0168 k = find(kstate(:,2) >= M_.maximum_lag+2 & kstate(:,3));
+0169 d(1:sdyn,k) = a(nstatic+1:end ,kstate(k,3)) ;
+0170 k1 = find(kstate(:,2) == M_.maximum_lag+2);
+0171 a1 = eye(sdyn);
+0172 e(1:sdyn,k1) = -a1(:,kstate(k1,1)-nstatic);
+0173 k = find(kstate(:,2) <= M_.maximum_lag+1 & kstate(:,4));
+0174 e(1:sdyn,k) = -a(nstatic+1:end ,kstate(k,4)) ;
+0175 k2 = find(kstate(:,2) == M_.maximum_lag+1);
+0176 k2 = k2(~ismember(kstate(k2,1),kstate(k1,1)));
+0177 d(1:sdyn,k2) = a1(:,kstate(k2,1)-nstatic);
+0178
+0179 if ~isempty(kad)
+0180 for j = 1:size(kad,1)
+0181 d(sdyn+j,kad(j)) = 1 ;
+0182 e(sdyn+j,kae(j)) = 1 ;
+0183 end
+0184 end
+0185 [Q,R] = qr(d);
+0186 C = Q'*[e [[b(nstatic+1:end ,:) fu(nstatic+1:end ,:)];...
+0187 zeros(nd-sdyn,inst_nbr+M_.exo_nbr)]];
+0188
+0189 nyf = sum(kstate(:,2) > M_.maximum_lag+1);
+0190
+0191
+0192 np = nd - nyf;
+0193
+0194
+0195 dd = zeros(2*nd+inst_nbr,2*nd+inst_nbr);
+0196 ee = dd;
+0197
+0198 dd(1:nd,1:np) = R(:,1:np);
+0199 ee(1:nd,1:np) = C(:,1:np);
+0200 dd(1:nd,nd+1:nd+nyf) = R(:,np+1:end);
+0201 ee(1:nd,nd+1:nd+nyf+inst_nbr) = C(:,np+1:nd+inst_nbr);
+0202
+0203
+0204
+0205
+0206 m = 1;
+0207 v0 = kstate(find(kstate(:,2)==M_.maximum_lag+2),1);
+0208 for i=1:nd;
+0209 if (kstate(i,2) == M_.maximum_lag+1 & isempty(find(kstate(i,1)==v0)))
+0210 k = find(order_var(kstate(i,1))==obj_var);
+0211 if ~isempty(k)
+0212 iq(m) = i;
+0213 m = m+1;
+0214 end
+0215 elseif kstate(i,2) == M_.maximum_lag+2
+0216 k = find(order_var(kstate(i,1))==obj_var);
+0217 if ~isempty(k)
+0218 iq(m) = i;
+0219 m = m+1;
+0220 end
+0221 end
+0222 end
+0223 QQ1 = zeros(nd,nd);
+0224 QQ1(iq,iq) = W(obj_var,obj_var);
+0225 UU1 = zeros(nd,inst_nbr);
+0226 UU1(iq,:) = W(obj_var,inst_i);
+0227 RR = W(inst_i,inst_i);
+0228 offset = nd;
+0229 ee(offset+1:2*offset,1:np) = bet*QQ1(1:np,:)';
+0230 dd(offset+1:2*offset,np+1:nd) = bet*C(np+1:nd,1:nd)';
+0231 ee(offset+1:2*offset,nd+1:nd+nyf) = bet*QQ1(np+1:end ,:)';
+0232 dd(offset+1:2*offset,nd+nyf+inst_nbr+1:end)=bet*C(1:np,1:nd)';
+0233 ee(offset+1:2*offset,np+1:nd) = R(np+1:end ,:)';
+0234 ee(offset+1:2*offset,nd+nyf+1:nd+nyf+inst_nbr) = -bet*UU1;
+0235 ee(offset+1:2*offset,nd+nyf+inst_nbr+1:end) = R(1:np,:)';
+0236
+0237
+0238 offset = 2*nd;
+0239 dd(offset+1:end ,np+1:nd) = -C(np+1:end ,nd+1:nd+inst_nbr)';
+0240 dd(offset+1:end ,nd+nyf+inst_nbr+1:end) = -C(1:np,nd+1:nd+inst_nbr)';
+0241 ee(offset+1:end ,1:np) = UU1(1:np,:)';
+0242 ee(offset+1:end ,nd+1:nd+nyf) = UU1(np+1:end ,:)';
+0243 ee(offset+1:end ,nd+nyf+1:nd+nyf+inst_nbr) = RR;
+0244
+0245 [ss,tt,w,sdim,oo_.eigenvalues,info] = mjdgges(ee,dd);
+0246
+0247 nba = sum(abs(oo_.eigenvalues) > 1+1e-5);
+0248 nyf1 = nd+inst_nbr;
+0249 nd = 2*nd+inst_nbr;
+0250
+0251 if nba ~= nyf1;
+0252 warning('OLR: Blanchard-Kahn conditions are not satisfied.' );
+0253 end
+0254
+0255 np1 = nd - nyf1;
+0256 n2 = np1 + 1;
+0257 n3 = np1;
+0258 n4 = n3 + 1;
+0259
+0260
+0261
+0262 gx = -w(n4:nd,n2:nd)'\w(1:n3,n2:nd)';
+0263
+0264 hx = w(n4:nd,1:np1)'*gx+w(1:n3,1:np1)';
+0265 hx = (tt(1:np1,1:np1)*hx)\(ss(1:np1,1:np1)*hx);
+0266
+0267
+0268 for i=1:M_.maximum_lead
+0269 k = find(kstate(:,2)==M_.maximum_lag+1+i);
+0270 temp = strcat('mult_' ,M_.endo_names(order_var(kstate(k,1)),:));
+0271 temp = strcat(temp,['_' int2str(i)]);
+0272 M_.endo_names = strvcat(M_.endo_names,temp);
+0273 end
+0274
+0275 if nyf > nboth
+0276 order_var = [order_var(1:nstatic+npred+nboth);[M_.endo_nbr+1:M_.endo_nbr+nyf]'; ...
+0277 order_var(nstatic+npred+nboth+1:end); inst_i];
+0278 else
+0279 order_var = [order_var(1:nstatic+npred+nboth);[M_.endo_nbr+1:M_.endo_nbr+nyf]'; ...
+0280 inst_i];
+0281 end
+0282 kstate = [kstate(1:np,:);zeros(nyf,4);kstate(np+1:end ,:);zeros(inst_nbr+np,4)];
+0283 k = find(kstate(:,2) <= M_.maximum_lag+1);
+0284 kstate(np+1:np+nyf,1:2) = [[nstatic+npred+nboth+1:nstatic+npred+nboth+nyf]' ...
+0285 (M_.maximum_lag+1)*ones(nyf,1)];
+0286 kstate(np+2*nyf+1:np+2*nyf+inst_nbr,1:2) = [[endo_nbr_1+1:endo_nbr_1+inst_nbr]' ...
+0287 (M_.maximum_lag+2)*ones(inst_nbr,1)];
+0288 kstate(np+2*nyf+inst_nbr+1:end ,1:2) = [[M_.endo_nbr+1:M_.endo_nbr+np]' (M_.maximum_lag+2)*ones(np,1)];
+0289
+0290 k1 = find(kstate(:,2) == M_.maximum_lag+1);
+0291 k2 = find(kstate(:,2) == M_.maximum_lag+2)-np-nyf;
+0292 dr.ghx = [hx(k1,:); gx(k2(nboth+1:end),:)];
+0293
+0294
+0295
+0296 if M_.exo_nbr
+0297 n1 = find(kstate(:,2) > M_.maximum_lag+1);
+0298 ghu = [dd(:,n1(1):end)*gx+dd(:,1:n1(1)-1) -ee(:,np+nyf+1:end)]\[C(:,end-M_.exo_nbr+1:end); zeros(size(dd,1)-size(C,1),M_.exo_nbr)];
+0299 dr.ghu = [ghu(k1,:);ghu(k2(nboth+1:end)+np+nyf,:)];
+0300 end
+0301
+0302
+0303 if nstatic > 0
+0304 j3 = nonzeros(kstate(:,3));
+0305 j4 = find(kstate(:,3))-np-nyf;
+0306 temp = -a(1:nstatic,j3)*gx(j4,:)*hx;
+0307 temp = temp + b(1:nstatic,:)*gx(nyf+1:nyf+inst_nbr,:);
+0308 j5 = find(kstate(:,4));
+0309 temp(:,j5) = temp(:,j5)-a(1:nstatic,nonzeros(kstate(:,4)));
+0310 dr.ghx = [temp; dr.ghx];
+0311 temp = -a(1:nstatic,j3)*gx(j4,:)*ghu(1:np+nyf,:);
+0312 temp = temp + b(1:nstatic,:)*ghu(np+2*nyf+1:np+2*nyf+inst_nbr,:);
+0313 temp = temp + fu(1:nstatic,:);
+0314 dr.ghu = [temp; dr.ghu];
+0315 temp = [];
+0316 end
+0317
+0318 dr.ghx = dr.ghx(1:M_.endo_nbr+nyf,:);
+0319 dr.ghu = dr.ghu(1:M_.endo_nbr+nyf,:);
+0320
+0321 dr.ys = [dr.ys; zeros(nyf,1)];
+0322 dr.nstatic1 = nstatic1;
+0323 dr.nstatic = nstatic;
+0324 dr.npred = npred+nyf+nboth;
+0325 dr.kstate = kstate;
+0326 dr.order_var = order_var;
+0327 M_.endo_nbr = M_.endo_nbr+nyf;
+0328
+0329
+0330
+0331
+0332
+0333
+0334
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/osr.html b/matlab/doc/osr.html
new file mode 100644
index 000000000..f9a06a8bd
--- /dev/null
+++ b/matlab/doc/osr.html
@@ -0,0 +1,193 @@
+
+
+
+ Description of osr
+
+
+
+
+
+
+
+
+
+
+
+
+
+osr
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function osr(var_list,params,W)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function osr(var_list,params,W)
+0004 global M_ options_ oo_
+0005
+0006 options_.order = 1;
+0007 options_.linear = 1;
+0008 options_ = set_default_option (options_,'ar' ,5);
+0009 options_ = set_default_option (options_,'irf' ,40);
+0010 options_ = set_default_option (options_,'dr_algo' ,0);
+0011 options_ = set_default_option (options_,'simul_algo' ,0);
+0012 options_ = set_default_option (options_,'drop' ,100);
+0013 options_ = set_default_option (options_,'replic' ,1);
+0014 options_ = set_default_option (options_,'nomoments' ,0);
+0015 options_ = set_default_option (options_,'nocorr' ,0);
+0016 options_ = set_default_option (options_,'simul_seed' ,[]);
+0017 options_ = set_default_option (options_,'hp_filter' ,0);
+0018 options_ = set_default_option (options_,'hp_ngrid' ,512);
+0019 options_ = set_default_option (options_,'simul' ,0);
+0020 options_ = set_default_option (options_,'periods' ,1);
+0021 if options_.simul & ~isempty(options_.periods) & options_.periods == 0
+0022 options_.periods = options_.periods;
+0023 end
+0024
+0025 options_.periods = max(options_.periods,1);
+0026 options_.periods = options_.periods;
+0027
+0028 make_ex_ ;
+0029
+0030 disp(' ' )
+0031 disp('OPTIMAL SIMPLE RULE' )
+0032 disp(' ' )
+0033 oo_.dr = osr1 (params,W);
+0034 disp('MODEL SUMMARY' )
+0035 disp(' ' )
+0036 disp([' Number of variables: ' int2str(M_.endo_nbr)])
+0037 disp([' Number of stochastic shocks: ' int2str(M_.exo_nbr)])
+0038 disp([' Number of state variables: ' ...
+0039 int2str(length(find(oo_.dr.kstate(:,2) <= M_.maximum_lag+1)))])
+0040 disp([' Number of jumpers: ' ...
+0041 int2str(length(find(oo_.dr.kstate(:,2) == M_.maximum_lag+2)))])
+0042 disp([' Number of static variables: ' int2str(oo_.dr.nstatic)])
+0043 my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS' ;
+0044 labels = deblank(M_.exo_name);
+0045 headers = strvcat('Variables' ,labels);
+0046 lh = size(labels,2)+2;
+0047 table (my_title,headers,labels,M_.Sigma_e,lh,10,6);
+0048 disp(' ' )
+0049 disp_dr (oo_.dr,options_.order,var_list);
+0050 if options_.order == 1 & options_.simul == 0 & options_.nomoments == 0
+0051 disp_th_moments (oo_.dr,var_list);
+0052 elseif options_.simul == 1 | options_.nomoments == 0
+0053 if options_.periods == 0
+0054 error('OSR error: number of periods for the simulation isn''t specified' )
+0055 end
+0056 if options_.periods < options_.drop
+0057 disp(['OSR error: The horizon of simulation is shorter' ...
+0058 ' than the number of observations to be DROPed' ])
+0059 return
+0060 end
+0061
+0062 oo_.y_simul = simult (repmat(oo_.dr.ys,1,M_.maximum_lag),oo_.dr);
+0063 dyn2vec ;
+0064 if options_.nomoments == 0
+0065 disp_moments (oo_.y_simul,var_list);
+0066 end
+0067 end
+0068
+0069 n = size(var_list,1);
+0070 if n == 0
+0071 n = length(oo_.dr.order_var);
+0072 ivar = [1:n]';
+0073 var_list = M_.endo_names;
+0074 else
+0075 ivar=zeros(n,1);
+0076 for i=1:n
+0077 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0078 if isempty(i_tmp)
+0079 error (['One of the specified variables does not exist' ]) ;
+0080 else
+0081 ivar(i) = i_tmp;
+0082 end
+0083 end
+0084 end
+0085
+0086 if n < 13 & options_.irf > 0
+0087 if n == 1
+0088 nr = 1;
+0089 nc = 1;
+0090 elseif n == 2
+0091 nr = 1;
+0092 nc = 2;
+0093 elseif n <= 4
+0094 nr = 2;
+0095 nc = 2;
+0096 elseif n <= 6
+0097 nr = 2;
+0098 nc = 3;
+0099 elseif n <= 9
+0100 nr = 3;
+0101 nc = 3;
+0102 elseif n <= 12
+0103 nr = 3;
+0104 nc = 4;
+0105 end
+0106 olditer = options_.periods;
+0107 if options_.order == 1
+0108 options_.replic = 1;
+0109 else
+0110 if options_.replic == 0
+0111 options_.replic = 50;
+0112 end
+0113 end
+0114 for i = 1:M_.exo_nbr
+0115 figure('Name' ,['Shock to ' M_.exo_name(i,:)]);
+0116 y=irf (oo_.dr,M_.exo_name(i,:),sqrt(M_.Sigma_e(i,i)), options_.irf, options_.drop, options_.replic, options_.order);
+0117 for j = 1:n
+0118 subplot(nr,nc,j);
+0119 plot([y(ivar(j),:)']);
+0120 title(var_list(j,:),'Interpreter' ,'none' );
+0121 assignin('base' ,[deblank(var_list(j,:)) '_' deblank(M_.exo_name(i,:))],y(ivar(j),:)');
+0122 end
+0123
+0124 end
+0125 options_.periods = olditer;
+0126 end
+0127
+0128
+0129
+0130
+0131
+0132
+0133
+0134
+0135
+0136
+0137
+0138
+0139
+0140
+0141
+0142
+0143
+0144
+0145
+0146
+0147
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/osr1.html b/matlab/doc/osr1.html
new file mode 100644
index 000000000..ebe2a8399
--- /dev/null
+++ b/matlab/doc/osr1.html
@@ -0,0 +1,105 @@
+
+
+
+ Description of osr1
+
+
+
+
+
+
+
+
+
+
+
+
+
+osr1
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function oo_.dr=osr1(params,weights)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillarddynare_solve Copyright (C) 2001 Michel Juillardosr_obj the beginning and the end of this function may be adapted by the userxresol Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+osr Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001 function oo_.dr=osr1(params,weights)
+0002 global M_ oo_ options_ it_
+0003
+0004 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0005 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0006 iyv = M_.lead_lag_incidence';
+0007 iyv = iyv(:);
+0008 iyr0 = find(iyv) ;
+0009 it_ = M_.maximum_lag + 1 ;
+0010
+0011
+0012 if M_.exo_nbr == 0
+0013 oo_.exo_steady_state = [] ;
+0014 end
+0015
+0016 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0017 error ('OLR: Error in model specification: some variables don"t appear as current' ) ;
+0018 end
+0019
+0020 if M_.maximum_lead == 0
+0021 error ('Backward or static model: no point in using OLR' ) ;
+0022 end
+0023
+0024 if xlen > 1
+0025 error (['OLR: stochastic exogenous variables must appear only at the' ...
+0026 ' current period. Use additional endogenous variables' ]) ;
+0027 end
+0028
+0029
+0030 fh = str2func([M_.fname '_static' ]);
+0031 if max(abs(feval(fh,oo_.steady_state))) > options_.dynatol
+0032 [oo_.dr.ys, check ] = dynare_solve ([M_.fname '_static' ],oo_.steady_state);
+0033 if check
+0034 error('OLR: convergence problem in DYNARE_SOLVE' )
+0035 end
+0036 else
+0037 oo_.dr.ys = oo_.steady_state;
+0038 end
+0039
+0040
+0041 np = size(params,1);
+0042 t0 = zeros(np,1);
+0043 for i=1:np
+0044 t0(i)=evalin('base' ,[params(i,:) ';' ]);
+0045 end
+0046
+0047 [p,f]=fminsearch(@osr_obj ,t0,[],params,weights);
+0048
+0049 disp('' )
+0050 disp('OPTIMAL VALUE OF THE PARAMETERS:' )
+0051 disp('' )
+0052 for i=1:np
+0053 disp(sprintf('%16s %16.6g\n' ,params(i,:),p(i)))
+0054 end
+0055 disp(sprintf('Objective function : %16.6g\n' ,f));
+0056 disp(' ' )
+0057 oo_.dr=resol (oo_.steady_state,options_.dr_algo,options_.linear,options_.order);
+0058
+0059
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/osr_obj.html b/matlab/doc/osr_obj.html
new file mode 100644
index 000000000..b15fca18b
--- /dev/null
+++ b/matlab/doc/osr_obj.html
@@ -0,0 +1,105 @@
+
+
+
+ Description of osr_obj
+
+
+
+
+
+
+
+
+
+
+
+
+
+osr_obj
+
+
+ PURPOSE
+the beginning and the end of this function may be adapted by the userx
+
+ SYNOPSIS
+function [z,vx]=osr_obj(x,params,weights);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+resol Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002 function [z,vx]=osr_obj(x,params,weights);
+0003 global M_ oo_ optimal_Q_ it_
+0004
+0005
+0006 np = size(params,1);
+0007 for i=1:np
+0008 assignin('base' ,deblank(params(i,:)),x(i))
+0009 end
+0010
+0011
+0012 it_ = M_.maximum_lag+1;
+0013 oo_.dr = resol (oo_.steady_state,1,0,1);
+0014 nstatic = oo_.dr.nstatic;
+0015 npred = oo_.dr.npred;
+0016 ghx = oo_.dr.ghx;
+0017 ghu = oo_.dr.ghu;
+0018 order = oo_.dr.order_var;
+0019 k=[nstatic+1:nstatic+npred]';
+0020 vx1 = ghu(k,:)*M_.Sigma_e*ghu(k,:)';
+0021
+0022
+0023 vx = (eye(npred*npred)-kron(ghx(k,:),oo_.dr.ghx(k,:)))\vx1(:);
+0024 vx=reshape(vx,npred,npred);
+0025
+0026
+0027 if M_.endo_nbr > npred
+0028 qx = eye(npred);
+0029 qu = zeros(npred,M_.exo_nbr);
+0030 if nstatic > 0
+0031 qx = [ghx(1:nstatic,:);qx];
+0032 qu = [ghu(1:nstatic,:);qu];
+0033 end
+0034 if M_.endo_nbr > nstatic+npred
+0035 qx = [qx;ghx(nstatic+npred+1:end ,:)];
+0036 qu = [qu;ghu(nstatic+npred+1:end ,:)];
+0037 end
+0038 vx = qx*vx*qx'+qu*M_.Sigma_e*qu';
+0039 end
+0040
+0041
+0042
+0043 weights = weights(order,order);
+0044 z = weights(:)'*vx(:);
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+0055
+0056
+0057
+0058
+0059
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/p2toperc.html b/matlab/doc/p2toperc.html
new file mode 100644
index 000000000..36a8a0bcc
--- /dev/null
+++ b/matlab/doc/p2toperc.html
@@ -0,0 +1,75 @@
+
+
+
+ Description of p2toperc
+
+
+
+
+
+
+
+
+
+
+
+
+
+p2toperc
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function y=p2toperc(x)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+fbeta must restrict p2 such that a>0 and b>0 ....fgamma figamm qnorm QNORM The normal inverse distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function y=p2toperc(x)
+0002
+0003 n = size(x,1);
+0004 y = zeros(n,1);
+0005
+0006 for i=1:n
+0007
+0008 if 1
+0009 y(i) = x(i,3);
+0010 else
+0011 if x(i,3) < x(i,2)
+0012 p = 0.05;
+0013 else
+0014 p = 0.95;
+0015 end
+0016
+0017 if x(i,1) == 1
+0018 y(i) = fsolve(@fbeta ,1,p,x(i,2),x(i,3));
+0019 elseif x(i,1) == 2
+0020 y(i) = fsolve(@fgamma ,1,p,x(i,2),x(i,3));
+0021 elseif x(i,1) == 3
+0022 y(i) = (x(i,3)-x(i,2))/qnorm (p,0,1);
+0023 elseif x(i,1) == 4
+0024 y(i) = fsolve(@figamm ,1,p,x(i,2),x(i,3));
+0025 elseif x(i,1) == 5
+0026
+0027 end
+0028 end
+0029 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/pgamma.html b/matlab/doc/pgamma.html
new file mode 100644
index 000000000..68241ba6c
--- /dev/null
+++ b/matlab/doc/pgamma.html
@@ -0,0 +1,63 @@
+
+
+
+ Description of pgamma
+
+
+
+
+
+
+
+
+
+
+
+
+
+pgamma
+
+
+ PURPOSE
+PGAMMA The gamma distribution function
+
+ SYNOPSIS
+function F = pgamma(x,a)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function F = pgamma(x,a)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if any(any(a<=0))
+0010 error('Parameter a is wrong' )
+0011 end
+0012
+0013 F = gammainc(x,a);
+0014 I0 = find(x<0);
+0015 F(I0) = zeros(size(I0));
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/plot_priors.html b/matlab/doc/plot_priors.html
new file mode 100644
index 000000000..829c372e4
--- /dev/null
+++ b/matlab/doc/plot_priors.html
@@ -0,0 +1,185 @@
+
+
+
+ Description of plot_priors
+
+
+
+
+
+
+
+
+
+
+
+
+
+plot_priors
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [07-31-2004]
+
+ SYNOPSIS
+function plot_priors
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function plot_priors
+0002
+0003 global bayestopt_ M_ options_
+0004
+0005 TeX = options_.TeX;
+0006
+0007 figurename = 'Priors' ;
+0008 npar = length(bayestopt_.pmean);
+0009 [nbplt,nr,nc,lr,lc,nstar] = pltorg (npar);
+0010
+0011 if TeX
+0012 fidTeX = fopen([M_.fname '_Priors.TeX' ],'w' );
+0013 fprintf(fidTeX,'%% TeX eps-loader file generated by plot_priors.m (Dynare).\n' );
+0014 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0015 fprintf(fidTeX,' \n' );
+0016 end
+0017 if nbplt == 1
+0018 h1 = figure('Name' ,figurename);
+0019 if TeX
+0020 TeXNAMES = [];
+0021 NAMES = [];
+0022 end
+0023 for i=1:npar
+0024 [x,f,abscissa,dens,binf,bsup] = draw_prior_density (i);
+0025 [nam,texnam] = get_the_name (i,TeX);
+0026 if TeX
+0027 TeXNAMES = strvcat(TeXNAMES,texnam);
+0028 NAMES = strvcat(NAMES,nam);
+0029 end
+0030 subplot(nr,nc,i)
+0031 hh = plot(x,f,'-k' ,'linewidth' ,2);
+0032 set(hh,'color' ,[0.7 0.7 0.7]);
+0033 box on
+0034 title(nam,'Interpreter' ,'none' )
+0035 drawnow
+0036 end
+0037 eval(['print -depsc2 ' M_.fname '_Priors' int2str(1)]);
+0038 eval(['print -dpdf ' M_.fname '_Priors' int2str(1)]);
+0039 saveas(h1,[M_.fname '_Priors' int2str(1) '.fig' ]);
+0040 if options_.nograph, close(h1), end
+0041 if TeX
+0042 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0043 for jj = 1:npar
+0044 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0045 end
+0046 fprintf(fidTeX,'\\centering\n' );
+0047 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n' ,M_.fname,int2str(1));
+0048 fprintf(fidTeX,'\\caption{Priors.}' );
+0049 fprintf(fidTeX,'\\label{Fig:Priors:%s}\n' ,int2str(1));
+0050 fprintf(fidTeX,'\\end{figure}\n' );
+0051 fprintf(fidTeX,' \n' );
+0052 fprintf(fidTeX,'%% End of TeX file.\n' );
+0053 fclose(fidTeX);
+0054 end
+0055 else
+0056 for plt = 1:nbplt-1
+0057 hplt = figure('Name' ,figurename);
+0058 if TeX
+0059 TeXNAMES = [];
+0060 NAMES = [];
+0061 end
+0062 for index=1:nstar
+0063 names = [];
+0064 i = (plt-1)*nstar + index;
+0065 [nam,texnam] = get_the_name (i,TeX);
+0066 [x,f,abscissa,dens,binf,bsup] = draw_prior_density (i);
+0067 if TeX
+0068 TeXNAMES = strvcat(TeXNAMES,texnam);
+0069 NAMES = strvcat(NAMES,nam);
+0070 end
+0071 subplot(nr,nc,index)
+0072 hh = plot(x,f,'-k' ,'linewidth' ,2);
+0073 set(hh,'color' ,[0.7 0.7 0.7]);
+0074 box on
+0075 title(nam,'Interpreter' ,'none' )
+0076 drawnow
+0077 end
+0078 eval(['print -depsc2 ' M_.fname '_Priors' int2str(plt)]);
+0079 eval(['print -dpdf ' M_.fname '_Priors' int2str(plt)]);
+0080 saveas(hplt,[M_.fname '_Priors' int2str(plt) '.fig' ]);
+0081 if options_.nograph, close(hplt), end
+0082 if TeX
+0083 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0084 for jj = 1:nstar
+0085 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0086 end
+0087 fprintf(fidTeX,'\\centering\n' );
+0088 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n' ,M_.fname,int2str(plt));
+0089 fprintf(fidTeX,'\\caption{Priors.}' );
+0090 fprintf(fidTeX,'\\label{Fig:Priors:%s}\n' ,int2str(plt));
+0091 fprintf(fidTeX,'\\end{figure}\n' );
+0092 fprintf(fidTeX,' \n' );
+0093 end
+0094 end
+0095 hplt = figure('Name' ,figurename);
+0096 if TeX
+0097 TeXNAMES = [];
+0098 NAMES = [];
+0099 end
+0100 for index=1:npar-(nbplt-1)*nstar
+0101 i = (nbplt-1)*nstar + index;
+0102 [x,f,abscissa,dens,binf,bsup] = draw_prior_density (i);
+0103 [nam,texnam] = get_the_name (i,TeX);
+0104 if TeX
+0105 TeXNAMES = strvcat(TeXNAMES,texnam);
+0106 NAMES = strvcat(NAMES,nam);
+0107 end
+0108 if lr
+0109 subplot(lc,lr,index);
+0110 else
+0111 subplot(nr,nc,index);
+0112 end
+0113 hh = plot(x,f,'-k' ,'linewidth' ,2);
+0114 set(hh,'color' ,[0.7 0.7 0.7]);
+0115 box on
+0116 title(nam,'Interpreter' ,'none' )
+0117 drawnow
+0118 end
+0119 eval(['print -depsc2 ' M_.fname '_Priors' int2str(nbplt)]);
+0120 eval(['print -dpdf ' M_.fname '_Priors' int2str(nbplt)]);
+0121 saveas(hplt,[M_.fname '_Priors' int2str(nbplt) '.fig' ]);
+0122 if options_.nograph, close(hplt), end
+0123 if TeX
+0124 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0125 for jj = 1:npar-(nbplt-1)*nstar
+0126 fprintf(fidTeX,'\\psfrag{%s}[1][][0.5][0]{%s}\n' ,deblank(NAMES(jj,:)),deblank(TeXNAMES(jj,:)));
+0127 end
+0128 fprintf(fidTeX,'\\centering\n' );
+0129 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_Priors%s}\n' ,M_.fname,int2str(nbplt));
+0130 fprintf(fidTeX,'\\caption{Priors.}' );
+0131 fprintf(fidTeX,'\\label{Fig:Priors:%s}\n' ,int2str(nbplt));
+0132 fprintf(fidTeX,'\\end{figure}\n' );
+0133 fprintf(fidTeX,' \n' );
+0134 fprintf(fidTeX,'%% End of TeX file.\n' );
+0135 fclose(fidTeX);
+0136 end
+0137 end
+0138
+0139
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/pltorg.html b/matlab/doc/pltorg.html
new file mode 100644
index 000000000..c9eb81800
--- /dev/null
+++ b/matlab/doc/pltorg.html
@@ -0,0 +1,131 @@
+
+
+
+ Description of pltorg
+
+
+
+
+
+
+
+
+
+
+
+
+
+pltorg
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [06-07-2004]
+
+ SYNOPSIS
+function [nbplt,nr,nc,lr,lc,nstar] = pltorg(number)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [nbplt,nr,nc,lr,lc,nstar] = pltorg(number)
+0002
+0003 nrstar = 3;
+0004 ncstar = 3;
+0005 nstar = nrstar*ncstar;
+0006 nbplt = 0;
+0007 nr = 0;
+0008 nc = 0;
+0009 lr = 0;
+0010 lc = 0;
+0011 if number == 1
+0012 nbplt = 1;
+0013 nr = 1;
+0014 nc = 1;
+0015 elseif number == 2
+0016 nbplt = 1;
+0017 nr = 2;
+0018 nc = 1;
+0019 elseif number == 3
+0020 nbplt = 1;
+0021 nr = 3;
+0022 nc = 1;
+0023 elseif number == 4
+0024 nbplt = 1;
+0025 nr = 2;
+0026 nc = 2;
+0027 elseif number == 5
+0028 nbplt = 1;
+0029 nr = 3;
+0030 nc = 2;
+0031 elseif number == 6
+0032 nbplt = 1;
+0033 nr = 3;
+0034 nc = 2;
+0035 elseif number == 7
+0036 nbplt = 1;
+0037 nr = 3;
+0038 nc = 3;
+0039 elseif number == 8
+0040 nbplt = 1;
+0041 nr = 3;
+0042 nc = 3;
+0043 elseif number == 9
+0044 nbplt = 1;
+0045 nr = 3;
+0046 nc = 3;
+0047 else
+0048 if number/nstar == round(number/nstar)
+0049 nbplt = number/nstar;
+0050 nr = nrstar;
+0051 nc = ncstar;
+0052 lr = nr;
+0053 lc = nc;
+0054 else
+0055 nbplt = ceil(number/nstar);
+0056 nr = nrstar;
+0057 nc = ncstar;
+0058 reste = number-(nbplt-1)*nstar;
+0059 if reste == 1
+0060 lr = 1;
+0061 lc = 1;
+0062 elseif reste == 2
+0063 lr = 2;
+0064 lc = 1;
+0065 elseif reste == 3
+0066 lr = 3;
+0067 lc = 1;
+0068 elseif reste == 4
+0069 lr = 2;
+0070 lc = 2;
+0071 elseif reste == 5
+0072 lr = 3;
+0073 lc = 2;
+0074 elseif reste == 6
+0075 lr = 3;
+0076 lc = 2;
+0077 elseif reste == 7
+0078 lr = 3;
+0079 lc = 3;
+0080 elseif reste == 8
+0081 lr = 3;
+0082 lc = 3;
+0083 end
+0084 end
+0085 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/pnorm.html b/matlab/doc/pnorm.html
new file mode 100644
index 000000000..258f8fcc4
--- /dev/null
+++ b/matlab/doc/pnorm.html
@@ -0,0 +1,59 @@
+
+
+
+ Description of pnorm
+
+
+
+
+
+
+
+
+
+
+
+
+
+pnorm
+
+
+ PURPOSE
+PNORM The normal distribution function
+
+ SYNOPSIS
+function p = pnorm(x,m,s)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function p = pnorm(x,m,s)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if nargin<3, s=1; end
+0010 if nargin<2, m=0; end
+0011 p = (1+erf((x-m)./(sqrt(2).*s)))/2;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/posterior_density_estimate.html b/matlab/doc/posterior_density_estimate.html
new file mode 100644
index 000000000..3670e571f
--- /dev/null
+++ b/matlab/doc/posterior_density_estimate.html
@@ -0,0 +1,234 @@
+
+
+
+ Description of posterior_density_estimate
+
+
+
+
+
+
+
+
+
+Home >
. > posterior_density_estimate.m
+
+
+
+posterior_density_estimate
+
+
+ PURPOSE
+%
+
+ SYNOPSIS
+function [abscissa,f,h] = posterior_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [abscissa,f,h] = posterior_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014 if size(data,2) > 1 & size(data,1) == 1;
+0015 data = data';
+0016 elseif size(data,2)>1 & size(data,1)>1;
+0017 error('density_estimate: data must be a one dimensional array.' );
+0018 end ;
+0019 test = log(number_of_grid_points)/log(2);
+0020 if ( abs(test-round(test)) > 10^(-12));
+0021 error('The number of grid points must be a power of 2.' );
+0022 end ;
+0023
+0024 n = size(data,1);
+0025
+0026
+0027
+0028
+0029 if strcmp(kernel_function,'gaussian' );
+0030 k = inline('inv(sqrt(2*pi))*exp(-0.5*x.^2)' );
+0031 k2 = inline('inv(sqrt(2*pi))*(-exp(-0.5*x.^2)+(x.^2).*exp(-0.5*x.^2))' );
+0032 k4 = inline('inv(sqrt(2*pi))*(3*exp(-0.5*x.^2)-6*(x.^2).*exp(-0.5*x.^2)+(x.^4).*exp(-0.5*x.^2))' );
+0033 k6 = inline('inv(sqrt(2*pi))*(-15*exp(-0.5*x.^2)+45*(x.^2).*exp(-0.5*x.^2)-15*(x.^4).*exp(-0.5*x.^2)+(x.^6).*exp(-0.5*x.^2))' );
+0034 mu02 = inv(2*sqrt(pi));
+0035 mu21 = 1;
+0036 elseif strcmp(kernel_function,'uniform' );
+0037 k = inline('0.5*(abs(x) <= 1)' );
+0038 mu02 = 0.5;
+0039 mu21 = 1/3;
+0040 elseif strcmp(kernel_function,'triangle' );
+0041 k = inline('(1-abs(x)).*(abs(x) <= 1)' );
+0042 mu02 = 2/3;
+0043 mu21 = 1/6;
+0044 elseif strcmp(kernel_function,'epanechnikov' );
+0045 k = inline('0.75*(1-x.^2).*(abs(x) <= 1)' );
+0046 mu02 = 3/5;
+0047 mu21 = 1/5;
+0048 elseif strcmp(kernel_function,'quartic' );
+0049 k = inline('0.9375*((1-x.^2).^2).*(abs(x) <= 1)' );
+0050 mu02 = 15/21;
+0051 mu21 = 1/7;
+0052 elseif strcmp(kernel_function,'triweight' );
+0053 k = inline('1.09375*((1-x.^2).^3).*(abs(x) <= 1)' );
+0054 k2 = inline('(105/4*(1-x.^2).*x.^2-105/16*(1-x.^2).^2).*(abs(x) <= 1)' );
+0055 k4 = inline('(-1575/4*x.^2+315/4).*(abs(x) <= 1)' );
+0056 k6 = inline('(-1575/2).*(abs(x) <= 1)' );
+0057 mu02 = 350/429;
+0058 mu21 = 1/9;
+0059 elseif strcmp(kernel_function,'cosinus' );
+0060 k = inline('(pi/4)*cos((pi/2)*x).*(abs(x) <= 1)' );
+0061 k2 = inline('(-1/16*cos(pi*x/2)*pi^3).*(abs(x) <= 1)' );
+0062 k4 = inline('(1/64*cos(pi*x/2)*pi^5).*(abs(x) <= 1)' );
+0063 k6 = inline('(-1/256*cos(pi*x/2)*pi^7).*(abs(x) <= 1)' );
+0064 mu02 = (pi^2)/16;
+0065 mu21 = (pi^2-8)/pi^2;
+0066 end ;
+0067
+0068
+0069
+0070
+0071 if bandwidth == 0;
+0072
+0073 sigma = std(data);
+0074 h = 2*sigma*(sqrt(pi)*mu02/(12*(mu21^2)*n))^(1/5);
+0075 A = 0;
+0076 for i=1:n;
+0077 j = i;
+0078 while j<= n & data(j,1)==data(i,1);
+0079 j = j+1;
+0080 end ;
+0081 A = A + 2*(j-i) - 1;
+0082 end ;
+0083 A = A/n;
+0084 h = h*A^(1/5);
+0085 elseif bandwidth == -1;
+0086
+0087 if strcmp(kernel_function,'uniform' ) | ...
+0088 strcmp(kernel_function,'triangle' ) | ...
+0089 strcmp(kernel_function,'epanechnikov' ) | ...
+0090 strcmp(kernel_function,'quartic' );
+0091 error('I can''t compute the optimal bandwidth with this kernel... Try the gaussian, triweight or cosinus kernels.' );
+0092 end ;
+0093 sigma = std(data);
+0094 A = 0;
+0095 for i=1:n;
+0096 j = i;
+0097 while j<= n & data(j,1)==data(i,1);
+0098 j = j+1;
+0099 end ;
+0100 A = A + 2*(j-i) - 1;
+0101 end ;
+0102 A = A/n;
+0103 Itilda4 = 8*7*6*5/(((2*sigma)^9)*sqrt(pi));
+0104 g3 = abs(2*A*k6(0)/(mu21*Itilda4*n))^(1/9);
+0105 Ihat3 = 0;
+0106 for i=1:n;
+0107 Ihat3 = Ihat3 + sum(k6((data(i,1)-data)/g3));
+0108 end ;
+0109 Ihat3 = -Ihat3/((n^2)*g3^7);
+0110 g2 = abs(2*A*k4(0)/(mu21*Ihat3*n))^(1/7);
+0111 Ihat2 = 0;
+0112 for i=1:n;
+0113 Ihat2 = Ihat2 + sum(k4((data(i)-data)/g2));
+0114 end ;
+0115 Ihat2 = Ihat2/((n^2)*g2^5);
+0116 h = (A*mu02/(n*Ihat2*mu21^2))^(1/5);
+0117 elseif bandwidth == -2;
+0118
+0119 if strcmp(kernel_function,'uniform' ) | ...
+0120 strcmp(kernel_function,'triangle' ) | ...
+0121 strcmp(kernel_function,'epanechnikov' ) | ...
+0122 strcmp(kernel_function,'quartic' );
+0123 error('I can''t compute the optimal bandwidth with this kernel... Try the gaussian, triweight or cosinus kernels.' );
+0124 end ;
+0125 sigma = std(data);
+0126 A = 0;
+0127 T = zeros(n,1);
+0128 for i=1:n;
+0129 j = i;
+0130 while j<= n & data(j,1)==data(i,1);
+0131 j = j+1;
+0132 end ;
+0133 T(i) = (j-i);
+0134 A = A + 2*T(i) - 1;
+0135 end ;
+0136 A = A/n;
+0137 Itilda4 = 8*7*6*5/(((2*sigma)^9)*sqrt(pi));
+0138 g3 = abs(2*A*k6(0)/(mu21*Itilda4*n))^(1/9);
+0139 Ihat3 = 0;
+0140 for i=1:n;
+0141 Ihat3 = Ihat3 + sum(k6((data(i,1)-data)/g3));
+0142 end ;
+0143 Ihat3 = -Ihat3/((n^2)*g3^7);
+0144 g2 = abs(2*A*k4(0)/(mu21*Ihat3*n))^(1/7);
+0145 Ihat2 = 0;
+0146 for i=1:n;
+0147 Ihat2 = Ihat2 + sum(k4((data(i)-data)/g2));
+0148 end ;
+0149 Ihat2 = Ihat2/((n^2)*g2^5);
+0150 h = ((2*T-1)*mu02/(n*Ihat2*mu21^2)).^(1/5);
+0151 elseif bandwidth > 0;
+0152 h = bandwidth;
+0153 else ;
+0154 error('density_estimate: bandwidth must be positive or equal to 0,-1 or -2.' );
+0155 end ;
+0156
+0157
+0158
+0159
+0160
+0161
+0162
+0163 a = min(data) - (max(data)-min(data))/3;
+0164 b = max(data) + (max(data)-min(data))/3;
+0165 abscissa = linspace(a,b,number_of_grid_points)';
+0166 d = abscissa(2)-abscissa(1);
+0167 xi = zeros(number_of_grid_points,1);
+0168 xa = (data-a)/(b-a)*number_of_grid_points;
+0169 for i = 1:n;
+0170 indx = floor(xa(i));
+0171 temp = xa(i)-indx;
+0172 xi(indx+[1 2]) = xi(indx+[1 2]) + [1-temp,temp]';
+0173 end ;
+0174 xk = [-number_of_grid_points:number_of_grid_points-1]'*d;
+0175 kk = k(xk/h);
+0176 kk = kk / (sum(kk)*d*n);
+0177 f = ifft(fft(fftshift(kk)).*fft([xi ;zeros(size(xi))]));
+0178 f = real(f(1:number_of_grid_points));
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/posterior_distribution.html b/matlab/doc/posterior_distribution.html
new file mode 100644
index 000000000..1cd1117dc
--- /dev/null
+++ b/matlab/doc/posterior_distribution.html
@@ -0,0 +1,118 @@
+
+
+
+ Description of posterior_distribution
+
+
+
+
+
+
+
+
+
+Home >
. > posterior_distribution.m
+
+
+
+posterior_distribution
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [07-15-2004]
+
+ SYNOPSIS
+function [borneinf,bornesup,x1,x2,f1,f2,top,nam,texnam] =posterior_distribution(indx,number_of_mh_files,first_mh_file,first_line,number_of_blocks,number_of_simulations,number_of_simulations_per_file,TeX);
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [borneinf,bornesup,x1,x2,f1,f2,top,nam,texnam] = ...
+0002 posterior_distribution(indx,number_of_mh_files,first_mh_file,first_line,...
+0003 number_of_blocks,number_of_simulations,...
+0004 number_of_simulations_per_file,TeX);
+0005
+0006
+0007 global M_ bayestopt_ estim_params_ options_
+0008
+0009 number_of_grid_points = 2^9;
+0010 bandwidth = 0;
+0011 kernel_function = 'gaussian' ;
+0012
+0013
+0014 mcsimulations = zeros(number_of_simulations,1);
+0015
+0016 if number_of_blocks == 1
+0017 EndOfFile = number_of_simulations_per_file(first_mh_file+1)-first_line+1;
+0018 instr = [M_.fname '_mh' int2str(first_mh_file)];
+0019 eval(['load ' instr]);
+0020 clear post2 logpo2;
+0021 mcsimulations(1:EndOfFile) = x2(first_line:end ,indx);
+0022 OldEndOfFile = EndOfFile;
+0023 for f = first_mh_file+1:number_of_mh_files
+0024 NewEndOfFile = number_of_simulations_per_file(f+1);
+0025 instr = [M_.fname '_mh' int2str(f)];
+0026 eval(['load ' instr]);
+0027 clear post2 logpo2;
+0028 mcsimulations(OldEndOfFile+1:OldEndOfFile+NewEndOfFile) = x2(:,indx);
+0029 OldEndOfFile = OldEndOfFile + NewEndOfFile;
+0030 end
+0031 clear x2;
+0032 else
+0033 EndOfFile = number_of_simulations_per_file(first_mh_file+1)-first_line+1;
+0034 NewStartLine = 0;
+0035 inst = [M_.fname '_mh' int2str(first_mh_file)];
+0036 for b = 1:number_of_blocks
+0037 instr = [inst '_blck' int2str(b)];
+0038 eval(['load ' instr]);
+0039 clear post2 logpo2;
+0040 mcsimulations(NewStartLine+1:NewStartLine+EndOfFile,1) = x2(first_line:end ,indx);
+0041 NewStartLine = NewStartLine + EndOfFile;
+0042 end
+0043 for f = first_mh_file+1:number_of_mh_files
+0044 EndOfFile = number_of_simulations_per_file(f+1);
+0045 inst = [M_.fname '_mh' int2str(f)];
+0046 for B = 1:number_of_blocks
+0047 instr = [inst '_blck' int2str(b)];
+0048 eval(['load ' instr]);
+0049 clear post2 logpo2;
+0050 mcsimulations(NewStartLine+1:NewStartLine+EndOfFile,1) = x2(:,indx);
+0051 NewStartLine = NewStartLine + EndOfFile;
+0052 end
+0053 end
+0054 clear x2;
+0055 end
+0056
+0057 [nam,texnam] = get_the_name (indx,TeX);
+0058
+0059
+0060 optimal_bandwidth = mh_optimal_bandwidth (mcsimulations,number_of_simulations,bandwidth,kernel_function);
+0061 [x1,f1] = kernel_density_estimate (mcsimulations,number_of_grid_points,...
+0062 optimal_bandwidth,kernel_function);
+0063 binf1 = x1(1);
+0064 bsup1 = x1(length(x1));
+0065
+0066
+0067 [x2,f2,abscissa,dens,binf2,bsup2] = draw_prior_density (indx);
+0068 clear abscissa dens;
+0069
+0070 borneinf = min(binf1,binf2);
+0071 bornesup = max(bsup1,bsup2);
+0072 top = max([max(f1);max(f2)]);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/posterior_moments.html b/matlab/doc/posterior_moments.html
new file mode 100644
index 000000000..3f0c151cb
--- /dev/null
+++ b/matlab/doc/posterior_moments.html
@@ -0,0 +1,90 @@
+
+
+
+ Description of posterior_moments
+
+
+
+
+
+
+
+
+
+Home >
. > posterior_moments.m
+
+
+
+posterior_moments
+
+
+ PURPOSE
+stephane.adjemian@ens.fr [09-09-2005]
+
+ SYNOPSIS
+function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)
+0002
+0003
+0004 global options_
+0005
+0006 xx = xx(:);
+0007 xx = sort(xx);
+0008
+0009
+0010 post_mean = mean(xx);
+0011 post_median = median(xx);
+0012 post_var = var(xx);
+0013
+0014 n = length(xx);
+0015 m = round((1-options_.mh_conf_sig)*n);
+0016 k = zeros(m,1);
+0017 jj = n-m;
+0018 for ii = 1:m
+0019 k(ii) = xx(jj)-xx(ii);
+0020 jj = jj + 1;
+0021 end
+0022 [kmin,idx] = min(k);
+0023 hpd_interval = [xx(idx) xx(idx)+kmin];
+0024
+0025 post_deciles = xx([round(0.1*n) ...
+0026 round(0.2*n)...
+0027 round(0.3*n)...
+0028 round(0.4*n)...
+0029 round(0.5*n)...
+0030 round(0.6*n)...
+0031 round(0.7*n)...
+0032 round(0.8*n)...
+0033 round(0.9*n)]);
+0034
+0035 if ~info
+0036 density = [];
+0037 else
+0038 number_of_grid_points = 2^9;
+0039 bandwidth = 0;
+0040 kernel_function = 'gaussian' ;
+0041 optimal_bandwidth = mh_optimal_bandwidth (xx,length(xx),bandwidth,kernel_function);
+0042 [density(:,1),density(:,2)] = kernel_density_estimate (xx,number_of_grid_points,optimal_bandwidth,kernel_function);
+0043 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/print_info.html b/matlab/doc/print_info.html
new file mode 100644
index 000000000..16979d7c5
--- /dev/null
+++ b/matlab/doc/print_info.html
@@ -0,0 +1,85 @@
+
+
+
+ Description of print_info
+
+
+
+
+
+
+
+
+
+
+
+
+
+print_info
+
+
+ PURPOSE
+Copyright (C) 2005 Michel Juillard
+
+ SYNOPSIS
+function print_info(info)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+check Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function print_info(info)
+0004 global options_
+0005
+0006 options_ = set_default_option (options_,'noprint' ,0);
+0007
+0008 if ~options_.noprint
+0009 if info(1) > 10 & info(1) < 20
+0010 disp('Failure in dr_algo=2' )
+0011 info(1) = info(1) - 10;
+0012 end
+0013 switch info(1)
+0014 case 1
+0015 error(['The model doesn''t determine the current variables' ...
+0016 ' uniquely' ])
+0017 case 2
+0018 error(['MJDGGES returns the following error code' ...
+0019 int2str(info(2))])
+0020 case 3
+0021 error(['Blanchard Kahn conditions are not satisfied: no stable' ...
+0022 ' equilibrium' ])
+0023 case 4
+0024 error(['Blanchard Kahn conditions are not satisfied:' ...
+0025 ' indeterminacy' ])
+0026 case 5
+0027 error(['Blanchard Kahn conditions are not satisfied:' ...
+0028 ' indeterminacy due to rank failure' ])
+0029 case 20
+0030 error(['Impossible to find the steady state. Either the model' ...
+0031 ' doesn''t have a unique steady state of the guess values' ...
+0032 ' are too far from the solution' ])
+0033 case 30
+0034 error('Variance can''t be computed' )
+0035 otherwise
+0036 error('This case shouldn''t happen. Contact the authors of Dynare' )
+0037 end
+0038 end
+0039
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/prior_bounds.html b/matlab/doc/prior_bounds.html
new file mode 100644
index 000000000..f1bc7d93e
--- /dev/null
+++ b/matlab/doc/prior_bounds.html
@@ -0,0 +1,90 @@
+
+
+
+ Description of prior_bounds
+
+
+
+
+
+
+
+
+
+Home >
. > prior_bounds.m
+
+
+
+prior_bounds
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function bounds = prior_bounds(bayestopt)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+mj_qgamma MJ_QGAMMA The gamma inverse distribution functionqbeta QBETA The beta inverse distribution functionqnorm QNORM The normal inverse distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function bounds = prior_bounds(bayestopt)
+0002 global options_
+0003
+0004 pshape = bayestopt.pshape;
+0005 pmean = bayestopt.pmean;
+0006 p2 = bayestopt.p2;
+0007 p3 = bayestopt.p3;
+0008 p4 = bayestopt.p4;
+0009
+0010 n = length(pmean);
+0011 bounds = zeros(n,2);
+0012
+0013 for i=1:n
+0014 switch pshape(i)
+0015 case 1
+0016 mu = (pmean(i)-p3(i))/(p4(i)-p3(i));
+0017 stdd = p2(i)/(p4(i)-p3(i));
+0018 A = (1-mu)*mu^2/stdd^2 - mu;
+0019 B = A*(1/mu - 1);
+0020 bounds(i,1) = qbeta (options_.prior_trunc,A,B)*(p4(i)-p3(i))+p3(i);
+0021 bounds(i,2) = qbeta (1-options_.prior_trunc,A,B)*(p4(i)-p3(i))+p3(i);
+0022 case 2
+0023 b = p2(i)^2/(pmean(i)-p3(i));
+0024 a = (pmean(i)-p3(i))/b;
+0025 bounds(i,1) = mj_qgamma (options_.prior_trunc,a)*b+p3(i);
+0026 bounds(i,2) = mj_qgamma (1-options_.prior_trunc,a)*b+p3(i);
+0027 case 3
+0028 bounds(i,1) = qnorm (options_.prior_trunc,pmean(i),p2(i));
+0029 bounds(i,2) = qnorm (1-options_.prior_trunc,pmean(i),p2(i));
+0030 case 4
+0031 nu = p2(i);
+0032 mu = pmean(i);
+0033 beta = ( gamma( (nu-1)/2 ) / mu / gamma( nu/2 ) )^2;
+0034 a=2/beta;
+0035 bounds(i,1) = 1/sqrt(mj_qgamma (1-options_.prior_trunc,p2(i)/2)*beta);
+0036 bounds(i,2) = 1/sqrt(mj_qgamma (options_.prior_trunc,p2(i)/2)*beta);
+0037 case 5
+0038 bounds(i,1) = p3(i);
+0039 bounds(i,2) = p4(i);
+0040 otherwise
+0041 bounds(i,1) = -Inf;
+0042 bounds(i,2) = Inf;
+0043 end
+0044 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/priordens.html b/matlab/doc/priordens.html
new file mode 100644
index 000000000..6c2d27eb6
--- /dev/null
+++ b/matlab/doc/priordens.html
@@ -0,0 +1,99 @@
+
+
+
+ Description of priordens
+
+
+
+
+
+
+
+
+
+
+
+
+
+priordens
+
+
+ PURPOSE
+This procedure computes a prior density for
+
+ SYNOPSIS
+function lnprior = priordens(para, pshape, p1, p2, p3, p4)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function lnprior = priordens(para, pshape, p1, p2, p3, p4)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011 lnprior = 0;
+0012 nprio = length(pshape);
+0013
+0014 i = 1;
+0015 while i <= nprio;
+0016 a = 0;
+0017 b = 0;
+0018 if pshape(i) == 1;
+0019 mu = (p1(i)-p3(i))/(p4(i)-p3(i));
+0020 stdd = p2(i)/(p4(i)-p3(i));
+0021 a = (1-mu)*mu^2/stdd^2 - mu;
+0022 b = a*(1/mu - 1);
+0023 lnprior = lnprior + lpdfgbeta (para(i),a,b,p3(i),p4(i)) ;
+0024 elseif pshape(i) == 2;
+0025 b = p2(i)^2/(p1(i)-p3(i));
+0026 a = (p1(i)-p3(i))/b;
+0027 lnprior = lnprior + lpdfgam (para(i)-p3(i),a,b);
+0028 elseif pshape(i) == 3;
+0029 lnprior = lnprior + lpdfnorm (para(i),p1(i),p2(i));
+0030 elseif pshape(i) == 4;
+0031 lnprior = lnprior + lpdfig1 (para(i),p1(i),p2(i));
+0032 elseif pshape(i) == 5;
+0033 lnprior = lnprior + log(1/(p2(i)-p1(i)));
+0034 elseif pshape(i) == 6;
+0035 lnprior = lnprior + lpdfig2 (para(i),p1(i),p2(i));
+0036 end ;
+0037 i = i+1;
+0038 end ;
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/qbeta.html b/matlab/doc/qbeta.html
new file mode 100644
index 000000000..0a2ce5004
--- /dev/null
+++ b/matlab/doc/qbeta.html
@@ -0,0 +1,74 @@
+
+
+
+ Description of qbeta
+
+
+
+
+
+
+
+
+
+
+
+
+
+qbeta
+
+
+ PURPOSE
+QBETA The beta inverse distribution function
+
+ SYNOPSIS
+function x = qbeta(p,a,b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+dbeta DBETA The beta density function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x = qbeta(p,a,b)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if any(any((a<=0)|(b<=0)))
+0010 error('Parameter a or b is nonpositive' )
+0011 end
+0012 if any(any(abs(2*p-1)>1))
+0013 error('A probability should be 0<=p<=1, please!' )
+0014 end
+0015 b = min(b,100000);
+0016
+0017 x = a ./ (a+b);
+0018 dx = 1;
+0019 while any(any(abs(dx)>256*eps*max(x,1)))
+0020 dx = (betainc(x,a,b) - p) ./ dbeta (x,a,b);
+0021 x = x - dx;
+0022 x = x + (dx - x) / 2 .* (x<0);
+0023 x = x + (1 + (dx - x)) / 2 .* (x>1);
+0024 end
+0025
+0026
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/qchisq.html b/matlab/doc/qchisq.html
new file mode 100644
index 000000000..0d4176ce7
--- /dev/null
+++ b/matlab/doc/qchisq.html
@@ -0,0 +1,64 @@
+
+
+
+ Description of qchisq
+
+
+
+
+
+
+
+
+
+
+
+
+
+qchisq
+
+
+ PURPOSE
+QCHISQ The chisquare inverse distribution function
+
+ SYNOPSIS
+function x = qchisq(p,a)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+qgamma QGAMMA The gamma inverse distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x = qchisq(p,a)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if any(any(abs(2*p-1)>1))
+0010 error('A probability should be 0<=p<=1, please!' )
+0011 end
+0012 if any(any(a<=0))
+0013 error('DegreesOfFreedom is wrong' )
+0014 end
+0015
+0016 x = qgamma (p,a*0.5)*2;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/qgamma.html b/matlab/doc/qgamma.html
new file mode 100644
index 000000000..2a086b983
--- /dev/null
+++ b/matlab/doc/qgamma.html
@@ -0,0 +1,75 @@
+
+
+
+ Description of qgamma
+
+
+
+
+
+
+
+
+
+
+
+
+
+qgamma
+
+
+ PURPOSE
+QGAMMA The gamma inverse distribution function
+
+ SYNOPSIS
+function x = qgamma(p,a)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+dgamma DGAMMA The gamma density functionpgamma PGAMMA The gamma distribution function
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x = qgamma(p,a)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if any(any(abs(2*p-1)>1))
+0010 error('A probability should be 0<=p<=1, please!' )
+0011 end
+0012 if any(any(a<=0))
+0013 error('Parameter a is wrong' )
+0014 end
+0015
+0016 x = max(a-1,0.1);
+0017 dx = 1;
+0018 while any(any(abs(dx)>256*eps*max(x,1)))
+0019 dx = (pgamma (x,a) - p) ./ dgamma (x,a,1);
+0020 x = x - dx;
+0021 x = x + (dx - x) / 2 .* (x<0);
+0022 end
+0023
+0024 I0 = find(p==0);
+0025 x(I0) = zeros(size(I0));
+0026 I1 = find(p==1);
+0027 x(I1) = zeros(size(I1)) + Inf;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/qnorm.html b/matlab/doc/qnorm.html
new file mode 100644
index 000000000..1dbe12d4b
--- /dev/null
+++ b/matlab/doc/qnorm.html
@@ -0,0 +1,68 @@
+
+
+
+ Description of qnorm
+
+
+
+
+
+
+
+
+
+
+
+
+
+qnorm
+
+
+ PURPOSE
+QNORM The normal inverse distribution function
+
+ SYNOPSIS
+function x = qnorm(p,m,s)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x = qnorm(p,m,s)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009 if nargin<3, s=1; end
+0010 if nargin<2, m=0; end
+0011
+0012 if any(any(abs(2*p-1)>1))
+0013 error('A probability should be 0<=p<=1, please!' )
+0014 end
+0015 if any(any(s<=0))
+0016 error('Parameter s is wrong' )
+0017 end
+0018
+0019 x = erfinv(2*p-1).*sqrt(2).*s + m;
+0020
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/qzdiv.html b/matlab/doc/qzdiv.html
new file mode 100644
index 000000000..0f44bd319
--- /dev/null
+++ b/matlab/doc/qzdiv.html
@@ -0,0 +1,81 @@
+
+
+
+ Description of qzdiv
+
+
+
+
+
+
+
+
+
+
+
+
+
+qzdiv
+
+
+ PURPOSE
+from Chris Sims web site
+
+ SYNOPSIS
+function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dr1 Copyright (C) 2001 Michel Juillarddr11 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005 function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013 [n jnk] = size(A);
+0014 root = abs([diag(A) diag(B)]);
+0015 root(:,1) = root(:,1)-(root(:,1)<1.e-13).*(root(:,1)+root(:,2));
+0016 root(:,2) = root(:,2)./root(:,1);
+0017 for i = n:-1:1
+0018 m=0;
+0019 for j=i:-1:1
+0020 if (root(j,2) > stake | root(j,2) < -.1)
+0021 m=j;
+0022 break
+0023 end
+0024 end
+0025 if (m==0)
+0026 return
+0027 end
+0028 for k=m:1:i-1
+0029 [A B Q Z] = qzswitch (k,A,B,Q,Z);
+0030 tmp = root(k,2);
+0031 root(k,2) = root(k+1,2);
+0032 root(k+1,2) = tmp;
+0033 end
+0034 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/qzswitch.html b/matlab/doc/qzswitch.html
new file mode 100644
index 000000000..713e521dc
--- /dev/null
+++ b/matlab/doc/qzswitch.html
@@ -0,0 +1,111 @@
+
+
+
+ Description of qzswitch
+
+
+
+
+
+
+
+
+
+
+
+
+
+qzswitch
+
+
+ PURPOSE
+from Chris Sims web site
+
+ SYNOPSIS
+function [A,B,Q,Z] = qzswitch(i,A,B,Q,Z)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+qzdiv from Chris Sims web site
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005 function [A,B,Q,Z] = qzswitch(i,A,B,Q,Z)
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016 realsmall=sqrt(eps)*10;
+0017
+0018 a = A(i,i); d = B(i,i); b = A(i,i+1); e = B(i,i+1);
+0019 c = A(i+1,i+1); f = B(i+1,i+1);
+0020
+0021
+0022 if (abs(c)<realsmall & abs(f)<realsmall)
+0023 if abs(a)<realsmall
+0024
+0025 return
+0026 else
+0027
+0028 wz=[b; -a];
+0029 wz=wz/sqrt(wz'*wz);
+0030 wz=[wz [wz(2)';-wz(1)'] ];
+0031 xy=eye(2);
+0032 end
+0033 elseif (abs(a)<realsmall & abs(d)<realsmall)
+0034 if abs(c)<realsmall
+0035
+0036 return
+0037 else
+0038
+0039 wz=eye(2);
+0040 xy=[c -b];
+0041 xy=xy/sqrt(xy*xy');
+0042 xy=[[xy(2)' -xy(1)'];xy];
+0043 end
+0044 else
+0045
+0046 wz = [c*e-f*b, (c*d-f*a)'];
+0047 xy = [(b*d-e*a)', (c*d-f*a)'];
+0048 n = sqrt(wz*wz');
+0049 m = sqrt(xy*xy');
+0050 if m<eps*100
+0051
+0052 return
+0053 end
+0054 wz = n\wz;
+0055 xy = m\xy;
+0056 wz = [wz; -wz(2)', wz(1)'];
+0057 xy = [xy;-xy(2)', xy(1)'];
+0058 end
+0059 A(i:i+1,:) = xy*A(i:i+1,:);
+0060 B(i:i+1,:) = xy*B(i:i+1,:);
+0061 A(:,i:i+1) = A(:,i:i+1)*wz;
+0062 B(:,i:i+1) = B(:,i:i+1)*wz;
+0063 Z(:,i:i+1) = Z(:,i:i+1)*wz;
+0064 Q(i:i+1,:) = xy*Q(i:i+1,:);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/read_variables.html b/matlab/doc/read_variables.html
new file mode 100644
index 000000000..cbde9bcf0
--- /dev/null
+++ b/matlab/doc/read_variables.html
@@ -0,0 +1,94 @@
+
+
+
+ Description of read_variables
+
+
+
+
+
+
+
+
+
+Home >
. > read_variables.m
+
+
+
+read_variables
+
+
+ PURPOSE
+Copyright (C) 2005 Michel Juillard
+
+ SYNOPSIS
+function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sheet,xls_range)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006 function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sheet,xls_range)
+0007
+0008 dyn_size_01 = size(dyn_data_01,1);
+0009 var_size_01 = size(var_names_01,1);
+0010 if exist(file_name_01)
+0011 file_name_02 = [file_name_01 '.m' ];
+0012 dyn_instr_01 = file_name_01;
+0013 eval(dyn_instr_01);
+0014 for dyn_i_01=1:var_size_01
+0015 dyn_tmp_01 = eval(var_names_01(dyn_i_01,:));
+0016 if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
+0017 error('data size is too large' )
+0018 end
+0019 dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
+0020 end
+0021 elseif exist([file_name_01 '.mat' ])
+0022 file_name_02 = [file_name_01 '.mat' ]
+0023 s = load(file_name_01);
+0024 for dyn_i_01=1:var_size_01
+0025 dyn_tmp_01 = s.(deblank(var_names_01(dyn_i_01,:)));
+0026 if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
+0027 error('data size is too large' )
+0028 end
+0029 dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
+0030 end
+0031 elseif exist([file_name_01 '.xls' ])
+0032 file_name_02 = [file_name_01 '.xls' ]
+0033 [num,txt,raw] = xlsread(file_name_01,xls_sheet,xls_range);
+0034 for dyn_i_01=1:var_size_01
+0035 iv = strmatch(var_names_01(dyn_i_01,:),raw(1,:),'exact' );
+0036 dyn_tmp_01 = [raw{2:end ,iv}]';
+0037 if length(dyn_tmp_01) > dyn_size_01 & dyn_size_01 > 0
+0038 error('data size is too large' )
+0039 end
+0040 dyn_data_01(:,dyn_i_01) = dyn_tmp_01;
+0041 end
+0042
+0043 end
+0044 disp(sprintf('Loading %d observations from %s\n' ,...
+0045 size(dyn_data_01,1),file_name_02))
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/recursive_moments.html b/matlab/doc/recursive_moments.html
new file mode 100644
index 000000000..8cf98155b
--- /dev/null
+++ b/matlab/doc/recursive_moments.html
@@ -0,0 +1,83 @@
+
+
+
+ Description of recursive_moments
+
+
+
+
+
+
+
+
+
+Home >
. > recursive_moments.m
+
+
+
+recursive_moments
+
+
+ PURPOSE
+stephane.adjemian@cepremap.cnrs.fr [02-03-2005]
+
+ SYNOPSIS
+function [mu,sigma] = recursive_moments(m0,s0,data,offset)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [mu,sigma] = recursive_moments(m0,s0,data,offset)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012 T = size(data,1);
+0013 n = size(data,2);
+0014
+0015 for t = 1:T
+0016 tt = t+offset;
+0017 m1 = m0 + (1/tt)*(data(t,:)'-m0);
+0018 s1 = s0 + (1/tt)*(data(t,:)'*data(t,:)-m1*m1'-s0) + ((tt-1)/tt)*(m0*m0'-m1*m1');
+0019 m0 = m1;
+0020 s0 = s1;
+0021 end
+0022
+0023 mu = m1;
+0024 sigma = s1;
+0025
+0026
+0027
+0028
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/resid.html b/matlab/doc/resid.html
new file mode 100644
index 000000000..49236160e
--- /dev/null
+++ b/matlab/doc/resid.html
@@ -0,0 +1,82 @@
+
+
+
+ Description of resid
+
+
+
+
+
+
+
+
+
+
+
+
+
+resid
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function resid(period)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dr1 Copyright (C) 2001 Michel Juillardresol Copyright (C) 2001 Michel Juillardresol1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function resid(period)
+0004 global M_ options_ oo_ it_ endval_ z
+0005
+0006 oo_.exo_simul = ones(M_.maximum_lag+M_.maximum_lead+period,1)*oo_.exo_steady_state';
+0007 n = size(M_.lead_lag_incidence,2);
+0008
+0009 if ~ options_.initval_file
+0010 if size(oo_.steady_state,1) == 1 & oo_.steady_state == 0
+0011 oo_.steady_state = zeros(size(oo_.steady_state,1),1) ;
+0012 end
+0013 oo_.y_simul = oo_.steady_state*ones(1,period+M_.maximum_lag+M_.maximum_lead) ;
+0014 if endval_ == 1
+0015 oo_.y_simul(:,1:M_.maximum_lag) = ys0_*ones(1,M_.maximum_lag) ;
+0016 end
+0017 end
+0018
+0019 i = M_.lead_lag_incidence';
+0020 iyr0 = find(i(:));
+0021
+0022 y =oo_.y_simul(:);
+0023 z = zeros(n,period);
+0024 fh = str2func([M_.fname '_dynamic' ]);
+0025 for it_=M_.maximum_lag+1:period+M_.maximum_lag
+0026 z(:,it_-M_.maximum_lag) = feval(fh,y(iyr0),oo_.exo_simul);
+0027 iyr0 = iyr0 + n;
+0028 end
+0029
+0030 disp([[1:period]' z']);
+0031
+0032
+0033
+0034
+0035
+0036
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/resol.html b/matlab/doc/resol.html
new file mode 100644
index 000000000..e40788b8b
--- /dev/null
+++ b/matlab/doc/resol.html
@@ -0,0 +1,128 @@
+
+
+
+ Description of resol
+
+
+
+
+
+
+
+
+
+
+
+
+
+resol
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [dr,info]=resol(ys,check_flag)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [dr,info]=resol(ys,check_flag)
+0004 global M_ options_ oo_
+0005
+0006 global it_
+0007
+0008
+0009
+0010
+0011
+0012
+0013 jacobian_flag = 0;
+0014
+0015 options_ = set_default_option (options_,'olr' ,0);
+0016 options_ = set_default_option (options_,'jacobian_flag' ,1);
+0017 info = 0;
+0018
+0019 it_ = M_.maximum_lag + 1 ;
+0020
+0021 if M_.exo_nbr == 0
+0022 oo_.exo_steady_state = [] ;
+0023 end
+0024
+0025
+0026 tempex = oo_.exo_simul;
+0027 oo_.exo_simul = repmat(oo_.exo_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
+0028 if M_.exo_det_nbr > 0
+0029 tempexdet = oo_.exo_det_simul;
+0030 oo_.exo_det_simul = repmat(oo_.exo_det_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);
+0031 end
+0032 dr.ys = ys;
+0033 fh = str2func([M_.fname '_static' ]);
+0034 if options_.linear == 0
+0035 if max(abs(feval(fh,dr.ys,[oo_.exo_steady_state; oo_.exo_det_steady_state]))) > options_.dynatol & options_.olr == 0
+0036 if exist([M_.fname '_steadystate' ])
+0037 [dr.ys,check1] = feval([M_.fname '_steadystate' ],dr.ys,...
+0038 [oo_.exo_steady_state; oo_.exo_det_steady_state]);
+0039 else
+0040 [dr.ys,check1] = dynare_solve (fh,dr.ys,options_.jacobian_flag,...
+0041 [oo_.exo_steady_state; oo_.exo_det_steady_state]);
+0042 end
+0043 if check1
+0044 info(1) = 20;
+0045 resid = feval(fh,ys,oo_.exo_steady_state);
+0046 info(2) = resid '*resid ;
+0047 return
+0048 end
+0049 end
+0050 else
+0051 [fvec,jacob] = feval(fh,dr.ys,oo_.exo_steady_state);
+0052 if max(abs(fvec)) > options_.dynatol & options_.olr == 0
+0053 dr.ys = dr.ys-jacob\fvec;
+0054 end
+0055 end
+0056
+0057 dr.fbias = zeros(M_.endo_nbr,1);
+0058 [dr,info] = dr1 (dr,check_flag);
+0059
+0060 if info(1)
+0061 return
+0062 end
+0063
+0064 if options_.dr_algo == 1 & options_.order > 1
+0065 dr.ys = dynare_solve ('dr2' ,ys,0,dr);
+0066 dr.fbias = 2*feval([M_.fname '_static' ],dr.ys,oo_.exo_steady_state);
+0067 [dr, info1] = dr1 (dr,check_flag);
+0068 if info1(1)
+0069 info(1) = info(1)+10;
+0070 return
+0071 end
+0072 end
+0073 if M_.exo_det_nbr > 0
+0074 oo_.exo_det_simul = tempexdet;
+0075 end
+0076 oo_.exo_simul = tempex;
+0077 tempex = [];
+0078
+0079
+0080
+0081
+0082
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/resol1.html b/matlab/doc/resol1.html
new file mode 100644
index 000000000..00ff2fd5d
--- /dev/null
+++ b/matlab/doc/resol1.html
@@ -0,0 +1,114 @@
+
+
+
+ Description of resol1
+
+
+
+
+
+
+
+
+
+
+
+
+
+resol1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dr=resol1(ys,algo,linear,iorder)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+dr11 Copyright (C) 2001 Michel Juillarddynare_solve Copyright (C) 2001 Michel Juillardresid Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dr=resol1(ys,algo,linear,iorder)
+0004
+0005 global M_ options_ oo_ bayestopt_
+0006 global it_ means_ stderrs_ dr1_test_
+0007
+0008 dr1_test_ = zeros(2,1);
+0009
+0010 if linear == 1
+0011 iorder =1;
+0012 end
+0013
+0014 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0015 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0016 iyv = M_.lead_lag_incidence';
+0017 iyv = iyv(:);
+0018 iyr0 = find(iyv) ;
+0019 it_ = M_.maximum_lag + 1 ;
+0020
+0021 if M_.exo_nbr == 0
+0022 oo_.exo_steady_state = [] ;
+0023 end
+0024
+0025 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0026 error ('RESOL: Error in model specification: some variables don"t appear as current' ) ;
+0027 end
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035 tempex = oo_.exo_simul;
+0036 oo_.exo_simul = repmat(transpose(oo_.exo_steady_state), M_.maximum_lag + ...
+0037 M_.maximum_lead+1,1);
+0038 fh = str2func([M_.fname '_static' ]);
+0039 if max(abs(feval(fh,ys,oo_.exo_simul))) > options_.dynatol
+0040
+0041 [dr.ys, cheik] = feval(bayestopt_.static_solve,[M_.fname '_static' ],ys,oo_.exo_simul);
+0042 if cheik
+0043 dr1_test_(1) = 1;
+0044 resid = feval([M_.fname '_static' ],dr.ys,oo_.exo_simul);
+0045 dr1_test_(2) = resid '*resid ;
+0046 disp('dynare_solve is unable to find the steady state.' )
+0047 return
+0048 end
+0049 else
+0050 dr.ys = ys;
+0051 end
+0052
+0053 dr.fbias = zeros(M_.endo_nbr,1);
+0054 dr = dr11 (iorder,dr,0);
+0055
+0056 if algo == 1 & iorder > 1
+0057 dr.ys = dynare_solve ('dr2' ,ys,dr);
+0058 dr.fbias = 2*feval([M_.fname '_static' ],dr.ys,oo_.exo_simul);
+0059 dr = dr11 (iorder,dr,0);
+0060 end
+0061 oo_.exo_simul = tempex;
+0062 tempex = [];
+0063
+0064
+0065
+0066
+0067
+0068
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/rfvar3.html b/matlab/doc/rfvar3.html
new file mode 100644
index 000000000..17cea2201
--- /dev/null
+++ b/matlab/doc/rfvar3.html
@@ -0,0 +1,179 @@
+
+
+
+ Description of rfvar3
+
+
+
+
+
+
+
+
+
+
+
+
+
+rfvar3
+
+
+ PURPOSE
+function var=rfvar3(ydata,lags,xdata,breaks,lambda,mu)
+
+ SYNOPSIS
+function var=rfvar3(ydata,lags,xdata,breaks,lambda,mu)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+mgnldnsty function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat)
+
+
+
+ SOURCE CODE
+0001 function var=rfvar3(ydata,lags,xdata,breaks,lambda,mu)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030 [T,nvar]=size(ydata);
+0031 nox=isempty(xdata);
+0032 if ~nox
+0033 [T2,nx]=size(xdata);
+0034 else
+0035 T2=T;nx=0;xdata=zeros(T2,0);
+0036 end
+0037
+0038
+0039 if T2 ~= T, disp('Mismatch of x and y data lengths' ),end
+0040 if nargin<4
+0041 nbreaks=0;breaks=[];
+0042 else
+0043 nbreaks=length(breaks);
+0044 end
+0045 breaks=[0;breaks;T];
+0046 smpl=[];
+0047 for nb=1:nbreaks+1
+0048 smpl=[smpl;[breaks(nb)+lags+1:breaks(nb+1)]'];
+0049 end
+0050 Tsmpl=size(smpl,1);
+0051 X=zeros(Tsmpl,nvar,lags);
+0052 for is=1:length(smpl)
+0053 X(is,:,:)=ydata(smpl(is)-(1:lags),:)';
+0054 end
+0055 X=[X(:,:) xdata(smpl,:)];
+0056 y=ydata(smpl,:);
+0057
+0058
+0059 if lambda~=0 | mu>0
+0060 ybar=mean(ydata(1:lags,:),1);
+0061 if ~nox
+0062 xbar=mean(xdata(1:lags,:),1);
+0063 else
+0064 xbar=[];
+0065 end
+0066 if lambda~=0
+0067 if lambda>0
+0068 xdum=lambda*[repmat(ybar,1,lags) xbar];
+0069 else
+0070 lambda=-lambda;
+0071 xdum=lambda*[repmat(ybar,1,lags) zeros(size(xbar))];
+0072 end
+0073 ydum=zeros(1,nvar);
+0074 ydum(1,:)=lambda*ybar;
+0075 y=[y;ydum];
+0076 X=[X(:,:);xdum];
+0077 end
+0078 if mu>0
+0079 xdum=[repmat(diag(ybar),1,lags) zeros(nvar,nx)]*mu;
+0080 ydum=mu*diag(ybar);
+0081 X=[X;xdum];
+0082 y=[y;ydum];
+0083 end
+0084 end
+0085 [vl,d,vr]=svd(X(:,:),0);
+0086 di=1../diag(d);
+0087 B=vl'*y;
+0088 B=(vr.*repmat(di',nvar*lags+nx,1))*B;
+0089 u=y-X(:,:)*B;
+0090 xxi=vr.*repmat(di',nvar*lags+nx,1);
+0091 xxi=xxi*xxi';
+0092 B=reshape(B,[nvar*lags+nx,nvar]);
+0093 By=B(1:nvar*lags,:);
+0094 By=reshape(By,nvar,lags,nvar);
+0095 By=permute(By,[3,1,2]);
+0096 if nox
+0097 Bx=[];
+0098 else
+0099 Bx=B(nvar*lags+(1:nx),:)';
+0100 end
+0101
+0102 var.By=By;var.Bx=Bx;var.u=u;var.xxi=xxi;
+0103
+0104
+0105
+0106
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/right.png b/matlab/doc/right.png
new file mode 100644
index 000000000..067c5baf2
Binary files /dev/null and b/matlab/doc/right.png differ
diff --git a/matlab/doc/rndprior.html b/matlab/doc/rndprior.html
new file mode 100644
index 000000000..a49a9d6e5
--- /dev/null
+++ b/matlab/doc/rndprior.html
@@ -0,0 +1,98 @@
+
+
+
+ Description of rndprior
+
+
+
+
+
+
+
+
+
+
+
+
+
+rndprior
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function y = rndprior(bayestopt_)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+beta_rnd PURPOSE: random draws from the beta(a,b) distributiongamm_rnd PURPOSE: a matrix of random draws from the gamma distribution
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function y = rndprior(bayestopt_)
+0002
+0003 pshape=bayestopt_.pshape;
+0004 pmean=bayestopt_.pmean;
+0005 p2=bayestopt_.p2;
+0006 p3=bayestopt_.p3;
+0007 p4=bayestopt_.p4;
+0008
+0009 for i=1:length(pmean),
+0010
+0011 switch pshape(i)
+0012
+0013 case 1
+0014 mu = (pmean(i)-p3(i))/(p4(i)-p3(i));
+0015 stdd = p2(i)/(p4(i)-p3(i));
+0016 A = (1-mu)*mu^2/stdd^2 - mu;
+0017 B = A*(1/mu - 1);
+0018 y(1,i) = beta_rnd (1, A, B);
+0019 y(1,i) = y(1,i) * (p4(i)-p3(i)) + p3(i);
+0020
+0021 case 2
+0022 mu = pmean(i)-p3(i);
+0023 B = mu/p2(i)^2;
+0024 A = mu/B;
+0025 y(1,i) = gamm_rnd (1, A, B);
+0026 y(1,i) = y(1,i) + p3(i);
+0027
+0028 case 3
+0029 MU = pmean(i);
+0030 SIGMA = p2(i);
+0031 y(1,i) = randn*SIGMA+ MU;
+0032
+0033 case 4
+0034 nu = p2(i);
+0035 mu = pmean(i);
+0036 a = nu/2;;
+0037 b = ( gamma( (nu-1)/2 ) / mu / gamma( nu/2 ) )^2;
+0038 A = b/2;
+0039 B = 2/a;
+0040 y(1,i) = gamm_rnd (1, A, B);
+0041 y(1,i) = 1/y(1,i)^(0.5);
+0042
+0043 case 5
+0044 y(1,i) = rand*(p4(i)-p3(i)) + p3(i);
+0045
+0046 end
+0047 end
+0048
+0049
+0050
+0051
+0052
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/rows.html b/matlab/doc/rows.html
new file mode 100644
index 000000000..e079c8644
--- /dev/null
+++ b/matlab/doc/rows.html
@@ -0,0 +1,48 @@
+
+
+
+ Description of rows
+
+
+
+
+
+
+
+
+
+
+
+
+
+rows
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function nr=rows(x)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/rplot.html b/matlab/doc/rplot.html
new file mode 100644
index 000000000..bed9b027e
--- /dev/null
+++ b/matlab/doc/rplot.html
@@ -0,0 +1,129 @@
+
+
+
+ Description of rplot
+
+
+
+
+
+
+
+
+
+
+
+
+
+rplot
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function rplot(s1)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function rplot(s1)
+0004
+0005
+0006
+0007
+0008
+0009
+0010 global M_ oo_ options_
+0011
+0012 rplottype = options_.rplottype;
+0013
+0014 col = ['y' ,'c' ,'r' ,'g' ,'b' ,'w' ,'m' ] ;
+0015 ix = [1 - M_.maximum_lag:size(oo_.y_simul,2)-M_.maximum_lag]' ;
+0016
+0017 y = [];
+0018 for k=1:size(s1,1)
+0019 if isempty(strmatch(s1(k,:),M_.endo_names,'exact' ))
+0020 error (['One of the variable specified does not exist' ]) ;
+0021 end
+0022
+0023 y = [y; oo_.y_simul(strmatch(s1(k,:),M_.endo_names,'exact' ),:)] ;
+0024 end
+0025
+0026 if options_.smpl == 0
+0027 i = [M_.maximum_lag:size(oo_.y_simul,2)]' ;
+0028 else
+0029 i = [options_.smpl(1)+M_.maximum_lag:options_.smpl(2)+M_.maximum_lag]' ;
+0030 end
+0031
+0032 t = ['Plot of ' ] ;
+0033 if rplottype == 0
+0034 for j = 1:size(y,1)
+0035 t = [t s1(j,:) ' ' ] ;
+0036 end
+0037 figure ;
+0038 plot(ix(i),y(:,i)) ;
+0039 title (t,'Interpreter' ,'none' ) ;
+0040 xlabel('Periods' ) ;
+0041 if size(s1,1) > 1
+0042 legend(s1,0);
+0043 end
+0044 elseif rplottype == 1
+0045 for j = 1:size(y,1)
+0046 figure ;
+0047 plot(ix(i),y(j,i)) ;
+0048 title(['Plot of ' s1(:,j)]) ;
+0049 xlabel('Periods' ) ;
+0050 end
+0051 elseif rplottype == 2
+0052 figure ;
+0053 nl = max(1,fix(size(y,1)/4)) ;
+0054 nc = ceil(size(y,1)/nl) ;
+0055 for j = 1:size(y,1)
+0056 subplot(nl,nc,j) ;
+0057 plot(ix(i),y(j,i)) ;
+0058 hold on ;
+0059 plot(ix(i),oo_.steady_state(j)*ones(1,size(i,1)),'w:' ) ;
+0060 xlabel('Periods' ) ;
+0061 ylabel([s1(:,j)]) ;
+0062 title(['Plot of ' s1(:,j)]) ;
+0063 end
+0064 end
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+0074
+0075
+0076
+0077
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/sec2hms.html b/matlab/doc/sec2hms.html
new file mode 100644
index 000000000..42ec4d0be
--- /dev/null
+++ b/matlab/doc/sec2hms.html
@@ -0,0 +1,68 @@
+
+
+
+ Description of sec2hms
+
+
+
+
+
+
+
+
+
+
+
+
+
+sec2hms
+
+
+ PURPOSE
+function [hour, minute, second] = sec2hms(sec)
+
+ SYNOPSIS
+function hms = sec2hms(sec)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function hms = sec2hms(sec)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013 hour = fix(sec/3600);
+0014 sec = sec - 3600*hour;
+0015 minute = fix(sec/60);
+0016 sec = sec - 60*minute;
+0017 second = sec;
+0018 hms = [num2str(hour,'%02g' ) ':' num2str(minute,'%02g' ) ':' num2str(second,'%02g' )];
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/selif.html b/matlab/doc/selif.html
new file mode 100644
index 000000000..3305b64ec
--- /dev/null
+++ b/matlab/doc/selif.html
@@ -0,0 +1,58 @@
+
+
+
+ Description of selif
+
+
+
+
+
+
+
+
+
+
+
+
+
+selif
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function x = selif(a,b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+bksup Copyright (C) 2001 Michel Juillardbksupk simk Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function x = selif(a,b)
+0004
+0005 if size(b,2) ~= 1
+0006 error ('The second argument in SELIF must be column vector' ) ;
+0007 end
+0008
+0009 x = a(find(b == 1),:) ;
+0010
+0011 return ;
+0012
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/set_all_parameters.html b/matlab/doc/set_all_parameters.html
new file mode 100644
index 000000000..61603397d
--- /dev/null
+++ b/matlab/doc/set_all_parameters.html
@@ -0,0 +1,107 @@
+
+
+
+ Description of set_all_parameters
+
+
+
+
+
+
+
+
+
+Home >
. > set_all_parameters.m
+
+
+
+set_all_parameters
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function set_all_parameters(xparam1)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function set_all_parameters(xparam1)
+0002 global estim_params_ M_
+0003
+0004 nvx = estim_params_.nvx;
+0005 ncx = estim_params_.ncx;
+0006 nvn = estim_params_.nvn;
+0007 ncn = estim_params_.ncn;
+0008 np = estim_params_.np;
+0009 Sigma_e = M_.Sigma_e;
+0010 H = M_.H;
+0011
+0012 if nvx
+0013 var_exo = estim_params_.var_exo;
+0014 for i=1:nvx
+0015 k =var_exo(i,1);
+0016 Sigma_e(k,k) = xparam1(i)^2;
+0017 end
+0018 end
+0019
+0020 if ncx
+0021 offset = nvx+nvn;
+0022 corrx = estim_params_.corrx;
+0023 for i=1:ncx
+0024 k1 = corrx(i,1);
+0025 k2 = corrx(i,2);
+0026 Sigma_e(k1,k2) = xparam1(i+offset)*sqrt(Sigma_e_(k1,k1)*Sigma_e_(k2,k2));
+0027 Sigma_e(k2,k1) = Sigma_e_(k1,k2);
+0028 end
+0029 end
+0030
+0031 if nvn
+0032 offset = nvx;
+0033 var_endo = estim_params_.var_endo;
+0034 for i=1:nvn
+0035 k = var_endo(i,1);
+0036 H(k,k) = xparam1(i+offset)^2;
+0037 end
+0038 end
+0039
+0040 if ncn
+0041 offset = nvx+nvn+ncx;
+0042 corrn = estim_params_.corrn;
+0043 for i=1:ncn
+0044 k1 = corr(i,1);
+0045 k2 = corr(i,2);
+0046 H(k1,k2) = xparam1(i+offset)*sqrt(H(k1,k1)*H(k2,k2));
+0047 H(k2,k1) = H(k1,k2);
+0048 end
+0049 end
+0050
+0051 if np
+0052 offset = nvx+ncx+nvn+ncn;
+0053 M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
+0054 end
+0055
+0056 if nvx
+0057 M_.Sigma_e = Sigma_e;
+0058 end
+0059 if nvn
+0060 M_.H = H;
+0061 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/set_default_option.html b/matlab/doc/set_default_option.html
new file mode 100644
index 000000000..5c97c1f7a
--- /dev/null
+++ b/matlab/doc/set_default_option.html
@@ -0,0 +1,56 @@
+
+
+
+ Description of set_default_option
+
+
+
+
+
+
+
+
+
+Home >
. > set_default_option.m
+
+
+
+set_default_option
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function options=set_default_option(options,field,default)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/set_parameters.html b/matlab/doc/set_parameters.html
new file mode 100644
index 000000000..3f2ece6e2
--- /dev/null
+++ b/matlab/doc/set_parameters.html
@@ -0,0 +1,80 @@
+
+
+
+ Description of set_parameters
+
+
+
+
+
+
+
+
+
+Home >
. > set_parameters.m
+
+
+
+set_parameters
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function set_parameters(xparam1)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function set_parameters(xparam1)
+0002 global estim_params_ M_
+0003
+0004 nvx = estim_params_.nvx;
+0005 ncx = estim_params_.ncx;
+0006 np = estim_params_.np;
+0007 Sigma_e = M_.Sigma_e;
+0008
+0009 if nvx
+0010 offset = nvx;
+0011 var_exo = estim_params_.var_exo;
+0012 for i=1:nvx
+0013 k = var_exo(i,1);
+0014 Sigma_e(k,k) = xparam1(i)^2;
+0015 end
+0016 end
+0017
+0018 if ncx
+0019 offset = nvx + nvn;
+0020 corrx = estim_params_.corrx;
+0021 for i=1:ncx
+0022 k1 = corrx(i,1);
+0023 k2 = corrx(i,2);
+0024 Sigma_e(k1,k2) = xparam1(i+offset)*sqrt(Sigma_e_(k1,k1)*Sigma_e_(k2,k2));
+0025 Sigma_e(k2,k1) = Sigma_e_(k1,k2);
+0026 end
+0027 end
+0028
+0029 if np
+0030 offset = offset+estim_params_.ncx+estim_params_.ncn;
+0031 M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
+0032 end
+0033
+0034 M_.Sigma_e = Sigma_e;
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/set_prior.html b/matlab/doc/set_prior.html
new file mode 100644
index 000000000..b3fe327ac
--- /dev/null
+++ b/matlab/doc/set_prior.html
@@ -0,0 +1,190 @@
+
+
+
+ Description of set_prior
+
+
+
+
+
+
+
+
+
+
+
+
+
+set_prior
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function [xparam1,estim_params_,bayestopt_,lb,ub]=set_prior(estim_params_)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [xparam1,estim_params_,bayestopt_,lb,ub]=set_prior(estim_params_)
+0002 global M_ options_
+0003
+0004 nvx = size(estim_params_.var_exo,1);
+0005 nvn = size(estim_params_.var_endo,1);
+0006 ncx = size(estim_params_.corrx,1);
+0007 ncn = size(estim_params_.corrn,1);
+0008 np = size(estim_params_.param_vals,1);
+0009
+0010 estim_params_.nvx = nvx;
+0011 estim_params_.nvn = nvn;
+0012 estim_params_.ncx = ncx;
+0013 estim_params_.ncn = ncn;
+0014 estim_params_.np = np;
+0015
+0016 xparam1 = [];
+0017 ub = [];
+0018 lb = [];
+0019 bayestopt_.pshape = [];
+0020 bayestopt_.pmean = [];
+0021 bayestopt_.pstdev = [];
+0022 bayestopt_.p1 = [];
+0023 bayestopt_.p2 = [];
+0024 bayestopt_.p3 = [];
+0025 bayestopt_.p4 = [];
+0026 bayestopt_.jscale = [];
+0027 bayestopt_.name = [];
+0028 if nvx
+0029 xparam1 = estim_params_.var_exo(:,2);
+0030 ub = estim_params_.var_exo(:,4);
+0031 lb = estim_params_.var_exo(:,3);
+0032 bayestopt_.pshape = estim_params_.var_exo(:,5);
+0033 bayestopt_.pmean = estim_params_.var_exo(:,6);
+0034 bayestopt_.pstdev = estim_params_.var_exo(:,7);
+0035 bayestopt_.p3 = estim_params_.var_exo(:,8);
+0036 bayestopt_.p4 = estim_params_.var_exo(:,9);
+0037 bayestopt_.jscale = estim_params_.var_exo(:,10);
+0038 bayestopt_.name = cellstr(M_.exo_names(estim_params_.var_exo(:,1),:));
+0039 end
+0040 if nvn
+0041 for i=1:nvn
+0042 estim_params_.var_endo(i,1) = strmatch(deblank(M_.endo_names(estim_params_.var_endo(i,1),:)),deblank(options_.varobs),'exact' );
+0043 end
+0044 xparam1 = [xparam1; estim_params_.var_endo(:,2)];
+0045 ub = [ub; estim_params_.var_endo(:,4)];
+0046 lb = [lb; estim_params_.var_endo(:,3)];
+0047 bayestopt_.pshape = [ bayestopt_.pshape; estim_params_.var_endo(:,5)];
+0048 bayestopt_.pmean = [ bayestopt_.pmean; estim_params_.var_endo(:,6)];
+0049 bayestopt_.pstdev = [ bayestopt_.pstdev; estim_params_.var_endo(:,7)];
+0050 bayestopt_.p3 = [ bayestopt_.p3; estim_params_.var_endo(:,8)];
+0051 bayestopt_.p4 = [ bayestopt_.p4; estim_params_.var_endo(:,9)];
+0052 bayestopt_.jscale = [ bayestopt_.jscale; estim_params_.var_endo(:,10)];
+0053 bayestopt_.name = cellstr(strvcat(char(bayestopt_.name),...
+0054 M_.endo_names(estim_params_.var_endo(:,1),:)));
+0055 end
+0056 if ncx
+0057 xparam1 = [xparam1; estim_params_.corrx(:,3)];
+0058 ub = [ub; max(min(estim_params_.corrx(:,5),1),-1)];
+0059 lb = [lb; max(min(estim_params_.corrx(:,4),1),-1)];
+0060 bayestopt_.pshape = [ bayestopt_.pshape; estim_params_.corrx(:,6)];
+0061 bayestopt_.pmean = [ bayestopt_.pmean; estim_params_.corrx(:,7)];
+0062 bayestopt_.pstdev = [ bayestopt_.pstdev; estim_params_.corrx(:,8)];
+0063 bayestopt_.p3 = [ bayestopt_.p3; estim_params_.corrx(:,9)];
+0064 bayestopt_.p4 = [ bayestopt_.p4; estim_params_.corrx(:,10)];
+0065 bayestopt_.jscale = [ bayestopt_.jscale; estim_params_.corrx(:,11)];
+0066 bayestopt_.name = cellstr(strvcat(char(bayestopt_.name),...
+0067 char(strcat(cellstr(M_.exo_names(estim_params_.corrx(:,1),:)),...
+0068 ',' ,...
+0069 cellstr(M_.exo_names(estim_params_.corrx(:,2),:))))));
+0070 end
+0071 if ncn
+0072 xparam1 = [xparam1; estim_params_.corrn(:,3)];
+0073 ub = [ub; max(min(estim_params_.corrn(:,5),1),-1)];
+0074 lb = [lb; max(min(estim_params_.corrn(:,4),1),-1)];
+0075 bayestopt_.pshape = [ bayestopt_.pshape; estim_params_.corrn(:,6)];
+0076 bayestopt_.pmean = [ bayestopt_.pmean; estim_params_.corrn(:,7)];
+0077 bayestopt_.pstdev = [ bayestopt_.pstdev; estim_params_.corrn(:,8)];
+0078 bayestopt_.p3 = [ bayestopt_.p3; estim_params_.corrn(:,9)];
+0079 bayestopt_.p4 = [ bayestopt_.p4; estim_params_.corrn(:,10)];
+0080 bayestopt_.jscale = [ bayestopt_.jscale; estim_params_.corrn(:,11)];
+0081 bayestopt_.name = cellstr(strvcat(char(bayestopt_.name),...
+0082 char(strcat(cellstr(M_.endo_names(estim_params_.corrn(:,1),:)),...
+0083 ',' ,...
+0084 cellstr(M_.endo_names(estim_params_.corrn(:,2),:))))));
+0085 end
+0086 if np
+0087 xparam1 = [xparam1; estim_params_.param_vals(:,2)];
+0088 ub = [ub; estim_params_.param_vals(:,4)];
+0089 lb = [lb; estim_params_.param_vals(:,3)];
+0090 bayestopt_.pshape = [ bayestopt_.pshape; estim_params_.param_vals(:,5)];
+0091 bayestopt_.pmean = [ bayestopt_.pmean; estim_params_.param_vals(:,6)];
+0092 bayestopt_.pstdev = [ bayestopt_.pstdev; estim_params_.param_vals(:,7)];
+0093 bayestopt_.p3 = [ bayestopt_.p3; estim_params_.param_vals(:,8)];
+0094 bayestopt_.p4 = [ bayestopt_.p4; estim_params_.param_vals(:,9)];
+0095 bayestopt_.jscale = [ bayestopt_.jscale; estim_params_.param_vals(:, ...
+0096 10)];
+0097 bayestopt_.name = cellstr(strvcat(char(bayestopt_.name),M_.param_names(estim_params_.param_vals(:,1),:)));
+0098 end
+0099
+0100 bayestopt_.ub = ub;
+0101 bayestopt_.lb = lb;
+0102
+0103 bayestopt_.p1 = bayestopt_.pmean;
+0104 bayestopt_.p2 = bayestopt_.pstdev;
+0105
+0106
+0107 k = find(bayestopt_.pshape == 1);
+0108 k1 = find(isnan(bayestopt_.p3(k)));
+0109 bayestopt_.p3(k(k1)) = zeros(length(k1),1);
+0110 k1 = find(isnan(bayestopt_.p4(k)));
+0111 bayestopt_.p4(k(k1)) = ones(length(k1),1);
+0112
+0113
+0114 k = find(bayestopt_.pshape == 2);
+0115 k1 = find(isnan(bayestopt_.p3(k)));
+0116 bayestopt_.p3(k(k1)) = zeros(length(k1),1);
+0117
+0118
+0119 k = find(bayestopt_.pshape == 3);
+0120 k1 = find(isnan(bayestopt_.p3(k)));
+0121 bayestopt_.p3(k(k1)) = -Inf*ones(length(k1),1);
+0122 k1 = find(isnan(bayestopt_.p4(k)));
+0123 bayestopt_.p4(k(k1)) = Inf*ones(length(k1),1);
+0124
+0125 k = find(bayestopt_.pshape == 4);
+0126 for i=1:length(k)
+0127 [bayestopt_.p1(k(i)),bayestopt_.p2(k(i))] = ...
+0128 inverse_gamma_specification (bayestopt_.pmean(k(i)),bayestopt_.pstdev(k(i)),1);
+0129 end
+0130
+0131 k = find(bayestopt_.pshape == 5);
+0132 for i=1:length(k)
+0133 [bayestopt_.pmean(k(i)),bayestopt_.pstdev(k(i)),bayestopt_.p1(k(i)),bayestopt_.p2(k(i))] = ...
+0134 uniform_specification (bayestopt_.pmean(k(i)),bayestopt_.pstdev(k(i)),bayestopt_.p3(k(i)),bayestopt_.p4(k(i)));
+0135 end
+0136
+0137 k = find(bayestopt_.pshape == 6);
+0138 for i=1:length(k)
+0139 [bayestopt_.p1(k(i)),bayestopt_.p2(k(i))] = ...
+0140 inverse_gamma_specification (bayestopt_.pmean(k(i)),bayestopt_.pstdev(k(i)),2);
+0141 end
+0142
+0143 k = find(isnan(xparam1));
+0144 xparam1(k) = bayestopt_.pmean(k);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/set_shocks.html b/matlab/doc/set_shocks.html
new file mode 100644
index 000000000..0edc8a7d9
--- /dev/null
+++ b/matlab/doc/set_shocks.html
@@ -0,0 +1,71 @@
+
+
+
+ Description of set_shocks
+
+
+
+
+
+
+
+
+
+
+
+
+
+set_shocks
+
+
+ PURPOSE
+Copyright (C) 2003 Michel Juillard
+
+ SYNOPSIS
+function set_shocks(flag,k,ivar,values)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function set_shocks(flag,k,ivar,values)
+0004 global oo_ M_
+0005
+0006 k = k + M_.maximum_lag;
+0007 n1 = size(oo_.exo_simul,1);
+0008 n2 = size(oo_.exo_det_simul,1);
+0009 if k(end) > n1 & flag <= 1
+0010 oo_.exo_simul = [oo_.exo_simul; repmat(oo_.exo_steady_state',k(end)-n1,1)];
+0011 elseif k(end) > n2 & flag > 1
+0012 oo_.exo_det_simul = [oo_.exo_det_simul; repmat(oo_.exo_steady_state',k(end)-n2,1)];
+0013 end
+0014
+0015 switch flag
+0016 case 0
+0017 oo_.exo_simul(k,ivar) = repmat(values,length(k),1);
+0018 case 1
+0019 oo_.exo_simul(k,ivar) = oo_.exo_simul(k,ivar).*values;
+0020 case 2
+0021 oo_.exo_det_simul(k,ivar) = repmat(values,length(k),1);
+0022 case 3
+0023 oo_.exo_det_simul(k,ivar) = oo_.exo_det_simul(k,ivar).*values;
+0024 end
+0025
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/set_state_space.html b/matlab/doc/set_state_space.html
new file mode 100644
index 000000000..f13711eb0
--- /dev/null
+++ b/matlab/doc/set_state_space.html
@@ -0,0 +1,130 @@
+
+
+
+ Description of set_state_space
+
+
+
+
+
+
+
+
+
+Home >
. > set_state_space.m
+
+
+
+set_state_space
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function dr=set_state_space(dr)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function dr=set_state_space(dr)
+0004
+0005 global M_ oo_ options_ it_
+0006
+0007 xlen = M_.maximum_lead + M_.maximum_lag + 1;
+0008 klen = M_.maximum_lag + M_.maximum_lead + 1;
+0009
+0010 if ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
+0011 error ('Error in model specification: some variables don"t appear as current' ) ;
+0012 end
+0013
+0014 fwrd_var = find(any(M_.lead_lag_incidence(M_.maximum_lag+2:end ,:),1))';
+0015 if M_.maximum_lag > 0
+0016 pred_var = find(any(M_.lead_lag_incidence(1:M_.maximum_lag,:),1))';
+0017 both_var = intersect(pred_var,fwrd_var);
+0018 pred_var = setdiff(pred_var,both_var);
+0019 fwrd_var = setdiff(fwrd_var,both_var);
+0020 stat_var = setdiff([1:M_.endo_nbr]',union (union (pred_var,both_var),fwrd_var));
+0021 else
+0022 pred_var = [];
+0023 both_var = [];
+0024 stat_var = setdiff([1:M_.endo_nbr]',fwrd_var);
+0025 end
+0026 nboth = length(both_var);
+0027 npred = length(pred_var);
+0028 nfwrd = length(fwrd_var);
+0029 nstatic = length(stat_var);
+0030 order_var = [ stat_var; pred_var; both_var; fwrd_var];
+0031
+0032
+0033 if M_.maximum_lag > 0
+0034 kmask = [];
+0035 if M_.maximum_lead > 0
+0036 kmask = [cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+2:end ,order_var)),1)] ;
+0037 end
+0038 kmask = [kmask; flipud(cumsum(M_.lead_lag_incidence(1:M_.maximum_lag,order_var),1))] ;
+0039 else
+0040 kmask = cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+2:klen,order_var)),1) ;
+0041 end
+0042
+0043 kmask = kmask';
+0044 kmask = kmask(:);
+0045 i_kmask = find(kmask);
+0046 nd = size(i_kmask,1);
+0047 kmask(i_kmask) = [1:nd];
+0048
+0049
+0050
+0051
+0052 k1 = find([kmask(1:end-M_.endo_nbr) & kmask(M_.endo_nbr+1:end)] );
+0053 kad = [];
+0054 kae = [];
+0055 if ~isempty(k1)
+0056 kad = kmask(k1+M_.endo_nbr);
+0057 kae = kmask(k1);
+0058 end
+0059
+0060
+0061
+0062
+0063 kstate = [ repmat([1:M_.endo_nbr]',klen-1,1) kron([klen:-1:2]',ones(M_.endo_nbr,1)) ...
+0064 zeros((klen-1)*M_.endo_nbr,2)];
+0065 kiy = flipud(M_.lead_lag_incidence(:,order_var))';
+0066 kiy = kiy(:);
+0067 kstate(1:M_.maximum_lead*M_.endo_nbr,3) = kiy(1:M_.maximum_lead*M_.endo_nbr)-M_.endo_nbr;
+0068 kstate(find(kstate(:,3) < 0),3) = 0;
+0069 kstate(M_.maximum_lead*M_.endo_nbr+1:end ,4) = kiy((M_.maximum_lead+1)*M_.endo_nbr+1:end);
+0070
+0071 kstate = kstate(i_kmask,:);
+0072
+0073 dr.order_var = order_var;
+0074 dr.nstatic = nstatic;
+0075 dr.npred = npred+nboth;
+0076 dr.kstate = kstate;
+0077 dr.kad = kad;
+0078 dr.kae = kae;
+0079 dr.nboth = nboth;
+0080 dr.nfwrd = nfwrd;
+0081
+0082 dr.nsfwrd = sum(kstate(:,2) > M_.maximum_lag+1);
+0083
+0084 dr.nspred = sum(kstate(:,2) <= M_.maximum_lag+1);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/sgi.png b/matlab/doc/sgi.png
new file mode 100644
index 000000000..20052bc56
Binary files /dev/null and b/matlab/doc/sgi.png differ
diff --git a/matlab/doc/sim1.html b/matlab/doc/sim1.html
new file mode 100644
index 000000000..d55698b59
--- /dev/null
+++ b/matlab/doc/sim1.html
@@ -0,0 +1,142 @@
+
+
+
+ Description of sim1
+
+
+
+
+
+
+
+
+
+
+
+
+
+sim1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function sim1
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+bksup1 Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function sim1
+0004
+0005 global M_ options_ oo_
+0006 global iyp iyf ct_ M_ it_ c
+0007
+0008 lead_lag_incidence = M_.lead_lag_incidence;
+0009
+0010 ny = size(oo_.y_simul,1) ;
+0011 nyp = nnz(lead_lag_incidence(1,:)) ;
+0012 nyf = nnz(lead_lag_incidence(3,:)) ;
+0013 nrs = ny+nyp+nyf+1 ;
+0014 nrc = nyf+1 ;
+0015 iyf = find(lead_lag_incidence(3,:)>0) ;
+0016 iyp = find(lead_lag_incidence(1,:)>0) ;
+0017 isp = [1:nyp] ;
+0018 is = [nyp+1:ny+nyp] ;
+0019 isf = iyf+nyp ;
+0020 isf1 = [nyp+ny+1:nyf+nyp+ny+1] ;
+0021 stop = 0 ;
+0022 iz = [1:ny+nyp+nyf];
+0023
+0024 disp (['-----------------------------------------------------' ]) ;
+0025 disp (['MODEL SIMULATION :' ]) ;
+0026 fprintf('\n' ) ;
+0027
+0028 it_init = 2 ;
+0029
+0030 h1 = clock ;
+0031 for iter = 1:options_.maxit
+0032 h2 = clock ;
+0033
+0034 if ct_ == 0
+0035 c = zeros(ny*options_.periods,nrc) ;
+0036 else
+0037 c = zeros(ny*(options_.periods+1),nrc) ;
+0038 end
+0039
+0040 it_ = it_init ;
+0041 z = [oo_.y_simul(iyp,it_-1) ; oo_.y_simul(:,it_) ; oo_.y_simul(iyf,it_+1)] ;
+0042 [d1,M_.jacobia] = feval([M_.fname '_dynamic' ],z,oo_.exo_simul);
+0043 M_.jacobia = [M_.jacobia(:,iz) -d1] ;
+0044 ic = [1:ny] ;
+0045 icp = iyp ;
+0046 c (ic,:) = M_.jacobia(:,is)\M_.jacobia(:,isf1) ;
+0047 for it_ = it_init+1:options_.periods+1
+0048 z = [oo_.y_simul(iyp,it_-1) ; oo_.y_simul(:,it_) ; oo_.y_simul(iyf,it_+1)] ;
+0049 [d1,M_.jacobia] = feval([M_.fname '_dynamic' ],z,oo_.exo_simul);
+0050 M_.jacobia = [M_.jacobia(:,iz) -d1] ;
+0051 M_.jacobia(:,[isf nrs]) = M_.jacobia(:,[isf nrs])-M_.jacobia(:,isp)*c(icp,:) ;
+0052 ic = ic + ny ;
+0053 icp = icp + ny ;
+0054 c (ic,:) = M_.jacobia(:,is)\M_.jacobia(:,isf1) ;
+0055 end
+0056
+0057 if ct_ == 1
+0058 s = eye(ny) ;
+0059 s(:,isf) = s(:,isf)+c(ic,1:nyf) ;
+0060 ic = ic + ny ;
+0061 c(ic,nrc) = s\c(:,nrc) ;
+0062 c = bksup1 (ny,nrc) ;
+0063 c = reshape(c,ny,options_.periods+1) ;
+0064 oo_.y_simul(:,it_init:options_.periods+2) = oo_.y_simul(:,it_init:options_.periods+2)+options_.slowc*c ;
+0065 else
+0066 c = bksup1 (ny,nrc) ;
+0067 c = reshape(c,ny,options_.periods) ;
+0068 oo_.y_simul(:,it_init:options_.periods+1) = oo_.y_simul(:,it_init:options_.periods+1)+options_.slowc*c ;
+0069 end
+0070
+0071 err = max(max(abs(c./options_.scalv')));
+0072 disp([num2str(iter) ' - err = ' num2str(err)]) ;
+0073 disp([' Time of iteration :' num2str(etime(clock,h2))]) ;
+0074
+0075 if err < options_.dynatol
+0076 stop = 1 ;
+0077 fprintf('\n' ) ;
+0078 disp([' Total time of simulation :' num2str(etime(clock,h1))]) ;
+0079 fprintf('\n' ) ;
+0080 disp([' Convergency obtained.' ]) ;
+0081 fprintf('\n' ) ;
+0082 break
+0083 end
+0084 end
+0085
+0086 if ~ stop
+0087 fprintf('\n' ) ;
+0088 disp([' Total time of simulation :' num2str(etime(clock,h1))]) ;
+0089 fprintf('\n' ) ;
+0090 disp(['WARNING : maximum number of iterations is reached (modify options_.maxit).' ]) ;
+0091 fprintf('\n' ) ;
+0092 end
+0093 disp (['-----------------------------------------------------' ]) ;
+0094 return ;
+0095
+0096
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/simk.html b/matlab/doc/simk.html
new file mode 100644
index 000000000..3f7cc4697
--- /dev/null
+++ b/matlab/doc/simk.html
@@ -0,0 +1,369 @@
+
+
+
+ Description of simk
+
+
+
+
+
+
+
+
+
+
+
+
+
+simk
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function simk
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+bksupk ffill Copyright (C) 2001 Michel Juillardindnv Copyright (C) 2001 Michel Juillardselif Copyright (C) 2001 Michel Juillardunion
+This function is called by:
+
+simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function simk
+0004
+0005 global M_ options_ oo_
+0006 global it_ iyr0 ct_ broyden_
+0007
+0008 func_name = [M_.fname '_static' ];
+0009 nk = M_.maximum_lag + M_.maximum_lead + 1 ;
+0010 ny = size(M_.lead_lag_incidence,2) ;
+0011 icc1 = M_.lead_lag_incidence(nk,:) > 0;
+0012
+0013 for i = 1:M_.maximum_lead -1
+0014 icc1 = [M_.lead_lag_incidence(nk-i,:) | icc1(1,:); icc1] ;
+0015 end
+0016
+0017 icc1 = find(icc1') ;
+0018 iy = M_.lead_lag_incidence > 0 ;
+0019 isc = cumsum(sum(iy',1))' ;
+0020 iyr0 = find(M_.lead_lag_incidence') ;
+0021 ncc1 = size(icc1,1) ;
+0022 ncc = ncc1 + 1 ;
+0023 ncs = size(iyr0,1) ;
+0024
+0025 ky = zeros(ny,nk) ;
+0026 lky = zeros(nk,1) ;
+0027 for i = 1:nk
+0028 j = find(M_.lead_lag_incidence(i,:))' ;
+0029 if isempty(j)
+0030 lky(i) = 0;
+0031 else
+0032 lky(i) = size(j,1) ;
+0033 ky(1:lky(i),i) = j ;
+0034 end
+0035 end
+0036
+0037 jwc = find(iy(2:M_.maximum_lead+1,:)') ;
+0038
+0039
+0040
+0041 if isempty(jwc)
+0042 jwc = 0 ;
+0043 ljwc = 0 ;
+0044 temp = icc1 ;
+0045 else
+0046 ljwc = size(jwc,1) ;
+0047 temp = union (jwc,icc1) ;
+0048 end
+0049
+0050 j1 = ky(1:lky(1),1) ;
+0051 lj1 = lky(1) ;
+0052
+0053 for i = 2:M_.maximum_lag
+0054 [j1,lj1] = ffill (j1,lj1,selif (temp+(i-1)*ny,temp <= ny)) ;
+0055 if M_.maximum_lead == 1
+0056 if lky(i+M_.maximum_lead) > 0
+0057 [jwc,ljwc] = ffill (jwc,ljwc, ky(1:lky(i+M_.maximum_lead),i+M_.maximum_lead)+(M_.maximum_lead-1)*ny) ;
+0058 if ljwc(i) == 0
+0059 temp = icc1;
+0060 else
+0061 temp = union (jwc(1:ljwc(i),i),icc1) ;
+0062 end
+0063 else
+0064 [jwc,ljwc] = ffill (jwc,ljwc,[]) ;
+0065 temp = icc1 ;
+0066 end
+0067 else
+0068 temp = temp(lj1(i)+1:size(temp,1),:) - ny ;
+0069 if lky(i+M_.maximum_lead) > 0
+0070 [jwc,ljwc] = ffill (jwc,ljwc,[temp;ky(1:lky(i+M_.maximum_lead),i+M_.maximum_lead)+(M_.maximum_lead-1)*ny]);
+0071 else
+0072 [jwc,ljwc] = ffill (jwc,ljwc,temp) ;
+0073 end
+0074 temp = union (jwc(1:ljwc(i),i),icc1) ;
+0075 end
+0076 end
+0077
+0078 [j1,lj1] = ffill (j1,lj1,selif (temp+M_.maximum_lag*ny, temp <= ny)) ;
+0079 ltemp = zeros(M_.maximum_lag,1) ;
+0080 jwc1 = zeros(ncc1,M_.maximum_lag) ;
+0081
+0082 for i = 1:M_.maximum_lag
+0083 temp = union (jwc(1:ljwc(i),i),icc1) ;
+0084 ltemp(i) = size(temp,1) ;
+0085 if ljwc(i) > 0
+0086 jwc(1:ljwc(i),i) = indnv (jwc(1:ljwc(i),i),temp) ;
+0087 end
+0088 jwc1(:,i) = indnv (icc1,temp) ;
+0089 end
+0090
+0091 h1 = clock ;
+0092
+0093 disp (['-----------------------------------------------------' ]) ;
+0094 disp ('MODEL SIMULATION' ) ;
+0095 fprintf ('\n' ) ;
+0096
+0097 for iter = 1:options_.maxit
+0098 h2 = clock ;
+0099 oo_.y_simul = oo_.y_simul(:);
+0100 err_f = 0;
+0101
+0102 fid = fopen('dynare.swp' ,'w+' ) ;
+0103
+0104 it_ = 1+M_.maximum_lag ;
+0105 ic = [1:ny] ;
+0106 iyr = iyr0 ;
+0107 i = M_.maximum_lag+1 ;
+0108 while (i>1) & (it_<=options_.periods+M_.maximum_lag)
+0109 h3 = clock ;
+0110 if broyden_ & iter > 1
+0111
+0112 d1 = -feval([M_.fname '_dynamic' ],oo_.y_simul(iyr),z,oo_.exo_simul);
+0113 else
+0114
+0115 [d1,M_.jacobia] = feval([M_.fname '_dynamic' ],oo_.y_simul(iyr),oo_.exo_simul);
+0116 d1 = -d1 ;
+0117 end
+0118 err_f = max(err_f,max(abs(d1)));
+0119 if lky(i) ~= 0
+0120 j1i = ky(1:lky(i),i) ;
+0121 w0 = M_.jacobia(:,isc(i-1)+1:isc(i)) ;
+0122 else
+0123 w0 = [];
+0124 end
+0125 ttemp = iy(i+1:i+M_.maximum_lead,:)' ;
+0126 jwci = find(ttemp) ;
+0127 if ~ isempty(jwci)
+0128 w = M_.jacobia(:,isc(i)+1:isc(i+M_.maximum_lead)) ;
+0129 end
+0130 j = i ;
+0131 while j <= M_.maximum_lag
+0132 if ~isempty(w0)
+0133
+0134 ofs = ((it_-M_.maximum_lag-M_.maximum_lag+j-2)*ny)*ncc*8 ;
+0135 junk = fseek(fid,ofs,-1) ;
+0136 c = fread(fid,[ncc,ny],'float64' ) ;
+0137
+0138 if isempty(jwci)
+0139 w = -w0*c(j1i,1:ncc1) ;
+0140 jwci = icc1 ;
+0141 else
+0142 iz = union (jwci,icc1) ;
+0143 ix = indnv (jwci,iz) ;
+0144 iy__ = indnv (icc1,iz) ;
+0145 temp = zeros(size(w,1),size(iz,1)) ;
+0146 temp(:,ix) = w ;
+0147 temp(:,iy__) = temp(:,iy__)-w0*c(j1i,1:ncc1) ;
+0148 w = temp ;
+0149 jwci = iz ;
+0150 clear temp iz ix iy__ ;
+0151 end
+0152 d1 = d1-w0*c(j1i,ncc) ;
+0153 clear c ;
+0154 end
+0155 j = j + 1 ;
+0156 if isempty(jwci)
+0157 j1i = [];
+0158 if lky(j+M_.maximum_lead) ~= 0
+0159 jwci = ky(1:lky(j+M_.maximum_lead),j+M_.maximum_lead) + (M_.maximum_lead-1)*ny ;
+0160 w = M_.jacobia(:,isc(j+M_.maximum_lead-1)+1:isc(j+M_.maximum_lead)) ;
+0161 else
+0162 jwci = [] ;
+0163 end
+0164 else
+0165 j1i = selif (jwci,jwci<(ny+1)) ;
+0166 w0 = w(:,1:size(j1i,1)) ;
+0167 if size(jwci,1) == size(j1i,1)
+0168 if lky(j+M_.maximum_lead) ~= 0
+0169 jwci = ky(1:lky(j+M_.maximum_lead),j+M_.maximum_lead)+(M_.maximum_lead-1)*ny ;
+0170 w = M_.jacobia(:,isc(j+M_.maximum_lead-1)+1:isc(j+M_.maximum_lead)) ;
+0171 else
+0172 jwci = [] ;
+0173 end
+0174 else
+0175 jwci = jwci(size(j1i,1)+1:size(jwci,1),:)-ny ;
+0176 w = w(:,size(j1i,1)+1:size(w,2)) ;
+0177 if lky(j+M_.maximum_lead) ~= 0
+0178 jwci = [ jwci; ky(1: lky(j+M_.maximum_lead),j+M_.maximum_lead)+(M_.maximum_lead-1)*ny] ;
+0179 w = [w M_.jacobia(:,isc(j+M_.maximum_lead-1)+1:isc(j+M_.maximum_lead))] ;
+0180
+0181
+0182 end
+0183 end
+0184 end
+0185 end
+0186 jwci = [indnv (jwci,icc1);ncc] ;
+0187 w = [w d1] ;
+0188 c = zeros(ny,ncc) ;
+0189 c(:,jwci) = w0\w ;
+0190 clear w w0 ;
+0191
+0192 junk = fseek(fid,0,1) ;
+0193 fwrite(fid,c,'float64' ) ;
+0194 clear c ;
+0195
+0196 it_ = it_ + 1;
+0197 ic = ic + ny ;
+0198 iyr = iyr + ny ;
+0199 i = i - 1 ;
+0200 end
+0201 icr0 = (it_-M_.maximum_lag-M_.maximum_lag -1)*ny ;
+0202 while it_ <= options_.periods+M_.maximum_lag
+0203 if broyden_
+0204
+0205 d1 = -feval([M_.fname '_dynamic' ],oo_.y_simul(iyr),z,oo_.exo_simul);
+0206 else
+0207
+0208 [d1,M_.jacobia] = feval([M_.fname '_dynamic' ],oo_.y_simul(iyr),oo_.exo_simul);
+0209 d1 = -d1 ;
+0210 end
+0211 err_f = max(err_f,max(abs(d1)));
+0212 w0 = M_.jacobia(:,1:isc(1)) ;
+0213 w = M_.jacobia(:,isc(1)+1:isc(1+M_.maximum_lead)) ;
+0214 j = 1 ;
+0215 while j <= M_.maximum_lag
+0216 icr = j1(1:lj1(j),j)-(j-1)*ny ;
+0217
+0218 ofs = ((icr0+(j-1)*ny+1)-1)*ncc*8 ;
+0219 junk = fseek(fid,ofs,-1) ;
+0220 c = fread(fid,[ncc,ny],'float64' ) ;
+0221
+0222 temp = zeros(ny,ltemp(j)) ;
+0223 if ljwc(j) > 0
+0224 temp(:,jwc(1:ljwc(j),j)) = w ;
+0225 end
+0226 temp(:,jwc1(:,j))=temp(:,jwc1(:,j))-w0*c(icr,1:ncc1) ;
+0227 w = temp ;
+0228 clear temp ;
+0229 d1 = d1-w0*c(icr,ncc) ;
+0230 clear c ;
+0231 j = j + 1 ;
+0232 w0 = w(:,1:lj1(j)) ;
+0233 if M_.maximum_lead == 1
+0234 w = M_.jacobia(:,isc(j+M_.maximum_lead-1)+1:isc(j+M_.maximum_lead)) ;
+0235 else
+0236 w = w(:,lj1(j)+1:size(w,2)) ;
+0237
+0238 if lky(j+M_.maximum_lead) > 0
+0239 w = [w M_.jacobia(:,isc(j+M_.maximum_lead-1)+1:isc(j+M_.maximum_lead))] ;
+0240 end
+0241 end
+0242 end
+0243 c = w0\[w d1] ;
+0244 d1 = [] ;
+0245 clear w w0 ;
+0246 junk = fseek(fid,0,1) ;
+0247 fwrite(fid,c,'float64' ) ;
+0248 clear c ;
+0249 it_ = it_ + 1 ;
+0250 ic = ic + ny ;
+0251 iyr = iyr + ny ;
+0252 icr0 = icr0 + ny ;
+0253 end
+0254 if ct_ == 1
+0255
+0256 ofs = (((it_-M_.maximum_lag-2)*ny+1)-1)*ncc*8 ;
+0257 junk = fseek(fid,ofs,-1) ;
+0258 c = fread(fid,[ncc,ny],'float64' ) ;
+0259
+0260 for i = 1:M_.maximum_lead
+0261 w = tril(triu(ones(ny,ny+ncc1))) ;
+0262 w(:,jwc1(:,M_.maximum_lag)) = w(:,jwc1(:,M_.maximum_lag))+c(:,1:ncc1) ;
+0263 c = [w(:,ny+1:size(w,2))' c(:,ncc)]/w(:,1:ny) ;
+0264
+0265 junk = fseek(fid,0,1) ;
+0266 fwrite(fid,c,'float64' ) ;
+0267
+0268 it_ = it_+1 ;
+0269 ic = ic + ny ;
+0270
+0271 end
+0272 end
+0273 oo_.y_simul = reshape(oo_.y_simul,ny,options_.periods+M_.maximum_lag+M_.maximum_lead) ;
+0274 if ct_ == 1
+0275 hbacsup = clock ;
+0276 c = bksupk (ny,fid,ncc,icc1) ;
+0277 hbacsup = etime(clock,hbacsup) ;
+0278 c = reshape(c,ny,options_.periods+M_.maximum_lead)' ;
+0279 y(:,1+M_.maximum_lag:(options_.periods+M_.maximum_lead+M_.maximum_lag)) = y(:,1+M_.maximum_lag:(options_.periods+M_.maximum_lead+M_.maximum_lag))+options_.slowc*c' ;
+0280 else
+0281 hbacsup = clock ;
+0282 c = bksupk (ny,fid,ncc,icc1) ;
+0283 hbacsup = etime(clock,hbacsup) ;
+0284 c = reshape(c,ny,options_.periods)' ;
+0285 oo_.y_simul(:,1+M_.maximum_lag:(options_.periods+M_.maximum_lag)) = oo_.y_simul(:,1+M_.maximum_lag:(options_.periods+M_.maximum_lag))+options_.slowc*c' ;
+0286 end
+0287
+0288 fclose(fid) ;
+0289
+0290 h2 = etime(clock,h2) ;
+0291 [junk,i1] = max(abs(c));
+0292 [junk,i2] = max(junk);
+0293 disp(['variable ' M_.endo_names(i2,:) ' period ' num2str(i1(i2))])
+0294 err = max(max(abs(c./options_.scalv'))) ;
+0295 disp ([num2str(iter) '- err = ' num2str(err)]) ;
+0296 disp (['err_f = ' num2str(err_f)])
+0297 disp ([' Time of this iteration : ' num2str(h2)]) ;
+0298 if options_.timing
+0299 disp ([' Back substitution : ' num2str(hbacsup)]) ;
+0300 end
+0301 if err < options_.dynatol
+0302 h1 = etime(clock,h1) ;
+0303 fprintf ('\n' ) ;
+0304 disp ([' Total time of simulation : ' num2str(h1)]) ;
+0305 fprintf ('\n' ) ;
+0306 disp ([' Convergence achieved.' ]) ;
+0307 disp (['-----------------------------------------------------' ]) ;
+0308 fprintf ('\n' ) ;
+0309 return ;
+0310 end
+0311 end
+0312 disp(['WARNING : the maximum number of iterations is reached.' ]) ;
+0313 fprintf ('\n' ) ;
+0314 disp (['-----------------------------------------------------' ]) ;
+0315 return ;
+0316
+0317
+0318
+0319
+0320
+0321
+0322
+0323
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/simul.html b/matlab/doc/simul.html
new file mode 100644
index 000000000..1af1e0a32
--- /dev/null
+++ b/matlab/doc/simul.html
@@ -0,0 +1,119 @@
+
+
+
+ Description of simul
+
+
+
+
+
+
+
+
+
+
+
+
+
+simul
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function simul(dr)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function simul(dr)
+0004
+0005 global M_ options_ oo_
+0006 global ys0_ ct_ endval_
+0007
+0008 if size(M_.lead_lag_incidence,2)-nnz(M_.lead_lag_incidence(M_.maximum_lag+1,:)) > 0
+0009 mess = ['DYNARE: error in model specification : variable ' M_.endo_names(find(M_.lead_lag_incidence(M_.maximum_lag+1,:)==0),:)] ;
+0010 mess = [mess ' doesn''t appear as current variable.' ] ;
+0011 error (mess) ;
+0012 end
+0013
+0014 options_ = set_default_option (options_,'simul_algo' ,0);
+0015 options_ = set_default_option (options_,'dynatol' ,0.00001);
+0016 options_ = set_default_option (options_,'maxit' ,10);
+0017 options_ = set_default_option (options_,'slowc' ,1);
+0018 options_ = set_default_option (options_,'timing' ,0);
+0019 options_ = set_default_option (options_,'gstep' ,1e-2);
+0020 options_ = set_default_option (options_,'scalv' ,1);
+0021 if ~isfield(options_,'periods' ) & ~isempty(options_.periods)
+0022 options_.periods = options_.periods
+0023 end
+0024 options_ = set_default_option (options_,'periods' ,0);
+0025 if options_.periods == 0
+0026 error('SIMUL: number of periods for the simulation isn''t specified' )
+0027 end
+0028 options_.periods = options_.periods;
+0029 ct_=0;
+0030
+0031 if options_.simul_algo == 0
+0032 if ~ options_.initval_file
+0033 make_y_ ;
+0034 make_ex_ ;
+0035 end
+0036
+0037 if isempty(options_.scalv) | options_.scalv == 0
+0038 options_.scalv = oo_.steady_state ;
+0039 end
+0040
+0041 options_.scalv= 1 ;
+0042
+0043 if M_.maximum_lag ==1 & M_.maximum_lead <= 1
+0044 sim1 ;
+0045 else
+0046 simk ;
+0047 end
+0048 else
+0049 set_default_option ('replic' ,1);
+0050 set_default_option ('simul_seed' ,1);
+0051 if isfield(dr,'ghxx' )
+0052 set_default_option ('order' ,2);
+0053 else
+0054 set_defaut_option('order' ,1);
+0055 end
+0056 oo_.y_simul=simult (oo_.steady_state,dr,options_);
+0057 end
+0058
+0059 dyn2vec ;
+0060
+0061
+0062
+0063
+0064
+0065
+0066
+0067
+0068
+0069
+0070
+0071
+0072
+0073
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/simulinkicon.gif b/matlab/doc/simulinkicon.gif
new file mode 100644
index 000000000..1386ddd4c
Binary files /dev/null and b/matlab/doc/simulinkicon.gif differ
diff --git a/matlab/doc/simult.html b/matlab/doc/simult.html
new file mode 100644
index 000000000..1eedb5839
--- /dev/null
+++ b/matlab/doc/simult.html
@@ -0,0 +1,100 @@
+
+
+
+ Description of simult
+
+
+
+
+
+
+
+
+
+
+
+
+
+simult
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function y_=simult(ys, dr)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+simult_ Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+olr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardsimul Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004 function y_=simult(ys, dr)
+0005 global M_ options_ oo_
+0006 global it_ means_
+0007
+0008 order = options_.order;
+0009 replic = options_.replic;
+0010 seed = options_.simul_seed;
+0011 options_.periods = options_.periods;
+0012
+0013 it_ = M_.maximum_lag + 1 ;
+0014
+0015 if replic > 1
+0016 fname = [M_.fname,'_simul' ];
+0017 fh = fopen(fname,'w+' );
+0018 end
+0019
+0020
+0021 i_exo_var = setdiff([1:M_.exo_nbr],find(diag(M_.Sigma_e) == 0));
+0022 nxs = length(i_exo_var);
+0023 oo_.exo_simul = zeros(M_.maximum_lag+M_.maximum_lead+options_.periods,M_.exo_nbr);
+0024 chol_S = chol(M_.Sigma_e(i_exo_var,i_exo_var));
+0025
+0026 for i=1:replic
+0027 if isempty(seed)
+0028 randn('state' ,sum(100*clock));
+0029 else
+0030 randn('state' ,seed+i-1);
+0031 end
+0032 if ~isempty(M_.Sigma_e)
+0033 oo_.exo_simul(:,i_exo_var) = randn(M_.maximum_lag+M_.maximum_lead+options_.periods,nxs)*chol_S;
+0034 end
+0035 y_ = simult_ (ys,dr,oo_.exo_simul,order);
+0036 if replic > 1
+0037 fwrite(fh,oo_.y_simul(:,M_.maximum_lag+1:end),'float64' );
+0038 end
+0039 end
+0040
+0041 if replic > 1
+0042 fclose(fh);
+0043 end
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052
+0053
+0054
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/simult_.html b/matlab/doc/simult_.html
new file mode 100644
index 000000000..127376c1a
--- /dev/null
+++ b/matlab/doc/simult_.html
@@ -0,0 +1,112 @@
+
+
+
+ Description of simult_
+
+
+
+
+
+
+
+
+
+
+
+
+
+simult_
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function y_=simult_(y0,dr,ex_,iorder)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004 function y_=simult_(y0,dr,ex_,iorder)
+0005 global M_ options_ it_
+0006 iter = size(ex_,1);
+0007 nx = size(dr.ghu,2);
+0008 y_ = zeros(size(y0,1),iter+M_.maximum_lag);
+0009 y_(:,1:M_.maximum_lag) = y0;
+0010 k1 = [M_.maximum_lag:-1:1];
+0011 k2 = dr.kstate(find(dr.kstate(:,2) <= M_.maximum_lag+1),[1 2]);
+0012 k2 = k2(:,1)+(M_.maximum_lag+1-k2(:,2))*M_.endo_nbr;
+0013 k3 = M_.lead_lag_incidence(1:M_.maximum_lag,:)';
+0014 k3 = find(k3(:));
+0015 k4 = dr.kstate(find(dr.kstate(:,2) < M_.maximum_lag+1),[1 2]);
+0016 k4 = k4(:,1)+(M_.maximum_lag+1-k4(:,2))*M_.endo_nbr;
+0017
+0018 options_ = set_default_option (options_,'simul_algo' ,0);
+0019 if options_.simul_algo == 1
+0020 o1 = dr.nstatic+1;
+0021 o2 = dr.nstatic+dr.npred;
+0022 o3 = o2-dr.nboth+1;
+0023 [junk, k5] = sort(dr.order_var(o1:o2));
+0024 [junk, k6] = sort(dr.order_var(o3:end));
+0025 end
+0026
+0027 if iorder == 1
+0028 for i = M_.maximum_lag+1: iter+M_.maximum_lag
+0029 tempx1 = y_(dr.order_var,k1);
+0030 tempx2 = tempx1-repmat(dr.ys(dr.order_var),1,M_.maximum_lag);
+0031 tempx = tempx2(k2);
+0032 if options_.simul_algo == 0
+0033 y_(dr.order_var,i) = dr.ys(dr.order_var)+dr.ghx*tempx+dr.ghu* ...
+0034 ex_(i-M_.maximum_lag,:)';
+0035 elseif options_.simul_algo == 1
+0036 it_ = i;
+0037 m = dr.ys(dr.order_var);
+0038 [y_(:,i), check ] = dynare_solve ('ff_simul1' ,y_(:,i-1),tempx1(k3), ...
+0039 m(o3:end),tempx(k4),o1,o2,o3,k6);
+0040 end
+0041 k1 = k1+1;
+0042 end
+0043 elseif iorder == 2
+0044 for i = M_.maximum_lag+1: iter+M_.maximum_lag
+0045 tempx1 = y_(dr.order_var,k1);
+0046 tempx2 = tempx1-repmat(dr.ys(dr.order_var),1,M_.maximum_lag);
+0047 tempx = tempx2(k2);
+0048 tempu = ex_(i-M_.maximum_lag,:)';
+0049 tempuu = kron(tempu,tempu);
+0050 if options_.simul_algo == 0
+0051 tempxx = kron(tempx,tempx);
+0052 tempxu = kron(tempx,tempu);
+0053 y_(dr.order_var,i) = dr.ys(dr.order_var)+dr.ghs2/2+dr.ghx*tempx+ ...
+0054 dr.ghu*tempu+0.5*(dr.ghxx*tempxx+dr.ghuu*tempuu)+dr.ghxu*tempxu;
+0055 elseif options_.simul_algo == 1
+0056 it_ = i;
+0057 m = dr.ys(dr.order_var)+dr.ghs2/2;
+0058 tempx1 = y_(:,k1);
+0059 [y_(:,i), check ] = dynare_solve ('ff_simul2' ,y_(:,i-1),tempx1(k3), ...
+0060 m(o3:end),tempx(k4),o1,o2,o3,k6);
+0061 end
+0062 k1 = k1+1;
+0063 end
+0064 end
+0065
+0066
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/smirnov.html b/matlab/doc/smirnov.html
new file mode 100644
index 000000000..ab7b350e1
--- /dev/null
+++ b/matlab/doc/smirnov.html
@@ -0,0 +1,107 @@
+
+
+
+ Description of smirnov
+
+
+
+
+
+
+
+
+
+
+
+
+
+smirnov
+
+
+ PURPOSE
+Smirnov test for 2 distributions
+
+ SYNOPSIS
+function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+filt_mc_ copyright Marco Ratto 2006stab_map_1 function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)
+
+
+
+ SOURCE CODE
+0001 function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010 if nargin<3
+0011 alpha = 0.05;
+0012 end
+0013 if nargin<4,
+0014 iflag=0;
+0015 end
+0016
+0017
+0018 xmix= [x1;x2];
+0019 bin = [-inf ; sort(xmix) ; inf];
+0020
+0021 ncount1 = histc (x1 , bin);
+0022 ncount2 = histc (x2 , bin);
+0023
+0024 cum1 = cumsum(ncount1)./sum(ncount1);
+0025 cum1 = cum1(1:end-1);
+0026
+0027 cum2 = cumsum(ncount2)./sum(ncount2);
+0028 cum2 = cum2(1:end-1);
+0029
+0030 n1= length(x1);
+0031 n2= length(x2);
+0032 n = n1*n2 /(n1+n2);
+0033
+0034
+0035
+0036 if iflag==0,
+0037 d = max(abs(cum1 - cum2));
+0038 elseif iflag==-1
+0039 d = max(cum2 - cum1);
+0040 elseif iflag==1
+0041 d = max(cum1 - cum2);
+0042 end
+0043
+0044
+0045
+0046
+0047 lam = max((sqrt(n) + 0.12 + 0.11/sqrt(n)) * d , 0);
+0048 if iflag == 0
+0049 j = [1:101]';
+0050 prob = 2 * sum((-1).^(j-1).*exp(-2*lam*lam*j.^2));
+0051
+0052 prob=max(prob,0);
+0053 prob=min(1,prob);
+0054 else
+0055 prob = exp(-2*lam*lam);
+0056 end
+0057
+0058 H = (alpha >= prob);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/solaris.png b/matlab/doc/solaris.png
new file mode 100644
index 000000000..e31e8a2a4
Binary files /dev/null and b/matlab/doc/solaris.png differ
diff --git a/matlab/doc/solve1.html b/matlab/doc/solve1.html
new file mode 100644
index 000000000..7fcd5a55d
--- /dev/null
+++ b/matlab/doc/solve1.html
@@ -0,0 +1,188 @@
+
+
+
+ Description of solve1
+
+
+
+
+
+
+
+
+
+
+
+
+
+solve1
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillardlnsrch1 Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)
+0004
+0005 global M_ options_ fjac
+0006
+0007 nn = length(j1);
+0008 fjac = zeros(nn,nn) ;
+0009 g = zeros(nn,1) ;
+0010
+0011 tolf = eps^(2/3) ;
+0012 tolmin = 3.7e-11 ;
+0013 tolx = 3.7e-11 ;
+0014
+0015 stpmx = 100 ;
+0016 maxit = 2000 ;
+0017
+0018 check = 0 ;
+0019
+0020 fvec = feval(func,x,varargin{:});
+0021 fvec = fvec(j1);
+0022
+0023 i = find(~isfinite(fvec));
+0024
+0025 if ~isempty(i)
+0026 disp(['STEADY: numerical initial values incompatible with the following' ...
+0027 ' equations' ])
+0028 disp(j1(i)')
+0029 end
+0030
+0031 f = 0.5*fvec'*fvec ;
+0032
+0033 if max(abs(fvec)) < 0.01*tolf
+0034 return ;
+0035 end
+0036
+0037 stpmax = stpmx*max([sqrt(x'*x);nn]) ;
+0038 first_time = 1;
+0039 for its = 1:maxit
+0040 if jacobian_flag
+0041 [fvec,fjac] = feval(func,x,varargin{:});
+0042 else
+0043 fvec = feval(func,x,varargin{:});
+0044 dh = max(abs(x(j2)),options_.gstep*ones(nn,1))*eps^(1/3);
+0045
+0046 for j = 1:nn
+0047 xdh = x ;
+0048 xdh(j2(j)) = xdh(j2(j))+dh(j) ;
+0049 t = feval(func,xdh,varargin{:});
+0050 fjac(:,j) = (t(j1) - fvec)./dh(j) ;
+0051 g(j) = fvec'*fjac(:,j) ;
+0052 end
+0053 end
+0054 fvec = fvec(j1);
+0055 fjac = fjac(j1,j2);
+0056 g = (fvec'*fjac)';
+0057 if options_.debug
+0058 disp(['cond(fjac) ' num2str(cond(fjac))])
+0059 end
+0060 M_.unit_root = 0;
+0061 if M_.unit_root
+0062 if first_time
+0063 first_time = 0;
+0064 [q,r,e]=qr(fjac);
+0065 n = sum(abs(diag(r)) < 1e-12);
+0066 fvec = q'*fvec;
+0067 p = e*[-r(1:end-n,1:end-n)\fvec(1:end-n);zeros(n,1)];
+0068 disp(' ' )
+0069 disp('STEADY with unit roots:' )
+0070 disp(' ' )
+0071 if n > 0
+0072 disp([' The following variable(s) kept their value given in INITVAL' ...
+0073 ' or ENDVAL' ])
+0074 disp(char(e(:,end-n+1:end)'*M_.endo_names))
+0075 else
+0076 disp(' STEADY can''t find any unit root!' )
+0077 end
+0078 else
+0079 [q,r]=qr(fjac*e);
+0080 fvec = q'*fvec;
+0081 p = e*[-r(1:end-n,1:end-n)\fvec(1:end-n);zeros(n,1)];
+0082 end
+0083
+0084 elseif cond(fjac) > 1/sqrt(eps)
+0085 fjac2=fjac'*fjac;
+0086 p=-(fjac2+sqrt(nn*eps)*max(sum(abs(fjac2)))*eye(nn))\(fjac'*fvec);
+0087 else
+0088 p = -fjac\fvec ;
+0089 end
+0090 xold = x ;
+0091 fold = f ;
+0092
+0093 [x,f,fvec,check ]=lnsrch1 (xold,fold,g,p,stpmax,func,j1,j2,varargin{:});
+0094
+0095 if options_.debug
+0096 disp([its f])
+0097 disp([xold x])
+0098 end
+0099
+0100 if check > 0
+0101 den = max([f;0.5*nn]) ;
+0102 if max(abs(g).*max([abs(x');ones(1,nn)])')/den < tolmin
+0103 return
+0104 else
+0105 disp (' ' )
+0106 disp (['SOLVE: Iteration ' num2str(its)])
+0107 disp (['Spurious convergence.' ])
+0108 disp (x)
+0109 return
+0110 end
+0111
+0112 if max(abs(x-xold)./max([abs(x);ones(1,nn)])') < tolx
+0113 disp (' ' )
+0114 disp (['SOLVE: Iteration ' num2str(its)])
+0115 disp (['Convergence on dX.' ])
+0116 disp (x)
+0117 return
+0118 end
+0119 elseif f < tolf
+0120 return
+0121 end
+0122 end
+0123
+0124 check = 1;
+0125 disp(' ' )
+0126 disp('SOLVE: maxit has been reached' )
+0127
+0128
+0129
+0130
+0131
+0132
+0133
+0134
+0135
+0136
+0137
+0138
+0139
+0140
+0141
+0142
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/stab_map_.html b/matlab/doc/stab_map_.html
new file mode 100644
index 000000000..866dac179
--- /dev/null
+++ b/matlab/doc/stab_map_.html
@@ -0,0 +1,488 @@
+
+
+
+ Description of stab_map_
+
+
+
+
+
+
+
+
+
+
+
+
+
+stab_map_
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function x0 = stab_map_(Nsam, fload, ksstat, alpha2, prepSA, pprior, ilptau, OutputDirectoryName)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+lptauSEQ [lpmat] = lptauSEQ(Nsam,Nvar)stab_map_1 function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)stab_map_2 function stab_map_2(x,alpha2,istab,fnam)stoch_simul Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x0 = stab_map_(Nsam, fload, ksstat, alpha2, prepSA, pprior, ilptau, OutputDirectoryName)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025
+0026
+0027
+0028
+0029
+0030
+0031
+0032
+0033
+0034
+0035
+0036
+0037
+0038
+0039
+0040
+0041
+0042
+0043
+0044
+0045
+0046
+0047
+0048
+0049
+0050
+0051
+0052 global bayestopt_ estim_params_ options_ oo_ M_
+0053
+0054 dr_ = oo_.dr;
+0055 if isfield(dr_,'ghx' ),
+0056 ys_ = oo_.dr.ys;
+0057 nspred = size(dr_.ghx,2);
+0058 nboth = dr_.nboth;
+0059 nfwrd = dr_.nfwrd;
+0060 end
+0061 fname_ = M_.fname;
+0062
+0063 nshock = estim_params_.nvx;
+0064 nshock = nshock + estim_params_.nvn;
+0065 nshock = nshock + estim_params_.ncx;
+0066 nshock = nshock + estim_params_.ncn;
+0067
+0068
+0069 if nargin==0,
+0070 Nsam=2000;
+0071 end
+0072 if nargin<2,
+0073 fload=0;
+0074 end
+0075 if nargin<3,
+0076 ksstat=0.1;
+0077 end
+0078 if nargin<4,
+0079 alpha2=0.3;
+0080 end
+0081 if nargin<5,
+0082 prepSA=0;
+0083 end
+0084 if nargin<6,
+0085 pprior=1;
+0086 end
+0087 if nargin<7,
+0088 ilptau=1;
+0089 end
+0090 if nargin<8,
+0091 OutputDirectoryName='' ;
+0092 end
+0093
+0094 options_.periods=0;
+0095 options_.nomoments=1;
+0096 options_.irf=0;
+0097 options_.noprint=1;
+0098
+0099 if fload==0 | nargin<2 | isempty(fload),
+0100 if prepSA
+0101 T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam/2);
+0102 end
+0103
+0104
+0105 if estim_params_.np<52 & ilptau,
+0106 [lpmat] = lptauSEQ (Nsam,estim_params_.np);
+0107 if estim_params_.np>30
+0108 for j=1:estim_params_.np,
+0109 lpmat(:,j)=lpmat(randperm(Nsam),j);
+0110 end
+0111 end
+0112 else
+0113
+0114 for j=1:estim_params_.np,
+0115 lpmat(:,j) = randperm(Nsam)'./(Nsam+1);
+0116 end
+0117 end
+0118
+0119 if pprior,
+0120 for j=1:nshock,
+0121 lpmat0(:,j) = randperm(Nsam)'./(Nsam+1);
+0122 lpmat0(:,j)=lpmat0(:,j).*(bayestopt_.ub(j)-bayestopt_.lb(j))+bayestopt_.lb(j);
+0123 end
+0124 for j=1:estim_params_.np,
+0125 lpmat(:,j)=lpmat(:,j).*(bayestopt_.ub(j+nshock)-bayestopt_.lb(j+nshock))+bayestopt_.lb(j+nshock);
+0126 end
+0127 else
+0128
+0129
+0130
+0131
+0132
+0133
+0134
+0135
+0136
+0137
+0138
+0139
+0140
+0141
+0142
+0143
+0144
+0145
+0146
+0147
+0148
+0149
+0150
+0151
+0152
+0153
+0154
+0155
+0156
+0157
+0158 eval(['load ' options_.mode_file ';' ]');
+0159 d = chol(inv(hh));
+0160 lp=randn(Nsam*2,nshock+estim_params_.np)*d+kron(ones(Nsam*2,1),xparam1');
+0161 for j=1:Nsam*2,
+0162 lnprior(j) = any(lp(j,:)'<=bayestopt_.lb | lp(j,:)'>=bayestopt_.ub);
+0163 end
+0164 ireal=[1:2*Nsam];
+0165 ireal=ireal(find(lnprior==0));
+0166 lp=lp(ireal,:);
+0167 Nsam=min(Nsam, length(ireal));
+0168 lpmat0=lp(1:Nsam,1:nshock);
+0169 lpmat=lp(1:Nsam,nshock+1:end);
+0170 clear lp lnprior ireal;
+0171 end
+0172
+0173 h = waitbar(0,'Please wait...' );
+0174 istable=[1:Nsam];
+0175 jstab=0;
+0176 iunstable=[1:Nsam];
+0177 iindeterm=zeros(1,Nsam);
+0178 iwrong=zeros(1,Nsam);
+0179 for j=1:Nsam,
+0180 M_.params(estim_params_.param_vals(:,1)) = lpmat(j,:)';
+0181 stoch_simul ([]);
+0182 dr_ = oo_.dr;
+0183 if isfield(dr_,'ghx' ),
+0184 egg(:,j) = sort(dr_.eigval);
+0185 iunstable(j)=0;
+0186 if prepSA
+0187 jstab=jstab+1;
+0188 T(:,:,jstab) = [dr_.ghx dr_.ghu];
+0189 end
+0190 if ~exist('nspred' ),
+0191 nspred = size(dr_.ghx,2);
+0192 nboth = dr_.nboth;
+0193 nfwrd = dr_.nfwrd;
+0194 end
+0195 else
+0196 istable(j)=0;
+0197 if isfield(dr_,'eigval' )
+0198 egg(:,j) = sort(dr_.eigval);
+0199 if any(isnan(egg(1:nspred,j)))
+0200 iwrong(j)=j;
+0201 else
+0202 if (nboth | nfwrd) & abs(egg(nspred+1,j))<=options_.qz_criterium,
+0203 iindeterm(j)=j;
+0204 end
+0205 end
+0206 else
+0207 egg(:,j)=ones(size(egg,1),1).*1.1;
+0208 iwrong(j)=j;
+0209 end
+0210 end
+0211 ys_=real(dr_.ys);
+0212 yys(:,j) = ys_;
+0213 ys_=yys(:,1);
+0214 waitbar(j/Nsam,h,['MC iteration ' ,int2str(j),'/' ,int2str(Nsam)])
+0215 end
+0216 close(h)
+0217 if prepSA,
+0218 T=T(:,:,1:jstab);
+0219 end
+0220 istable=istable(find(istable));
+0221 iunstable=iunstable(find(iunstable));
+0222 iindeterm=iindeterm(find(iindeterm));
+0223 iwrong=iwrong(find(iwrong));
+0224
+0225
+0226
+0227
+0228
+0229
+0230
+0231
+0232
+0233
+0234
+0235
+0236
+0237
+0238
+0239
+0240
+0241
+0242
+0243
+0244
+0245
+0246
+0247
+0248
+0249
+0250
+0251
+0252
+0253
+0254
+0255
+0256
+0257
+0258
+0259 if pprior,
+0260 if ~prepSA
+0261 save([OutputDirectoryName '\' fname_ '_prior' ],'lpmat' ,'lpmat0' ,'iunstable' ,'istable' ,'iindeterm' ,'iwrong' ,'egg' ,'yys' ,'nspred' ,'nboth' ,'nfwrd' )
+0262 else
+0263 save([OutputDirectoryName '\' fname_ '_prior' ],'lpmat' ,'lpmat0' ,'iunstable' ,'istable' ,'iindeterm' ,'iwrong' ,'egg' ,'yys' ,'T' ,'nspred' ,'nboth' ,'nfwrd' )
+0264 end
+0265
+0266 else
+0267 if ~prepSA
+0268 save([OutputDirectoryName '\' fname_ '_mc' ], ...
+0269 'lpmat' ,'lpmat0' ,'iunstable' ,'istable' ,'iindeterm' ,'iwrong' ,'egg' ,'yys' ,'nspred' ,'nboth' ,'nfwrd' )
+0270 else
+0271 save([OutputDirectoryName '\' fname_ '_mc' ], ...
+0272 'lpmat' ,'lpmat0' ,'iunstable' ,'istable' ,'iindeterm' ,'iwrong' ,'egg' ,'yys' ,'T' ,'nspred' ,'nboth' ,'nfwrd' )
+0273 end
+0274 end
+0275 else
+0276 if pprior,
+0277 filetoload=[OutputDirectoryName '\' fname_ '_prior' ];
+0278 else
+0279 filetoload=[OutputDirectoryName '\' fname_ '_mc' ];
+0280 end
+0281 load(filetoload,'lpmat' ,'lpmat0' ,'iunstable' ,'istable' ,'iindeterm' ,'iwrong' ,'egg' ,'yys' ,'nspred' ,'nboth' ,'nfwrd' )
+0282 Nsam = size(lpmat,1);
+0283
+0284 if prepSA & isempty(strmatch('T' ,who('-file' , filetoload),'exact' )),
+0285 h = waitbar(0,'Please wait...' );
+0286 options_.periods=0;
+0287 options_.nomoments=1;
+0288 options_.irf=0;
+0289 options_.noprint=1;
+0290 stoch_simul ([]);
+0291 T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),length(istable));
+0292 ntrans=length(istable);
+0293 for j=1:ntrans,
+0294 M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(j),:)';
+0295 stoch_simul ([]);
+0296 dr_ = oo_.dr;
+0297 T(:,:,j) = [dr_.ghx dr_.ghu];
+0298 if ~exist('nspred' )
+0299 nspred = size(dr_.ghx,2);
+0300 nboth = dr_.nboth;
+0301 nfwrd = dr_.nfwrd;
+0302 end
+0303 ys_=real(dr_.ys);
+0304 yys(:,j) = ys_;
+0305 ys_=yys(:,1);
+0306 waitbar(j/ntrans,h,['MC iteration ' ,int2str(j),'/' ,int2str(ntrans)])
+0307 end
+0308 close(h)
+0309 save(filetoload,'T' ,'-append' )
+0310 end
+0311 end
+0312
+0313 if pprior
+0314 aname='prior_stab' ;
+0315 auname='prior_unacceptable' ;
+0316 aunstname='prior_unstable' ;
+0317 aindname='prior_indeterm' ;
+0318 asname='prior_stable' ;
+0319 else
+0320 aname='mc_stab' ;
+0321 auname='mc_unacceptable' ;
+0322 aunstname='mc_unstable' ;
+0323 aindname='mc_indeterm' ;
+0324 asname='mc_stable' ;
+0325 end
+0326 delete([OutputDirectoryName,'\' ,fname_,'_' ,aname,'_*.*' ]);
+0327
+0328 delete([OutputDirectoryName,'\' ,fname_,'_' ,asname,'_corr_*.*' ]);
+0329 delete([OutputDirectoryName,'\' ,fname_,'_' ,auname,'_corr_*.*' ]);
+0330 delete([OutputDirectoryName,'\' ,fname_,'_' ,aunstname,'_corr_*.*' ]);
+0331 delete([OutputDirectoryName,'\' ,fname_,'_' ,aindname,'_corr_*.*' ]);
+0332
+0333 if length(iunstable)>0 & length(iunstable)<Nsam,
+0334 disp([num2str(length(istable)/Nsam*100),'\% of the prior support is stable.' ])
+0335 disp([num2str( (length(iunstable)-length(iwrong)-length(iindeterm) )/Nsam*100),'\% of the prior support is unstable.' ])
+0336 if ~isempty(iindeterm),
+0337 disp([num2str(length(iindeterm)/Nsam*100),'\% of the prior support gives indeterminacy.' ])
+0338 end
+0339 if ~isempty(iwrong),
+0340 disp(' ' );
+0341 disp(['For ' ,num2str(length(iwrong)/Nsam*100),'\% of the prior support dynare could not find a solution.' ])
+0342 end
+0343
+0344 [proba, dproba] = stab_map_1 (lpmat, istable, iunstable, aname,0);
+0345 indstab=find(dproba>ksstat);
+0346 disp('The following parameters mostly drive acceptable behaviour' )
+0347 disp(M_.param_names(estim_params_.param_vals(indstab,1),:))
+0348 stab_map_1 (lpmat, istable, iunstable, aname, 1, indstab, OutputDirectoryName);
+0349 if ~isempty(iindeterm),
+0350 ixun=iunstable(find(~ismember(iunstable,[iindeterm,iwrong])));
+0351 [proba, dproba] = stab_map_1 (lpmat, [1:Nsam], iindeterm, [aname, '_indet' ],0);
+0352 indindet=find(dproba>ksstat);
+0353 disp('The following parameters mostly drive indeterminacy' )
+0354 disp(M_.param_names(estim_params_.param_vals(indindet,1),:))
+0355 stab_map_1 (lpmat, [1:Nsam], iindeterm, [aname, '_indet' ], 1, indindet, OutputDirectoryName);
+0356 if ~isempty(ixun),
+0357 [proba, dproba] = stab_map_1 (lpmat, [1:Nsam], ixun, [aname, '_unst' ],0);
+0358 indunst=find(dproba>ksstat);
+0359 disp('The following parameters mostly drive instability' )
+0360 disp(M_.param_names(estim_params_.param_vals(indunst,1),:))
+0361 stab_map_1 (lpmat, [1:Nsam], ixun, [aname, '_unst' ], 1, indunst, OutputDirectoryName);
+0362 end
+0363 end
+0364
+0365 disp(' ' )
+0366 disp('Starting bivariate analysis:' )
+0367
+0368 c0=corrcoef(lpmat(istable,:));
+0369 c00=tril(c0,-1);
+0370
+0371 stab_map_2 (lpmat(istable,:),alpha2, asname, OutputDirectoryName);
+0372 stab_map_2 (lpmat(iunstable,:),alpha2, auname, OutputDirectoryName);
+0373 if ~isempty(iindeterm),
+0374 stab_map_2 (lpmat(iindeterm,:),alpha2, aindname, OutputDirectoryName);
+0375 if ~isempty(ixun),
+0376 stab_map_2 (lpmat(ixun,:),alpha2, aunstname, OutputDirectoryName);
+0377 end
+0378 end
+0379
+0380 x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
+0381 x0 = [x0; lpmat(istable(1),:)'];
+0382 if istable(end)~=Nsam
+0383 M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(1),:)';
+0384 stoch_simul ([]);
+0385 end
+0386 else
+0387 if length(iunstable)==0,
+0388 disp('All parameter values in the specified ranges are stable!' )
+0389 x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
+0390 x0 = [x0; lpmat(istable(1),:)'];
+0391 else
+0392 disp('All parameter values in the specified ranges are not acceptable!' )
+0393 x0=[];
+0394 end
+0395
+0396 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/stab_map_1.html b/matlab/doc/stab_map_1.html
new file mode 100644
index 000000000..da0d0da57
--- /dev/null
+++ b/matlab/doc/stab_map_1.html
@@ -0,0 +1,131 @@
+
+
+
+ Description of stab_map_1
+
+
+
+
+
+
+
+
+
+
+
+
+
+stab_map_1
+
+
+ PURPOSE
+function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)
+
+ SYNOPSIS
+function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+cumplot function h =cumplot(x)smirnov Smirnov test for 2 distributions
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018 global estim_params_ bayestopt_ M_ options_
+0019
+0020 if nargin<5,
+0021 iplot=1;
+0022 end
+0023 fname_ = M_.fname;
+0024 if nargin<7,
+0025 dirname='' ;;
+0026 end
+0027
+0028 nshock = estim_params_.nvx;
+0029 nshock = nshock + estim_params_.nvn;
+0030 nshock = nshock + estim_params_.ncx;
+0031 nshock = nshock + estim_params_.ncn;
+0032
+0033 npar=size(lpmat,2);
+0034 ishock= npar>estim_params_.np;
+0035
+0036 if nargin<6,
+0037 ipar=[1:npar];
+0038 end
+0039 nparplot=length(ipar);
+0040
+0041
+0042 for j=1:npar,
+0043 [H,P,KSSTAT] = smirnov (lpmat(ibehaviour,j),lpmat(inonbehaviour,j));
+0044 proba(j)=P;
+0045 dproba(j)=KSSTAT;
+0046 end
+0047 if iplot
+0048 lpmat=lpmat(:,ipar);
+0049 ftit=bayestopt_.name(ipar+nshock*(1-ishock));
+0050
+0051 for i=1:ceil(nparplot/12),
+0052 figure('name' ,aname),
+0053 for j=1+12*(i-1):min(nparplot,12*i),
+0054 subplot(3,4,j-12*(i-1))
+0055 if ~isempty(ibehaviour),
+0056 h=cumplot (lpmat(ibehaviour,j));
+0057 set(h,'color' ,[0 0 0], 'linestyle' ,':' )
+0058 end
+0059 hold on,
+0060 if ~isempty(inonbehaviour),
+0061 h=cumplot (lpmat(inonbehaviour,j));
+0062 set(h,'color' ,[0 0 0])
+0063 end
+0064 title([ftit{j},'. D-stat ' , num2str(dproba(ipar(j)),2)],'interpreter' ,'none' )
+0065 end
+0066 saveas(gcf,[dirname,'\' ,fname_,'_' ,aname,'_SA_' ,int2str(i)])
+0067 eval(['print -depsc2 ' dirname '\' fname_ '_' aname '_SA_' int2str(i)]);
+0068 eval(['print -dpdf ' dirname '\' fname_ '_' aname '_SA_' int2str(i)]);
+0069 if options_.nograph, close(gcf), end
+0070 end
+0071 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/stab_map_2.html b/matlab/doc/stab_map_2.html
new file mode 100644
index 000000000..8be741d5a
--- /dev/null
+++ b/matlab/doc/stab_map_2.html
@@ -0,0 +1,149 @@
+
+
+
+ Description of stab_map_2
+
+
+
+
+
+
+
+
+
+
+
+
+
+stab_map_2
+
+
+ PURPOSE
+function stab_map_2(x,alpha2,istab,fnam)
+
+ SYNOPSIS
+function stab_map_2(x,alpha2,fnam, dirname)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002 function stab_map_2(x,alpha2,fnam, dirname)
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017 global bayestopt_ estim_params_ options_ oo_ M_
+0018
+0019 npar=size(x,2);
+0020 ishock= npar>estim_params_.np;
+0021 if nargin<3,
+0022 fnam='' ;
+0023 end
+0024 if nargin<4,
+0025 dirname='' ;
+0026 end
+0027
+0028 ys_ = oo_.dr.ys;
+0029 dr_ = oo_.dr;
+0030 fname_ = M_.fname;
+0031 nshock = estim_params_.nvx;
+0032 nshock = nshock + estim_params_.nvn;
+0033 nshock = nshock + estim_params_.ncx;
+0034 nshock = nshock + estim_params_.ncn;
+0035
+0036 c0=corrcoef(x);
+0037 c00=tril(c0,-1);
+0038 fig_nam_=[fname_,'_' ,fnam,'_corr_' ];
+0039
+0040 ifig=0;
+0041 j2=0;
+0042 if ishock==0
+0043 npar=estim_params_.np;
+0044 else
+0045 npar=estim_params_.np+nshock;
+0046 end
+0047 for j=1:npar,
+0048 i2=find(abs(c00(:,j))>alpha2);
+0049 if length(i2)>0,
+0050 for jx=1:length(i2),
+0051 j2=j2+1;
+0052 if mod(j2,12)==1,
+0053 ifig=ifig+1;
+0054 figure('name' ,['Correlations in the ' ,fnam,' sample ' , num2str(ifig)]),
+0055 end
+0056 subplot(3,4,j2-(ifig-1)*12)
+0057
+0058
+0059
+0060
+0061
+0062 plot(x(:,j),x(:,i2(jx)),'.' )
+0063
+0064
+0065 if ishock,
+0066 xlabel(bayestopt_.name{j},'interpreter' ,'none' ),
+0067 ylabel(bayestopt_.name{i2(jx)},'interpreter' ,'none' ),
+0068 else
+0069 xlabel(bayestopt_.name{j+nshock},'interpreter' ,'none' ),
+0070 ylabel(bayestopt_.name{i2(jx)+nshock},'interpreter' ,'none' ),
+0071 end
+0072 title(['cc = ' ,num2str(c0(i2(jx),j))])
+0073 if (mod(j2,12)==0) & j2>0,
+0074 saveas(gcf,[dirname,'\' ,fig_nam_,int2str(ifig)])
+0075 eval(['print -depsc2 ' dirname '\' fig_nam_ int2str(ifig)]);
+0076 eval(['print -dpdf ' dirname '\' fig_nam_ int2str(ifig)]);
+0077 if options_.nograph, close(gcf), end
+0078 end
+0079 end
+0080 end
+0081 if (j==(npar)) & j2>0,
+0082 saveas(gcf,[dirname,'\' ,fig_nam_,int2str(ifig)])
+0083 eval(['print -depsc2 ' dirname '\' fig_nam_ int2str(ifig)]);
+0084 eval(['print -dpdf ' dirname '\' fig_nam_ int2str(ifig)]);
+0085 if options_.nograph, close(gcf), end
+0086 end
+0087
+0088 end
+0089 if ifig==0,
+0090 disp(['No correlation term >' , num2str(alpha2),' found for ' ,fnam])
+0091 end
+0092
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/stab_map_marginal.html b/matlab/doc/stab_map_marginal.html
new file mode 100644
index 000000000..4ab71abb5
--- /dev/null
+++ b/matlab/doc/stab_map_marginal.html
@@ -0,0 +1,120 @@
+
+
+
+ Description of stab_map_marginal
+
+
+
+
+
+
+
+
+
+Home >
. > stab_map_marginal.m
+
+
+
+stab_map_marginal
+
+
+ PURPOSE
+function stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, ipar, dirname)
+
+ SYNOPSIS
+function stab_map_marginal(lpmat, ibehaviour, inonbehaviour, aname, ipar, dirname)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function stab_map_marginal(lpmat, ibehaviour, inonbehaviour, aname, ipar, dirname)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016 global estim_params_ bayestopt_ M_ options_
+0017
+0018 fname_ = M_.fname;
+0019 if nargin<5,
+0020 ipar=[1:npar];
+0021 end
+0022 nparplot=length(ipar);
+0023 if nargin<6,
+0024 dirname='' ;;
+0025 end
+0026
+0027 nshock = estim_params_.nvx;
+0028 nshock = nshock + estim_params_.nvn;
+0029 nshock = nshock + estim_params_.ncx;
+0030 nshock = nshock + estim_params_.ncn;
+0031
+0032 npar=size(lpmat,2);
+0033 ishock= npar>estim_params_.np;
+0034
+0035 number_of_grid_points = 2^9;
+0036 bandwidth = 0;
+0037 kernel_function = 'gaussian' ;
+0038
+0039
+0040 lpmat=lpmat(:,ipar);
+0041 ftit=bayestopt_.name(ipar+nshock*(1-ishock));
+0042
+0043 for i=1:ceil(npar/12),
+0044 figure('name' ,aname),
+0045 for j=1+12*(i-1):min(npar,12*i),
+0046 subplot(3,4,j-12*(i-1))
+0047 optimal_bandwidth = mh_optimal_bandwidth (lpmat(ibehaviour,j),length(ibehaviour),bandwidth,kernel_function);
+0048 [x1,f1] = kernel_density_estimate (lpmat(ibehaviour,j),number_of_grid_points,...
+0049 optimal_bandwidth,kernel_function);
+0050 plot(x1, f1,':k' ,'linewidth' ,2)
+0051 optimal_bandwidth = mh_optimal_bandwidth (lpmat(inonbehaviour,j),length(inonbehaviour),bandwidth,kernel_function);
+0052 [x1,f1] = kernel_density_estimate (lpmat(inonbehaviour,j),number_of_grid_points,...
+0053 optimal_bandwidth,kernel_function);
+0054 hold on, plot(x1, f1,'k' ,'linewidth' ,2)
+0055
+0056 title(ftit{j},'interpreter' ,'none' )
+0057 end
+0058 saveas(gcf,[dirname,'/' ,fname_,'_' ,aname,'_' ,int2str(i)])
+0059 eval(['print -depsc2 ' dirname '\' fname_ '_' aname '_' int2str(i)]);
+0060 eval(['print -dpdf ' dirname '\' fname_ '_' aname '_' int2str(i)]);
+0061 if options_.nograph, close(gcf), end
+0062 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/steady.html b/matlab/doc/steady.html
new file mode 100644
index 000000000..3d0f522f6
--- /dev/null
+++ b/matlab/doc/steady.html
@@ -0,0 +1,75 @@
+
+
+
+ Description of steady
+
+
+
+
+
+
+
+
+
+
+
+
+
+steady
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function steady(linear)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+DiffuseKalmanSmoother1 modified by M. Ratto:DiffuseKalmanSmoother3 function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)DiffuseKalmanSmootherH1 modified by M. Ratto:DiffuseKalmanSmootherH3 Modified by M. RattoDiffuseKalmanSmootherH3corr stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function steady(linear)
+0004
+0005 global M_ oo_ options_ ys0_
+0006
+0007 options_ = set_default_option (options_,'jacobian_flag' ,1);
+0008
+0009 steady_ ;
+0010
+0011 disp(' ' )
+0012 disp('STEADY-STATE RESULTS:' )
+0013 disp(' ' )
+0014 endo_names = M_.endo_names;
+0015 steady_state = oo_.steady_state;
+0016 for i=1:size(oo_.steady_state,1)
+0017 disp(sprintf('%s \t\t %g' ,endo_names(i,:),steady_state(i)));
+0018 end
+0019
+0020 if isempty(ys0_)
+0021 oo_.y_simul(:,1:M_.maximum_lag) = oo_.steady_state * ones(1,M_.maximum_lag);
+0022 else
+0023 options_ =set_default_option (options_,'periods' ,1);
+0024 oo_.y_simul(:,M_.maximum_lag+1:M_.maximum_lag+options_.periods+M_.maximum_lead) = oo_.steady_state * ones(1,options_.periods+M_.maximum_lead);
+0025 end
+0026
+0027
+0028
+0029
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/steady_.html b/matlab/doc/steady_.html
new file mode 100644
index 000000000..374d7b55e
--- /dev/null
+++ b/matlab/doc/steady_.html
@@ -0,0 +1,70 @@
+
+
+
+ Description of steady_
+
+
+
+
+
+
+
+
+
+
+
+
+
+steady_
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function steady_()
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+check Copyright (C) 2001 Michel Juillarddynare_solve Copyright (C) 2001 Michel Juillard
+This function is called by:
+
+filt_mc_ copyright Marco Ratto 2006steady Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function steady_()
+0004
+0005 global M_ oo_ it_ options_
+0006
+0007 if exist([M_.fname '_steadystate' ])
+0008 [oo_.steady_state,check ] = feval([M_.fname '_steadystate' ],...
+0009 oo_.steady_state,...
+0010 [oo_.exo_steady_state; ...
+0011 oo_.exo_det_steady_state]);
+0012 else
+0013 [oo_.steady_state,check ] = dynare_solve ([M_.fname '_static' ],...
+0014 oo_.steady_state,...
+0015 options_.jacobian_flag, ...
+0016 [oo_.exo_steady_state; ...
+0017 oo_.exo_det_steady_state]);
+0018 end
+0019
+0020 if check ~= 0
+0021 error('STEADY: convergence problems' )
+0022 end
+0023
+0024
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/stoch_simul.html b/matlab/doc/stoch_simul.html
new file mode 100644
index 000000000..ac28b631a
--- /dev/null
+++ b/matlab/doc/stoch_simul.html
@@ -0,0 +1,322 @@
+
+
+
+ Description of stoch_simul
+
+
+
+
+
+
+
+
+
+
+
+
+
+stoch_simul
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function info=stoch_simul(var_list)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function info=stoch_simul(var_list)
+0004 global M_ options_ oo_
+0005
+0006 global it_
+0007 options_ = set_default_option (options_,'TeX' ,0);
+0008 options_ = set_default_option (options_,'order' ,2);
+0009 options_ = set_default_option (options_,'linear' ,0);
+0010 if options_.linear
+0011 options_.order = 1;
+0012 end
+0013 options_ = set_default_option (options_,'ar' ,5);
+0014 options_ = set_default_option (options_,'irf' ,40);
+0015 options_ = set_default_option (options_,'relative_irf' ,0);
+0016 options_ = set_default_option (options_,'dr_algo' ,0);
+0017 options_ = set_default_option (options_,'simul_algo' ,0);
+0018 options_ = set_default_option (options_,'drop' ,100);
+0019 if options_.order == 1
+0020 options_.replic = 1;
+0021 else
+0022 options_ = set_default_option (options_,'replic' ,50);
+0023 end
+0024 options_ = set_default_option (options_,'nomoments' ,0);
+0025 options_ = set_default_option (options_,'nocorr' ,0);
+0026 options_ = set_default_option (options_,'simul_seed' ,[]);
+0027 options_ = set_default_option (options_,'hp_filter' ,0);
+0028 options_ = set_default_option (options_,'hp_ngrid' ,512);
+0029 options_ = set_default_option (options_,'simul' ,0);
+0030 options_ = set_default_option (options_,'periods' ,0);
+0031 options_ = set_default_option (options_,'noprint' ,0);
+0032
+0033 TeX = options_.TeX;
+0034
+0035 iter_ = max(options_.periods,1);
+0036 if M_.exo_nbr > 0
+0037 oo_.exo_simul= ones(iter_ + M_.maximum_lag + M_.maximum_lead,1) * oo_.exo_steady_state';
+0038 end
+0039
+0040 check_model ;
+0041
+0042 [oo_.dr, info] = resol (oo_.steady_state,0);
+0043
+0044 if info(1)
+0045 print_info (info);
+0046 return
+0047 end
+0048
+0049 if ~options_.noprint
+0050 disp(' ' )
+0051 disp('MODEL SUMMARY' )
+0052 disp(' ' )
+0053 disp([' Number of variables: ' int2str(M_.endo_nbr)])
+0054 disp([' Number of stochastic shocks: ' int2str(M_.exo_nbr)])
+0055 disp([' Number of state variables: ' ...
+0056 int2str(length(find(oo_.dr.kstate(:,2) <= M_.maximum_lag+1)))])
+0057 disp([' Number of jumpers: ' ...
+0058 int2str(length(find(oo_.dr.kstate(:,2) == M_.maximum_lag+2)))])
+0059 disp([' Number of static variables: ' int2str(oo_.dr.nstatic)])
+0060 my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS' ;
+0061 labels = deblank(M_.exo_names);
+0062 headers = strvcat('Variables' ,labels);
+0063 lh = size(labels,2)+2;
+0064 table (my_title,headers,labels,M_.Sigma_e,lh,10,6);
+0065 disp(' ' )
+0066 disp_dr (oo_.dr,options_.order,var_list);
+0067 end
+0068
+0069 if options_.simul == 0 & options_.nomoments == 0
+0070 disp_th_moments (oo_.dr,var_list);
+0071 elseif options_.simul == 1
+0072 if options_.periods == 0
+0073 error('STOCH_SIMUL error: number of periods for the simulation isn''t specified' )
+0074 end
+0075 if options_.periods < options_.drop
+0076 disp(['STOCH_SIMUL error: The horizon of simulation is shorter' ...
+0077 ' than the number of observations to be DROPed' ])
+0078 return
+0079 end
+0080 oo_.endo_simul = simult (repmat(oo_.dr.ys,1,M_.maximum_lag),oo_.dr);
+0081 dyn2vec ;
+0082 if options_.nomoments == 0
+0083 disp_moments (oo_.endo_simul,var_list);
+0084 end
+0085 end
+0086
+0087
+0088
+0089 if options_.irf
+0090 n = size(var_list,1);
+0091 if n == 0
+0092 n = M_.endo_nbr;
+0093 ivar = [1:n]';
+0094 var_list = M_.endo_names;
+0095 if TeX
+0096 var_listTeX = M_.endo_names_tex;
+0097 end
+0098 else
+0099 ivar=zeros(n,1);
+0100 if TeX
+0101 var_listTeX = [];
+0102 end
+0103 for i=1:n
+0104 i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact' );
+0105 if isempty(i_tmp)
+0106 error (['One of the specified variables does not exist' ]) ;
+0107 else
+0108 ivar(i) = i_tmp;
+0109 if TeX
+0110 var_listTeX = strvcat(var_listTeX,deblank(M_.endo_names_tex(i_tmp,:)));
+0111 end
+0112 end
+0113 end
+0114 end
+0115 if TeX
+0116 fidTeX = fopen([M_.fname '_IRF.TeX' ],'w' );
+0117 fprintf(fidTeX,'%% TeX eps-loader file generated by stoch_simul.m (Dynare).\n' );
+0118 fprintf(fidTeX,['%% ' datestr(now,0) '\n' ]);
+0119 fprintf(fidTeX,' \n' );
+0120 end
+0121 olditer = iter_;
+0122 SS(M_.exo_names_orig_ord,M_.exo_names_orig_ord)=M_.Sigma_e+1e-14*eye(M_.exo_nbr);
+0123 cs = transpose(chol(SS));
+0124 tit(M_.exo_names_orig_ord,:) = M_.exo_names;
+0125 if TeX
+0126 titTeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex;
+0127 end
+0128 for i=1:M_.exo_nbr
+0129 if SS(i,i) > 1e-13
+0130 y=irf (oo_.dr,cs(M_.exo_names_orig_ord,i), options_.irf, options_.drop, ...
+0131 options_.replic, options_.order);
+0132 if options_.relative_irf
+0133 y = 100*y/cs(i,i);
+0134 end
+0135 irfs = [];
+0136 mylist = [];
+0137 if TeX
+0138 mylistTeX = [];
+0139 end
+0140 for j = 1:n
+0141 if max(y(ivar(j),:)) - min(y(ivar(j),:)) > 1e-10
+0142 irfs = cat(1,irfs,y(ivar(j),:));
+0143 mylist = strvcat(mylist,deblank(var_list(j,:)));
+0144 if TeX
+0145 mylistTeX = strvcat(mylistTeX,deblank(var_listTeX(j,:)));
+0146 end
+0147 end
+0148 end
+0149 number_of_plots_to_draw = size(irfs,1);
+0150 [nbplt,nr,nc,lr,lc,nstar] = pltorg (number_of_plots_to_draw);
+0151 if nbplt == 0
+0152 elseif nbplt == 1
+0153 if options_.relative_irf
+0154 hh = figure('Name' ,['Relative response to' ...
+0155 ' orthogonalized shock to ' tit(i,:)]);
+0156 else
+0157 hh = figure('Name' ,['Orthogonalized shock to' ...
+0158 ' ' tit(i,:)]);
+0159 end
+0160 for j = 1:number_of_plots_to_draw
+0161 subplot(nr,nc,j);
+0162 plot(1:options_.irf,transpose(irfs(j,:)),'-k' ,'linewidth' ,1);
+0163 hold on
+0164 plot([1 options_.irf],[0 0],'-r' ,'linewidth' ,0.5);
+0165 hold off
+0166 xlim([1 options_.irf]);
+0167 title(deblank(mylist(j,:)),'Interpreter' ,'none' );
+0168 assignin('base' ,[deblank(mylist(j,:)) '_' deblank(tit(i,:))],transpose(irfs(j,:)));
+0169 end
+0170 eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:))]);
+0171 eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:))]);
+0172 saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) '.fig' ]);
+0173 if TeX
+0174 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0175 for j = 1:number_of_plots_to_draw
+0176 fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n' ],deblank(mylist(j,:)),deblank(mylistTeX(j,:)));
+0177 end
+0178 fprintf(fidTeX,'\\centering \n' );
+0179 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s}\n' ,M_.fname,deblank(tit(i,:)));
+0180 fprintf(fidTeX,'\\caption{Impulse response functions (orthogonalized shock to $%s$).}' ,titTeX(i,:));
+0181 fprintf(fidTeX,'\\label{Fig:IRF:%s}\n' ,deblank(tit(i,:)));
+0182 fprintf(fidTeX,'\\end{figure}\n' );
+0183 fprintf(fidTeX,' \n' );
+0184 end
+0185
+0186 else
+0187 for fig = 1:nbplt-1
+0188 if options_.relative_irf == 1
+0189 hh = figure('Name' ,['Relative response to orthogonalized shock' ...
+0190 ' to ' tit(i,:) ' figure ' int2str(fig)]);
+0191 else
+0192 hh = figure('Name' ,['Orthogonalized shock to ' tit(i,:) ...
+0193 ' figure ' int2str(fig)]);
+0194 end
+0195 for plt = 1:nstar
+0196 subplot(nr,nc,plt);
+0197 plot(1:options_.irf,transpose(irfs((fig-1)*nstar+plt,:)),'-k' ,'linewidth' ,1);
+0198 hold on
+0199 plot([1 options_.irf],[0 0],'-r' ,'linewidth' ,0.5);
+0200 hold off
+0201 xlim([1 options_.irf]);
+0202 title(deblank(mylist((fig-1)*nstar+plt,:)),'Interpreter' ,'none' );
+0203 assignin('base' ,[deblank(mylist((fig-1)*nstar+plt,:)) '_' deblank(tit(i,:))],transpose(irfs((fig-1)*nstar+plt,:)));
+0204 end
+0205 eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)]);
+0206 eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig)]);
+0207 saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) int2str(fig) '.fig' ]);
+0208 if TeX
+0209 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0210 for j = 1:nstar
+0211 fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n' ],deblank(mylist((fig-1)*nstar+j,:)),deblank(mylistTeX((fig-1)*nstar+j,:)));
+0212 end
+0213 fprintf(fidTeX,'\\centering \n' );
+0214 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s%s}\n' ,M_.fname,deblank(tit(i,:)),int2str(fig));
+0215 if options_.relative_irf
+0216 fprintf(fidTeX,['\\caption{Relative impulse response' ...
+0217 ' functions (orthogonalized shock to $%s$).}' ],deblank(titTeX(i,:)));
+0218 else
+0219 fprintf(fidTeX,['\\caption{Impulse response functions' ...
+0220 ' (orthogonalized shock to $%s$).}' ],deblank(titTeX(i,:)));
+0221 end
+0222 fprintf(fidTeX,'\\label{Fig:BayesianIRF:%s:%s}\n' ,deblank(tit(i,:)),int2str(fig));
+0223 fprintf(fidTeX,'\\end{figure}\n' );
+0224 fprintf(fidTeX,' \n' );
+0225 end
+0226
+0227 end
+0228 hh = figure('Name' ,['Orthogonalized shock to ' tit(i,:) ' figure ' int2str(nbplt) '.' ]);
+0229 m = 0;
+0230 for plt = 1:number_of_plots_to_draw-(nbplt-1)*nstar;
+0231 m = m+1;
+0232 subplot(lr,lc,m);
+0233 plot(1:options_.irf,transpose(irfs((nbplt-1)*nstar+plt,:)),'-k' ,'linewidth' ,1);
+0234 hold on
+0235 plot([1 options_.irf],[0 0],'-r' ,'linewidth' ,0.5);
+0236 hold off
+0237 xlim([1 options_.irf]);
+0238 title(deblank(mylist((nbplt-1)*nstar+plt,:)),'Interpreter' ,'none' );
+0239 assignin('base' ,[deblank(mylist((nbplt-1)*nstar+plt,:)) '_' deblank(tit(i,:))],transpose(irfs((nbplt-1)*nstar+plt,:)));
+0240 end
+0241 eval(['print -depsc2 ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt)]);
+0242 eval(['print -dpdf ' M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt)]);
+0243 saveas(hh,[M_.fname '_IRF_' deblank(tit(i,:)) int2str(nbplt) '.fig' ]);
+0244 if TeX
+0245 fprintf(fidTeX,'\\begin{figure}[H]\n' );
+0246 for j = 1:m
+0247 fprintf(fidTeX,['\\psfrag{%s}[1][][0.5][0]{$%s$}\n' ],deblank(mylist((nbplt-1)*nstar+j,:)),deblank(mylistTeX((nbplt-1)*nstar+j,:)));
+0248 end
+0249 fprintf(fidTeX,'\\centering \n' );
+0250 fprintf(fidTeX,'\\includegraphics[scale=0.5]{%s_IRF_%s%s}\n' ,M_.fname,deblank(tit(i,:)),int2str(nbplt));
+0251 if options_.relative_irf
+0252 fprintf(fidTeX,['\\caption{Relative impulse response functions' ...
+0253 ' (orthogonalized shock to $%s$).}' ],deblank(titTeX(i,:)));
+0254 else
+0255 fprintf(fidTeX,['\\caption{Impulse response functions' ...
+0256 ' (orthogonalized shock to $%s$).}' ],deblank(titTeX(i,:)));
+0257 end
+0258 fprintf(fidTeX,'\\label{Fig:IRF:%s:%s}\n' ,deblank(tit(i,:)),int2str(nbplt));
+0259 fprintf(fidTeX,'\\end{figure}\n' );
+0260 fprintf(fidTeX,' \n' );
+0261 end
+0262
+0263 end
+0264 end
+0265 end
+0266 iter_ = olditer;
+0267 if TeX
+0268 fprintf(fidTeX,' \n' );
+0269 fprintf(fidTeX,'%% End Of TeX file. \n' );
+0270 fclose(fidTeX);
+0271 end
+0272 end
+0273
+0274
+0275
+0276 [omega,f] = UnivariateSpectralDensity (oo_.dr,var_list);
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/sylvester3.html b/matlab/doc/sylvester3.html
new file mode 100644
index 000000000..8acbbf4a3
--- /dev/null
+++ b/matlab/doc/sylvester3.html
@@ -0,0 +1,95 @@
+
+
+
+ Description of sylvester3
+
+
+
+
+
+
+
+
+
+
+
+
+
+sylvester3
+
+
+ PURPOSE
+solves a*x+b*x*c=d
+
+ SYNOPSIS
+function x=sylvester3(a,b,c,d)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dr1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002 function x=sylvester3(a,b,c,d)
+0003 n = size(a,1);
+0004 m = size(c,1);
+0005 if n == 1
+0006 x=d./(a*ones(1,m)+b*c);
+0007 return
+0008 end
+0009 if m == 1
+0010 x = (a+c*b)\d;
+0011 return ;
+0012 end
+0013 x=zeros(n,m);
+0014 [u,t]=schur(c);
+0015 [aa,bb,qq,zz]=qz(full(a),full(b),'real' );
+0016 d=qq*d*u;
+0017 i = 1;
+0018 while i < m
+0019 if t(i+1,i) == 0
+0020 if i == 1
+0021 c = zeros(n,1);
+0022 else
+0023 c = bb*(x(:,1:i-1)*t(1:i-1,i));
+0024 end
+0025 x(:,i)=(aa+bb*t(i,i))\(d(:,i)-c);
+0026 i = i+1;
+0027 else
+0028 if i == n
+0029 c = zeros(n,1);
+0030 c1 = zeros(n,1);
+0031 else
+0032 c = bb*(x(:,1:i-1)*t(1:i-1,i));
+0033 c1 = bb*(x(:,1:i-1)*t(1:i-1,i+1));
+0034 end
+0035 z = [aa+bb*t(i,i) bb*t(i+1,i); bb*t(i,i+1) aa+bb*t(i+1,i+1)]...
+0036 \[d(:,i)-c;d(:,i+1)-c1];
+0037 x(:,i) = z(1:n);
+0038 x(:,i+1) = z(n+1:end);
+0039 i = i + 2;
+0040 end
+0041 end
+0042 if i == m
+0043 c = bb*(x(:,1:m-1)*t(1:m-1,m));
+0044 x(:,m)=(aa+bb*t(m,m))\(d(:,m)-c);
+0045 end
+0046 x=zz*x*u';
+0047
+0048
+0049
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/sylvester3a.html b/matlab/doc/sylvester3a.html
new file mode 100644
index 000000000..a66aadb56
--- /dev/null
+++ b/matlab/doc/sylvester3a.html
@@ -0,0 +1,63 @@
+
+
+
+ Description of sylvester3a
+
+
+
+
+
+
+
+
+
+
+
+
+
+sylvester3a
+
+
+ PURPOSE
+solves iteratively ax+bxc=d
+
+ SYNOPSIS
+function x=sylvester3a(x0,a,b,c,d)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dr1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function x=sylvester3a(x0,a,b,c,d)
+0004 a_1 = inv(a);
+0005 b = a_1*b;
+0006 d = a_1*d;
+0007 e = 1;
+0008 iter = 1;
+0009 while e > 1e-8 & iter < 500
+0010 x = d-b*x0*c;
+0011 e = max(max(abs(x-x0)));
+0012 x0 = x;
+0013 iter = iter + 1;
+0014 end
+0015 if iter == 500
+0016 warning('sylvester3a : Only accuracy of %10.8f is achieved after 500 iterations' )
+0017 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/table.html b/matlab/doc/table.html
new file mode 100644
index 000000000..775aeca43
--- /dev/null
+++ b/matlab/doc/table.html
@@ -0,0 +1,72 @@
+
+
+
+ Description of table
+
+
+
+
+
+
+
+
+
+
+
+
+
+table
+
+
+ PURPOSE
+Copyright (C) 2002 Michel Juillard
+
+ SYNOPSIS
+function table(title,headers,labels,values,label_width,val_width,val_precis)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+disp_moments Copyright (C) 2001 Michel Juillarddisp_th_moments Copyright (C) 2001 Michel Juillardolr Copyright (C) 2001 Michel Juillardosr Copyright (C) 2001 Michel Juillardstoch_simul Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function table(title,headers,labels,values,label_width,val_width, ...
+0004 val_precis)
+0005 label_width = max(size(deblank(strvcat(headers(1,:),labels)),2)+2, ...
+0006 label_width);
+0007 val_width = max(size(deblank(headers(2:end ,:)),2)+2,val_width);
+0008 label_fmt = sprintf('%%-%ds' ,label_width);
+0009 header_fmt = sprintf('%%-%ds' ,val_width);
+0010 val_fmt = sprintf('%%%d.%df' ,val_width,val_precis);
+0011 if length(title) > 0
+0012 disp(sprintf('\n\n%s\n' ,title));
+0013 end
+0014 if length(headers) > 0
+0015 hh = sprintf(label_fmt,headers(1,:));
+0016 hh = [hh char(32*ones(1,floor(val_width/4)))];
+0017 for i=2:size(headers,1)
+0018 hh = [hh sprintf(header_fmt,headers(i,:))];
+0019 end
+0020 disp(hh);
+0021 end
+0022 for i=1:size(values,1)
+0023 disp([sprintf(label_fmt,labels(i,:)) sprintf(val_fmt,values(i,:))]);
+0024 end
+0025
+0026
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/th_autocovariances.html b/matlab/doc/th_autocovariances.html
new file mode 100644
index 000000000..af31c2dff
--- /dev/null
+++ b/matlab/doc/th_autocovariances.html
@@ -0,0 +1,255 @@
+
+
+
+ Description of th_autocovariances
+
+
+
+
+
+
+
+
+
+Home >
. > th_autocovariances.m
+
+
+
+th_autocovariances
+
+
+ PURPOSE
+Copyright (C) 2001 Michel Juillard
+
+ SYNOPSIS
+function [Gamma_y,ivar]=th_autocovariances(dr,ivar)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001
+0002
+0003
+0004
+0005
+0006
+0007
+0008 function [Gamma_y,ivar]=th_autocovariances(dr,ivar)
+0009 global M_ options_
+0010
+0011 exo_names_orig_ord = M_.exo_names_orig_ord;
+0012 if sscanf(version('-release' ),'%d' ) < 13
+0013 warning off
+0014 else
+0015 eval('warning off MATLAB:dividebyzero' )
+0016 end
+0017 nar = options_.ar;
+0018 Gamma_y = cell(nar+1,1);
+0019 if isempty(ivar)
+0020 ivar = [1:M_.endo_nbr]';
+0021 end
+0022 nvar = size(ivar,1);
+0023
+0024 ghx = dr.ghx;
+0025 ghu = dr.ghu;
+0026 npred = dr.npred;
+0027 nstatic = dr.nstatic;
+0028 kstate = dr.kstate;
+0029 order = dr.order_var;
+0030 iv(order) = [1:length(order)];
+0031 nx = size(ghx,2);
+0032
+0033 ikx = [nstatic+1:nstatic+npred];
+0034
+0035 A = zeros(nx,nx);
+0036 k0 = kstate(find(kstate(:,2) <= M_.maximum_lag+1),:);
+0037 i0 = find(k0(:,2) == M_.maximum_lag+1);
+0038 i00 = i0;
+0039 n0 = length(i0);
+0040 A(i0,:) = ghx(ikx,:);
+0041 AS = ghx(:,i0);
+0042 ghu1 = zeros(nx,M_.exo_nbr);
+0043 ghu1(i0,:) = ghu(ikx,:);
+0044 for i=M_.maximum_lag:-1:2
+0045 i1 = find(k0(:,2) == i);
+0046 n1 = size(i1,1);
+0047 j1 = zeros(n1,1);
+0048 j2 = j1;
+0049 for k1 = 1:n1
+0050 j1(k1) = find(k0(i00,1)==k0(i1(k1),1));
+0051 j2(k1) = find(k0(i0,1)==k0(i1(k1),1));
+0052 end
+0053 AS(:,j1) = AS(:,j1)+ghx(:,i1);
+0054 i0 = i1;
+0055 end
+0056 b = ghu1*M_.Sigma_e*ghu1';
+0057
+0058
+0059 [A,B] = kalman_transition_matrix (dr);
+0060
+0061 i_pred = [nstatic+(1:npred) M_.endo_nbr+1:length(A)];
+0062 A = A(i_pred,i_pred);
+0063
+0064 if options_.order == 2
+0065 [vx,ns_var] = lyapunov_symm (A,b);
+0066 i_ivar = find(~ismember(ivar,dr.order_var(ns_var+nstatic)));
+0067 ivar = ivar(i_ivar);
+0068 iky = iv(ivar);
+0069 aa = ghx(iky,:);
+0070 bb = ghu(iky,:);
+0071 Ex = (dr.ghs2(ikx)+dr.ghxx(ikx,:)*vx(:)+dr.ghuu(ikx,:)*M_.Sigma_e(:))/2;
+0072 Ex = (eye(n0)-AS(ikx,:))\Ex;
+0073 Gamma_y{nar+3} = AS(iky,:)*Ex+(dr.ghs2(iky)+dr.ghxx(iky,:)*vx(:)+dr.ghuu(iky,:)*M_.Sigma_e(:))/2;
+0074 end
+0075 if options_.hp_filter == 0
+0076 if options_.order < 2
+0077 [vx, ns_var] = lyapunov_symm (A,b);
+0078 i_ivar = find(~ismember(ivar,dr.order_var(ns_var+nstatic)));
+0079 ivar = ivar(i_ivar);
+0080 iky = iv(ivar);
+0081 aa = ghx(iky,:);
+0082 bb = ghu(iky,:);
+0083 end
+0084 Gamma_y{1} = aa*vx*aa'+ bb*M_.Sigma_e*bb';
+0085 k = find(abs(Gamma_y{1}) < 1e-12);
+0086 Gamma_y{1}(k) = 0;
+0087
+0088
+0089 if nar > 0
+0090 vxy = (A*vx*aa'+ghu1*M_.Sigma_e*bb');
+0091
+0092 sy = sqrt(diag(Gamma_y{1}));
+0093 sy = sy *sy';
+0094 Gamma_y{2} = aa*vxy./sy;
+0095
+0096 for i=2:nar
+0097 vxy = A*vxy;
+0098 Gamma_y{i+1} = aa*vxy./sy;
+0099 end
+0100 end
+0101
+0102
+0103 if M_.exo_nbr > 1
+0104 Gamma_y{nar+2} = zeros(length(ivar),M_.exo_nbr);
+0105 SS(exo_names_orig_ord,exo_names_orig_ord)=M_.Sigma_e+1e-14*eye(M_.exo_nbr);
+0106 cs = chol(SS)';
+0107 b1(:,exo_names_orig_ord) = ghu1;
+0108 b1 = b1*cs;
+0109 b2(:,exo_names_orig_ord) = ghu(iky,:);
+0110 b2 = b2*cs;
+0111 vx = lyapunov_symm (A,b1*b1');
+0112 vv = diag(aa*vx*aa'+b2*b2');
+0113 for i=1:M_.exo_nbr
+0114 vx1 = lyapunov_symm (A,b1(:,i)*b1(:,i)');
+0115 Gamma_y{nar+2}(:,i) = abs(diag(aa*vx1*aa'+b2(:,i)*b2(:,i)'))./vv;
+0116 end
+0117 end
+0118 else
+0119 if options_.order < 2
+0120 iky = iv(ivar);
+0121 aa = ghx(iky,:);
+0122 bb = ghu(iky,:);
+0123 end
+0124 lambda = options_.hp_filter;
+0125 ngrid = options_.hp_ngrid;
+0126 freqs = 0 : ((2*pi)/ngrid) : (2*pi*(1 - .5/ngrid));
+0127 tpos = exp( sqrt(-1)*freqs);
+0128 tneg = exp(-sqrt(-1)*freqs);
+0129 hp1 = 4*lambda*(1 - cos(freqs)).^2 ./ (1 + 4*lambda*(1 - cos(freqs)).^2);
+0130
+0131 mathp_col = [];
+0132 IA = eye(size(A,1));
+0133 IE = eye(M_.exo_nbr);
+0134 for ig = 1:ngrid
+0135 f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*ghu1;IE]...
+0136 *M_.Sigma_e*[ghu1'*inv(IA-A'*tpos(ig)) ...
+0137 IE]);
+0138 g_omega = [aa*tneg(ig) bb]*f_omega*[aa'*tpos(ig); bb'];
+0139 f_hp = hp1(ig)^2*g_omega;
+0140 mathp_col = [mathp_col ; (f_hp(:))'];
+0141
+0142 end ;
+0143
+0144
+0145 imathp_col = real(ifft(mathp_col))*(2*pi);
+0146
+0147 Gamma_y{1} = reshape(imathp_col(1,:),nvar,nvar);
+0148
+0149
+0150 if nar > 0
+0151 sy = sqrt(diag(Gamma_y{1}));
+0152 sy = sy *sy';
+0153 for i=1:nar
+0154 Gamma_y{i+1} = reshape(imathp_col(i+1,:),nvar,nvar)./sy;
+0155 end
+0156 end
+0157
+0158
+0159 if M_.exo_nbr > 1
+0160 Gamma_y{nar+2} = zeros(nvar,M_.exo_nbr);
+0161 SS(exo_names_orig_ord,exo_names_orig_ord)=M_.Sigma_e+1e-14*eye(M_.exo_nbr);
+0162 cs = chol(SS)';
+0163 SS = cs*cs';
+0164 b1(:,exo_names_orig_ord) = ghu1;
+0165 b2(:,exo_names_orig_ord) = ghu(iky,:);
+0166 mathp_col = [];
+0167 IA = eye(size(A,1));
+0168 IE = eye(M_.exo_nbr);
+0169 for ig = 1:ngrid
+0170 f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*b1;IE]...
+0171 *SS*[b1'*inv(IA-A'*tpos(ig)) ...
+0172 IE]);
+0173 g_omega = [aa*tneg(ig) b2]*f_omega*[aa'*tpos(ig); b2'];
+0174 f_hp = hp1(ig)^2*g_omega;
+0175 mathp_col = [mathp_col ; (f_hp(:))'];
+0176
+0177 end ;
+0178
+0179 imathp_col = real(ifft(mathp_col))*(2*pi);
+0180 vv = diag(reshape(imathp_col(1,:),nvar,nvar));
+0181 for i=1:M_.exo_nbr
+0182 mathp_col = [];
+0183 SSi = cs(:,i)*cs(:,i)';
+0184 for ig = 1:ngrid
+0185 f_omega =(1/(2*pi))*( [inv(IA-A*tneg(ig))*b1;IE]...
+0186 *SSi*[b1'*inv(IA-A'*tpos(ig)) ...
+0187 IE]);
+0188 g_omega = [aa*tneg(ig) b2]*f_omega*[aa'*tpos(ig); b2'];
+0189 f_hp = hp1(ig)^2*g_omega;
+0190 mathp_col = [mathp_col ; (f_hp(:))'];
+0191
+0192 end ;
+0193
+0194 imathp_col = real(ifft(mathp_col))*(2*pi);
+0195 Gamma_y{nar+2}(:,i) = abs(diag(reshape(imathp_col(1,:),nvar,nvar)))./vv;
+0196 end
+0197 end
+0198 end
+0199 if sscanf(version('-release' ),'%d' ) < 13
+0200 warning on
+0201 else
+0202 eval('warning on MATLAB:dividebyzero' )
+0203 end
+0204
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/transition_matrix.html b/matlab/doc/transition_matrix.html
new file mode 100644
index 000000000..a225beef1
--- /dev/null
+++ b/matlab/doc/transition_matrix.html
@@ -0,0 +1,73 @@
+
+
+
+ Description of transition_matrix
+
+
+
+
+
+
+
+
+
+Home >
. > transition_matrix.m
+
+
+
+transition_matrix
+
+
+ PURPOSE
+makes transition matrices out of ghx and ghu
+
+ SYNOPSIS
+function [A,B] = transition_matrix(dr)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+dr1 Copyright (C) 2001 Michel Juillard
+
+
+
+ SOURCE CODE
+0001
+0002
+0003 function [A,B] = transition_matrix(dr)
+0004 global M_
+0005 exo_nbr = M_.exo_nbr;
+0006 ykmin_ = M_.maximum_endo_lag;
+0007
+0008 nx = size(dr.ghx,2);
+0009 kstate = dr.kstate;
+0010 ikx = [dr.nstatic+1:dr.nstatic+dr.npred];
+0011
+0012 A = zeros(nx,nx);
+0013 k0 = kstate(find(kstate(:,2) <= ykmin_+1),:);
+0014 i0 = find(k0(:,2) == ykmin_+1);
+0015 A(i0,:) = dr.ghx(ikx,:);
+0016 B = zeros(nx,exo_nbr);
+0017 B(i0,:) = dr.ghu(ikx,:);
+0018 for i=ykmin_:-1:2
+0019 i1 = find(k0(:,2) == i);
+0020 n1 = size(i1,1);
+0021 j = zeros(n1,1);
+0022 for j1 = 1:n1
+0023 j(j1) = find(k0(i0,1)==k0(i1(j1),1));
+0024 end
+0025 A(i1,i0(j))=eye(n1);
+0026 i0 = i1;
+0027 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/uniform_specification.html b/matlab/doc/uniform_specification.html
new file mode 100644
index 000000000..2182d3acd
--- /dev/null
+++ b/matlab/doc/uniform_specification.html
@@ -0,0 +1,58 @@
+
+
+
+ Description of uniform_specification
+
+
+
+
+
+
+
+
+
+Home >
. > uniform_specification.m
+
+
+
+uniform_specification
+
+
+ PURPOSE
+Copyright (C) 2004 Michel Juillard
+
+ SYNOPSIS
+function [m,s,p1,p2] = uniform_specification(m,s,p3,p4)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/union.html b/matlab/doc/union.html
new file mode 100644
index 000000000..7184dfec6
--- /dev/null
+++ b/matlab/doc/union.html
@@ -0,0 +1,58 @@
+
+
+
+ Description of union
+
+
+
+
+
+
+
+
+
+
+
+
+
+union
+
+
+ PURPOSE
+
+
+ SYNOPSIS
+function x = union(a,b)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+
+
+
+ SOURCE CODE
+0001 function x = union(a,b)
+0002
+0003 xx = sort([a;b]) ;
+0004 x(1) = xx(1) ;
+0005 for i = 2:size(xx,1)
+0006 if xx(i) ~= xx(i-1)
+0007 x =[x;xx(i)];
+0008 end
+0009 end
+0010 return ;
+0011
+0012
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/up.png b/matlab/doc/up.png
new file mode 100644
index 000000000..b348b9a1b
Binary files /dev/null and b/matlab/doc/up.png differ
diff --git a/matlab/doc/varprior.html b/matlab/doc/varprior.html
new file mode 100644
index 000000000..22c027551
--- /dev/null
+++ b/matlab/doc/varprior.html
@@ -0,0 +1,121 @@
+
+
+
+ Description of varprior
+
+
+
+
+
+
+
+
+
+
+
+
+
+varprior
+
+
+ PURPOSE
+function [ydum,xdum,breaks]=varprior(nv,nx,lags,mnprior,vprior)
+
+ SYNOPSIS
+function [ydum,xdum,breaks]=varprior(nv,nx,lags,mnprior,vprior)
+
+ DESCRIPTION
+
+
+
+ CROSS-REFERENCE INFORMATION
+This function calls:
+
+This function is called by:
+
+mgnldnsty function w=mgnldnsty(ydata,lags,xdata,breaks,lambda,mu,mnprior,vprior,train,flat)
+
+
+
+ SOURCE CODE
+0001 function [ydum,xdum,breaks]=varprior(nv,nx,lags,mnprior,vprior)
+0002
+0003
+0004
+0005
+0006
+0007
+0008
+0009
+0010
+0011
+0012
+0013
+0014
+0015
+0016
+0017
+0018
+0019
+0020
+0021
+0022
+0023
+0024
+0025 if ~isempty(mnprior)
+0026 xdum=zeros(lags+1,nx,lags,nv);
+0027 ydum=zeros(lags+1,nv,lags,nv);
+0028 for il=1:lags
+0029 ydum(il+1,:,il,:)=il^mnprior.decay*diag(vprior.sig);
+0030 end
+0031 ydum(1,:,1,:)=diag(vprior.sig);
+0032 ydum=mnprior.tight*reshape(ydum,[lags+1,nv,lags*nv]);
+0033 ydum=flipdim(ydum,1);
+0034 xdum=mnprior.tight*reshape(xdum,[lags+1,nx,lags*nv]);
+0035 xdum=flipdim(xdum,1);
+0036 breaks=(lags+1)*[1:(nv*lags)]';
+0037 lbreak=breaks(end);
+0038 else
+0039 ydum=[];
+0040 xdum=[];
+0041 breaks=[];
+0042 lbreak=0;
+0043 end
+0044 if ~isempty(vprior) & vprior.w>0
+0045 ydum2=zeros(lags+1,nv,nv);
+0046 xdum2=zeros(lags+1,nx,nv);
+0047 ydum2(end ,:,:)=diag(vprior.sig);
+0048 ydum=cat(3,ydum,ydum2);
+0049 xdum=cat(3,xdum,xdum2);
+0050 dimy=size(ydum);
+0051 ydum=reshape(permute(ydum,[1 3 2]),dimy(1)*dimy(3),nv);
+0052 xdum=reshape(permute(xdum,[1 3 2]),dimy(1)*dimy(3),nx);
+0053 breaks=[breaks;(lags+1)*[1:nv-1]'+lbreak];
+0054 end
+Generated on Fri 16-Jun-2006 09:09:06 by m2html © 2003
+
+
\ No newline at end of file
diff --git a/matlab/doc/windows.png b/matlab/doc/windows.png
new file mode 100644
index 000000000..6cec95b88
Binary files /dev/null and b/matlab/doc/windows.png differ
diff --git a/matlab/dynare_estimation.m b/matlab/dynare_estimation.m
index e90b91f65..94414d41e 100644
--- a/matlab/dynare_estimation.m
+++ b/matlab/dynare_estimation.m
@@ -215,6 +215,11 @@ bayestopt_.restrict_state = k2;
% for filtering and smoothing
bayestopt_.mf2 = k;
bayestopt_.mfys = k1;
+bayestopt_.Z = zeros(n_varobs,length(k2));
+for i=1:n_varobs
+ bayestopt_.Z(i,bayestopt_.mf1(i)) = 1;
+end
+
options_ = set_default_option(options_,'nobs',size(rawdata,1)-options_.first_obs+1);
gend = options_.nobs;
diff --git a/matlab/resol.m b/matlab/resol.m
index 10dc3e0b5..2ed9495cf 100644
--- a/matlab/resol.m
+++ b/matlab/resol.m
@@ -8,7 +8,9 @@ global it_
% 11 .... same as dr1 for dr_algo = 2
% 20: can't find steady state info(2) contains sum of sqare residuals
-
+
+%unfinished
+jacobian_flag = 0;
options_ = set_default_option(options_,'olr',0);
options_ = set_default_option(options_,'jacobian_flag',1);
@@ -77,4 +79,4 @@ tempex = [];
% 01/01/2003 MJ added dr_algo == 1
% 08/24/2001 MJ uses Schmitt-Grohe and Uribe (2001) constant correction
% in dr.ghs2
-% 05/26/2003 MJ added temporary values for oo_.exo_simul
\ No newline at end of file
+% 05/26/2003 MJ added temporary values for oo_.exo_simul