v4 matlab/doc: removed obsolete directory
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1953 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
|
@ -1,55 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of CheckPath</title>
|
||||
<meta name="keywords" content="CheckPath">
|
||||
<meta name="description" content="06-03-2005">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > CheckPath.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>CheckPath
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>06-03-2005</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function DirectoryName = CheckPath(type) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> 06-03-2005</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CutSample.html" class="code" title="function CutSample()">CutSample</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="GetPosteriorParametersStatistics.html" class="code" title="function GetPosteriorParametersStatistics()">GetPosteriorParametersStatistics</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="McMCDiagnostics.html" class="code" title="function McmcDiagnostic">McMCDiagnostics</a> stephane.adjemian@ens.fr [06-04-2005]</li><li><a href="PlotPosteriorDistributions.html" class="code" title="function PlotPosteriorDistributions()">PlotPosteriorDistributions</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="PosteriorIRF.html" class="code" title="function PosteriorIRF(type)">PosteriorIRF</a> stephane.adjemian@ens.fr [09-25-2005]</li><li><a href="PosteriorSmoother.html" class="code" title="function PosteriorSmoother(Y,gend, type)">PosteriorSmoother</a> stephane.adjemian@ens.fr [09-25-2005]</li><li><a href="ReshapeMatFiles.html" class="code" title="function ReshapeMatFiles(type)">ReshapeMatFiles</a> Reshape and sort (along the mcmc simulations) the mat files generated</li><li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li><li><a href="dynare_sensitivity.html" class="code" title="function x0=dynare_sensitivity()">dynare_sensitivity</a> copyright Marco Ratto 2006</li><li><a href="filt_mc_.html" class="code" title="function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)">filt_mc_</a> copyright Marco Ratto 2006</li><li><a href="marginal_density.html" class="code" title="function marginal = marginal_density()">marginal_density</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="metropolis.html" class="code" title="function metropolis(xparam1,vv,gend,data,rawdata,mh_bounds)">metropolis</a> stephane.adjemian@ens.fr [09-02-2005]</li><li><a href="metropolis_draw.html" class="code" title="function [xparams, logpost]=metropolis_draw(init)">metropolis_draw</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function DirectoryName = CheckPath(type)</a>
|
||||
0002 <span class="comment">% 06-03-2005</span>
|
||||
0003 <span class="keyword">global</span> M_
|
||||
0004
|
||||
0005 DirectoryName = [ M_.dname <span class="string">'/'</span> type ];
|
||||
0006
|
||||
0007 <span class="keyword">if</span> ~isdir(DirectoryName)
|
||||
0008 mkdir(<span class="string">'.'</span>,DirectoryName);
|
||||
0009 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,54 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of CreateBenchmark</title>
|
||||
<meta name="keywords" content="CreateBenchmark">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [12-06-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > CreateBenchmark.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>CreateBenchmark
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [12-06-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function CreateBenchmark </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [12-06-2004]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function CreateBenchmark</a>
|
||||
0002
|
||||
0003 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [12-06-2004]</span>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> oo_
|
||||
0006
|
||||
0007 eval([M_.fname <span class="string">'_oo_ = oo_;'</span>])
|
||||
0008 eval([<span class="string">'save '</span> M_.fname <span class="string">'_benchmark_oo '</span> M_.fname <span class="string">'_oo_'</span>])</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,89 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of CutSample</title>
|
||||
<meta name="keywords" content="CutSample">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-09-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > CutSample.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>CutSample
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-09-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function CutSample() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-09-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function CutSample()</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-09-2005]</span>
|
||||
0003 <span class="keyword">global</span> 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 = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0008 file = dir([ DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh_history.mat'</span>]);
|
||||
0009 files = dir([ DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh*.mat'</span> ]);
|
||||
0010 <span class="keyword">if</span> ~length(files)
|
||||
0011 disp(<span class="string">'MH:: FAILURE! there is no MH file to load here!'</span>)
|
||||
0012 <span class="keyword">return</span>
|
||||
0013 <span class="keyword">end</span>
|
||||
0014 <span class="keyword">if</span> ~length(file)
|
||||
0015 disp(<span class="string">'MH:: FAILURE! there is no MH-history file!'</span>)
|
||||
0016 <span class="keyword">return</span>
|
||||
0017 <span class="keyword">else</span>
|
||||
0018 load([ DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh_history'</span>])
|
||||
0019 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> (TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1 > 0
|
||||
0029 record.KeepedDraws.Distribution = [ MAX_nruns-FirstLine+1 ; <span class="keyword">...</span>
|
||||
0030 ones((TotalNumberOfMhFiles-1)-(FirstMhFile+1)+1,1)*MAX_nruns ; <span class="keyword">...</span>
|
||||
0031 record.MhDraws(<span class="keyword">end</span>,3) ];
|
||||
0032 <span class="keyword">elseif</span> TotalNumberOfMhFiles == 1
|
||||
0033 record.KeepedDraws.Distribution = [];
|
||||
0034 <span class="keyword">elseif</span> TotalNumberOfMhFiles == 2 & FirstMhFile > 1
|
||||
0035 record.KeepedDraws.Distribution = [MAX_nruns-FirstLine+1 ; record.MhDraws(<span class="keyword">end</span>,3)];
|
||||
0036 <span class="keyword">end</span>
|
||||
0037 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh_history'</span>],<span class="string">'record'</span>);
|
||||
0038 fprintf(<span class="string">'MH: Total number of Mh draws: %d.\n'</span>,TotalNumberOfMhDraws);
|
||||
0039 fprintf(<span class="string">'MH: Total number of generated Mh files: %d.\n'</span>,TotalNumberOfMhFiles);
|
||||
0040 fprintf(<span class="string">'MH: I''ll use mh-files %d to %d.\n'</span>,FirstMhFile,TotalNumberOfMhFiles);
|
||||
0041 fprintf(<span class="string">'MH: In mh-file number %d i''ll start at line %d.\n'</span>,FirstMhFile,FirstLine);
|
||||
0042 fprintf(<span class="string">'MH: Finally I keep %d draws.\n'</span>,TotalNumberOfMhDraws-FirstDraw);
|
||||
0043 disp(<span class="string">' '</span>);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,193 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseKalmanSmoother1</title>
|
||||
<meta name="keywords" content="DiffuseKalmanSmoother1">
|
||||
<meta name="description" content="modified by M. Ratto:">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseKalmanSmoother1.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseKalmanSmoother1
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>modified by M. Ratto:</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [alphahat,etahat,a, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> modified by M. Ratto:
|
||||
new output argument aK (1-step to k-step predictions)
|
||||
new options_.nk: the max step ahed prediction in aK (default is 4)
|
||||
new crit1 value for rank of Pinf
|
||||
it is assured that P is symmetric
|
||||
|
||||
stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
|
||||
|
||||
See "Filtering and Smoothing of State Vector for Diffuse State Space
|
||||
Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
|
||||
Analysis, vol. 24(1), pp. 85-98).</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="steady.html" class="code" title="function steady(linear)">steady</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [alphahat,etahat,a, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</a>
|
||||
0002 <span class="comment">% modified by M. Ratto:</span>
|
||||
0003 <span class="comment">% new output argument aK (1-step to k-step predictions)</span>
|
||||
0004 <span class="comment">% new options_.nk: the max step ahed prediction in aK (default is 4)</span>
|
||||
0005 <span class="comment">% new crit1 value for rank of Pinf</span>
|
||||
0006 <span class="comment">% it is assured that P is symmetric</span>
|
||||
0007 <span class="comment">%</span>
|
||||
0008 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-16-2004]</span>
|
||||
0009 <span class="comment">%</span>
|
||||
0010 <span class="comment">% See "Filtering and Smoothing of State Vector for Diffuse State Space</span>
|
||||
0011 <span class="comment">% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series</span>
|
||||
0012 <span class="comment">% Analysis, vol. 24(1), pp. 85-98).</span>
|
||||
0013
|
||||
0014 <span class="keyword">global</span> 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 <a href="steady.html" class="code" title="function steady(linear)">steady</a> = 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 <span class="keyword">for</span> i=1:pp;
|
||||
0044 Z(i,mf(i)) = 1;
|
||||
0045 <span class="keyword">end</span>
|
||||
0046
|
||||
0047 t = 0;
|
||||
0048 <span class="keyword">while</span> rank(Pinf(:,:,t+1),crit1) & t<smpl
|
||||
0049 t = t+1;
|
||||
0050 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
|
||||
0051 <span class="keyword">if</span> rcond(Pinf(mf,mf,t)) < crit
|
||||
0052 <span class="keyword">return</span>
|
||||
0053 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> jnk=2:nk,
|
||||
0059 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
|
||||
0060 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">while</span> 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 <span class="keyword">if</span> rcond(P(mf,mf,t)) < crit
|
||||
0081 <span class="keyword">return</span>
|
||||
0082 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> jnk=2:nk,
|
||||
0089 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
|
||||
0090 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0094 K_s = K(:,:,t);
|
||||
0095 iF_s = iF(:,:,t);
|
||||
0096 P_s = P(:,:,t+1);
|
||||
0097 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0104 <span class="keyword">while</span> 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 <span class="keyword">for</span> jnk=2:nk,
|
||||
0110 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
|
||||
0111 <span class="keyword">end</span>
|
||||
0112 <span class="keyword">end</span>
|
||||
0113 t = smpl+1;
|
||||
0114 <span class="keyword">while</span> 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 <span class="keyword">end</span>
|
||||
0120 <span class="keyword">if</span> d
|
||||
0121 r0 = zeros(mm,d); r0(:,d) = r(:,d);
|
||||
0122 r1 = zeros(mm,d);
|
||||
0123 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">else</span>
|
||||
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 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,318 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseKalmanSmoother3</title>
|
||||
<meta name="keywords" content="DiffuseKalmanSmoother3">
|
||||
<meta name="description" content="function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseKalmanSmoother3.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseKalmanSmoother3
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)
|
||||
Modified by M. Ratto
|
||||
New output argument aK: 1-step to nk-stpe ahed predictions)
|
||||
New input argument nk: max order of predictions in aK
|
||||
New option options_.diffuse_d where the DKF stops (common with
|
||||
diffuselikelihood3)
|
||||
New icc variable to count number of iterations for Finf steps
|
||||
Pstar % Pinf simmetric
|
||||
New termination of DKF iterations based on options_.diffuse_d
|
||||
Li also stored during DKF iterations !!
|
||||
some bugs corrected in the DKF part of the smoother (Z matrix and
|
||||
alphahat)
|
||||
|
||||
stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
|
||||
|
||||
See "Fast Filtering and Smoothing for Multivariate State Space
|
||||
Models", S.J. Koopman and J. Durbin (2000, in Journal of Time Series
|
||||
Analysis, vol. 21(3), pp. 281-296).</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="steady.html" class="code" title="function steady(linear)">steady</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</a>
|
||||
0002 <span class="comment">%function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</span>
|
||||
0003 <span class="comment">% Modified by M. Ratto</span>
|
||||
0004 <span class="comment">% New output argument aK: 1-step to nk-stpe ahed predictions)</span>
|
||||
0005 <span class="comment">% New input argument nk: max order of predictions in aK</span>
|
||||
0006 <span class="comment">% New option options_.diffuse_d where the DKF stops (common with</span>
|
||||
0007 <span class="comment">% diffuselikelihood3)</span>
|
||||
0008 <span class="comment">% New icc variable to count number of iterations for Finf steps</span>
|
||||
0009 <span class="comment">% Pstar % Pinf simmetric</span>
|
||||
0010 <span class="comment">% New termination of DKF iterations based on options_.diffuse_d</span>
|
||||
0011 <span class="comment">% Li also stored during DKF iterations !!</span>
|
||||
0012 <span class="comment">% some bugs corrected in the DKF part of the smoother (Z matrix and</span>
|
||||
0013 <span class="comment">% alphahat)</span>
|
||||
0014 <span class="comment">%</span>
|
||||
0015 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-16-2004]</span>
|
||||
0016 <span class="comment">%</span>
|
||||
0017 <span class="comment">% See "Fast Filtering and Smoothing for Multivariate State Space</span>
|
||||
0018 <span class="comment">% Models", S.J. Koopman and J. Durbin (2000, in Journal of Time Series</span>
|
||||
0019 <span class="comment">% Analysis, vol. 21(3), pp. 281-296).</span>
|
||||
0020
|
||||
0021 <span class="keyword">global</span> 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 <a href="steady.html" class="code" title="function steady(linear)">steady</a> = 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 <span class="keyword">for</span> i=1:pp;
|
||||
0055 Z(i,mf(i)) = 1;
|
||||
0056 <span class="keyword">end</span>
|
||||
0057
|
||||
0058 t = 0;
|
||||
0059 icc=0;
|
||||
0060 newRank = rank(Pinf(:,:,1),crit1);
|
||||
0061 <span class="keyword">while</span> 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 <span class="keyword">for</span> 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 <span class="keyword">if</span> Finf(i,t) > crit & newRank, <span class="comment">% original MJ: if Finf(i,t) > crit</span>
|
||||
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) + <span class="keyword">...</span>
|
||||
0080 Kinf(:,i,t)*transpose(Kinf(:,i,t))*Fstar(i,t)/(Finf(i,t)*Finf(i,t)) - <span class="keyword">...</span>
|
||||
0081 (Kstar(:,i,t)*transpose(Kinf(:,i,t)) +<span class="keyword">...</span>
|
||||
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 <span class="comment">% new terminiation criteria by M. Ratto</span>
|
||||
0087 P0=Pinf(:,:,t);
|
||||
0088 <span class="comment">% newRank = any(diag(P0(mf,mf))>crit);</span>
|
||||
0089 <span class="comment">% if newRank==0, id = i; end,</span>
|
||||
0090 <span class="keyword">if</span> ~isempty(options_.diffuse_d),
|
||||
0091 newRank = (icc<options_.diffuse_d);
|
||||
0092 <span class="comment">%if newRank & any(diag(P0(mf,mf))>crit)==0;</span>
|
||||
0093 <span class="keyword">if</span> newRank & (any(diag(P0(mf,mf))>crit)==0 & rank(P0,crit1)==0);
|
||||
0094 disp(<span class="string">'WARNING!! Change in OPTIONS_.DIFFUSE_D in univariate DKF'</span>)
|
||||
0095 options_.diffuse_d = icc;
|
||||
0096 newRank=0;
|
||||
0097 <span class="keyword">end</span>
|
||||
0098 <span class="keyword">else</span>
|
||||
0099 <span class="comment">%newRank = any(diag(P0(mf,mf))>crit);</span>
|
||||
0100 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1));
|
||||
0101 <span class="keyword">if</span> newRank==0,
|
||||
0102 options_.diffuse_d = icc;
|
||||
0103 <span class="keyword">end</span>
|
||||
0104 <span class="keyword">end</span>,
|
||||
0105 <span class="comment">% if newRank==0,</span>
|
||||
0106 <span class="comment">% options_.diffuse_d=i; %this is buggy</span>
|
||||
0107 <span class="comment">% end</span>
|
||||
0108 <span class="comment">% end new terminiation criteria by M. Ratto</span>
|
||||
0109 <span class="keyword">else</span>
|
||||
0110 <span class="comment">%% Note that : (1) rank(Pinf)=0 implies that Finf = 0, (2) outside this loop (when for some i and t the condition</span>
|
||||
0111 <span class="comment">%% rank(Pinf)=0 is satisfied we have P = Pstar and F = Fstar and (3) Finf = 0 does not imply that</span>
|
||||
0112 <span class="comment">%% rank(Pinf)=0. [stphane,11-03-2004].</span>
|
||||
0113 Li(:,:,i,t) = eye(mm)-Kstar(:,i,t)*Z(i,:)/Fstar(i,t); <span class="comment">% we need to store Li for DKF smoother</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0118 <span class="keyword">end</span>
|
||||
0119 a(:,t+1) = T*a(:,t);
|
||||
0120 <span class="keyword">for</span> jnk=1:nk,
|
||||
0121 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
|
||||
0122 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> newRank,
|
||||
0127 <span class="comment">%newRank = any(diag(P0(mf,mf))>crit);</span>
|
||||
0128 newRank = rank(P0,crit1);
|
||||
0129 <span class="keyword">end</span>
|
||||
0130 <span class="keyword">end</span>
|
||||
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 <span class="keyword">while</span> 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 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0160 <span class="keyword">end</span>
|
||||
0161 a(:,t+1) = T*a(:,t);
|
||||
0162 <span class="keyword">for</span> jnk=1:nk,
|
||||
0163 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
|
||||
0164 <span class="keyword">end</span>
|
||||
0165 P(:,:,t+1) = T*P(:,:,t)*transpose(T) + QQ;
|
||||
0166 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
|
||||
0167 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0179 <span class="keyword">while</span> t<smpl
|
||||
0180 t=t+1;
|
||||
0181 a1(:,t) = a(:,t);
|
||||
0182 <span class="keyword">for</span> i=1:pp
|
||||
0183 v(i,t) = Y(i,t) - a(mf(i),t) - trend(i,t);
|
||||
0184 <span class="keyword">if</span> Fi_s(i) > crit
|
||||
0185 a(:,t) = a(:,t) + Ki_s(:,i)*v(i,t)/Fi_s(i);
|
||||
0186 <span class="keyword">end</span>
|
||||
0187 <span class="keyword">end</span>
|
||||
0188 a(:,t+1) = T*a(:,t);
|
||||
0189 <span class="keyword">for</span> jnk=1:nk,
|
||||
0190 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
|
||||
0191 <span class="keyword">end</span>
|
||||
0192 <span class="keyword">end</span>
|
||||
0193 a1(:,t+1) = a(:,t+1);
|
||||
0194 ri=r;
|
||||
0195 t = smpl+1;
|
||||
0196 <span class="keyword">while</span> t>d+1 & t>2,
|
||||
0197 t = t-1;
|
||||
0198 <span class="keyword">for</span> i=pp:-1:1
|
||||
0199 <span class="keyword">if</span> Fi(i,t) > crit
|
||||
0200 ri(:,t)=transpose(Z(i,:))/Fi(i,t)*v(i,t)+transpose(Li(:,:,i,t))*ri(:,t);
|
||||
0201 <span class="keyword">end</span>
|
||||
0202 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0208 <span class="keyword">if</span> d
|
||||
0209 r0 = zeros(mm,d); r0(:,d) = ri(:,d);
|
||||
0210 r1 = zeros(mm,d);
|
||||
0211 <span class="keyword">for</span> t = d:-1:2
|
||||
0212 <span class="keyword">for</span> i=pp:-1:1
|
||||
0213 <span class="keyword">if</span> Finf(i,t) > crit & ~(t==d & i>options_.diffuse_d), <span class="comment">% use of options_.diffuse_d to be sure of DKF termination</span>
|
||||
0214 <span class="comment">%r1(:,t) = transpose(Z)*v(:,t)/Finf(i,t) + ... BUG HERE in transpose(Z)</span>
|
||||
0215 r1(:,t) = transpose(Z(i,:))*v(i,t)/Finf(i,t) + <span class="keyword">...</span>
|
||||
0216 transpose(L0(:,:,i,t))*r0(:,t) + transpose(Linf(:,:,i,t))*r1(:,t);
|
||||
0217 r0(:,t) = transpose(Linf(:,:,i,t))*r0(:,t);
|
||||
0218 <span class="keyword">elseif</span> Fstar(i,t) > crit <span class="comment">% step needed whe Finf == 0</span>
|
||||
0219 r0(:,t)=transpose(Z(i,:))/Fstar(i,t)*v(i,t)+Li(:,:,i,t)'*r0(:,t);
|
||||
0220 <span class="keyword">end</span>
|
||||
0221 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0228 r0_0 = r0(:,1);
|
||||
0229 r1_0 = r1(:,1);
|
||||
0230 <span class="keyword">for</span> i=pp:-1:1
|
||||
0231 <span class="keyword">if</span> Finf(i,1) > crit,
|
||||
0232 <span class="comment">%r1_0 = transpose(Z)*v(:,1)/Finf(i,1) + ... %bug with Z here</span>
|
||||
0233 r1_0 = transpose(Z(i,:))*v(i,1)/Finf(i,1) + <span class="keyword">...</span>
|
||||
0234 transpose(L0(:,:,i,1))*r0_0 + transpose(Linf(:,:,i,1))*r1_0;
|
||||
0235 r0_0 = transpose(Linf(:,:,i,1))*r0_0;
|
||||
0236 <span class="keyword">elseif</span> Fstar(i,1) > crit, <span class="comment">% step needed when Finf=0</span>
|
||||
0237 r0_0=transpose(Z(i,:))/Fstar(i,1)*v(i,1)+Li(:,:,i,1)'*r0_0;
|
||||
0238 <span class="keyword">end</span>
|
||||
0239 <span class="keyword">end</span>
|
||||
0240 <span class="comment">%alphahat(:,1) = a(:,1) + Pstar(:,:,1)*r0_0 + Pinf(:,:,1)*r1_0; %this line is buggy</span>
|
||||
0241 alphahat(:,1) = a1(:,1) + Pstar1(:,:,1)*r0_0 + Pinf1(:,:,1)*r1_0;
|
||||
0242 etahat(:,1) = QRt*r(:,1);
|
||||
0243 <span class="keyword">else</span>
|
||||
0244 r0 = ri(:,1);
|
||||
0245 <span class="keyword">for</span> i=pp:-1:1
|
||||
0246 <span class="keyword">if</span> Fi(i,1) > crit
|
||||
0247 r0=transpose(Z(i,:))/Fi(i,1)*v(i,1)+transpose(Li(:,:,i,1))*r0;
|
||||
0248 <span class="keyword">end</span>
|
||||
0249 <span class="keyword">end</span>
|
||||
0250 <span class="comment">%alphahat(:,1) = a(:,1) + P(:,:,1)*r0; % this line is buggy</span>
|
||||
0251 alphahat(:,1) = a1(:,1) + P1(:,:,1)*r0;
|
||||
0252 etahat(:,1) = QRt*r(:,1);
|
||||
0253 <span class="keyword">end</span>
|
||||
0254
|
||||
0255 a=a(:,1:end-1);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,194 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseKalmanSmootherH1</title>
|
||||
<meta name="keywords" content="DiffuseKalmanSmootherH1">
|
||||
<meta name="description" content="modified by M. Ratto:">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseKalmanSmootherH1.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseKalmanSmootherH1
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>modified by M. Ratto:</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [alphahat,epsilonhat,etahat,a, aK] = DiffuseKalmanSmootherH1(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> modified by M. Ratto:
|
||||
new output argument aK (1-step to k-step predictions)
|
||||
new options_.nk: the max step ahed prediction in aK (default is 4)
|
||||
new crit1 value for rank of Pinf
|
||||
it is assured that P is symmetric
|
||||
|
||||
stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
|
||||
|
||||
See "Filtering and Smoothing of State Vector for Diffuse State Space
|
||||
Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
|
||||
Analysis, vol. 24(1), pp. 85-98).</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="steady.html" class="code" title="function steady(linear)">steady</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [alphahat,epsilonhat,etahat,a, aK] = DiffuseKalmanSmootherH1(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</a>
|
||||
0002 <span class="comment">% modified by M. Ratto:</span>
|
||||
0003 <span class="comment">% new output argument aK (1-step to k-step predictions)</span>
|
||||
0004 <span class="comment">% new options_.nk: the max step ahed prediction in aK (default is 4)</span>
|
||||
0005 <span class="comment">% new crit1 value for rank of Pinf</span>
|
||||
0006 <span class="comment">% it is assured that P is symmetric</span>
|
||||
0007 <span class="comment">%</span>
|
||||
0008 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-16-2004]</span>
|
||||
0009 <span class="comment">%</span>
|
||||
0010 <span class="comment">% See "Filtering and Smoothing of State Vector for Diffuse State Space</span>
|
||||
0011 <span class="comment">% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series</span>
|
||||
0012 <span class="comment">% Analysis, vol. 24(1), pp. 85-98).</span>
|
||||
0013
|
||||
0014 <span class="keyword">global</span> 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 <a href="steady.html" class="code" title="function steady(linear)">steady</a> = 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 <span class="keyword">for</span> i=1:pp;
|
||||
0044 Z(i,mf(i)) = 1;
|
||||
0045 <span class="keyword">end</span>
|
||||
0046
|
||||
0047 t = 0;
|
||||
0048 <span class="keyword">while</span> rank(Pinf(:,:,t+1),crit1) & t<smpl
|
||||
0049 t = t+1;
|
||||
0050 v(:,t) = Y(:,t) - a(mf,t) - trend(:,t);
|
||||
0051 <span class="keyword">if</span> rcond(Pinf(mf,mf,t)) < crit
|
||||
0052 <span class="keyword">return</span>
|
||||
0053 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> jnk=2:nk,
|
||||
0059 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
|
||||
0060 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">while</span> 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 <span class="keyword">if</span> rcond(P(mf,mf,t) + H) < crit
|
||||
0081 <span class="keyword">return</span>
|
||||
0082 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> jnk=2:nk,
|
||||
0089 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
|
||||
0090 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0094 K_s = K(:,:,t);
|
||||
0095 iF_s = iF(:,:,t);
|
||||
0096 P_s = P(:,:,t+1);
|
||||
0097 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0104 <span class="keyword">while</span> 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 <span class="keyword">for</span> jnk=2:nk,
|
||||
0110 aK(jnk,:,t+jnk) = T^(jnk-1)*a(:,t+1);
|
||||
0111 <span class="keyword">end</span>
|
||||
0112 <span class="keyword">end</span>
|
||||
0113 t = smpl+1;
|
||||
0114 <span class="keyword">while</span> 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 <span class="keyword">end</span>
|
||||
0120 <span class="keyword">if</span> d
|
||||
0121 r0 = zeros(mm,d); r0(:,d) = r(:,d);
|
||||
0122 r1 = zeros(mm,d);
|
||||
0123 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">else</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0138 epsilonhat = Y-alphahat(mf,:)-trend;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,317 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseKalmanSmootherH3</title>
|
||||
<meta name="keywords" content="DiffuseKalmanSmootherH3">
|
||||
<meta name="description" content="Modified by M. Ratto">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseKalmanSmootherH3.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseKalmanSmootherH3
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Modified by M. Ratto</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Modified by M. Ratto
|
||||
New output argument aK: 1-step to nk-stpe ahed predictions)
|
||||
New input argument nk: max order of predictions in aK
|
||||
New global variable id_ where the DKF stops (common with
|
||||
diffuselikelihood3)
|
||||
New icc variable to count number of iterations for Finf steps
|
||||
Pstar % Pinf simmetric
|
||||
New termination of DKF iterations based on id_
|
||||
Li also stored during DKF iterations !!
|
||||
some bugs corrected in the DKF part of the smoother (Z matrix and
|
||||
alphahat)
|
||||
|
||||
stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
|
||||
|
||||
See "Fast Filtering and Smoothing for Multivariate State Space
|
||||
Models", S.J. Koopman and J. Durbin (2000, in Journal of Time Series
|
||||
Analysis, vol. 21(3), pp. 281-296).</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="steady.html" class="code" title="function steady(linear)">steady</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</a>
|
||||
0002 <span class="comment">% Modified by M. Ratto</span>
|
||||
0003 <span class="comment">% New output argument aK: 1-step to nk-stpe ahed predictions)</span>
|
||||
0004 <span class="comment">% New input argument nk: max order of predictions in aK</span>
|
||||
0005 <span class="comment">% New global variable id_ where the DKF stops (common with</span>
|
||||
0006 <span class="comment">% diffuselikelihood3)</span>
|
||||
0007 <span class="comment">% New icc variable to count number of iterations for Finf steps</span>
|
||||
0008 <span class="comment">% Pstar % Pinf simmetric</span>
|
||||
0009 <span class="comment">% New termination of DKF iterations based on id_</span>
|
||||
0010 <span class="comment">% Li also stored during DKF iterations !!</span>
|
||||
0011 <span class="comment">% some bugs corrected in the DKF part of the smoother (Z matrix and</span>
|
||||
0012 <span class="comment">% alphahat)</span>
|
||||
0013 <span class="comment">%</span>
|
||||
0014 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-16-2004]</span>
|
||||
0015 <span class="comment">%</span>
|
||||
0016 <span class="comment">% See "Fast Filtering and Smoothing for Multivariate State Space</span>
|
||||
0017 <span class="comment">% Models", S.J. Koopman and J. Durbin (2000, in Journal of Time Series</span>
|
||||
0018 <span class="comment">% Analysis, vol. 21(3), pp. 281-296).</span>
|
||||
0019
|
||||
0020 <span class="keyword">global</span> 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 <a href="steady.html" class="code" title="function steady(linear)">steady</a> = 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 <span class="keyword">for</span> i=1:pp;
|
||||
0055 Z(i,mf(i)) = 1;
|
||||
0056 <span class="keyword">end</span>
|
||||
0057
|
||||
0058 t = 0;
|
||||
0059 icc=0;
|
||||
0060 newRank = rank(Pinf(:,:,1),crit1);
|
||||
0061 <span class="keyword">while</span> 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 <span class="keyword">for</span> 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 <span class="keyword">if</span> Finf(i,t) > crit & newRank, <span class="comment">% original MJ: if Finf(i,t) > crit</span>
|
||||
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) + <span class="keyword">...</span>
|
||||
0080 Kinf(:,i,t)*transpose(Kinf(:,i,t))*Fstar(i,t)/(Finf(i,t)*Finf(i,t)) - <span class="keyword">...</span>
|
||||
0081 (Kstar(:,i,t)*transpose(Kinf(:,i,t)) +<span class="keyword">...</span>
|
||||
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 <span class="comment">% new terminiation criteria by M. Ratto</span>
|
||||
0087 P0=Pinf(:,:,t);
|
||||
0088 <span class="comment">% newRank = any(diag(P0(mf,mf))>crit);</span>
|
||||
0089 <span class="comment">% if newRank==0, options_.diffuse_d = i; end,</span>
|
||||
0090 <span class="keyword">if</span> ~isempty(options_.diffuse_d),
|
||||
0091 newRank = (icc<options_.diffuse_d);
|
||||
0092 <span class="comment">%if newRank & any(diag(P0(mf,mf))>crit)==0;</span>
|
||||
0093 <span class="keyword">if</span> newRank & (any(diag(P0(mf,mf))>crit)==0 & rank(P0,crit1)==0);
|
||||
0094 disp(<span class="string">'WARNING!! Change in OPTIONS_.DIFFUSE_D in univariate DKF'</span>)
|
||||
0095 options_.diffuse_d = icc;
|
||||
0096 newRank=0;
|
||||
0097 <span class="keyword">end</span>
|
||||
0098 <span class="keyword">else</span>
|
||||
0099 <span class="comment">%newRank = any(diag(P0(mf,mf))>crit);</span>
|
||||
0100 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1));
|
||||
0101 <span class="keyword">if</span> newRank==0,
|
||||
0102 options_.diffuse_d = icc;
|
||||
0103 <span class="keyword">end</span>
|
||||
0104 <span class="keyword">end</span>,
|
||||
0105 <span class="comment">% if newRank==0,</span>
|
||||
0106 <span class="comment">% options_.diffuse_d=i; % this line is buggy!</span>
|
||||
0107 <span class="comment">% end</span>
|
||||
0108 <span class="comment">% end new terminiation criteria by M. Ratto</span>
|
||||
0109 <span class="keyword">else</span>
|
||||
0110 <span class="comment">%% Note that : (1) rank(Pinf)=0 implies that Finf = 0, (2) outside this loop (when for some i and t the condition</span>
|
||||
0111 <span class="comment">%% rank(Pinf)=0 is satisfied we have P = Pstar and F = Fstar and (3) Finf = 0 does not imply that</span>
|
||||
0112 <span class="comment">%% rank(Pinf)=0. [stphane,11-03-2004].</span>
|
||||
0113 Li(:,:,i,t) = eye(mm)-Kstar(:,i,t)*Z(i,:)/Fstar(i,t); <span class="comment">% we need to store Li for DKF smoother</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0118 <span class="keyword">end</span>
|
||||
0119 a(:,t+1) = T*a(:,t);
|
||||
0120 <span class="keyword">for</span> jnk=1:nk,
|
||||
0121 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
|
||||
0122 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> newRank,
|
||||
0127 <span class="comment">%newRank = any(diag(P0(mf,mf))>crit);</span>
|
||||
0128 newRank = rank(P0,crit1);
|
||||
0129 <span class="keyword">end</span>
|
||||
0130 <span class="keyword">end</span>
|
||||
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 <span class="keyword">while</span> 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 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0160 <span class="keyword">end</span>
|
||||
0161 a(:,t+1) = T*a(:,t);
|
||||
0162 <span class="keyword">for</span> jnk=1:nk,
|
||||
0163 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
|
||||
0164 <span class="keyword">end</span>
|
||||
0165 P(:,:,t+1) = T*P(:,:,t)*transpose(T) + QQ;
|
||||
0166 notsteady = ~(max(max(abs(P(:,:,t+1)-P(:,:,t))))<crit);
|
||||
0167 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0179 <span class="keyword">while</span> t<smpl
|
||||
0180 t=t+1;
|
||||
0181 a1(:,t) = a(:,t);
|
||||
0182 <span class="keyword">for</span> i=1:pp
|
||||
0183 v(i,t) = Y(i,t) - a(mf(i),t) - trend(i,t);
|
||||
0184 <span class="keyword">if</span> Fi_s(i) > crit
|
||||
0185 a(:,t) = a(:,t) + Ki_s(:,i)*v(i,t)/Fi_s(i);
|
||||
0186 <span class="keyword">end</span>
|
||||
0187 <span class="keyword">end</span>
|
||||
0188 a(:,t+1) = T*a(:,t);
|
||||
0189 <span class="keyword">for</span> jnk=1:nk,
|
||||
0190 aK(jnk,:,t+jnk) = T^jnk*a(:,t);
|
||||
0191 <span class="keyword">end</span>
|
||||
0192 <span class="keyword">end</span>
|
||||
0193 a1(:,t+1) = a(:,t+1);
|
||||
0194 ri=r;
|
||||
0195 t = smpl+1;
|
||||
0196 <span class="keyword">while</span> t>d+1 & t>2,
|
||||
0197 t = t-1;
|
||||
0198 <span class="keyword">for</span> i=pp:-1:1
|
||||
0199 <span class="keyword">if</span> Fi(i,t) > crit
|
||||
0200 ri(:,t)=transpose(Z(i,:))/Fi(i,t)*v(i,t)+transpose(Li(:,:,i,t))*ri(:,t);
|
||||
0201 <span class="keyword">end</span>
|
||||
0202 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0208 <span class="keyword">if</span> d
|
||||
0209 r0 = zeros(mm,d); r0(:,d) = ri(:,d);
|
||||
0210 r1 = zeros(mm,d);
|
||||
0211 <span class="keyword">for</span> t = d:-1:2
|
||||
0212 <span class="keyword">for</span> i=pp:-1:1
|
||||
0213 <span class="keyword">if</span> Finf(i,t) > crit & ~(t==d & i>options_.diffuse_d), <span class="comment">% use of options_.diffuse_d to be sure of DKF termination</span>
|
||||
0214 <span class="comment">%r1(:,t) = transpose(Z)*v(:,t)/Finf(i,t) + ... BUG HERE in transpose(Z)</span>
|
||||
0215 r1(:,t) = transpose(Z(i,:))*v(i,t)/Finf(i,t) + <span class="keyword">...</span>
|
||||
0216 transpose(L0(:,:,i,t))*r0(:,t) + transpose(Linf(:,:,i,t))*r1(:,t);
|
||||
0217 r0(:,t) = transpose(Linf(:,:,i,t))*r0(:,t);
|
||||
0218 <span class="keyword">elseif</span> Fstar(i,t) > crit <span class="comment">% step needed whe Finf == 0</span>
|
||||
0219 r0(:,t)=transpose(Z(i,:))/Fstar(i,t)*v(i,t)+Li(:,:,i,t)'*r0(:,t);
|
||||
0220 <span class="keyword">end</span>
|
||||
0221 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0228 r0_0 = r0(:,1);
|
||||
0229 r1_0 = r1(:,1);
|
||||
0230 <span class="keyword">for</span> i=pp:-1:1
|
||||
0231 <span class="keyword">if</span> Finf(i,1) > crit,
|
||||
0232 <span class="comment">%r1_0 = transpose(Z)*v(:,1)/Finf(i,1) + ... %bug with Z here</span>
|
||||
0233 r1_0 = transpose(Z(i,:))*v(i,1)/Finf(i,1) + <span class="keyword">...</span>
|
||||
0234 transpose(L0(:,:,i,1))*r0_0 + transpose(Linf(:,:,i,1))*r1_0;
|
||||
0235 r0_0 = transpose(Linf(:,:,i,1))*r0_0;
|
||||
0236 <span class="keyword">elseif</span> Fstar(i,1) > crit, <span class="comment">% step needed when Finf=0</span>
|
||||
0237 r0_0=transpose(Z(i,:))/Fstar(i,1)*v(i,1)+Li(:,:,i,1)'*r0_0;
|
||||
0238 <span class="keyword">end</span>
|
||||
0239 <span class="keyword">end</span>
|
||||
0240 <span class="comment">%alphahat(:,1) = a(:,1) + Pstar(:,:,1)*r0_0 + Pinf(:,:,1)*r1_0; %this line is buggy</span>
|
||||
0241 alphahat(:,1) = a1(:,1) + Pstar1(:,:,1)*r0_0 + Pinf1(:,:,1)*r1_0;
|
||||
0242 etahat(:,1) = QRt*r(:,1);
|
||||
0243 <span class="keyword">else</span>
|
||||
0244 r0 = ri(:,1);
|
||||
0245 <span class="keyword">for</span> i=pp:-1:1
|
||||
0246 <span class="keyword">if</span> Fi(i,1) > crit
|
||||
0247 r0=transpose(Z(i,:))/Fi(i,1)*v(i,1)+transpose(Li(:,:,i,1))*r0;
|
||||
0248 <span class="keyword">end</span>
|
||||
0249 <span class="keyword">end</span>
|
||||
0250 <span class="comment">%alphahat(:,1) = a(:,1) + P(:,:,1)*r0; % this line is buggy</span>
|
||||
0251 alphahat(:,1) = a1(:,1) + P1(:,:,1)*r0;
|
||||
0252 etahat(:,1) = QRt*r(:,1);
|
||||
0253 <span class="keyword">end</span>
|
||||
0254 epsilonhat = Y-alphahat(mf,:)-trend;
|
||||
0255</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,253 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseKalmanSmootherH3corr</title>
|
||||
<meta name="keywords" content="DiffuseKalmanSmootherH3corr">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [09-16-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseKalmanSmootherH3corr.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseKalmanSmootherH3corr
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [09-16-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [alphahat,epsilonhat,etahat,a1] = DiffuseKalmanSmootherH3corr(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [09-16-2004]
|
||||
|
||||
See "Fast Filtering and Smoothing for Multivariate State Space
|
||||
Models", S.J. Koopman and J. Durbin (2000, in Journal of Time Series
|
||||
Analysis, vol. 21(3), pp. 281-296).</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="steady.html" class="code" title="function steady(linear)">steady</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [alphahat,epsilonhat,etahat,a1] = DiffuseKalmanSmootherH3corr(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-16-2004]</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% See "Fast Filtering and Smoothing for Multivariate State Space</span>
|
||||
0005 <span class="comment">% Models", S.J. Koopman and J. Durbin (2000, in Journal of Time Series</span>
|
||||
0006 <span class="comment">% Analysis, vol. 21(3), pp. 281-296).</span>
|
||||
0007
|
||||
0008 <span class="keyword">global</span> 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 <span class="keyword">if</span> size(Pinf1,1) <span class="comment">% Otherwise Pinf = 0 (no unit root)</span>
|
||||
0015 Pinf1 = cat(1,cat(2,Pinf1,zeros(mm,pp)),zeros(pp,mm+pp));
|
||||
0016 <span class="keyword">end</span>
|
||||
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 <a href="steady.html" class="code" title="function steady(linear)">steady</a> = 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 <span class="keyword">for</span> i=1:pp;
|
||||
0048 Z(i,mf(i)) = 1;
|
||||
0049 Z(i,mm+i) = 1;
|
||||
0050 <span class="keyword">end</span>
|
||||
0051 <span class="comment">%% [1] Kalman filter...</span>
|
||||
0052 t = 0;
|
||||
0053 newRank = rank(Pinf(:,:,1),crit);
|
||||
0054 <span class="keyword">while</span> newRank & t < smpl
|
||||
0055 t = t+1;
|
||||
0056 a1(:,t) = a(:,t);
|
||||
0057 Pstar1(:,:,t) = Pstar(:,:,t);
|
||||
0058 Pinf1(:,:,t) = Pinf(:,:,t);
|
||||
0059 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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) + <span class="keyword">...</span>
|
||||
0070 Kinf(:,i,t)*transpose(Kinf(:,i,t))*Fstar(i,t)/(Finf(i,t)*Finf(i,t)) - <span class="keyword">...</span>
|
||||
0071 (Kstar(:,i,t)*transpose(Kinf(:,i,t)) +<span class="keyword">...</span>
|
||||
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 <span class="keyword">else</span> <span class="comment">%% Note that : (1) rank(Pinf)=0 implies that Finf = 0, (2) outside this loop (when for some i and t the condition</span>
|
||||
0075 <span class="comment">%% rank(Pinf)=0 is satisfied we have P = Pstar and F = Fstar and (3) Finf = 0 does not imply that</span>
|
||||
0076 <span class="comment">%% rank(Pinf)=0. [stphane,11-03-2004].</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0080 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">while</span> 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 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0114 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0130 <span class="keyword">while</span> t<smpl
|
||||
0131 t=t+1;
|
||||
0132 a1(:,t) = a(:,t);
|
||||
0133 <span class="keyword">for</span> i=1:pp
|
||||
0134 v(i,t) = Y(i,t) - a(mf(i),t) - a(mm+i,t) - trend(i,t);
|
||||
0135 <span class="keyword">if</span> Fi_s(i) > crit
|
||||
0136 a(:,t) = a(:,t) + Ki_s(:,i)*v(i,t)/Fi_s(i);
|
||||
0137 <span class="keyword">end</span>
|
||||
0138 <span class="keyword">end</span>
|
||||
0139 a(:,t+1) = T*a(:,t);
|
||||
0140 <span class="keyword">end</span>
|
||||
0141 a1(:,t+1) = a(:,t+1);
|
||||
0142 <span class="comment">%% [2] Kalman smoother...</span>
|
||||
0143 ri=r;
|
||||
0144 t = smpl+1;
|
||||
0145 <span class="keyword">while</span> t>d+1 & t>2,
|
||||
0146 t = t-1;
|
||||
0147 <span class="keyword">for</span> i=pp:-1:1
|
||||
0148 <span class="keyword">if</span> Fi(i,t) > crit
|
||||
0149 ri(:,t)=transpose(Z(i,:))/Fi(i,t)*v(i,t)+transpose(Li(:,:,i,t))*ri(:,t);
|
||||
0150 <span class="keyword">end</span>
|
||||
0151 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0159 <span class="keyword">if</span> d
|
||||
0160 r0 = zeros(mm+pp,d); r0(:,d) = ri(:,d);
|
||||
0161 r1 = zeros(mm+pp,d);
|
||||
0162 <span class="keyword">for</span> t = d:-1:2
|
||||
0163 <span class="keyword">for</span> i=pp:-1:1
|
||||
0164 <span class="keyword">if</span> Finf(i,t) > crit
|
||||
0165 r1(:,t) = transpose(Z)*v(:,t)/Finf(i,t) + <span class="keyword">...</span>
|
||||
0166 transpose(L0(:,:,i,t))*r0(:,t) + transpose(Linf(:,:,i,t))*r1(:,t);
|
||||
0167 r0(:,t) = transpose(Linf(:,:,i,t))*r0(:,t);
|
||||
0168 <span class="keyword">end</span>
|
||||
0169 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0178 r0_0 = r0(:,1);
|
||||
0179 r1_0 = r1(:,1);
|
||||
0180 <span class="keyword">for</span> i=pp:-1:1
|
||||
0181 <span class="keyword">if</span> Finf(i,1) > crit,
|
||||
0182 r1_0 = transpose(Z)*v(:,1)/Finf(i,1) + <span class="keyword">...</span>
|
||||
0183 transpose(L0(:,:,i,1))*r0_0 + transpose(Linf(:,:,i,1))*r1_0;
|
||||
0184 r0_0 = transpose(Linf(:,:,i,1))*r0_0;
|
||||
0185 <span class="keyword">end</span>
|
||||
0186 <span class="keyword">end</span>
|
||||
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 <span class="keyword">else</span>
|
||||
0192 r0 = ri(:,1);
|
||||
0193 <span class="keyword">for</span> i=pp:-1:1
|
||||
0194 <span class="keyword">if</span> Fi(i,1) > crit
|
||||
0195 r0=transpose(Z(i,:))/Fi(i,1)*v(i,1)+transpose(Li(:,:,i,1))*r0;
|
||||
0196 <span class="keyword">end</span>
|
||||
0197 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0203 alphahat = alphahat(1:mm,:);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,140 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseLikelihood1</title>
|
||||
<meta name="keywords" content="DiffuseLikelihood1">
|
||||
<meta name="description" content="M. Ratto added lik in output">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseLikelihood1.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseLikelihood1
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>M. Ratto added lik in output</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> M. Ratto added lik in output
|
||||
stephane.adjemian@cepremap.cnrs.fr [07-19-2004]
|
||||
|
||||
Same as DiffuseLikelihoodH1 without measurement error.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [LIK, lik] = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,Y,trend,start)</a>
|
||||
0002 <span class="comment">% M. Ratto added lik in output</span>
|
||||
0003 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [07-19-2004]</span>
|
||||
0004 <span class="comment">%</span>
|
||||
0005 <span class="comment">% Same as DiffuseLikelihoodH1 without measurement error.</span>
|
||||
0006 <span class="keyword">global</span> 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 <span class="keyword">while</span> rank(Pinf,crit) & t < smpl
|
||||
0023 t = t+1;
|
||||
0024 v = Y(:,t)-a(mf)-trend(:,t);
|
||||
0025 Finf = Pinf(mf,mf);
|
||||
0026 <span class="keyword">if</span> rcond(Finf) < crit
|
||||
0027 <span class="keyword">if</span> ~all(abs(Finf(:)) < crit)
|
||||
0028 <span class="keyword">return</span>
|
||||
0029 <span class="keyword">else</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0038 <span class="keyword">else</span>
|
||||
0039 lik(t) = log(det(Finf));
|
||||
0040 iFinf = inv(Finf);
|
||||
0041 Kinf = Pinf(:,mf)*iFinf; <span class="comment">%% premultiplication by the transition matrix T is removed (stephane)</span>
|
||||
0042 Fstar = Pstar(mf,mf);
|
||||
0043 Kstar = (Pstar(:,mf)-Kinf*Fstar)*iFinf; <span class="comment">%% premultiplication by the transition matrix T is removed (stephane)</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0048 <span class="keyword">end</span>
|
||||
0049 <span class="keyword">if</span> t == smpl
|
||||
0050 error([<span class="string">'There isn''t enough information to estimate the initial'</span> <span class="keyword">...</span><span class="comment"> </span>
|
||||
0051 <span class="string">' conditions of the nonstationary variables'</span>]);
|
||||
0052 <span class="keyword">end</span>
|
||||
0053 F_singular = 1;
|
||||
0054 <span class="keyword">while</span> 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 <span class="keyword">if</span> rcond(F) < crit
|
||||
0061 <span class="keyword">if</span> ~all(abs(F(:))<crit)
|
||||
0062 <span class="keyword">return</span>
|
||||
0063 <span class="keyword">else</span>
|
||||
0064 a = T*a;
|
||||
0065 Pstar = T*Pstar*transpose(T)+QQ;
|
||||
0066 <span class="keyword">end</span>
|
||||
0067 <span class="keyword">else</span>
|
||||
0068 F_singular = 0;
|
||||
0069 iF = inv(F);
|
||||
0070 lik(t) = log(dF)+transpose(v)*iF*v;
|
||||
0071 K = Pstar(:,mf)*iF; <span class="comment">%% premultiplication by the transition matrix T is removed (stephane)</span>
|
||||
0072 a = T*(a+K*v); <span class="comment">%% --> factorization of the transition matrix...</span>
|
||||
0073 Pstar = T*(Pstar-K*Pstar(mf,:))*transpose(T)+QQ; <span class="comment">%% ... idem (stephane)</span>
|
||||
0074 <span class="keyword">end</span>
|
||||
0075 notsteady = ~(max(max(abs(Pstar-oldPstar)))<crit);
|
||||
0076 <span class="keyword">end</span>
|
||||
0077 <span class="keyword">if</span> F_singular == 1
|
||||
0078 error([<span class="string">'The variance of the forecast error remains singular until the'</span> <span class="keyword">...</span>
|
||||
0079 <span class="string">'end of the sample'</span>])
|
||||
0080 <span class="keyword">end</span>
|
||||
0081 reste = smpl-t;
|
||||
0082 <span class="keyword">while</span> 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 <span class="keyword">end</span>
|
||||
0088 lik(t) = lik(t) + reste*log(dF);
|
||||
0089
|
||||
0090
|
||||
0091 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);<span class="comment">% Minus the log-likelihood.</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,348 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseLikelihood3</title>
|
||||
<meta name="keywords" content="DiffuseLikelihood3">
|
||||
<meta name="description" content="M. Ratto added lik in output [October 2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseLikelihood3.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseLikelihood3
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>M. Ratto added lik in output [October 2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)%//Z,T,R,Q,Pinf,Pstar,Y) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> M. Ratto added lik in output [October 2005]
|
||||
changes by M. Ratto [April 2005]
|
||||
introduced new options options_.diffuse_d for termination of DKF
|
||||
new icc counter for Finf steps in DKF
|
||||
new termination for DKF
|
||||
likelihood terms for Fstar must be cumulated in DKF also when Pinf is non
|
||||
zero.
|
||||
|
||||
[4/5/2005] correctyed bug in the modified verson of Ratto for rank of Pinf
|
||||
introduced a specific crit1 for the DKF termination
|
||||
|
||||
stepane.adjemian@cepremap.cnrs.fr [07-19-2004]
|
||||
|
||||
See "Filtering and Smoothing of State Vector for Diffuse State Space
|
||||
Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
|
||||
Analysis, vol. 24(1), pp. 85-98).
|
||||
|
||||
Case where F_{\infty,t} is singular ==> Univariate treatment of multivariate
|
||||
time series.
|
||||
|
||||
THE PROBLEM:
|
||||
|
||||
y_t = Z_t * \alpha_t + \varepsilon_t
|
||||
\alpha_{t+1} = T_t * \alpha_t + R_t * \eta_t
|
||||
|
||||
with:
|
||||
|
||||
\alpha_1 = a + A*\delta + R_0*\eta_0
|
||||
|
||||
m*q matrix A and m*(m-q) matrix R_0 are selection matrices (their
|
||||
columns constitue all the columns of the m*m identity matrix) so that
|
||||
|
||||
A'*R_0 = 0 and A'*\alpha_1 = \delta
|
||||
|
||||
We assume that the vector \delta is distributed as a N(0,\kappa*I_q)
|
||||
for a given \kappa > 0. So that the expectation of \alpha_1 is a and
|
||||
its variance is P, with
|
||||
|
||||
P = \kappa*P_{\infty} + P_{\star}
|
||||
|
||||
P_{\infty} = A*A'
|
||||
P_{\star} = R_0*Q_0*R_0'
|
||||
|
||||
P_{\infty} is a m*m diagonal matrix with q ones and m-q zeros.
|
||||
|
||||
|
||||
and where:
|
||||
|
||||
y_t is a pp*1 vector
|
||||
\alpha_t is a mm*1 vector
|
||||
\varepsilon_t is a pp*1 multivariate random variable (iid N(0,H_t))
|
||||
\eta_t is a rr*1 multivariate random variable (iid N(0,Q_t))
|
||||
a_1 is a mm*1 vector
|
||||
|
||||
Z_t is a pp*mm matrix
|
||||
T_t is a mm*mm matrix
|
||||
H_t is a pp*pp matrix
|
||||
R_t is a mm*rr matrix
|
||||
Q_t is a rr*rr matrix
|
||||
P_1 is a mm*mm matrix
|
||||
|
||||
|
||||
FILTERING EQUATIONS:
|
||||
|
||||
v_t = y_t - Z_t* a_t
|
||||
F_t = Z_t * P_t * Z_t' + H_t
|
||||
K_t = T_t * P_t * Z_t' * F_t^{-1}
|
||||
L_t = T_t - K_t * Z_t
|
||||
a_{t+1} = T_t * a_t + K_t * v_t
|
||||
P_{t+1} = T_t * P_t * L_t' + R_t*Q_t*R_t'
|
||||
|
||||
|
||||
DIFFUSE FILTERING EQUATIONS:
|
||||
|
||||
a_{t+1} = T_t*a_t + K_{\ast,t}v_t
|
||||
P_{\infty,t+1} = T_t*P_{\infty,t}*T_t'
|
||||
P_{\ast,t+1} = T_t*P_{\ast,t}*L_{\ast,t}' + R_t*Q_t*R_t'
|
||||
K_{\ast,t} = T_t*P_{\ast,t}*Z_t'*F_{\ast,t}^{-1}
|
||||
v_t = y_t - Z_t*a_t
|
||||
L_{\ast,t} = T_t - K_{\ast,t}*Z_t
|
||||
F_{\ast,t} = Z_t*P_{\ast,t}*Z_t' + H_t</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)</a><span class="comment">%//Z,T,R,Q,Pinf,Pstar,Y)</span>
|
||||
0002 <span class="comment">% M. Ratto added lik in output [October 2005]</span>
|
||||
0003 <span class="comment">% changes by M. Ratto [April 2005]</span>
|
||||
0004 <span class="comment">% introduced new options options_.diffuse_d for termination of DKF</span>
|
||||
0005 <span class="comment">% new icc counter for Finf steps in DKF</span>
|
||||
0006 <span class="comment">% new termination for DKF</span>
|
||||
0007 <span class="comment">% likelihood terms for Fstar must be cumulated in DKF also when Pinf is non</span>
|
||||
0008 <span class="comment">% zero.</span>
|
||||
0009 <span class="comment">%</span>
|
||||
0010 <span class="comment">% [4/5/2005] correctyed bug in the modified verson of Ratto for rank of Pinf</span>
|
||||
0011 <span class="comment">% introduced a specific crit1 for the DKF termination</span>
|
||||
0012 <span class="comment">%</span>
|
||||
0013 <span class="comment">% stepane.adjemian@cepremap.cnrs.fr [07-19-2004]</span>
|
||||
0014 <span class="comment">%</span>
|
||||
0015 <span class="comment">% See "Filtering and Smoothing of State Vector for Diffuse State Space</span>
|
||||
0016 <span class="comment">% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series</span>
|
||||
0017 <span class="comment">% Analysis, vol. 24(1), pp. 85-98).</span>
|
||||
0018 <span class="comment">%</span>
|
||||
0019 <span class="comment">% Case where F_{\infty,t} is singular ==> Univariate treatment of multivariate</span>
|
||||
0020 <span class="comment">% time series.</span>
|
||||
0021 <span class="comment">%</span>
|
||||
0022 <span class="comment">% THE PROBLEM:</span>
|
||||
0023 <span class="comment">%</span>
|
||||
0024 <span class="comment">% y_t = Z_t * \alpha_t + \varepsilon_t</span>
|
||||
0025 <span class="comment">% \alpha_{t+1} = T_t * \alpha_t + R_t * \eta_t</span>
|
||||
0026 <span class="comment">%</span>
|
||||
0027 <span class="comment">% with:</span>
|
||||
0028 <span class="comment">%</span>
|
||||
0029 <span class="comment">% \alpha_1 = a + A*\delta + R_0*\eta_0</span>
|
||||
0030 <span class="comment">%</span>
|
||||
0031 <span class="comment">% m*q matrix A and m*(m-q) matrix R_0 are selection matrices (their</span>
|
||||
0032 <span class="comment">% columns constitue all the columns of the m*m identity matrix) so that</span>
|
||||
0033 <span class="comment">%</span>
|
||||
0034 <span class="comment">% A'*R_0 = 0 and A'*\alpha_1 = \delta</span>
|
||||
0035 <span class="comment">%</span>
|
||||
0036 <span class="comment">% We assume that the vector \delta is distributed as a N(0,\kappa*I_q)</span>
|
||||
0037 <span class="comment">% for a given \kappa > 0. So that the expectation of \alpha_1 is a and</span>
|
||||
0038 <span class="comment">% its variance is P, with</span>
|
||||
0039 <span class="comment">%</span>
|
||||
0040 <span class="comment">% P = \kappa*P_{\infty} + P_{\star}</span>
|
||||
0041 <span class="comment">%</span>
|
||||
0042 <span class="comment">% P_{\infty} = A*A'</span>
|
||||
0043 <span class="comment">% P_{\star} = R_0*Q_0*R_0'</span>
|
||||
0044 <span class="comment">%</span>
|
||||
0045 <span class="comment">% P_{\infty} is a m*m diagonal matrix with q ones and m-q zeros.</span>
|
||||
0046 <span class="comment">%</span>
|
||||
0047 <span class="comment">%</span>
|
||||
0048 <span class="comment">% and where:</span>
|
||||
0049 <span class="comment">%</span>
|
||||
0050 <span class="comment">% y_t is a pp*1 vector</span>
|
||||
0051 <span class="comment">% \alpha_t is a mm*1 vector</span>
|
||||
0052 <span class="comment">% \varepsilon_t is a pp*1 multivariate random variable (iid N(0,H_t))</span>
|
||||
0053 <span class="comment">% \eta_t is a rr*1 multivariate random variable (iid N(0,Q_t))</span>
|
||||
0054 <span class="comment">% a_1 is a mm*1 vector</span>
|
||||
0055 <span class="comment">%</span>
|
||||
0056 <span class="comment">% Z_t is a pp*mm matrix</span>
|
||||
0057 <span class="comment">% T_t is a mm*mm matrix</span>
|
||||
0058 <span class="comment">% H_t is a pp*pp matrix</span>
|
||||
0059 <span class="comment">% R_t is a mm*rr matrix</span>
|
||||
0060 <span class="comment">% Q_t is a rr*rr matrix</span>
|
||||
0061 <span class="comment">% P_1 is a mm*mm matrix</span>
|
||||
0062 <span class="comment">%</span>
|
||||
0063 <span class="comment">%</span>
|
||||
0064 <span class="comment">% FILTERING EQUATIONS:</span>
|
||||
0065 <span class="comment">%</span>
|
||||
0066 <span class="comment">% v_t = y_t - Z_t* a_t</span>
|
||||
0067 <span class="comment">% F_t = Z_t * P_t * Z_t' + H_t</span>
|
||||
0068 <span class="comment">% K_t = T_t * P_t * Z_t' * F_t^{-1}</span>
|
||||
0069 <span class="comment">% L_t = T_t - K_t * Z_t</span>
|
||||
0070 <span class="comment">% a_{t+1} = T_t * a_t + K_t * v_t</span>
|
||||
0071 <span class="comment">% P_{t+1} = T_t * P_t * L_t' + R_t*Q_t*R_t'</span>
|
||||
0072 <span class="comment">%</span>
|
||||
0073 <span class="comment">%</span>
|
||||
0074 <span class="comment">% DIFFUSE FILTERING EQUATIONS:</span>
|
||||
0075 <span class="comment">%</span>
|
||||
0076 <span class="comment">% a_{t+1} = T_t*a_t + K_{\ast,t}v_t</span>
|
||||
0077 <span class="comment">% P_{\infty,t+1} = T_t*P_{\infty,t}*T_t'</span>
|
||||
0078 <span class="comment">% P_{\ast,t+1} = T_t*P_{\ast,t}*L_{\ast,t}' + R_t*Q_t*R_t'</span>
|
||||
0079 <span class="comment">% K_{\ast,t} = T_t*P_{\ast,t}*Z_t'*F_{\ast,t}^{-1}</span>
|
||||
0080 <span class="comment">% v_t = y_t - Z_t*a_t</span>
|
||||
0081 <span class="comment">% L_{\ast,t} = T_t - K_{\ast,t}*Z_t</span>
|
||||
0082 <span class="comment">% F_{\ast,t} = Z_t*P_{\ast,t}*Z_t' + H_t</span>
|
||||
0083 <span class="keyword">global</span> 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); <span class="comment">%% the constant of minus two times the log-likelihood</span>
|
||||
0094 notsteady = 1;
|
||||
0095 crit = options_.kalman_tol;
|
||||
0096 crit1 = 1.e-6;
|
||||
0097 newRank = rank(Pinf,crit1);
|
||||
0098 icc=0;
|
||||
0099 <span class="keyword">while</span> newRank & t < smpl
|
||||
0100 t = t+1;
|
||||
0101 <span class="keyword">for</span> 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 <span class="keyword">if</span> Finf > crit & newRank, <span class="comment">%added newRank criterion</span>
|
||||
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) - <span class="keyword">...</span>
|
||||
0111 (Kstar*transpose(Kinf)+Kinf*transpose(Kstar))/Finf;
|
||||
0112 Pinf = Pinf - Kinf*transpose(Kinf)/Finf;
|
||||
0113 lik(t) = lik(t) + log(Finf);
|
||||
0114 <span class="comment">% start new termination criterion for DKF</span>
|
||||
0115 <span class="keyword">if</span> ~isempty(options_.diffuse_d),
|
||||
0116 newRank = (icc<options_.diffuse_d);
|
||||
0117 <span class="comment">%if newRank & any(diag(Pinf(mf,mf))>crit)==0; % M. Ratto this line is BUGGY</span>
|
||||
0118 <span class="keyword">if</span> newRank & (any(diag(Pinf(mf,mf))>crit)==0 & rank(Pinf,crit1)==0);
|
||||
0119 options_.diffuse_d = icc;
|
||||
0120 newRank=0;
|
||||
0121 disp(<span class="string">'WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF'</span>)
|
||||
0122 disp([<span class="string">'new OPTIONS_.DIFFUSE_D = '</span>,int2str(icc)])
|
||||
0123 disp(<span class="string">'You may have to reset the optimisation'</span>)
|
||||
0124 <span class="keyword">end</span>
|
||||
0125 <span class="keyword">else</span>
|
||||
0126 <span class="comment">%newRank = any(diag(Pinf(mf,mf))>crit); % M. Ratto this line is BUGGY</span>
|
||||
0127 newRank = (any(diag(Pinf(mf,mf))>crit) | rank(Pinf,crit1));
|
||||
0128 <span class="keyword">if</span> newRank==0,
|
||||
0129 P0= T*Pinf*transpose(T);
|
||||
0130 <span class="comment">%newRank = any(diag(P0(mf,mf))>crit); % M. Ratto this line is BUGGY</span>
|
||||
0131 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1)); <span class="comment">% M. Ratto 11/10/2005</span>
|
||||
0132 <span class="keyword">if</span> newRank==0,
|
||||
0133 options_.diffuse_d = icc;
|
||||
0134 <span class="keyword">end</span>
|
||||
0135 <span class="keyword">end</span>
|
||||
0136 <span class="keyword">end</span>,
|
||||
0137 <span class="comment">% end new termination and checks for DKF</span>
|
||||
0138 <span class="keyword">elseif</span> Fstar > crit
|
||||
0139 <span class="comment">%% Note that : (1) rank(Pinf)=0 implies that Finf = 0, (2) outside this loop (when for some i and t the condition</span>
|
||||
0140 <span class="comment">%% rank(Pinf)=0 is satisfied we have P = Pstar and F = Fstar and (3) Finf = 0 does not imply that</span>
|
||||
0141 <span class="comment">%% rank(Pinf)=0. [stphane,11-03-2004].</span>
|
||||
0142 <span class="comment">%if rank(Pinf,crit) == 0</span>
|
||||
0143 <span class="comment">% the likelihood terms should alwasy be cumulated, not only</span>
|
||||
0144 <span class="comment">% when Pinf=0, otherwise the lik would depend on the ordering</span>
|
||||
0145 <span class="comment">% of observed variables</span>
|
||||
0146 <span class="comment">% presample options can be used to ignore initial time points</span>
|
||||
0147 lik(t) = lik(t) + log(Fstar) + v(i)*v(i)/Fstar;
|
||||
0148 <span class="comment">%end</span>
|
||||
0149 a = a + Kstar*v(i)/Fstar;
|
||||
0150 Pstar = Pstar - Kstar*transpose(Kstar)/Fstar;
|
||||
0151 <span class="keyword">else</span>
|
||||
0152 <span class="comment">%disp(['zero F term in DKF for observed ',int2str(i),' ',num2str(Fstar)])</span>
|
||||
0153 <span class="keyword">end</span>
|
||||
0154 <span class="keyword">end</span>
|
||||
0155 <span class="comment">% if all(abs(Pinf(:))<crit),</span>
|
||||
0156 <span class="comment">% oldRank = 0;</span>
|
||||
0157 <span class="comment">% else</span>
|
||||
0158 <span class="comment">% oldRank = rank(Pinf,crit);</span>
|
||||
0159 <span class="comment">% end</span>
|
||||
0160 <span class="keyword">if</span> newRank,
|
||||
0161 oldRank = rank(Pinf,crit1);
|
||||
0162 <span class="keyword">else</span>
|
||||
0163 oldRank = 0;
|
||||
0164 <span class="keyword">end</span>
|
||||
0165 a = T*a;
|
||||
0166 Pstar = T*Pstar*transpose(T)+QQ;
|
||||
0167 Pinf = T*Pinf*transpose(T);
|
||||
0168 <span class="comment">% if all(abs(Pinf(:))<crit),</span>
|
||||
0169 <span class="comment">% newRank = 0;</span>
|
||||
0170 <span class="comment">% else</span>
|
||||
0171 <span class="comment">% newRank = rank(Pinf,crit);</span>
|
||||
0172 <span class="comment">% end</span>
|
||||
0173 <span class="keyword">if</span> newRank,
|
||||
0174 newRank = rank(Pinf,crit1); <span class="comment">% new crit1 is used</span>
|
||||
0175 <span class="keyword">end</span>
|
||||
0176 <span class="keyword">if</span> oldRank ~= newRank
|
||||
0177 disp(<span class="string">'DiffuseLiklihood3 :: T does influence the rank of Pinf!'</span>)
|
||||
0178 <span class="keyword">end</span>
|
||||
0179 <span class="keyword">end</span>
|
||||
0180 <span class="keyword">if</span> t == smpl
|
||||
0181 error([<span class="string">'There isn''t enough information to estimate the initial'</span> <span class="keyword">...</span><span class="comment"> </span>
|
||||
0182 <span class="string">' conditions of the nonstationary variables'</span>]);
|
||||
0183 <span class="keyword">end</span>
|
||||
0184 <span class="keyword">while</span> notsteady & t < smpl
|
||||
0185 t = t+1;
|
||||
0186 oldP = Pstar;
|
||||
0187 <span class="keyword">for</span> i=1:pp
|
||||
0188 v(i) = Y(i,t) - a(mf(i)) - trend(i,t);
|
||||
0189 Fi = Pstar(mf(i),mf(i));
|
||||
0190 <span class="keyword">if</span> 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 <span class="keyword">else</span>
|
||||
0196 <span class="comment">%disp(['zero F term for observed ',int2str(i),' ',num2str(Fi)])</span>
|
||||
0197 <span class="keyword">end</span>
|
||||
0198 <span class="keyword">end</span>
|
||||
0199 a = T*a;
|
||||
0200 Pstar = T*Pstar*transpose(T) + QQ;
|
||||
0201 notsteady = ~(max(max(abs(Pstar-oldP)))<crit);
|
||||
0202 <span class="keyword">end</span>
|
||||
0203 <span class="keyword">while</span> t < smpl
|
||||
0204 t = t+1;
|
||||
0205 Pstar = oldP;
|
||||
0206 <span class="keyword">for</span> i=1:pp
|
||||
0207 v(i) = Y(i,t) - a(mf(i)) - trend(i,t);
|
||||
0208 Fi = Pstar(mf(i),mf(i));
|
||||
0209 <span class="keyword">if</span> 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 <span class="keyword">else</span>
|
||||
0215 <span class="comment">%disp(['zero F term for observed ',int2str(i),' ',num2str(Fi)])</span>
|
||||
0216 <span class="keyword">end</span>
|
||||
0217 <span class="keyword">end</span>
|
||||
0218 a = T*a;
|
||||
0219 <span class="keyword">end</span>
|
||||
0220
|
||||
0221 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
|
||||
0222</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,282 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseLikelihoodH1</title>
|
||||
<meta name="keywords" content="DiffuseLikelihoodH1">
|
||||
<meta name="description" content="M. Ratto added lik in output">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseLikelihoodH1.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseLikelihoodH1
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>M. Ratto added lik in output</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> M. Ratto added lik in output
|
||||
stephane.adjemian@cepremap.cnrs.fr [07-19-2004]
|
||||
|
||||
See "Filtering and Smoothing of State Vector for Diffuse State Space
|
||||
Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
|
||||
Analysis, vol. 24(1), pp. 85-98).
|
||||
|
||||
THE PROBLEM:
|
||||
|
||||
y_t = Z_t * \alpha_t + \varepsilon_t
|
||||
\alpha_{t+1} = T_t * \alpha_t + R_t * \eta_t
|
||||
|
||||
with:
|
||||
|
||||
\alpha_1 = a + A*\delta + R_0*\eta_0
|
||||
|
||||
m*q matrix A and m*(m-q) matrix R_0 are selection matrices (their
|
||||
columns constitue all the columns of the m*m identity matrix) so that
|
||||
|
||||
A'*R_0 = 0 and A'*\alpha_1 = \delta
|
||||
|
||||
We assume that the vector \delta is distributed as a N(0,\kappa*I_q)
|
||||
for a given \kappa > 0. So that the expectation of \alpha_1 is a and
|
||||
its variance is P, with
|
||||
|
||||
P = \kappa*P_{\infty} + P_{\star}
|
||||
|
||||
P_{\infty} = A*A'
|
||||
P_{\star} = R_0*Q_0*R_0'
|
||||
|
||||
P_{\infty} is a m*m diagonal matrix with q ones and m-q zeros.
|
||||
|
||||
|
||||
and where:
|
||||
|
||||
y_t is a pp*1 vector
|
||||
\alpha_t is a mm*1 vector
|
||||
\varepsilon_t is a pp*1 multivariate random variable (iid N(0,H_t))
|
||||
\eta_t is a rr*1 multivariate random variable (iid N(0,Q_t))
|
||||
a_1 is a mm*1 vector
|
||||
|
||||
Z_t is a pp*mm matrix
|
||||
T_t is a mm*mm matrix
|
||||
H_t is a pp*pp matrix
|
||||
R_t is a mm*rr matrix
|
||||
Q_t is a rr*rr matrix
|
||||
P_1 is a mm*mm matrix
|
||||
|
||||
|
||||
FILTERING EQUATIONS:
|
||||
|
||||
v_t = y_t - Z_t* a_t
|
||||
F_t = Z_t * P_t * Z_t' + H_t
|
||||
K_t = T_t * P_t * Z_t' * F_t^{-1}
|
||||
L_t = T_t - K_t * Z_t
|
||||
a_{t+1} = T_t * a_t + K_t * v_t
|
||||
P_{t+1} = T_t * P_t * L_t' + R_t*Q_t*R_t'
|
||||
|
||||
|
||||
DIFFUSE FILTERING EQUATIONS:
|
||||
|
||||
a_{t+1} = T_t*a_t + K_{\infty,t}v_t
|
||||
P_{\infty,t+1} = T_t*P_{\infty,t}*L_{\infty,t}'
|
||||
P_{\ast,t+1} = T_t*P_{\ast,t}*L_{\infty,t}' - K_{\infty,t}*F_{\infty,t}*K_{\ast,t}' + R_t*Q_t*R_t'
|
||||
K_{\infty,t} = T_t*P_{\infty,t}*Z_t'*F_{\infty,t}^{-1}
|
||||
v_t = y_t - Z_t*a_t
|
||||
L_{\infty,t} = T_t - K_{\infty,t}*Z_t
|
||||
F_{\infty,t} = Z_t*P_{\infty,t}*Z_t'
|
||||
K_{\ast,t} = (T_t*P_{\ast,t}*Z_t' + K_{\infty,t}*F_{\ast,t})*F_{\infty,t}^{-1}
|
||||
F_{\ast,t} = Z_t*P_{\ast,t}*Z_t' + H_t
|
||||
|
||||
Matrix Finf is assumed to be non singular. If this is not the case we have
|
||||
to switch to another algorithm (NewAlg=3).
|
||||
|
||||
start = options_.presample</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)</a>
|
||||
0002 <span class="comment">% M. Ratto added lik in output</span>
|
||||
0003 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [07-19-2004]</span>
|
||||
0004 <span class="comment">%</span>
|
||||
0005 <span class="comment">% See "Filtering and Smoothing of State Vector for Diffuse State Space</span>
|
||||
0006 <span class="comment">% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series</span>
|
||||
0007 <span class="comment">% Analysis, vol. 24(1), pp. 85-98).</span>
|
||||
0008 <span class="comment">%</span>
|
||||
0009 <span class="comment">% THE PROBLEM:</span>
|
||||
0010 <span class="comment">%</span>
|
||||
0011 <span class="comment">% y_t = Z_t * \alpha_t + \varepsilon_t</span>
|
||||
0012 <span class="comment">% \alpha_{t+1} = T_t * \alpha_t + R_t * \eta_t</span>
|
||||
0013 <span class="comment">%</span>
|
||||
0014 <span class="comment">% with:</span>
|
||||
0015 <span class="comment">%</span>
|
||||
0016 <span class="comment">% \alpha_1 = a + A*\delta + R_0*\eta_0</span>
|
||||
0017 <span class="comment">%</span>
|
||||
0018 <span class="comment">% m*q matrix A and m*(m-q) matrix R_0 are selection matrices (their</span>
|
||||
0019 <span class="comment">% columns constitue all the columns of the m*m identity matrix) so that</span>
|
||||
0020 <span class="comment">%</span>
|
||||
0021 <span class="comment">% A'*R_0 = 0 and A'*\alpha_1 = \delta</span>
|
||||
0022 <span class="comment">%</span>
|
||||
0023 <span class="comment">% We assume that the vector \delta is distributed as a N(0,\kappa*I_q)</span>
|
||||
0024 <span class="comment">% for a given \kappa > 0. So that the expectation of \alpha_1 is a and</span>
|
||||
0025 <span class="comment">% its variance is P, with</span>
|
||||
0026 <span class="comment">%</span>
|
||||
0027 <span class="comment">% P = \kappa*P_{\infty} + P_{\star}</span>
|
||||
0028 <span class="comment">%</span>
|
||||
0029 <span class="comment">% P_{\infty} = A*A'</span>
|
||||
0030 <span class="comment">% P_{\star} = R_0*Q_0*R_0'</span>
|
||||
0031 <span class="comment">%</span>
|
||||
0032 <span class="comment">% P_{\infty} is a m*m diagonal matrix with q ones and m-q zeros.</span>
|
||||
0033 <span class="comment">%</span>
|
||||
0034 <span class="comment">%</span>
|
||||
0035 <span class="comment">% and where:</span>
|
||||
0036 <span class="comment">%</span>
|
||||
0037 <span class="comment">% y_t is a pp*1 vector</span>
|
||||
0038 <span class="comment">% \alpha_t is a mm*1 vector</span>
|
||||
0039 <span class="comment">% \varepsilon_t is a pp*1 multivariate random variable (iid N(0,H_t))</span>
|
||||
0040 <span class="comment">% \eta_t is a rr*1 multivariate random variable (iid N(0,Q_t))</span>
|
||||
0041 <span class="comment">% a_1 is a mm*1 vector</span>
|
||||
0042 <span class="comment">%</span>
|
||||
0043 <span class="comment">% Z_t is a pp*mm matrix</span>
|
||||
0044 <span class="comment">% T_t is a mm*mm matrix</span>
|
||||
0045 <span class="comment">% H_t is a pp*pp matrix</span>
|
||||
0046 <span class="comment">% R_t is a mm*rr matrix</span>
|
||||
0047 <span class="comment">% Q_t is a rr*rr matrix</span>
|
||||
0048 <span class="comment">% P_1 is a mm*mm matrix</span>
|
||||
0049 <span class="comment">%</span>
|
||||
0050 <span class="comment">%</span>
|
||||
0051 <span class="comment">% FILTERING EQUATIONS:</span>
|
||||
0052 <span class="comment">%</span>
|
||||
0053 <span class="comment">% v_t = y_t - Z_t* a_t</span>
|
||||
0054 <span class="comment">% F_t = Z_t * P_t * Z_t' + H_t</span>
|
||||
0055 <span class="comment">% K_t = T_t * P_t * Z_t' * F_t^{-1}</span>
|
||||
0056 <span class="comment">% L_t = T_t - K_t * Z_t</span>
|
||||
0057 <span class="comment">% a_{t+1} = T_t * a_t + K_t * v_t</span>
|
||||
0058 <span class="comment">% P_{t+1} = T_t * P_t * L_t' + R_t*Q_t*R_t'</span>
|
||||
0059 <span class="comment">%</span>
|
||||
0060 <span class="comment">%</span>
|
||||
0061 <span class="comment">% DIFFUSE FILTERING EQUATIONS:</span>
|
||||
0062 <span class="comment">%</span>
|
||||
0063 <span class="comment">% a_{t+1} = T_t*a_t + K_{\infty,t}v_t</span>
|
||||
0064 <span class="comment">% P_{\infty,t+1} = T_t*P_{\infty,t}*L_{\infty,t}'</span>
|
||||
0065 <span class="comment">% P_{\ast,t+1} = T_t*P_{\ast,t}*L_{\infty,t}' - K_{\infty,t}*F_{\infty,t}*K_{\ast,t}' + R_t*Q_t*R_t'</span>
|
||||
0066 <span class="comment">% K_{\infty,t} = T_t*P_{\infty,t}*Z_t'*F_{\infty,t}^{-1}</span>
|
||||
0067 <span class="comment">% v_t = y_t - Z_t*a_t</span>
|
||||
0068 <span class="comment">% L_{\infty,t} = T_t - K_{\infty,t}*Z_t</span>
|
||||
0069 <span class="comment">% F_{\infty,t} = Z_t*P_{\infty,t}*Z_t'</span>
|
||||
0070 <span class="comment">% K_{\ast,t} = (T_t*P_{\ast,t}*Z_t' + K_{\infty,t}*F_{\ast,t})*F_{\infty,t}^{-1}</span>
|
||||
0071 <span class="comment">% F_{\ast,t} = Z_t*P_{\ast,t}*Z_t' + H_t</span>
|
||||
0072 <span class="comment">%</span>
|
||||
0073 <span class="comment">% Matrix Finf is assumed to be non singular. If this is not the case we have</span>
|
||||
0074 <span class="comment">% to switch to another algorithm (NewAlg=3).</span>
|
||||
0075 <span class="comment">%</span>
|
||||
0076 <span class="comment">% start = options_.presample</span>
|
||||
0077 <span class="keyword">global</span> 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 <span class="keyword">while</span> rank(Pinf,crit) & t < smpl
|
||||
0094 t = t+1;
|
||||
0095 v = Y(:,t)-a(mf)-trend(:,t);
|
||||
0096 Finf = Pinf(mf,mf);
|
||||
0097 <span class="keyword">if</span> rcond(Finf) < crit
|
||||
0098 <span class="keyword">if</span> ~all(abs(Finf(:))<crit)
|
||||
0099 <span class="keyword">return</span>
|
||||
0100 <span class="keyword">else</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0109 <span class="keyword">else</span>
|
||||
0110 lik(t) = log(det(Finf));
|
||||
0111 iFinf = inv(Finf);
|
||||
0112 Kinf = Pinf(:,mf)*iFinf; <span class="comment">%% premultiplication by the transition matrix T is removed (stephane)</span>
|
||||
0113 Fstar = Pstar(mf,mf)+H;
|
||||
0114 Kstar = (Pstar(:,mf)-Kinf*Fstar)*iFinf; <span class="comment">%% premultiplication by the transition matrix T is removed (stephane)</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0119 <span class="keyword">end</span>
|
||||
0120 <span class="keyword">if</span> t == smpl
|
||||
0121 error([<span class="string">'There isn''t enough information to estimate the initial'</span> <span class="keyword">...</span><span class="comment"> </span>
|
||||
0122 <span class="string">' conditions of the nonstationary variables'</span>]);
|
||||
0123 <span class="keyword">end</span>
|
||||
0124 F_singular = 1;
|
||||
0125 <span class="keyword">while</span> 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 <span class="keyword">if</span> rcond(F) < crit
|
||||
0132 <span class="keyword">if</span> ~all(abs(F(:))<crit)
|
||||
0133 <span class="keyword">return</span>
|
||||
0134 <span class="keyword">else</span>
|
||||
0135 a = T*a;
|
||||
0136 Pstar = T*Pstar*transpose(T)+QQ;
|
||||
0137 <span class="keyword">end</span>
|
||||
0138 <span class="keyword">else</span>
|
||||
0139 F_singular = 0;
|
||||
0140 iF = inv(F);
|
||||
0141 lik(t) = log(dF)+transpose(v)*iF*v;
|
||||
0142 K = Pstar(:,mf)*iF; <span class="comment">%% premultiplication by the transition matrix T is removed (stephane)</span>
|
||||
0143 a = T*(a+K*v); <span class="comment">%% --> factorization of the transition matrix...</span>
|
||||
0144 Pstar = T*(Pstar-K*Pstar(mf,:))*transpose(T)+QQ; <span class="comment">%% ... idem (stephane)</span>
|
||||
0145 <span class="keyword">end</span>
|
||||
0146 notsteady = ~(max(max(abs(Pstar-oldPstar)))<crit);
|
||||
0147 <span class="keyword">end</span>
|
||||
0148 <span class="keyword">if</span> F_singular == 1
|
||||
0149 error([<span class="string">'The variance of the forecast error remains singular until the'</span> <span class="keyword">...</span>
|
||||
0150 <span class="string">'end of the sample'</span>])
|
||||
0151 <span class="keyword">end</span>
|
||||
0152 reste = smpl-t;
|
||||
0153 <span class="keyword">while</span> 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 <span class="keyword">end</span>
|
||||
0159 lik(t) = lik(t) + reste*log(dF);
|
||||
0160 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);<span class="comment">% Minus the</span>
|
||||
0161 <span class="comment">% log-likelihood.</span>
|
||||
0162</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,329 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseLikelihoodH3</title>
|
||||
<meta name="keywords" content="DiffuseLikelihoodH3">
|
||||
<meta name="description" content="M. Ratto added lik in output [October 2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseLikelihoodH3.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseLikelihoodH3
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>M. Ratto added lik in output [October 2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> M. Ratto added lik in output [October 2005]
|
||||
changes by M. Ratto
|
||||
introduced new global variable id_ for termination of DKF
|
||||
introduced a persistent fmax, in order to keep track the max order of
|
||||
magnitude of the 'zero' values in Pinf at DKF termination
|
||||
new icc counter for Finf steps in DKF
|
||||
new termination for DKF
|
||||
likelihood terms for Fstar must be cumulated in DKF also when Pinf is non
|
||||
zero. this bug is fixed.
|
||||
|
||||
stephane.adjemian@cepremap.cnrs.fr [07-19-2004]
|
||||
|
||||
See "Filtering and Smoothing of State Vector for Diffuse State Space
|
||||
Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series
|
||||
Analysis, vol. 24(1), pp. 85-98).
|
||||
|
||||
Case where F_{\infty,t} is singular ==> Univariate treatment of multivariate
|
||||
time series.
|
||||
|
||||
THE PROBLEM:
|
||||
|
||||
y_t = Z_t * \alpha_t + \varepsilon_t
|
||||
\alpha_{t+1} = T_t * \alpha_t + R_t * \eta_t
|
||||
|
||||
with:
|
||||
|
||||
\alpha_1 = a + A*\delta + R_0*\eta_0
|
||||
|
||||
m*q matrix A and m*(m-q) matrix R_0 are selection matrices (their
|
||||
columns constitue all the columns of the m*m identity matrix) so that
|
||||
|
||||
A'*R_0 = 0 and A'*\alpha_1 = \delta
|
||||
|
||||
We assume that the vector \delta is distributed as a N(0,\kappa*I_q)
|
||||
for a given \kappa > 0. So that the expectation of \alpha_1 is a and
|
||||
its variance is P, with
|
||||
|
||||
P = \kappa*P_{\infty} + P_{\star}
|
||||
|
||||
P_{\infty} = A*A'
|
||||
P_{\star} = R_0*Q_0*R_0'
|
||||
|
||||
P_{\infty} is a m*m diagonal matrix with q ones and m-q zeros.
|
||||
|
||||
|
||||
and where:
|
||||
|
||||
y_t is a pp*1 vector
|
||||
\alpha_t is a mm*1 vector
|
||||
\varepsilon_t is a pp*1 multivariate random variable (iid N(0,H_t))
|
||||
\eta_t is a rr*1 multivariate random variable (iid N(0,Q_t))
|
||||
a_1 is a mm*1 vector
|
||||
|
||||
Z_t is a pp*mm matrix
|
||||
T_t is a mm*mm matrix
|
||||
H_t is a pp*pp matrix
|
||||
R_t is a mm*rr matrix
|
||||
Q_t is a rr*rr matrix
|
||||
P_1 is a mm*mm matrix
|
||||
|
||||
|
||||
FILTERING EQUATIONS:
|
||||
|
||||
v_t = y_t - Z_t* a_t
|
||||
F_t = Z_t * P_t * Z_t' + H_t
|
||||
K_t = T_t * P_t * Z_t' * F_t^{-1}
|
||||
L_t = T_t - K_t * Z_t
|
||||
a_{t+1} = T_t * a_t + K_t * v_t
|
||||
P_{t+1} = T_t * P_t * L_t' + R_t*Q_t*R_t'
|
||||
|
||||
|
||||
DIFFUSE FILTERING EQUATIONS:
|
||||
|
||||
a_{t+1} = T_t*a_t + K_{\ast,t}v_t
|
||||
P_{\infty,t+1} = T_t*P_{\infty,t}*T_t'
|
||||
P_{\ast,t+1} = T_t*P_{\ast,t}*L_{\ast,t}' + R_t*Q_t*R_t'
|
||||
K_{\ast,t} = T_t*P_{\ast,t}*Z_t'*F_{\ast,t}^{-1}
|
||||
v_t = y_t - Z_t*a_t
|
||||
L_{\ast,t} = T_t - K_{\ast,t}*Z_t
|
||||
F_{\ast,t} = Z_t*P_{\ast,t}*Z_t' + H_t</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start)</a>
|
||||
0002 <span class="comment">% M. Ratto added lik in output [October 2005]</span>
|
||||
0003 <span class="comment">% changes by M. Ratto</span>
|
||||
0004 <span class="comment">% introduced new global variable id_ for termination of DKF</span>
|
||||
0005 <span class="comment">% introduced a persistent fmax, in order to keep track the max order of</span>
|
||||
0006 <span class="comment">% magnitude of the 'zero' values in Pinf at DKF termination</span>
|
||||
0007 <span class="comment">% new icc counter for Finf steps in DKF</span>
|
||||
0008 <span class="comment">% new termination for DKF</span>
|
||||
0009 <span class="comment">% likelihood terms for Fstar must be cumulated in DKF also when Pinf is non</span>
|
||||
0010 <span class="comment">% zero. this bug is fixed.</span>
|
||||
0011 <span class="comment">%</span>
|
||||
0012 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [07-19-2004]</span>
|
||||
0013 <span class="comment">%</span>
|
||||
0014 <span class="comment">% See "Filtering and Smoothing of State Vector for Diffuse State Space</span>
|
||||
0015 <span class="comment">% Models", S.J. Koopman and J. Durbin (2003, in Journal of Time Series</span>
|
||||
0016 <span class="comment">% Analysis, vol. 24(1), pp. 85-98).</span>
|
||||
0017 <span class="comment">%</span>
|
||||
0018 <span class="comment">% Case where F_{\infty,t} is singular ==> Univariate treatment of multivariate</span>
|
||||
0019 <span class="comment">% time series.</span>
|
||||
0020 <span class="comment">%</span>
|
||||
0021 <span class="comment">% THE PROBLEM:</span>
|
||||
0022 <span class="comment">%</span>
|
||||
0023 <span class="comment">% y_t = Z_t * \alpha_t + \varepsilon_t</span>
|
||||
0024 <span class="comment">% \alpha_{t+1} = T_t * \alpha_t + R_t * \eta_t</span>
|
||||
0025 <span class="comment">%</span>
|
||||
0026 <span class="comment">% with:</span>
|
||||
0027 <span class="comment">%</span>
|
||||
0028 <span class="comment">% \alpha_1 = a + A*\delta + R_0*\eta_0</span>
|
||||
0029 <span class="comment">%</span>
|
||||
0030 <span class="comment">% m*q matrix A and m*(m-q) matrix R_0 are selection matrices (their</span>
|
||||
0031 <span class="comment">% columns constitue all the columns of the m*m identity matrix) so that</span>
|
||||
0032 <span class="comment">%</span>
|
||||
0033 <span class="comment">% A'*R_0 = 0 and A'*\alpha_1 = \delta</span>
|
||||
0034 <span class="comment">%</span>
|
||||
0035 <span class="comment">% We assume that the vector \delta is distributed as a N(0,\kappa*I_q)</span>
|
||||
0036 <span class="comment">% for a given \kappa > 0. So that the expectation of \alpha_1 is a and</span>
|
||||
0037 <span class="comment">% its variance is P, with</span>
|
||||
0038 <span class="comment">%</span>
|
||||
0039 <span class="comment">% P = \kappa*P_{\infty} + P_{\star}</span>
|
||||
0040 <span class="comment">%</span>
|
||||
0041 <span class="comment">% P_{\infty} = A*A'</span>
|
||||
0042 <span class="comment">% P_{\star} = R_0*Q_0*R_0'</span>
|
||||
0043 <span class="comment">%</span>
|
||||
0044 <span class="comment">% P_{\infty} is a m*m diagonal matrix with q ones and m-q zeros.</span>
|
||||
0045 <span class="comment">%</span>
|
||||
0046 <span class="comment">%</span>
|
||||
0047 <span class="comment">% and where:</span>
|
||||
0048 <span class="comment">%</span>
|
||||
0049 <span class="comment">% y_t is a pp*1 vector</span>
|
||||
0050 <span class="comment">% \alpha_t is a mm*1 vector</span>
|
||||
0051 <span class="comment">% \varepsilon_t is a pp*1 multivariate random variable (iid N(0,H_t))</span>
|
||||
0052 <span class="comment">% \eta_t is a rr*1 multivariate random variable (iid N(0,Q_t))</span>
|
||||
0053 <span class="comment">% a_1 is a mm*1 vector</span>
|
||||
0054 <span class="comment">%</span>
|
||||
0055 <span class="comment">% Z_t is a pp*mm matrix</span>
|
||||
0056 <span class="comment">% T_t is a mm*mm matrix</span>
|
||||
0057 <span class="comment">% H_t is a pp*pp matrix</span>
|
||||
0058 <span class="comment">% R_t is a mm*rr matrix</span>
|
||||
0059 <span class="comment">% Q_t is a rr*rr matrix</span>
|
||||
0060 <span class="comment">% P_1 is a mm*mm matrix</span>
|
||||
0061 <span class="comment">%</span>
|
||||
0062 <span class="comment">%</span>
|
||||
0063 <span class="comment">% FILTERING EQUATIONS:</span>
|
||||
0064 <span class="comment">%</span>
|
||||
0065 <span class="comment">% v_t = y_t - Z_t* a_t</span>
|
||||
0066 <span class="comment">% F_t = Z_t * P_t * Z_t' + H_t</span>
|
||||
0067 <span class="comment">% K_t = T_t * P_t * Z_t' * F_t^{-1}</span>
|
||||
0068 <span class="comment">% L_t = T_t - K_t * Z_t</span>
|
||||
0069 <span class="comment">% a_{t+1} = T_t * a_t + K_t * v_t</span>
|
||||
0070 <span class="comment">% P_{t+1} = T_t * P_t * L_t' + R_t*Q_t*R_t'</span>
|
||||
0071 <span class="comment">%</span>
|
||||
0072 <span class="comment">%</span>
|
||||
0073 <span class="comment">% DIFFUSE FILTERING EQUATIONS:</span>
|
||||
0074 <span class="comment">%</span>
|
||||
0075 <span class="comment">% a_{t+1} = T_t*a_t + K_{\ast,t}v_t</span>
|
||||
0076 <span class="comment">% P_{\infty,t+1} = T_t*P_{\infty,t}*T_t'</span>
|
||||
0077 <span class="comment">% P_{\ast,t+1} = T_t*P_{\ast,t}*L_{\ast,t}' + R_t*Q_t*R_t'</span>
|
||||
0078 <span class="comment">% K_{\ast,t} = T_t*P_{\ast,t}*Z_t'*F_{\ast,t}^{-1}</span>
|
||||
0079 <span class="comment">% v_t = y_t - Z_t*a_t</span>
|
||||
0080 <span class="comment">% L_{\ast,t} = T_t - K_{\ast,t}*Z_t</span>
|
||||
0081 <span class="comment">% F_{\ast,t} = Z_t*P_{\ast,t}*Z_t' + H_t</span>
|
||||
0082 <span class="keyword">global</span> 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); <span class="comment">%% the constant of minus two times the log-likelihood</span>
|
||||
0093 notsteady = 1;
|
||||
0094 crit = options_.kalman_tol;
|
||||
0095 crit1 = 1.e-6;
|
||||
0096 newRank = rank(Pinf,crit1);
|
||||
0097 icc = 0;
|
||||
0098 <span class="keyword">while</span> newRank & t < smpl <span class="comment">%% Matrix Finf is assumed to be zero</span>
|
||||
0099 t = t+1;
|
||||
0100 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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) - <span class="keyword">...</span>
|
||||
0110 (Kstar*transpose(Kinf)+Kinf*transpose(Kstar))/Finf;
|
||||
0111 Pinf = Pinf - Kinf*transpose(Kinf)/Finf;
|
||||
0112 lik(t) = lik(t) + log(Finf);
|
||||
0113 <span class="comment">% start new termination criterion for DKF</span>
|
||||
0114 <span class="keyword">if</span> ~isempty(options_.diffuse_d),
|
||||
0115 newRank = (icc<options_.diffuse_d);
|
||||
0116 <span class="comment">%if newRank & any(diag(Pinf(mf,mf))>crit)==0; % M. Ratto this line is BUGGY</span>
|
||||
0117 <span class="keyword">if</span> newRank & (any(diag(Pinf(mf,mf))>crit)==0 & rank(Pinf,crit1)==0);
|
||||
0118 options_.diffuse_d = icc;
|
||||
0119 newRank=0;
|
||||
0120 disp(<span class="string">'WARNING: Change in OPTIONS_.DIFFUSE_D in univariate DKF'</span>)
|
||||
0121 disp([<span class="string">'new OPTIONS_.DIFFUSE_D = '</span>,int2str(icc)])
|
||||
0122 disp(<span class="string">'You may have to reset the optimisation'</span>)
|
||||
0123 <span class="keyword">end</span>
|
||||
0124 <span class="keyword">else</span>
|
||||
0125 <span class="comment">%newRank = any(diag(Pinf(mf,mf))>crit); % M. Ratto this line is BUGGY</span>
|
||||
0126 newRank = (any(diag(Pinf(mf,mf))>crit) | rank(Pinf,crit1));
|
||||
0127 <span class="keyword">if</span> newRank==0,
|
||||
0128 P0= T*Pinf*transpose(T);
|
||||
0129 <span class="comment">%newRank = any(diag(P0(mf,mf))>crit); % M. Ratto this line is BUGGY</span>
|
||||
0130 newRank = (any(diag(P0(mf,mf))>crit) | rank(P0,crit1)); <span class="comment">% M. Ratto 10 Oct 2005</span>
|
||||
0131 <span class="keyword">if</span> newRank==0,
|
||||
0132 options_.diffuse_d = icc;
|
||||
0133 <span class="keyword">end</span>
|
||||
0134 <span class="keyword">end</span>
|
||||
0135 <span class="keyword">end</span>,
|
||||
0136 <span class="comment">% end new termination and checks for DKF and fmax</span>
|
||||
0137 <span class="keyword">elseif</span> Finf > crit
|
||||
0138 <span class="comment">%% Note that : (1) rank(Pinf)=0 implies that Finf = 0, (2) outside this loop (when for some i and t the condition</span>
|
||||
0139 <span class="comment">%% rank(Pinf)=0 is satisfied we have P = Pstar and F = Fstar and (3) Finf = 0 does not imply that</span>
|
||||
0140 <span class="comment">%% rank(Pinf)=0. [stphane,11-03-2004].</span>
|
||||
0141 <span class="comment">%if rank(Pinf) == 0</span>
|
||||
0142 <span class="comment">% the likelihood terms should alwasy be cumulated, not only</span>
|
||||
0143 <span class="comment">% when Pinf=0, otherwise the lik would depend on the ordering</span>
|
||||
0144 <span class="comment">% of observed variables</span>
|
||||
0145 lik(t) = lik(t) + log(Fstar) + v(i)*v(i)/Fstar;
|
||||
0146 <span class="comment">%end</span>
|
||||
0147 a = a + Kstar*v(i)/Fstar;
|
||||
0148 Pstar = Pstar - Kstar*transpose(Kstar)/Fstar;
|
||||
0149 <span class="keyword">else</span>
|
||||
0150 <span class="comment">% disp(['zero F term in DKF for observed ',int2str(i),' ',num2str(Fi)])</span>
|
||||
0151 <span class="keyword">end</span>
|
||||
0152 <span class="keyword">end</span>
|
||||
0153 <span class="keyword">if</span> newRank
|
||||
0154 oldRank = rank(Pinf,crit1);
|
||||
0155 <span class="keyword">else</span>
|
||||
0156 oldRank = 0;
|
||||
0157 <span class="keyword">end</span>
|
||||
0158 a = T*a;
|
||||
0159 Pstar = T*Pstar*transpose(T)+QQ;
|
||||
0160 Pinf = T*Pinf*transpose(T);
|
||||
0161 <span class="keyword">if</span> newRank
|
||||
0162 newRank = rank(Pinf,crit1);
|
||||
0163 <span class="keyword">end</span>
|
||||
0164 <span class="keyword">if</span> oldRank ~= newRank
|
||||
0165 disp(<span class="string">'DiffuseLiklihoodH3 :: T does influence the rank of Pinf!'</span>)
|
||||
0166 <span class="keyword">end</span>
|
||||
0167 <span class="keyword">end</span>
|
||||
0168 <span class="keyword">if</span> t == smpl
|
||||
0169 error([<span class="string">'There isn''t enough information to estimate the initial'</span> <span class="keyword">...</span><span class="comment"> </span>
|
||||
0170 <span class="string">' conditions of the nonstationary variables'</span>]);
|
||||
0171 <span class="keyword">end</span>
|
||||
0172 <span class="keyword">while</span> notsteady & t < smpl
|
||||
0173 t = t+1;
|
||||
0174 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0183 <span class="keyword">end</span>
|
||||
0184 oldP = Pstar;
|
||||
0185 a = T*a;
|
||||
0186 Pstar = T*Pstar*transpose(T) + QQ;
|
||||
0187 notsteady = ~(max(max(abs(Pstar-oldP)))<crit);
|
||||
0188 <span class="keyword">end</span>
|
||||
0189 <span class="keyword">while</span> t < smpl
|
||||
0190 t = t+1;
|
||||
0191 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0200 <span class="keyword">end</span>
|
||||
0201 a = T*a;
|
||||
0202 <span class="keyword">end</span>
|
||||
0203 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);
|
||||
0204</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,147 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DiffuseLikelihoodH3corr</title>
|
||||
<meta name="keywords" content="DiffuseLikelihoodH3corr">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [12-13-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DiffuseLikelihoodH3corr.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DiffuseLikelihoodH3corr
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [12-13-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [12-13-2004]
|
||||
|
||||
Same as DiffuseLikelihoodH3 but allows correlation between the measurement
|
||||
errors (this is not a problem with the multivariate approach).</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [12-13-2004]</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% Same as DiffuseLikelihoodH3 but allows correlation between the measurement</span>
|
||||
0005 <span class="comment">% errors (this is not a problem with the multivariate approach).</span>
|
||||
0006
|
||||
0007 <span class="keyword">global</span> 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 <span class="keyword">if</span> size(Pinf,1) <span class="comment">% Otherwise Pinf = 0 (no unit root)</span>
|
||||
0018 Pinf = cat(1,cat(2,Pinf,zeros(mm,pp)),zeros(pp,mm+pp));
|
||||
0019 <span class="keyword">end</span>
|
||||
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); <span class="comment">%% the constant of minus two times the log-likelihood</span>
|
||||
0026 notsteady = 1;
|
||||
0027 crit = options_.kalman_tol;
|
||||
0028 newRank = rank(Pinf,crit);
|
||||
0029
|
||||
0030 <span class="keyword">while</span> rank(Pinf,crit) & t < smpl <span class="comment">%% Matrix Finf is assumed to be zero</span>
|
||||
0031 t = t+1;
|
||||
0032 <span class="keyword">for</span> 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 <span class="keyword">if</span> Finf > crit
|
||||
0038 Kinf = Pinf(:,mf(i));
|
||||
0039 a = a + Kinf*v(i)/Finf;
|
||||
0040 Pstar = Pstar + Kinf*transpose(Kinf)*Fstar/(Finf*Finf) - <span class="keyword">...</span>
|
||||
0041 (Kstar*transpose(Kinf)+Kinf*transpose(Kstar))/Finf;
|
||||
0042 Pinf = Pinf - Kinf*transpose(Kinf)/Finf;
|
||||
0043 lik(t) = lik(t) + log(Finf);
|
||||
0044 <span class="keyword">else</span> <span class="comment">%% Note that : (1) rank(Pinf)=0 implies that Finf = 0, (2) outside this loop (when for some i and t the condition</span>
|
||||
0045 <span class="comment">%% rank(Pinf)=0 is satisfied we have P = Pstar and F = Fstar and (3) Finf = 0 does not imply that</span>
|
||||
0046 <span class="comment">%% rank(Pinf)=0. [stphane,11-03-2004].</span>
|
||||
0047 <span class="keyword">if</span> rank(Pinf) == 0
|
||||
0048 lik(t) = lik(t) + log(Fstar) + v(i)*v(i)/Fstar;
|
||||
0049 <span class="keyword">end</span>
|
||||
0050 a = a + Kstar*v(i)/Fstar;
|
||||
0051 Pstar = Pstar - Kstar*transpose(Kstar)/Fstar;
|
||||
0052 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> oldRank ~= newRank
|
||||
0059 disp(<span class="string">'DiffuseLiklihoodH3 :: T does influence the rank of Pinf!'</span>)
|
||||
0060 <span class="keyword">end</span>
|
||||
0061 <span class="keyword">end</span>
|
||||
0062 <span class="keyword">end</span>
|
||||
0063 <span class="keyword">if</span> t == smpl
|
||||
0064 error([<span class="string">'There isn''t enough information to estimate the initial'</span> <span class="keyword">...</span><span class="comment"> </span>
|
||||
0065 <span class="string">' conditions of the nonstationary variables'</span>]);
|
||||
0066 <span class="keyword">end</span>
|
||||
0067 <span class="keyword">while</span> notsteady & t < smpl
|
||||
0068 t = t+1;
|
||||
0069 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 oldP = Pstar;
|
||||
0080 a = T*a;
|
||||
0081 Pstar = T*Pstar*transpose(T) + QQ;
|
||||
0082 notsteady = ~(max(max(abs(Pstar-oldP)))<crit);
|
||||
0083 <span class="keyword">end</span>
|
||||
0084 <span class="keyword">while</span> t < smpl
|
||||
0085 t = t+1;
|
||||
0086 <span class="keyword">for</span> 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 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0095 <span class="keyword">end</span>
|
||||
0096 a = T*a;
|
||||
0097 <span class="keyword">end</span>
|
||||
0098 LIK = .5*(sum(lik(start:end))-(start-1)*lik(smpl+1)/smpl);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,232 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DsgeLikelihood</title>
|
||||
<meta name="keywords" content="DsgeLikelihood">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [09-07-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DsgeLikelihood.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DsgeLikelihood
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
|
||||
|
||||
Adapted from mj_optmumlik.m</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DiffuseLikelihood3.html" class="code" title="function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)%//Z,T,R,Q,Pinf,Pstar,Y)">DiffuseLikelihood3</a> M. Ratto added lik in output [October 2005]</li><li><a href="DiffuseLikelihoodH1.html" class="code" title="function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH1</a> M. Ratto added lik in output</li><li><a href="DiffuseLikelihoodH3.html" class="code" title="function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH3</a> M. Ratto added lik in output [October 2005]</li><li><a href="DiffuseLikelihoodH3corr.html" class="code" title="function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH3corr</a> stephane.adjemian@cepremap.cnrs.fr [12-13-2004]</li><li><a href="dynare_resolve.html" class="code" title="function [A,B,ys,info] = dynare_resolve()">dynare_resolve</a> </li><li><a href="kalman_filter.html" class="code" title="function [loglik, per, d] = kalman_filter(varargin)">kalman_filter</a> SYNOPSIS</li><li><a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a> solves x-a*x*a'=b for b (and then x) symmetrical</li><li><a href="priordens.html" class="code" title="function lnprior = priordens(para, pshape, p1, p2, p3, p4)">priordens</a> This procedure computes a prior density for</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_MC.html" class="code" title="function dynare_MC(var_list_)">dynare_MC</a> </li><li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li><li><a href="initial_estimation_checks.html" class="code" title="function initial_estimation_checks(xparam1,gend,data)">initial_estimation_checks</a> </li><li><a href="metropolis.html" class="code" title="function metropolis(xparam1,vv,gend,data,rawdata,mh_bounds)">metropolis</a> stephane.adjemian@ens.fr [09-02-2005]</li><li><a href="mode_check.html" class="code" title="function mode_check(x,fval,hessian,gend,data,lb,ub)">mode_check</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% Adapted from mj_optmumlik.m</span>
|
||||
0005 <span class="keyword">global</span> 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 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0014 <span class="comment">% 1. Get the structural parameters & define penalties</span>
|
||||
0015 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0016 <span class="keyword">if</span> 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 <span class="keyword">return</span>;
|
||||
0021 <span class="keyword">end</span>
|
||||
0022 <span class="keyword">if</span> 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 <span class="keyword">return</span>;
|
||||
0027 <span class="keyword">end</span>
|
||||
0028 Q = M_.Sigma_e;
|
||||
0029 <span class="keyword">for</span> i=1:estim_params_.nvx
|
||||
0030 k =estim_params_.var_exo(i,1);
|
||||
0031 Q(k,k) = xparam1(i)*xparam1(i);
|
||||
0032 <span class="keyword">end</span>
|
||||
0033 offset = estim_params_.nvx;
|
||||
0034 <span class="keyword">if</span> estim_params_.nvn
|
||||
0035 H = zeros(nobs,nobs);
|
||||
0036 <span class="keyword">for</span> i=1:estim_params_.nvn
|
||||
0037 k = estim_params_.var_endo(i,1);
|
||||
0038 H(k,k) = xparam1(i+offset)*xparam1(i+offset);
|
||||
0039 <span class="keyword">end</span>
|
||||
0040 offset = offset+estim_params_.nvn;
|
||||
0041 <span class="keyword">end</span>
|
||||
0042 <span class="keyword">if</span> estim_params_.ncx
|
||||
0043 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0049 [CholQ,testQ] = chol(Q);
|
||||
0050 <span class="keyword">if</span> testQ <span class="comment">%% The variance-covariance matrix of the structural innovations is not definite positive.</span>
|
||||
0051 <span class="comment">%% We have to compute the eigenvalues of this matrix in order to build the penalty.</span>
|
||||
0052 a = diag(eig(Q));
|
||||
0053 k = find(a < 0);
|
||||
0054 <span class="keyword">if</span> k > 0
|
||||
0055 fval = bayestopt_.penalty+sum(-a(k));
|
||||
0056 cost_flag = 0;
|
||||
0057 <span class="keyword">return</span>
|
||||
0058 <span class="keyword">end</span>
|
||||
0059 <span class="keyword">end</span>
|
||||
0060 offset = offset+estim_params_.ncx;
|
||||
0061 <span class="keyword">end</span>
|
||||
0062 <span class="keyword">if</span> estim_params_.ncn
|
||||
0063 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0069 [CholH,testH] = chol(H);
|
||||
0070 <span class="keyword">if</span> testH
|
||||
0071 a = diag(eig(H));
|
||||
0072 k = find(a < 0);
|
||||
0073 <span class="keyword">if</span> k > 0
|
||||
0074 fval = bayestopt_.penalty+sum(-a(k));
|
||||
0075 cost_flag = 0;
|
||||
0076 <span class="keyword">return</span>
|
||||
0077 <span class="keyword">end</span>
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 offset = offset+estim_params_.ncn;
|
||||
0080 <span class="keyword">end</span>
|
||||
0081 M_.params(estim_params_.param_vals(:,1)) = xparam1(offset+1:end);
|
||||
0082 <span class="comment">% for i=1:estim_params_.np</span>
|
||||
0083 <span class="comment">% M_.params(estim_params_.param_vals(i,1)) = xparam1(i+offset);</span>
|
||||
0084 <span class="comment">%end</span>
|
||||
0085 M_.Sigma_e = Q;
|
||||
0086 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0087 <span class="comment">% 2. call model setup & reduction program</span>
|
||||
0088 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0089 [T,R,SteadyState,info] = <a href="dynare_resolve.html" class="code" title="function [A,B,ys,info] = dynare_resolve()">dynare_resolve</a>;
|
||||
0090 rs = bayestopt_.restrict_state;
|
||||
0091 <span class="keyword">if</span> info(1) == 1 | info(1) == 2 | info(1) == 5
|
||||
0092 fval = bayestopt_.penalty+1;
|
||||
0093 cost_flag = 0;
|
||||
0094 <span class="keyword">return</span>
|
||||
0095 <span class="keyword">elseif</span> info(1) == 3 | info(1) == 4 | info(1) == 20
|
||||
0096 fval = bayestopt_.penalty+info(2)^2;
|
||||
0097 cost_flag = 0;
|
||||
0098 <span class="keyword">return</span>
|
||||
0099 <span class="keyword">end</span>
|
||||
0100 T = T(rs,rs);
|
||||
0101 R = R(rs,:);
|
||||
0102 bayestopt_.mf = bayestopt_.mf1;
|
||||
0103 <span class="keyword">if</span> options_.loglinear == 1
|
||||
0104 constant = log(SteadyState(bayestopt_.mfys));
|
||||
0105 <span class="keyword">else</span>
|
||||
0106 constant = SteadyState(bayestopt_.mfys);
|
||||
0107 <span class="keyword">end</span>
|
||||
0108 <span class="keyword">if</span> bayestopt_.with_trend == 1
|
||||
0109 trend_coeff = zeros(nobs,1);
|
||||
0110 <span class="keyword">for</span> i=1:nobs
|
||||
0111 trend_coeff(i) = evalin(<span class="string">'base'</span>,bayestopt_.trend_coeff{i});
|
||||
0112 <span class="keyword">end</span>
|
||||
0113 trend = repmat(constant,1,gend)+trend_coeff*[1:gend];
|
||||
0114 <span class="keyword">else</span>
|
||||
0115 trend = repmat(constant,1,gend);
|
||||
0116 <span class="keyword">end</span>
|
||||
0117 start = options_.presample+1;
|
||||
0118 np = size(T,1);
|
||||
0119 mf = bayestopt_.mf;
|
||||
0120 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0121 <span class="comment">% 3. Initial condition of the Kalman filter</span>
|
||||
0122 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0123 <span class="keyword">if</span> options_.lik_init == 1 <span class="comment">% Kalman filter</span>
|
||||
0124 Pstar = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(T,R*Q*transpose(R));
|
||||
0125 Pinf = [];
|
||||
0126 <span class="keyword">elseif</span> options_.lik_init == 2 <span class="comment">% Old Diffuse Kalman filter</span>
|
||||
0127 Pstar = 10*eye(np);
|
||||
0128 Pinf = [];
|
||||
0129 <span class="keyword">elseif</span> options_.lik_init == 3 <span class="comment">% Diffuse Kalman filter</span>
|
||||
0130 Pstar = zeros(np,np);
|
||||
0131 ivs = bayestopt_.i_T_var_stable;
|
||||
0132 Pstar(ivs,ivs) = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(T(ivs,ivs),R(ivs,:)*Q* <span class="keyword">...</span>
|
||||
0133 transpose(R(ivs,:)));
|
||||
0134 Pinf = bayestopt_.Pinf;
|
||||
0135 <span class="comment">% by M. Ratto</span>
|
||||
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 <span class="comment">% by M. Ratto</span>
|
||||
0142 <span class="keyword">end</span>
|
||||
0143 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0144 <span class="comment">% 4. Likelihood evaluation</span>
|
||||
0145 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0146 <span class="keyword">if</span> estim_params_.nvn
|
||||
0147 <span class="keyword">if</span> options_.kalman_algo == 1
|
||||
0148 LIK = <a href="DiffuseLikelihoodH1.html" class="code" title="function [LIK, lik] = DiffuseLikelihoodH1(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH1</a>(T,R,Q,H,Pinf,Pstar,data,trend,start);
|
||||
0149 <span class="keyword">if</span> isinf(LIK) & ~estim_params_.ncn <span class="comment">%% The univariate approach considered here doesn't</span>
|
||||
0150 <span class="comment">%% apply when H has some off-diagonal elements.</span>
|
||||
0151 LIK = <a href="DiffuseLikelihoodH3.html" class="code" title="function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH3</a>(T,R,Q,H,Pinf,Pstar,data,trend,start);
|
||||
0152 <span class="keyword">elseif</span> isinf(LIK) & estim_params_.ncn
|
||||
0153 LIK = <a href="DiffuseLikelihoodH3corr.html" class="code" title="function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH3corr</a>(T,R,Q,H,Pinf,Pstar,data,trend,start);
|
||||
0154 <span class="keyword">end</span>
|
||||
0155 <span class="keyword">elseif</span> options_.kalman_algo == 3
|
||||
0156 <span class="keyword">if</span> ~estim_params_.ncn <span class="comment">%% The univariate approach considered here doesn't</span>
|
||||
0157 <span class="comment">%% apply when H has some off-diagonal elements.</span>
|
||||
0158 LIK = <a href="DiffuseLikelihoodH3.html" class="code" title="function [LIK, lik] = DiffuseLikelihoodH3(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH3</a>(T,R,Q,H,Pinf,Pstar,data,trend,start);
|
||||
0159 <span class="keyword">else</span>
|
||||
0160 LIK = <a href="DiffuseLikelihoodH3corr.html" class="code" title="function LIK = DiffuseLikelihoodH3corr(T,R,Q,H,Pinf,Pstar,Y,trend,start)">DiffuseLikelihoodH3corr</a>(T,R,Q,H,Pinf,Pstar,data,trend,start);
|
||||
0161 <span class="keyword">end</span>
|
||||
0162 <span class="keyword">end</span>
|
||||
0163 <span class="keyword">else</span>
|
||||
0164 <span class="keyword">if</span> options_.kalman_algo == 1
|
||||
0165 nv = size(bayestopt_.Z,1);
|
||||
0166 LIK = <a href="kalman_filter.html" class="code" title="function [loglik, per, d] = kalman_filter(varargin)">kalman_filter</a>(bayestopt_.Z,zeros(nv,nv),T,R,Q,data,zeros(size(T,1),1),Pstar,<span class="string">'u'</span>);
|
||||
0167 <span class="comment">% LIK = DiffuseLikelihood1(T,R,Q,Pinf,Pstar,data,trend,start);</span>
|
||||
0168 <span class="keyword">if</span> isinf(LIK)
|
||||
0169 LIK = <a href="DiffuseLikelihood3.html" class="code" title="function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)%//Z,T,R,Q,Pinf,Pstar,Y)">DiffuseLikelihood3</a>(T,R,Q,Pinf,Pstar,data,trend,start);
|
||||
0170 <span class="keyword">end</span>
|
||||
0171 <span class="keyword">elseif</span> options_.kalman_algo == 3
|
||||
0172 LIK = <a href="DiffuseLikelihood3.html" class="code" title="function [LIK, lik] = DiffuseLikelihood3(T,R,Q,Pinf,Pstar,Y,trend,start)%//Z,T,R,Q,Pinf,Pstar,Y)">DiffuseLikelihood3</a>(T,R,Q,Pinf,Pstar,data,trend,start);
|
||||
0173 <span class="keyword">end</span>
|
||||
0174 <span class="keyword">end</span>
|
||||
0175 <span class="keyword">if</span> imag(LIK) ~= 0
|
||||
0176 likelihood = bayestopt_.penalty;
|
||||
0177 <span class="keyword">else</span>
|
||||
0178 likelihood = LIK;
|
||||
0179 <span class="keyword">end</span>
|
||||
0180 <span class="comment">% ------------------------------------------------------------------------------</span>
|
||||
0181 <span class="comment">% Adds prior if necessary</span>
|
||||
0182 <span class="comment">% ------------------------------------------------------------------------------</span>
|
||||
0183 lnprior = <a href="priordens.html" class="code" title="function lnprior = priordens(para, pshape, p1, p2, p3, p4)">priordens</a>(xparam1,bayestopt_.pshape,bayestopt_.p1,bayestopt_.p2,bayestopt_.p3,bayestopt_.p4);
|
||||
0184 fval = (likelihood-lnprior);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,139 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of DsgeSmoother</title>
|
||||
<meta name="keywords" content="DsgeSmoother">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [09-07-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > DsgeSmoother.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>DsgeSmoother
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]
|
||||
|
||||
Adapted from mj_optmumlik.m</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DiffuseKalmanSmoother1.html" class="code" title="function [alphahat,etahat,a, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmoother1</a> modified by M. Ratto:</li><li><a href="DiffuseKalmanSmoother3.html" class="code" title="function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmoother3</a> function [a,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)</li><li><a href="DiffuseKalmanSmootherH1.html" class="code" title="function [alphahat,epsilonhat,etahat,a, aK] = DiffuseKalmanSmootherH1(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmootherH1</a> modified by M. Ratto:</li><li><a href="DiffuseKalmanSmootherH3.html" class="code" title="function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmootherH3</a> Modified by M. Ratto</li><li><a href="dynare_resolve.html" class="code" title="function [A,B,ys,info] = dynare_resolve()">dynare_resolve</a> </li><li><a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a> solves x-a*x*a'=b for b (and then x) symmetrical</li><li><a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="PosteriorSmoother.html" class="code" title="function PosteriorSmoother(Y,gend, type)">PosteriorSmoother</a> stephane.adjemian@ens.fr [09-25-2005]</li><li><a href="dynare_MC.html" class="code" title="function dynare_MC(var_list_)">dynare_MC</a> </li><li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li><li><a href="filt_mc_.html" class="code" title="function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)">filt_mc_</a> copyright Marco Ratto 2006</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% Adapted from mj_optmumlik.m</span>
|
||||
0005 <span class="keyword">global</span> 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 <a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a>(xparam1);
|
||||
0014
|
||||
0015 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0016 <span class="comment">% 2. call model setup & reduction program</span>
|
||||
0017 <span class="comment">%------------------------------------------------------------------------------</span>
|
||||
0018 [T,R,SteadyState] = <a href="dynare_resolve.html" class="code" title="function [A,B,ys,info] = dynare_resolve()">dynare_resolve</a>;
|
||||
0019 bayestopt_.mf = bayestopt_.mf2;
|
||||
0020 <span class="keyword">if</span> options_.loglinear == 1
|
||||
0021 constant = log(SteadyState(bayestopt_.mfys));
|
||||
0022 <span class="keyword">else</span>
|
||||
0023 constant = SteadyState(bayestopt_.mfys);
|
||||
0024 <span class="keyword">end</span>
|
||||
0025 trend_coeff = zeros(nobs,1);
|
||||
0026 <span class="keyword">if</span> 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 <span class="keyword">for</span> i=1:nobs
|
||||
0030 trend_coeff(i) = evalin(<span class="string">'base'</span>,bayestopt_.trend_coeff{i});
|
||||
0031 <span class="keyword">end</span>
|
||||
0032 trend = constant*ones(1,gend)+trend_coeff*(1:gend);
|
||||
0033 <span class="keyword">else</span>
|
||||
0034 trend = constant*ones(1,gend);
|
||||
0035 <span class="keyword">end</span>
|
||||
0036 start = options_.presample+1;
|
||||
0037 np = size(T,1);
|
||||
0038 mf = bayestopt_.mf;
|
||||
0039 <span class="comment">% ------------------------------------------------------------------------------</span>
|
||||
0040 <span class="comment">% 3. Initial condition of the Kalman filter</span>
|
||||
0041 <span class="comment">% ------------------------------------------------------------------------------</span>
|
||||
0042 <span class="comment">%</span>
|
||||
0043 <span class="comment">% C'est ici qu'il faut dterminer Pinf et Pstar. Si le modle est stationnaire,</span>
|
||||
0044 <span class="comment">% alors il suffit de poser Pstar comme la solution de l'uation de Lyapounov et</span>
|
||||
0045 <span class="comment">% Pinf=[].</span>
|
||||
0046 <span class="comment">%</span>
|
||||
0047 Q = M_.Sigma_e;
|
||||
0048 H = M_.H;
|
||||
0049
|
||||
0050 <span class="keyword">if</span> options_.lik_init == 1 <span class="comment">% Kalman filter</span>
|
||||
0051 Pstar = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(T,R*Q*transpose(R));
|
||||
0052 Pinf = [];
|
||||
0053 <span class="keyword">elseif</span> options_.lik_init == 2 <span class="comment">% Old Diffuse Kalman filter</span>
|
||||
0054 Pstar = 10*eye(np);
|
||||
0055 Pinf = [];
|
||||
0056 <span class="keyword">elseif</span> options_.lik_init == 3 <span class="comment">% Diffuse Kalman filter</span>
|
||||
0057 Pstar = zeros(np,np);
|
||||
0058 ivs = bayestopt_.i_T_var_stable;
|
||||
0059 Pstar(ivs,ivs) = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(T(ivs,ivs),R(ivs,:)*Q* <span class="keyword">...</span>
|
||||
0060 transpose(R(ivs,:)));
|
||||
0061 Pinf = bayestopt_.Pinf;
|
||||
0062 <span class="comment">% by M. Ratto</span>
|
||||
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 <span class="comment">% by M. Ratto</span>
|
||||
0069 <span class="keyword">end</span>
|
||||
0070 <span class="comment">% -----------------------------------------------------------------------------</span>
|
||||
0071 <span class="comment">% 4. Kalman smoother</span>
|
||||
0072 <span class="comment">% -----------------------------------------------------------------------------</span>
|
||||
0073 <span class="keyword">if</span> estim_params_.nvn
|
||||
0074 <span class="keyword">if</span> options_.kalman_algo == 1
|
||||
0075 [alphahat,epsilonhat,etahat,ahat,aK] = <a href="DiffuseKalmanSmootherH1.html" class="code" title="function [alphahat,epsilonhat,etahat,a, aK] = DiffuseKalmanSmootherH1(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmootherH1</a>(T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
|
||||
0076 <span class="keyword">if</span> all(alphahat(:)==0)
|
||||
0077 [alphahat,epsilonhat,etahat,ahat,aK] = <a href="DiffuseKalmanSmootherH3.html" class="code" title="function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmootherH3</a>(T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 <span class="keyword">elseif</span> options_.kalman_algo == 3
|
||||
0080 [alphahat,epsilonhat,etahat,ahat,aK] = <a href="DiffuseKalmanSmootherH3.html" class="code" title="function [alphahat,epsilonhat,etahat,a1, aK] = DiffuseKalmanSmootherH3(T,R,Q,H,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmootherH3</a>(T,R,Q,H,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
|
||||
0081 <span class="keyword">end</span>
|
||||
0082 <span class="keyword">else</span>
|
||||
0083 <span class="keyword">if</span> options_.kalman_algo == 1
|
||||
0084 [alphahat,etahat,ahat,aK] = <a href="DiffuseKalmanSmoother1.html" class="code" title="function [alphahat,etahat,a, aK] = DiffuseKalmanSmoother1(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmoother1</a>(T,R,Q,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
|
||||
0085 <span class="keyword">if</span> all(alphahat(:)==0)
|
||||
0086 [alphahat,etahat,ahat,aK] = <a href="DiffuseKalmanSmoother3.html" class="code" title="function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmoother3</a>(T,R,Q,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
|
||||
0087 <span class="keyword">end</span>
|
||||
0088 <span class="keyword">elseif</span> options_.kalman_algo == 3
|
||||
0089 [alphahat,etahat,ahat,aK] = <a href="DiffuseKalmanSmoother3.html" class="code" title="function [alphahat,etahat,a1, aK] = DiffuseKalmanSmoother3(T,R,Q,Pinf1,Pstar1,Y,trend,pp,mm,smpl,mf)">DiffuseKalmanSmoother3</a>(T,R,Q,Pinf,Pstar,Y,trend,nobs,np,smpl,mf);
|
||||
0090 <span class="keyword">end</span>
|
||||
0091 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,76 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of GetAllPosteriorDraws</title>
|
||||
<meta name="keywords" content="GetAllPosteriorDraws">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-09-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > GetAllPosteriorDraws.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>GetAllPosteriorDraws
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-09-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-09-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="GetPosteriorParametersStatistics.html" class="code" title="function GetPosteriorParametersStatistics()">GetPosteriorParametersStatistics</a> stephane.adjemian@ens.fr [09-09-2005]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-09-2005]</span>
|
||||
0003 <span class="keyword">global</span> M_ options_
|
||||
0004
|
||||
0005 nblck = options_.mh_nblck;
|
||||
0006 iline = FirstLine;
|
||||
0007 linee = 1;
|
||||
0008 DirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0009 Draws = zeros(NumberOfDraws*nblck,1);
|
||||
0010 logpo = zeros(NumberOfDraws*nblck,1);
|
||||
0011 ipost=0;
|
||||
0012 <span class="keyword">if</span> column<0,
|
||||
0013 column=1;
|
||||
0014 ipost=1;
|
||||
0015 <span class="keyword">end</span>
|
||||
0016
|
||||
0017 <span class="keyword">for</span> file = FirstMhFile:TotalNumberOfMhFile
|
||||
0018 <span class="keyword">for</span> blck = 1:nblck
|
||||
0019 load([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh'</span> int2str(file) <span class="string">'_blck'</span> int2str(blck)],<span class="string">'x2'</span>,<span class="string">'logpo2'</span>)
|
||||
0020 NumberOfLines = size(x2(iline:<span class="keyword">end</span>,:),1);
|
||||
0021 Draws(linee:linee+NumberOfLines-1) = x2(iline:<span class="keyword">end</span>,column);
|
||||
0022 logpo(linee:linee+NumberOfLines-1) = logpo2(iline:end);
|
||||
0023 linee = linee+NumberOfLines;
|
||||
0024 <span class="keyword">end</span>
|
||||
0025 iline = 1;
|
||||
0026 <span class="keyword">end</span>
|
||||
0027
|
||||
0028 <span class="keyword">if</span> ipost,
|
||||
0029 Draws=logpo;
|
||||
0030 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,55 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of GetOneDraw</title>
|
||||
<meta name="keywords" content="GetOneDraw">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-25-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > GetOneDraw.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>GetOneDraw
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-25-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [xparams, logpost] = GetOneDraw(type) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-25-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="metropolis_draw.html" class="code" title="function [xparams, logpost]=metropolis_draw(init)">metropolis_draw</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="PosteriorIRF.html" class="code" title="function PosteriorIRF(type)">PosteriorIRF</a> stephane.adjemian@ens.fr [09-25-2005]</li><li><a href="PosteriorSmoother.html" class="code" title="function PosteriorSmoother(Y,gend, type)">PosteriorSmoother</a> stephane.adjemian@ens.fr [09-25-2005]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [xparams, logpost] = GetOneDraw(type)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-25-2005]</span>
|
||||
0003
|
||||
0004 <span class="keyword">switch</span> type
|
||||
0005 <span class="keyword">case</span> <span class="string">'posterior'</span>
|
||||
0006 [xparams, logpost] = <a href="metropolis_draw.html" class="code" title="function [xparams, logpost]=metropolis_draw(init)">metropolis_draw</a>(0);
|
||||
0007 <span class="keyword">case</span> <span class="string">'prior'</span>
|
||||
0008 xparams = prior_draw(0);
|
||||
0009 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,204 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of GetPosteriorParametersStatistics</title>
|
||||
<meta name="keywords" content="GetPosteriorParametersStatistics">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-09-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > GetPosteriorParametersStatistics.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>GetPosteriorParametersStatistics
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-09-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function GetPosteriorParametersStatistics() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-09-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a> stephane.adjemian@ens.fr [09-09-2005]</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function GetPosteriorParametersStatistics()</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-09-2005]</span>
|
||||
0003 <span class="keyword">global</span> 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 = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0015 load([ DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh_history'</span>])
|
||||
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(<span class="string">' '</span>)
|
||||
0025 disp(<span class="string">' '</span>)
|
||||
0026 disp(<span class="string">'ESTIMATION RESULTS'</span>)
|
||||
0027 disp(<span class="string">' '</span>)
|
||||
0028 disp(sprintf(<span class="string">'Log data density is %f.'</span>,oo_.MarginalDensity.ModifiedHarmonicMean))
|
||||
0029 pnames=[<span class="string">' '</span>;<span class="string">'beta '</span>;<span class="string">'gamm '</span>;<span class="string">'norm '</span>;<span class="string">'invg '</span>;<span class="string">'unif '</span>;<span class="string">'invg2'</span>];
|
||||
0030 tit2 = sprintf(<span class="string">'%10s %7s %10s %14s %4s %6s\n'</span>,<span class="string">' '</span>,<span class="string">'prior mean'</span>,<span class="string">'post. mean'</span>,<span class="string">'conf. interval'</span>,<span class="string">'prior'</span>,<span class="string">'pstdev'</span>);
|
||||
0031 <span class="keyword">if</span> np
|
||||
0032 disp(<span class="string">' '</span>)
|
||||
0033 disp(<span class="string">'parameters'</span>)
|
||||
0034 disp(tit2)
|
||||
0035 ip = nvx+nvn+ncx+ncn+1;
|
||||
0036 <span class="keyword">for</span> i=1:np
|
||||
0037 Draws = <a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a>(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
||||
0038 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = <a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a>(Draws,1);
|
||||
0039 name = bayestopt_.name{ip};
|
||||
0040 disp(sprintf(<span class="string">'%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f'</span>, <span class="keyword">...</span>
|
||||
0041 name, <span class="keyword">...</span>
|
||||
0042 bayestopt_.pmean(ip),post_mean,hpd_interval, <span class="keyword">...</span>
|
||||
0043 pnames(bayestopt_.pshape(ip)+1,:), <span class="keyword">...</span>
|
||||
0044 bayestopt_.pstdev(ip)));
|
||||
0045 eval([<span class="string">'oo_.posterior_mean.parameters.'</span> name <span class="string">' = post_mean;'</span>]);
|
||||
0046 eval([<span class="string">'oo_.posterior_hpdinf.parameters.'</span> name <span class="string">' = hpd_interval(1);'</span>]);
|
||||
0047 eval([<span class="string">'oo_.posterior_hpdsup.parameters.'</span> name <span class="string">' = hpd_interval(2);'</span>]);
|
||||
0048 eval([<span class="string">'oo_.posterior_median.'</span> name <span class="string">' = post_median;'</span>]);
|
||||
0049 eval([<span class="string">'oo_.posterior_variance.'</span> name <span class="string">' = post_var;'</span>]);
|
||||
0050 eval([<span class="string">'oo_.posterior_deciles.'</span> name <span class="string">' = post_deciles;'</span>]);
|
||||
0051 eval([<span class="string">'oo_.posterior_density.'</span> name <span class="string">' = density;'</span>]);
|
||||
0052 ip = ip+1;
|
||||
0053 <span class="keyword">end</span>
|
||||
0054 <span class="keyword">end</span>
|
||||
0055 <span class="keyword">if</span> nvx
|
||||
0056 ip = 1;
|
||||
0057 disp(<span class="string">' '</span>)
|
||||
0058 disp(<span class="string">'standard deviation of shocks'</span>)
|
||||
0059 disp(tit2)
|
||||
0060 <span class="keyword">for</span> i=1:nvx
|
||||
0061 Draws = <a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a>(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
||||
0062 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = <a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a>(Draws,1);
|
||||
0063 k = estim_params_.var_exo(i,1);
|
||||
0064 name = deblank(M_.exo_names(k,:));
|
||||
0065 disp(sprintf(<span class="string">'%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f'</span>, <span class="keyword">...</span>
|
||||
0066 name,bayestopt_.pmean(ip),post_mean, <span class="keyword">...</span>
|
||||
0067 hpd_interval,pnames(bayestopt_.pshape(ip)+1,:), <span class="keyword">...</span>
|
||||
0068 bayestopt_.pstdev(ip)));
|
||||
0069 M_.Sigma_e(k,k) = post_mean*post_mean;
|
||||
0070 eval([<span class="string">'oo_.posterior_mean.shocks_std.'</span> name <span class="string">' = post_mean;'</span>]);
|
||||
0071 eval([<span class="string">'oo_.posterior_hpdinf.shocks_std.'</span> name <span class="string">' = hpd_interval(1);'</span>]);
|
||||
0072 eval([<span class="string">'oo_.posterior_hpdsup.shocks_std.'</span> name <span class="string">' = hpd_interval(2);'</span>]);
|
||||
0073 eval([<span class="string">'oo_.posterior_median.shocks_std.'</span> name <span class="string">' = post_median;'</span>]);
|
||||
0074 eval([<span class="string">'oo_.posterior_variance.shocks_std.'</span> name <span class="string">' = post_var;'</span>]);
|
||||
0075 eval([<span class="string">'oo_.posterior_deciles.shocks_std.'</span> name <span class="string">' = post_deciles;'</span>]);
|
||||
0076 eval([<span class="string">'oo_.posterior_density.shocks_std.'</span> name <span class="string">' = density;'</span>]);
|
||||
0077 ip = ip+1;
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 <span class="keyword">end</span>
|
||||
0080 <span class="keyword">if</span> nvn
|
||||
0081 disp(<span class="string">' '</span>)
|
||||
0082 disp(<span class="string">'standard deviation of measurement errors'</span>)
|
||||
0083 disp(tit2)
|
||||
0084 ip = nvx+1;
|
||||
0085 <span class="keyword">for</span> i=1:nvn
|
||||
0086 Draws = <a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a>(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
||||
0087 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = <a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a>(Draws,1);
|
||||
0088 name = deblank(options_.varobs(estim_params_.var_endo(i,1),:));
|
||||
0089 disp(sprintf(<span class="string">'%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f'</span>, <span class="keyword">...</span>
|
||||
0090 name,<span class="keyword">...</span>
|
||||
0091 bayestopt_.pmean(ip), <span class="keyword">...</span>
|
||||
0092 post_mean,hpd_interval, <span class="keyword">...</span>
|
||||
0093 pnames(bayestopt_.pshape(ip)+1,:), <span class="keyword">...</span>
|
||||
0094 bayestopt_.pstdev(ip)));
|
||||
0095 eval([<span class="string">'oo_.posterior_mean.measurement_errors_std.'</span> name <span class="string">' = post_mean;'</span>]);
|
||||
0096 eval([<span class="string">'oo_.posterior_hpdinf.measurement_errors_std.'</span> name <span class="string">' = hpd_interval(1);'</span>]);
|
||||
0097 eval([<span class="string">'oo_.posterior_hpdsup.measurement_errors_std.'</span> name <span class="string">' = hpd_interval(2);'</span>]);
|
||||
0098 eval([<span class="string">'oo_.posterior_median.measurement_errors_std.'</span> name <span class="string">' = post_median;'</span>]);
|
||||
0099 eval([<span class="string">'oo_.posterior_variance.measurement_errors_std.'</span> name <span class="string">' = post_var;'</span>]);
|
||||
0100 eval([<span class="string">'oo_.posterior_deciles.measurement_errors_std.'</span> name <span class="string">' = post_deciles;'</span>]);
|
||||
0101 eval([<span class="string">'oo_.posterior_density.measurement_errors_std.'</span> name <span class="string">' = density;'</span>]);
|
||||
0102 ip = ip+1;
|
||||
0103 <span class="keyword">end</span>
|
||||
0104 <span class="keyword">end</span>
|
||||
0105 <span class="keyword">if</span> ncx
|
||||
0106 disp(<span class="string">' '</span>)
|
||||
0107 disp(<span class="string">'correlation of shocks'</span>)
|
||||
0108 disp(tit2)
|
||||
0109 ip = nvx+nvn+1;
|
||||
0110 <span class="keyword">for</span> i=1:ncx
|
||||
0111 Draws = <a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a>(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
||||
0112 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = <a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a>(Draws,1);
|
||||
0113 k1 = estim_params_.corrx(i,1);
|
||||
0114 k2 = estim_params_.corrx(i,2);
|
||||
0115 name = [deblank(M_.exo_names(k1,:)) <span class="string">','</span> deblank(M_.exo_names(k2,:))];
|
||||
0116 NAME = [deblank(M_.exo_names(k1,:)) <span class="string">'_'</span> deblank(M_.exo_names(k2,:))];
|
||||
0117 disp(sprintf(<span class="string">'%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f'</span>, name, <span class="keyword">...</span>
|
||||
0118 bayestopt_.pmean(ip),post_mean,hpd_interval, <span class="keyword">...</span>
|
||||
0119 pnames(bayestopt_.pshape(ip)+1,:), <span class="keyword">...</span>
|
||||
0120 bayestopt_.pstdev(ip)));
|
||||
0121 eval([<span class="string">'oo_.posterior_mean.shocks_corr.'</span> NAME <span class="string">' = post_mean;'</span>]);
|
||||
0122 eval([<span class="string">'oo_.posterior_hpdinf.shocks_corr.'</span> NAME <span class="string">' = hpd_interval(1);'</span>]);
|
||||
0123 eval([<span class="string">'oo_.posterior_hpdsup.shocks_corr.'</span> NAME <span class="string">' = hpd_interval(2);'</span>]);
|
||||
0124 eval([<span class="string">'oo_.posterior_median.shocks_corr.'</span> NAME <span class="string">' = post_median;'</span>]);
|
||||
0125 eval([<span class="string">'oo_.posterior_variance.shocks_corr.'</span> NAME <span class="string">' = post_var;'</span>]);
|
||||
0126 eval([<span class="string">'oo_.posterior_deciles.shocks_corr.'</span> NAME <span class="string">' = post_deciles;'</span>]);
|
||||
0127 eval([<span class="string">'oo_.posterior_density.shocks_corr.'</span> NAME <span class="string">' = density;'</span>]);
|
||||
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 <span class="keyword">end</span>
|
||||
0132 <span class="keyword">end</span>
|
||||
0133 <span class="keyword">if</span> ncn
|
||||
0134 disp(<span class="string">' '</span>)
|
||||
0135 disp(<span class="string">'correlation of measurement errors'</span>)
|
||||
0136 disp(tit2)
|
||||
0137 ip = nvx+nvn+ncx+1;
|
||||
0138 <span class="keyword">for</span> i=1:ncn
|
||||
0139 Draws = <a href="GetAllPosteriorDraws.html" class="code" title="function Draws = GetAllPosteriorDraws(column,FirstMhFile,FirstLine,TotalNumberOfMhFile,NumberOfDraws)">GetAllPosteriorDraws</a>(ip,FirstMhFile,FirstLine,TotalNumberOfMhFiles,NumberOfDraws);
|
||||
0140 [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = <a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a>(Draws,1);
|
||||
0141 k1 = estim_params_.corrn(i,1);
|
||||
0142 k2 = estim_params_.corrn(i,2);
|
||||
0143 name = [deblank(M_.endo_names(k1,:)) <span class="string">','</span> deblank(M_.endo_names(k2,:))];
|
||||
0144 NAME = [deblank(M_.endo_names(k1,:)) <span class="string">'_'</span> deblank(M_.endo_names(k2,:))];
|
||||
0145 disp(sprintf(<span class="string">'%12s %7.3f %8.4f %7.4f %7.4f %4s %6.4f'</span>, name, <span class="keyword">...</span>
|
||||
0146 bayestopt_.pmean(ip),post_mean,hpd_interval, <span class="keyword">...</span>
|
||||
0147 pnames(bayestopt_.pshape(ip)+1,:), <span class="keyword">...</span>
|
||||
0148 bayestopt_.pstdev(ip)));
|
||||
0149 eval([<span class="string">'oo_.posterior_mean.measurement_errors_corr.'</span> NAME <span class="string">' = post_mean;'</span>]);
|
||||
0150 eval([<span class="string">'oo_.posterior_hpdinf.measurement_errors_corr.'</span> NAME <span class="string">' = hpd_interval(1);'</span>]);
|
||||
0151 eval([<span class="string">'oo_.posterior_hpdsup.measurement_errors_corr.'</span> NAME <span class="string">' = hpd_interval(2);'</span>]);
|
||||
0152 eval([<span class="string">'oo_.posterior_median.measurement_errors_corr.'</span> NAME <span class="string">' = post_median;'</span>]);
|
||||
0153 eval([<span class="string">'oo_.posterior_variance.measurement_errors_corr.'</span> NAME <span class="string">' = post_var;'</span>]);
|
||||
0154 eval([<span class="string">'oo_.posterior_deciles.measurement_errors_corr.'</span> NAME <span class="string">' = post_decile;'</span>]);
|
||||
0155 eval([<span class="string">'oo_.posterior_density.measurement_errors_corr.'</span> NAME <span class="string">' = density;'</span>]);
|
||||
0156 ip = ip+1;
|
||||
0157 <span class="keyword">end</span>
|
||||
0158 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,91 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of InitSeed</title>
|
||||
<meta name="keywords" content="InitSeed">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [12-02-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > InitSeed.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>InitSeed
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [12-02-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function InitSeed </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [12-02-2004]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function InitSeed</a>
|
||||
0002
|
||||
0003 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [12-02-2004]</span>
|
||||
0004
|
||||
0005 normalseed = [ 220271 ;
|
||||
0006 220378];
|
||||
0007
|
||||
0008 uniformseed = [ 0.6776 ; <span class="keyword">...</span>
|
||||
0009 0.8239 ; <span class="keyword">...</span>
|
||||
0010 0.6219 ; <span class="keyword">...</span>
|
||||
0011 0.8169 ; <span class="keyword">...</span>
|
||||
0012 0.2796 ; <span class="keyword">...</span>
|
||||
0013 0.4337 ; <span class="keyword">...</span>
|
||||
0014 0.6205 ; <span class="keyword">...</span>
|
||||
0015 0.8994 ; <span class="keyword">...</span>
|
||||
0016 0.9718 ; <span class="keyword">...</span>
|
||||
0017 0.7993 ; <span class="keyword">...</span>
|
||||
0018 0.4444 ; <span class="keyword">...</span>
|
||||
0019 0.8896 ; <span class="keyword">...</span>
|
||||
0020 0.9231 ; <span class="keyword">...</span>
|
||||
0021 0.5838 ; <span class="keyword">...</span>
|
||||
0022 0.1788 ; <span class="keyword">...</span>
|
||||
0023 0.6556 ; <span class="keyword">...</span>
|
||||
0024 0.7464 ; <span class="keyword">...</span>
|
||||
0025 0.7545 ; <span class="keyword">...</span>
|
||||
0026 0.2400 ; <span class="keyword">...</span>
|
||||
0027 0.4431 ; <span class="keyword">...</span>
|
||||
0028 0.3453 ; <span class="keyword">...</span>
|
||||
0029 0.6687 ; <span class="keyword">...</span>
|
||||
0030 0.6287 ; <span class="keyword">...</span>
|
||||
0031 0.8371 ; <span class="keyword">...</span>
|
||||
0032 0.8041 ; <span class="keyword">...</span>
|
||||
0033 0.6802 ; <span class="keyword">...</span>
|
||||
0034 0.5864 ; <span class="keyword">...</span>
|
||||
0035 0.7713 ; <span class="keyword">...</span>
|
||||
0036 0.8282 ; <span class="keyword">...</span>
|
||||
0037 0.5748 ; <span class="keyword">...</span>
|
||||
0038 0.0999 ; <span class="keyword">...</span>
|
||||
0039 0.6360 ; <span class="keyword">...</span>
|
||||
0040 0 ; <span class="keyword">...</span>
|
||||
0041 0.0000 ; <span class="keyword">...</span>
|
||||
0042 0.0000];
|
||||
0043
|
||||
0044 randn(<span class="string">'state'</span>,normalseed);
|
||||
0045 rand(<span class="string">'state'</span>,uniformseed);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,628 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of LPTAU</title>
|
||||
<meta name="keywords" content="LPTAU">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > LPTAU.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>LPTAU
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function VECTOR = LPTAU(I, N) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">
|
||||
I.M. SOBOL', V.I. TURCHANINOV, Yu.L. LEVITAN, B.V. SHUKHMAN
|
||||
KELDYSH INSTITUTE OF APPLIED MATHEMATICS
|
||||
RUSSIAN ACADEMY OF SCIENCES
|
||||
|
||||
QUASIRANDOM SEQUENCE GENERATORS
|
||||
-------------------------------
|
||||
|
||||
28.11.1991
|
||||
|
||||
NOTE TO THE USER BY the NEA Data Bank:
|
||||
This quasi random number generator has been made available to
|
||||
you on condition that its identity is preserved when used
|
||||
in computer programs. If its use leads to scientific publication
|
||||
of results you should cite it in the references, in addition
|
||||
no commercial use should be made unless agreed upon with the
|
||||
main author (Prof. I.M. Sobol')
|
||||
|
||||
ABSTRACT
|
||||
........
|
||||
|
||||
POINTS BELONGING TO LP-TAU SEQUENCES UNIFORMLY DISTRIBUTED IN THE
|
||||
N-DIMENSIONAL UNIT CUBE ARE OFTEN USED IN NUMERICAL MATHEMATICS:
|
||||
|
||||
- AS NODES FOR MULTIDIMENSIONAL INTEGRATION;
|
||||
- AS SEARCHING POINTS IN GLOBAL OPTIMIZATION;
|
||||
- AS TRIAL POINTS IN MULTI-CRITERIA DECISION MAKING;
|
||||
- AS QUASIRANDOM POINTS FOR QUASI-MONTECARLO ALGORITHMS;
|
||||
- ETC.
|
||||
|
||||
THIS SUBROUTINE CONTAINS THE ALGORITHM FOR FAST GENERATION OF
|
||||
LP-TAU SEQUENCES THAT ARE SUITABLE FOR MULTI-PROCESSOR COMPUTATIONS.
|
||||
THE DIMENSIONS N.LE.51, THE NUMBER OF POINTS N.LT.2**30.
|
||||
THE PROGRAMMING LANGUAGE IS FORTRAN-77. THIS SUBROUTINE IS AVAILABLE
|
||||
ALSO IN %-LANGUAGE.
|
||||
THE REPORT DESCRIBING THE ALGORITHM CONTAINS THE DESCRIPTION OF THE
|
||||
ALGORITHM AND CERTAIN IMPORTANT PROPERTIES OF LP-TAU SEQUENCES AND
|
||||
THEIR GENERALIZATIONS ARE DISCUSSED.
|
||||
|
||||
REFERENCE:
|
||||
I.M. SOBOL', V.I. TURCHANINOV, Yu.L. LEVITAN, B.V. SHUKHMAN
|
||||
KELDYSH INSTITUTE OF APPLIED MATHEMATICS
|
||||
RUSSIAN ACADEMY OF SCIENCES
|
||||
|
||||
QUASIRANDOM SEQUENCE GENERATORS
|
||||
MOSCOW 1992, IPM ZAK. NO.30 (100 COPIES)
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
INPUT PARAMETERS:
|
||||
|
||||
I - NUMBER OF THE POINT (I=(0,2**30-1)),
|
||||
N - DIMENSION OF THE POINT (0<N<52);
|
||||
|
||||
OUTPUT PARAMETER:
|
||||
|
||||
VECTOR(N) - N-VECTOR CONTAINING THE CARTESIAN CO-ORDINATES OF
|
||||
THE I-TH POINT.
|
||||
|
||||
|
||||
TO CALL THE SUBROUTINE WRITE:
|
||||
|
||||
CALL LPTAU(I,N,VECTOR)
|
||||
WHERE I, N: INTEGER CAPABLE OF STORING 2**30 (INTEGER*4 ON IBM
|
||||
OR OTHER 32 BIT/WORD MACHINES)
|
||||
VECTOR: DOUBLE PRECISION ARRAY WHOSE LENGTH < 52.
|
||||
|
||||
INTEGER QP
|
||||
QP = QUANTITY POWER
|
||||
|
||||
PARAMETER (MAXDIM=51, QP=30, MAXNUM=2**30-1)</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="lptauSEQ.html" class="code" title="function [lpmat] = lptauSEQ(Nsam,Nvar)">lptauSEQ</a> [lpmat] = lptauSEQ(Nsam,Nvar)</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function VECTOR = LPTAU(I, N)</a>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <span class="comment">% I.M. SOBOL', V.I. TURCHANINOV, Yu.L. LEVITAN, B.V. SHUKHMAN</span>
|
||||
0004 <span class="comment">% KELDYSH INSTITUTE OF APPLIED MATHEMATICS</span>
|
||||
0005 <span class="comment">% RUSSIAN ACADEMY OF SCIENCES</span>
|
||||
0006 <span class="comment">%</span>
|
||||
0007 <span class="comment">% QUASIRANDOM SEQUENCE GENERATORS</span>
|
||||
0008 <span class="comment">% -------------------------------</span>
|
||||
0009 <span class="comment">%</span>
|
||||
0010 <span class="comment">% 28.11.1991</span>
|
||||
0011 <span class="comment">%</span>
|
||||
0012 <span class="comment">% NOTE TO THE USER BY the NEA Data Bank:</span>
|
||||
0013 <span class="comment">% This quasi random number generator has been made available to</span>
|
||||
0014 <span class="comment">% you on condition that its identity is preserved when used</span>
|
||||
0015 <span class="comment">% in computer programs. If its use leads to scientific publication</span>
|
||||
0016 <span class="comment">% of results you should cite it in the references, in addition</span>
|
||||
0017 <span class="comment">% no commercial use should be made unless agreed upon with the</span>
|
||||
0018 <span class="comment">% main author (Prof. I.M. Sobol')</span>
|
||||
0019 <span class="comment">%</span>
|
||||
0020 <span class="comment">% ABSTRACT</span>
|
||||
0021 <span class="comment">% ........</span>
|
||||
0022 <span class="comment">%</span>
|
||||
0023 <span class="comment">% POINTS BELONGING TO LP-TAU SEQUENCES UNIFORMLY DISTRIBUTED IN THE</span>
|
||||
0024 <span class="comment">% N-DIMENSIONAL UNIT CUBE ARE OFTEN USED IN NUMERICAL MATHEMATICS:</span>
|
||||
0025 <span class="comment">%</span>
|
||||
0026 <span class="comment">% - AS NODES FOR MULTIDIMENSIONAL INTEGRATION;</span>
|
||||
0027 <span class="comment">% - AS SEARCHING POINTS IN GLOBAL OPTIMIZATION;</span>
|
||||
0028 <span class="comment">% - AS TRIAL POINTS IN MULTI-CRITERIA DECISION MAKING;</span>
|
||||
0029 <span class="comment">% - AS QUASIRANDOM POINTS FOR QUASI-MONTECARLO ALGORITHMS;</span>
|
||||
0030 <span class="comment">% - ETC.</span>
|
||||
0031 <span class="comment">%</span>
|
||||
0032 <span class="comment">% THIS SUBROUTINE CONTAINS THE ALGORITHM FOR FAST GENERATION OF</span>
|
||||
0033 <span class="comment">% LP-TAU SEQUENCES THAT ARE SUITABLE FOR MULTI-PROCESSOR COMPUTATIONS.</span>
|
||||
0034 <span class="comment">% THE DIMENSIONS N.LE.51, THE NUMBER OF POINTS N.LT.2**30.</span>
|
||||
0035 <span class="comment">% THE PROGRAMMING LANGUAGE IS FORTRAN-77. THIS SUBROUTINE IS AVAILABLE</span>
|
||||
0036 <span class="comment">% ALSO IN %-LANGUAGE.</span>
|
||||
0037 <span class="comment">% THE REPORT DESCRIBING THE ALGORITHM CONTAINS THE DESCRIPTION OF THE</span>
|
||||
0038 <span class="comment">% ALGORITHM AND CERTAIN IMPORTANT PROPERTIES OF LP-TAU SEQUENCES AND</span>
|
||||
0039 <span class="comment">% THEIR GENERALIZATIONS ARE DISCUSSED.</span>
|
||||
0040 <span class="comment">%</span>
|
||||
0041 <span class="comment">% REFERENCE:</span>
|
||||
0042 <span class="comment">% I.M. SOBOL', V.I. TURCHANINOV, Yu.L. LEVITAN, B.V. SHUKHMAN</span>
|
||||
0043 <span class="comment">% KELDYSH INSTITUTE OF APPLIED MATHEMATICS</span>
|
||||
0044 <span class="comment">% RUSSIAN ACADEMY OF SCIENCES</span>
|
||||
0045 <span class="comment">%</span>
|
||||
0046 <span class="comment">% QUASIRANDOM SEQUENCE GENERATORS</span>
|
||||
0047 <span class="comment">% MOSCOW 1992, IPM ZAK. NO.30 (100 COPIES)</span>
|
||||
0048 <span class="comment">%</span>
|
||||
0049 <span class="comment">% ------------------------------------------------------------------------</span>
|
||||
0050 <span class="comment">%</span>
|
||||
0051 <span class="comment">% INPUT PARAMETERS:</span>
|
||||
0052 <span class="comment">%</span>
|
||||
0053 <span class="comment">% I - NUMBER OF THE POINT (I=(0,2**30-1)),</span>
|
||||
0054 <span class="comment">% N - DIMENSION OF THE POINT (0<N<52);</span>
|
||||
0055 <span class="comment">%</span>
|
||||
0056 <span class="comment">% OUTPUT PARAMETER:</span>
|
||||
0057 <span class="comment">%</span>
|
||||
0058 <span class="comment">% VECTOR(N) - N-VECTOR CONTAINING THE CARTESIAN CO-ORDINATES OF</span>
|
||||
0059 <span class="comment">% THE I-TH POINT.</span>
|
||||
0060 <span class="comment">%</span>
|
||||
0061 <span class="comment">%</span>
|
||||
0062 <span class="comment">% TO CALL THE SUBROUTINE WRITE:</span>
|
||||
0063 <span class="comment">%</span>
|
||||
0064 <span class="comment">% CALL LPTAU(I,N,VECTOR)</span>
|
||||
0065 <span class="comment">% WHERE I, N: INTEGER CAPABLE OF STORING 2**30 (INTEGER*4 ON IBM</span>
|
||||
0066 <span class="comment">% OR OTHER 32 BIT/WORD MACHINES)</span>
|
||||
0067 <span class="comment">% VECTOR: DOUBLE PRECISION ARRAY WHOSE LENGTH < 52.</span>
|
||||
0068 <span class="comment">%</span>
|
||||
0069 <span class="comment">% INTEGER QP</span>
|
||||
0070 <span class="comment">% QP = QUANTITY POWER</span>
|
||||
0071 <span class="comment">%</span>
|
||||
0072 <span class="comment">% PARAMETER (MAXDIM=51, QP=30, MAXNUM=2**30-1)</span>
|
||||
0073 MAXDIM=51; QP=30; MAXNUM=2^30-1;
|
||||
0074 <span class="comment">%</span>
|
||||
0075 <span class="comment">% THE DIMENSION OF THE POINT CANNOT EXCEED MAXDIM</span>
|
||||
0076 <span class="comment">% THE TOTAL NUMBER OF GENERATED POINTS CANNOT EXCEED 2**QP</span>
|
||||
0077 <span class="comment">% MAXNUM=2**30-1 // 1073741823</span>
|
||||
0078 <span class="comment">%</span>
|
||||
0079 <span class="comment">% DOUBLE PRECISION VECTOR(N)</span>
|
||||
0080 <span class="comment">% INTEGER I,N</span>
|
||||
0081 <span class="comment">%</span>
|
||||
0082 <span class="comment">% INTEGER PRVNUM,PRVDIM</span>
|
||||
0083 <span class="comment">% INTEGER DIRECT(MAXDIM,QP), MASKV(MAXDIM)</span>
|
||||
0084 <span class="comment">% DOUBLE PRECISION SCALE</span>
|
||||
0085 <span class="comment">%</span>
|
||||
0086 <span class="comment">% Translated into MATLAB by M. Ratto</span>
|
||||
0087 VECTOR=zeros(1,N);
|
||||
0088 SCALE =9.31322574615478516E-10;
|
||||
0089
|
||||
0090 <span class="keyword">persistent</span> PRVNUM PRVDIM MASKV DIRECT
|
||||
0091 <span class="keyword">if</span> isempty(PRVNUM), PRVNUM=-2; <span class="keyword">end</span>,
|
||||
0092 <span class="keyword">if</span> isempty(PRVDIM), PRVDIM=0; <span class="keyword">end</span>,
|
||||
0093
|
||||
0094 <span class="keyword">if</span> isempty(DIRECT), <span class="keyword">...</span>
|
||||
0095 DIRECT(1:MAXDIM,1)=[
|
||||
0096 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0097 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0098 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0099 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0100 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0101 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0102 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0103 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0104 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0105 536870912, 536870912, 536870912, 536870912, 536870912, <span class="keyword">...</span>
|
||||
0106 536870912]';
|
||||
0107 DIRECT(1:MAXDIM,2)=[
|
||||
0108 805306368, 268435456, 805306368, 268435456, 805306368, <span class="keyword">...</span>
|
||||
0109 268435456, 805306368, 268435456, 268435456, 805306368, <span class="keyword">...</span>
|
||||
0110 268435456, 805306368, 268435456, 805306368, 268435456, <span class="keyword">...</span>
|
||||
0111 805306368, 805306368, 268435456, 805306368, 268435456, <span class="keyword">...</span>
|
||||
0112 805306368, 268435456, 805306368, 268435456, 268435456, <span class="keyword">...</span>
|
||||
0113 805306368, 268435456, 805306368, 268435456, 805306368, <span class="keyword">...</span>
|
||||
0114 268435456, 805306368, 805306368, 268435456, 805306368, <span class="keyword">...</span>
|
||||
0115 268435456, 805306368, 268435456, 805306368, 268435456, <span class="keyword">...</span>
|
||||
0116 268435456, 805306368, 268435456, 805306368, 268435456, <span class="keyword">...</span>
|
||||
0117 805306368, 268435456, 805306368, 805306368, 268435456, <span class="keyword">...</span>
|
||||
0118 805306368]';
|
||||
0119 DIRECT(1:MAXDIM,3)=[
|
||||
0120 939524096, 939524096, 134217728, 671088640, 402653184, <span class="keyword">...</span>
|
||||
0121 402653184, 671088640, 134217728, 671088640, 402653184, <span class="keyword">...</span>
|
||||
0122 939524096, 134217728, 671088640, 939524096, 134217728, <span class="keyword">...</span>
|
||||
0123 671088640, 134217728, 939524096, 939524096, 402653184, <span class="keyword">...</span>
|
||||
0124 402653184, 134217728, 671088640, 402653184, 671088640, <span class="keyword">...</span>
|
||||
0125 402653184, 402653184, 671088640, 134217728, 134217728, <span class="keyword">...</span>
|
||||
0126 939524096, 939524096, 939524096, 939524096, 134217728, <span class="keyword">...</span>
|
||||
0127 671088640, 402653184, 402653184, 671088640, 134217728, <span class="keyword">...</span>
|
||||
0128 671088640, 402653184, 939524096, 134217728, 671088640, <span class="keyword">...</span>
|
||||
0129 939524096, 134217728, 671088640, 134217728, 939524096, <span class="keyword">...</span>
|
||||
0130 939524096]';
|
||||
0131 DIRECT(1:MAXDIM,4)=[
|
||||
0132 1006632960, 67108864, 603979776, 1006632960, 335544320, <span class="keyword">...</span>
|
||||
0133 469762048, 872415232, 738197504, 469762048, 872415232, <span class="keyword">...</span>
|
||||
0134 1006632960, 67108864, 872415232, 469762048, 469762048, <span class="keyword">...</span>
|
||||
0135 469762048, 1006632960, 335544320, 872415232, 603979776, <span class="keyword">...</span>
|
||||
0136 201326592, 67108864, 335544320, 67108864, 201326592, <span class="keyword">...</span>
|
||||
0137 738197504, 1006632960, 738197504, 603979776, 335544320, <span class="keyword">...</span>
|
||||
0138 738197504, 67108864, 1006632960, 67108864, 603979776, <span class="keyword">...</span>
|
||||
0139 1006632960, 335544320, 469762048, 872415232, 738197504, <span class="keyword">...</span>
|
||||
0140 469762048, 872415232, 1006632960, 67108864, 872415232, <span class="keyword">...</span>
|
||||
0141 469762048, 469762048, 469762048, 1006632960, 335544320, <span class="keyword">...</span>
|
||||
0142 872415232]';
|
||||
0143 DIRECT(1:MAXDIM,5)=[
|
||||
0144 1040187392, 637534208, 1040187392, 838860800, 167772160, <span class="keyword">...</span>
|
||||
0145 234881024, 167772160, 1040187392, 436207616, 33554432, <span class="keyword">...</span>
|
||||
0146 570425344, 1040187392, 503316480, 838860800, 973078528, <span class="keyword">...</span>
|
||||
0147 167772160, 234881024, 436207616, 771751936, 100663296, <span class="keyword">...</span>
|
||||
0148 234881024, 905969664, 771751936, 33554432, 838860800, <span class="keyword">...</span>
|
||||
0149 973078528, 905969664, 33554432, 301989888, 838860800, <span class="keyword">...</span>
|
||||
0150 100663296, 234881024, 1040187392, 637534208, 1040187392, <span class="keyword">...</span>
|
||||
0151 838860800, 167772160, 234881024, 167772160, 1040187392, <span class="keyword">...</span>
|
||||
0152 436207616, 33554432, 570425344, 1040187392, 503316480, <span class="keyword">...</span>
|
||||
0153 838860800, 973078528, 167772160, 234881024, 436207616, <span class="keyword">...</span>
|
||||
0154 771751936]';
|
||||
0155 DIRECT(1:MAXDIM,6)=[
|
||||
0156 1056964608, 352321536, 50331648, 419430400, 956301312, <span class="keyword">...</span>
|
||||
0157 889192448, 620756992, 117440512, 956301312, 922746880, <span class="keyword">...</span>
|
||||
0158 822083584, 218103808, 587202560, 385875968, 452984832, <span class="keyword">...</span>
|
||||
0159 218103808, 184549376, 285212672, 150994944, 956301312, <span class="keyword">...</span>
|
||||
0160 352321536, 654311424, 553648128, 352321536, 788529152, <span class="keyword">...</span>
|
||||
0161 956301312, 587202560, 251658240, 218103808, 721420288, <span class="keyword">...</span>
|
||||
0162 251658240, 1056964608, 520093696, 889192448, 587202560, <span class="keyword">...</span>
|
||||
0163 956301312, 419430400, 352321536, 83886080, 654311424, <span class="keyword">...</span>
|
||||
0164 419430400, 385875968, 285212672, 754974720, 50331648, <span class="keyword">...</span>
|
||||
0165 922746880, 989855744, 754974720, 721420288, 822083584, <span class="keyword">...</span>
|
||||
0166 687865856]';
|
||||
0167 DIRECT(1:MAXDIM,7)=[
|
||||
0168 1065353216, 1065353216, 578813952, 25165824, 125829120, <span class="keyword">...</span>
|
||||
0169 964689920, 327155712, 310378496, 360710144, 360710144, <span class="keyword">...</span>
|
||||
0170 159383552, 444596224, 947912704, 662700032, 444596224, <span class="keyword">...</span>
|
||||
0171 528482304, 578813952, 578813952, 75497472, 1065353216, <span class="keyword">...</span>
|
||||
0172 92274688, 511705088, 897581056, 847249408, 662700032, <span class="keyword">...</span>
|
||||
0173 931135488, 411041792, 713031680, 696254464, 528482304, <span class="keyword">...</span>
|
||||
0174 209715200, 578813952, 1065353216, 1065353216, 578813952, <span class="keyword">...</span>
|
||||
0175 25165824, 125829120, 964689920, 327155712, 310378496, <span class="keyword">...</span>
|
||||
0176 360710144, 360710144, 159383552, 444596224, 947912704, <span class="keyword">...</span>
|
||||
0177 662700032, 444596224, 528482304, 578813952, 578813952, <span class="keyword">...</span>
|
||||
0178 75497472]';
|
||||
0179 DIRECT(1:MAXDIM,8)=[
|
||||
0180 1069547520, 4194304, 826277888, 624951296, 616562688, <span class="keyword">...</span>
|
||||
0181 801112064, 952107008, 406847488, 398458880, 331350016, <span class="keyword">...</span>
|
||||
0182 356515840, 46137344, 1010827264, 1069547520, 734003200, <span class="keyword">...</span>
|
||||
0183 113246208, 490733568, 633339904, 910163968, 801112064, <span class="keyword">...</span>
|
||||
0184 893386752, 851443712, 801112064, 918552576, 742391808, <span class="keyword">...</span>
|
||||
0185 499122176, 62914560, 264241152, 708837376, 717225984, <span class="keyword">...</span>
|
||||
0186 759169024, 499122176, 272629760, 423624704, 155189248, <span class="keyword">...</span>
|
||||
0187 239075328, 205520896, 943718400, 373293056, 457179136, <span class="keyword">...</span>
|
||||
0188 406847488, 71303168, 473956352, 54525952, 624951296, <span class="keyword">...</span>
|
||||
0189 104857600, 1019215872, 901775360, 213909504, 281018368, <span class="keyword">...</span>
|
||||
0190 851443712]';
|
||||
0191 DIRECT(1:MAXDIM,9)=[
|
||||
0192 1071644672, 543162368, 190840832, 329252864, 853540864, <span class="keyword">...</span>
|
||||
0193 132120576, 778043392, 73400320, 178257920, 522190848, <span class="keyword">...</span>
|
||||
0194 639631360, 534773760, 991952896, 333447168, 48234496, <span class="keyword">...</span>
|
||||
0195 1059061760, 761266176, 673185792, 220200960, 396361728, <span class="keyword">...</span>
|
||||
0196 362807296, 815792128, 819986432, 346030080, 39845888, <span class="keyword">...</span>
|
||||
0197 752877568, 387973120, 643825664, 291504128, 274726912, <span class="keyword">...</span>
|
||||
0198 568328192, 526385152, 673185792, 98566144, 396361728, <span class="keyword">...</span>
|
||||
0199 727711744, 1042284544, 106954752, 299892736, 912261120, <span class="keyword">...</span>
|
||||
0200 44040192, 895483904, 333447168, 551550976, 467664896, <span class="keyword">...</span>
|
||||
0201 618659840, 606076928, 274726912, 245366784, 446693376, <span class="keyword">...</span>
|
||||
0202 421527552]';
|
||||
0203 DIRECT(1:MAXDIM,10)=[
|
||||
0204 1072693248, 273678336, 644874240, 753926144, 495976448, <span class="keyword">...</span>
|
||||
0205 869269504, 355467264, 57671680, 816840704, 961544192, <span class="keyword">...</span>
|
||||
0206 804257792, 495976448, 347078656, 426770432, 1066401792, <span class="keyword">...</span>
|
||||
0207 372244480, 84934656, 208666624, 313524224, 598736896, <span class="keyword">...</span>
|
||||
0208 487587840, 965738496, 1011875840, 296747008, 393216000, <span class="keyword">...</span>
|
||||
0209 523239424, 720371712, 823132160, 128974848, 407896064, <span class="keyword">...</span>
|
||||
0210 747634688, 850395136, 873463808, 504365056, 481296384, <span class="keyword">...</span>
|
||||
0211 686817280, 592445440, 995098624, 498073600, 969932800, <span class="keyword">...</span>
|
||||
0212 586153984, 1039138816, 814743552, 523239424, 294649856, <span class="keyword">...</span>
|
||||
0213 305135616, 506462208, 11534336, 449839104, 619708416, <span class="keyword">...</span>
|
||||
0214 479199232]';
|
||||
0215 DIRECT(1:MAXDIM,11)=[
|
||||
0216 1073217536, 947388416, 1070071808, 977797120, 365428736, <span class="keyword">...</span>
|
||||
0217 702021632, 461897728, 829947904, 425197568, 634912768, <span class="keyword">...</span>
|
||||
0218 437780480, 582483968, 792199168, 315097088, 611844096, <span class="keyword">...</span>
|
||||
0219 667418624, 166199296, 513277952, 187170816, 1036517376, <span class="keyword">...</span>
|
||||
0220 25690112, 201850880, 443023360, 990380032, 63438848, <span class="keyword">...</span>
|
||||
0221 211288064, 983040000, 1069023232, 421003264, 742916096, <span class="keyword">...</span>
|
||||
0222 487063552, 363331584, 973602816, 286785536, 171442176, <span class="keyword">...</span>
|
||||
0223 669515776, 110624768, 383254528, 289931264, 352845824, <span class="keyword">...</span>
|
||||
0224 878182400, 655884288, 836239360, 765984768, 549978112, <span class="keyword">...</span>
|
||||
0225 655884288, 85458944, 591921152, 563609600, 277348352, <span class="keyword">...</span>
|
||||
0226 919076864]';
|
||||
0227 DIRECT(1:MAXDIM,12)=[
|
||||
0228 1073479680, 71565312, 2359296, 891551744, 158597120, <span class="keyword">...</span>
|
||||
0229 383516672, 1019478016, 947126272, 621019136, 714866688, <span class="keyword">...</span>
|
||||
0230 738459648, 265027584, 468975616, 131858432, 504627200, <span class="keyword">...</span>
|
||||
0231 581173248, 266600448, 865861632, 658243584, 546045952, <span class="keyword">...</span>
|
||||
0232 521404416, 304873472, 1060896768, 163840000, 305922048, <span class="keyword">...</span>
|
||||
0233 257163264, 50069504, 773062656, 59506688, 779354112, <span class="keyword">...</span>
|
||||
0234 165937152, 587988992, 486801408, 160694272, 90439680, <span class="keyword">...</span>
|
||||
0235 423362560, 536608768, 614203392, 56885248, 999030784, <span class="keyword">...</span>
|
||||
0236 10747904, 764674048, 25952256, 989069312, 352583680, <span class="keyword">...</span>
|
||||
0237 799801344, 261357568, 873201664, 40108032, 769392640, <span class="keyword">...</span>
|
||||
0238 254541824]';
|
||||
0239 DIRECT(1:MAXDIM,13)=[
|
||||
0240 1073610752, 644218880, 538836992, 455475200, 1062600704, <span class="keyword">...</span>
|
||||
0241 139329536, 205651968, 905052160, 797048832, 452329472, <span class="keyword">...</span>
|
||||
0242 973471744, 627703808, 614072320, 803078144, 637403136, <span class="keyword">...</span>
|
||||
0243 835059712, 949878784, 662044672, 767950848, 426901504, <span class="keyword">...</span>
|
||||
0244 448659456, 23986176, 1016201216, 524943360, 525991936, <span class="keyword">...</span>
|
||||
0245 618790912, 781058048, 761659392, 458096640, 226361344, <span class="keyword">...</span>
|
||||
0246 950665216, 952500224, 516030464, 337510400, 496107520, <span class="keyword">...</span>
|
||||
0247 830865408, 944111616, 636354560, 978452480, 921567232, <span class="keyword">...</span>
|
||||
0248 533594112, 7471104, 678035456, 471203840, 1065746432, <span class="keyword">...</span>
|
||||
0249 575275008, 996540416, 909246464, 879362048, 637927424, <span class="keyword">...</span>
|
||||
0250 25821184]';
|
||||
0251 DIRECT(1:MAXDIM,14)=[
|
||||
0252 1073676288, 357892096, 808648704, 2424832, 2555904, <span class="keyword">...</span>
|
||||
0253 624230400, 69271552, 456851456, 1052966912, 600637440, <span class="keyword">...</span>
|
||||
0254 487260160, 794624000, 386727936, 467599360, 798031872, <span class="keyword">...</span>
|
||||
0255 630652928, 340983808, 493944832, 37945344, 264175616, <span class="keyword">...</span>
|
||||
0256 263520256, 833421312, 235077632, 464846848, 534839296, <span class="keyword">...</span>
|
||||
0257 992411648, 10813440, 367067136, 116457472, 115015680, <span class="keyword">...</span>
|
||||
0258 928710656, 619773952, 813760512, 1043398656, 967770112, <span class="keyword">...</span>
|
||||
0259 912850944, 72155136, 1009057792, 668532736, 462356480, <span class="keyword">...</span>
|
||||
0260 267321344, 795803648, 635764736, 574160896, 1003421696, <span class="keyword">...</span>
|
||||
0261 181075968, 56688640, 388562944, 190906368, 657915904, <span class="keyword">...</span>
|
||||
0262 474939392]';
|
||||
0263 DIRECT(1:MAXDIM,15)=[
|
||||
0264 1073709056, 1073709056, 137003008, 547782656, 545095680, <span class="keyword">...</span>
|
||||
0265 26836992, 34701312, 354385920, 925663232, 656965632, <span class="keyword">...</span>
|
||||
0266 327581696, 894795776, 110067712, 1038057472, 209354752, <span class="keyword">...</span>
|
||||
0267 596541440, 42631168, 471433216, 52527104, 666861568, <span class="keyword">...</span>
|
||||
0268 706707456, 674070528, 824410112, 305496064, 136282112, <span class="keyword">...</span>
|
||||
0269 847740928, 531464192, 222920704, 379289600, 507740160, <span class="keyword">...</span>
|
||||
0270 11894784, 1053392896, 129990656, 557547520, 666468352, <span class="keyword">...</span>
|
||||
0271 1061912576, 576684032, 1041334272, 380469248, 114196480, <span class="keyword">...</span>
|
||||
0272 133070848, 517046272, 129990656, 790396928, 563773440, <span class="keyword">...</span>
|
||||
0273 388333568, 661749760, 446791680, 737378304, 229998592, <span class="keyword">...</span>
|
||||
0274 348225536]';
|
||||
0275 DIRECT(1:MAXDIM,16)=[
|
||||
0276 1073725440, 16384, 605372416, 275234816, 817971200, <span class="keyword">...</span>
|
||||
0277 603963392, 555335680, 721534976, 997801984, 1028767744, <span class="keyword">...</span>
|
||||
0278 407060480, 375275520, 256688128, 1021165568, 303349760, <span class="keyword">...</span>
|
||||
0279 1022476288, 234143744, 106708992, 732971008, 733954048, <span class="keyword">...</span>
|
||||
0280 789889024, 879575040, 764657664, 762658816, 1010843648, <span class="keyword">...</span>
|
||||
0281 941080576, 827932672, 98942976, 1051738112, 624934912, <span class="keyword">...</span>
|
||||
0282 993280000, 134070272, 201375744, 567558144, 882163712, <span class="keyword">...</span>
|
||||
0283 649084928, 356564992, 489439232, 637091840, 60637184, <span class="keyword">...</span>
|
||||
0284 199278592, 815677440, 927678464, 94519296, 419184640, <span class="keyword">...</span>
|
||||
0285 933838848, 426655744, 911130624, 171393024, 561332224, <span class="keyword">...</span>
|
||||
0286 471613440]';
|
||||
0287 DIRECT(1:MAXDIM,17)=[
|
||||
0288 1073733632, 536895488, 1043685376, 679944192, 417505280, <span class="keyword">...</span>
|
||||
0289 301981696, 832561152, 210542592, 167501824, 1071341568, <span class="keyword">...</span>
|
||||
0290 229302272, 970661888, 732176384, 576659456, 402464768, <span class="keyword">...</span>
|
||||
0291 451584000, 368467968, 928260096, 933847040, 29319168, <span class="keyword">...</span>
|
||||
0292 582934528, 772612096, 330014720, 647323648, 174071808, <span class="keyword">...</span>
|
||||
0293 1008689152, 295919616, 353869824, 177774592, 580198400, <span class="keyword">...</span>
|
||||
0294 381837312, 638574592, 637558784, 679370752, 504012800, <span class="keyword">...</span>
|
||||
0295 747118592, 429973504, 1032609792, 932667392, 583360512, <span class="keyword">...</span>
|
||||
0296 969498624, 1056333824, 660955136, 247488512, 153509888, <span class="keyword">...</span>
|
||||
0297 242180096, 205840384, 797499392, 824565760, 234348544, <span class="keyword">...</span>
|
||||
0298 842326016]';
|
||||
0299 DIRECT(1:MAXDIM,18)=[
|
||||
0300 1073737728, 268455936, 52785152, 1020628992, 345018368, <span class="keyword">...</span>
|
||||
0301 452972544, 704442368, 255987712, 750759936, 697692160, <span class="keyword">...</span>
|
||||
0302 196677632, 764604416, 485625856, 522022912, 680620032, <span class="keyword">...</span>
|
||||
0303 362270720, 838103040, 83972096, 629133312, 46108672, <span class="keyword">...</span>
|
||||
0304 867561472, 725422080, 184504320, 751112192, 191918080, <span class="keyword">...</span>
|
||||
0305 306425856, 507310080, 30453760, 281858048, 604000256, <span class="keyword">...</span>
|
||||
0306 208662528, 319557632, 318779392, 476139520, 863719424, <span class="keyword">...</span>
|
||||
0307 567062528, 521179136, 712790016, 610299904, 293687296, <span class="keyword">...</span>
|
||||
0308 1023086592, 549089280, 1065242624, 707751936, 363024384, <span class="keyword">...</span>
|
||||
0309 16674816, 197136384, 1037561856, 195112960, 372707328, <span class="keyword">...</span>
|
||||
0310 992751616]';
|
||||
0311 DIRECT(1:MAXDIM,19)=[
|
||||
0312 1073739776, 939554816, 580732928, 854333440, 172619776, <span class="keyword">...</span>
|
||||
0313 511694848, 936142848, 518199296, 593348608, 225527808, <span class="keyword">...</span>
|
||||
0314 900982784, 180279296, 168904704, 62814208, 754485248, <span class="keyword">...</span>
|
||||
0315 730691584, 1005996032, 411174912, 249866240, 641669120, <span class="keyword">...</span>
|
||||
0316 1008719872, 749066240, 860993536, 94177280, 432564224, <span class="keyword">...</span>
|
||||
0317 226355200, 925784064, 995657728, 967731200, 436226048, <span class="keyword">...</span>
|
||||
0318 913799168, 549894144, 964696064, 843315200, 445863936, <span class="keyword">...</span>
|
||||
0319 1047422976, 548947968, 492066816, 953870336, 1002653696, <span class="keyword">...</span>
|
||||
0320 861440000, 385636352, 325253120, 187353088, 653584384, <span class="keyword">...</span>
|
||||
0321 1008269312, 748693504, 1013016576, 55814144, 255170560, <span class="keyword">...</span>
|
||||
0322 260708352]';
|
||||
0323 DIRECT(1:MAXDIM,20)=[
|
||||
0324 1073740800, 67126272, 829514752, 423777280, 968297472, <span class="keyword">...</span>
|
||||
0325 205511680, 147076096, 926669824, 202300416, 118395904, <span class="keyword">...</span>
|
||||
0326 381332480, 1002738688, 743042048, 292551680, 584567808, <span class="keyword">...</span>
|
||||
0327 284339200, 183936000, 616762368, 435221504, 159376384, <span class="keyword">...</span>
|
||||
0328 907322368, 595696640, 247497728, 553735168, 826051584, <span class="keyword">...</span>
|
||||
0329 564454400, 446024704, 214236160, 33661952, 251685888, <span class="keyword">...</span>
|
||||
0330 660327424, 284244992, 859868160, 722502656, 622844928, <span class="keyword">...</span>
|
||||
0331 324342784, 682374144, 400579584, 405353472, 605187072, <span class="keyword">...</span>
|
||||
0332 840682496, 212956160, 157891584, 193201152, 437990400, <span class="keyword">...</span>
|
||||
0333 573578240, 368053248, 580197376, 937905152, 565527552, <span class="keyword">...</span>
|
||||
0334 89064448]';
|
||||
0335 DIRECT(1:MAXDIM,21)=[
|
||||
0336 1073741312, 637560320, 189496832, 27474432, 129338880, <span class="keyword">...</span>
|
||||
0337 908054016, 641870336, 186375680, 302677504, 763663872, <span class="keyword">...</span>
|
||||
0338 103878144, 325187072, 858254848, 922041856, 261924352, <span class="keyword">...</span>
|
||||
0339 954978816, 292822528, 849512960, 210311680, 933232128, <span class="keyword">...</span>
|
||||
0340 691981824, 155417088, 627070464, 416795136, 182081024, <span class="keyword">...</span>
|
||||
0341 513433088, 848658944, 515770880, 627273216, 629169664, <span class="keyword">...</span>
|
||||
0342 414566912, 147450368, 698353152, 244844032, 226578944, <span class="keyword">...</span>
|
||||
0343 1020087808, 886978048, 389697024, 1007004160, 839646720, <span class="keyword">...</span>
|
||||
0344 621924864, 549962240, 609583616, 735976960, 87342592, <span class="keyword">...</span>
|
||||
0345 1058542080, 163066368, 307997184, 876471808, 794280448, <span class="keyword">...</span>
|
||||
0346 675386880]';
|
||||
0347 DIRECT(1:MAXDIM,22)=[
|
||||
0348 1073741568, 352343296, 644236032, 636735232, 615860480, <span class="keyword">...</span>
|
||||
0349 959444224, 287380736, 1007410432, 890187008, 399480576, <span class="keyword">...</span>
|
||||
0350 520092928, 643311360, 816901376, 695310080, 1019229440, <span class="keyword">...</span>
|
||||
0351 77034240, 733295872, 1035127552, 986582784, 332381952, <span class="keyword">...</span>
|
||||
0352 334852352, 364956416, 596672256, 800381696, 480316672, <span class="keyword">...</span>
|
||||
0353 574863104, 647347968, 702910208, 499965184, 364968704, <span class="keyword">...</span>
|
||||
0354 120862976, 1023256320, 995114240, 13951232, 32520448, <span class="keyword">...</span>
|
||||
0355 702127360, 45176064, 444945664, 237860096, 152839936, <span class="keyword">...</span>
|
||||
0356 530633984, 429135616, 267272448, 884808960, 933712640, <span class="keyword">...</span>
|
||||
0357 61605632, 174335744, 564911360, 302327552, 650589440, <span class="keyword">...</span>
|
||||
0358 450649344]';
|
||||
0359 DIRECT(1:MAXDIM,23)=[
|
||||
0360 1073741696, 1065385856, 1073734272, 331949184, 842310784, <span class="keyword">...</span>
|
||||
0361 799537536, 965852032, 369351808, 662886016, 86119808, <span class="keyword">...</span>
|
||||
0362 865109888, 299633792, 422735488, 181087360, 174252416, <span class="keyword">...</span>
|
||||
0363 1041212544, 840196224, 750314368, 391053440, 903306880, <span class="keyword">...</span>
|
||||
0364 742365312, 236995200, 42492800, 946000512, 771692416, <span class="keyword">...</span>
|
||||
0365 897405824, 613803136, 924258688, 808338304, 1038125440, <span class="keyword">...</span>
|
||||
0366 683814272, 177186176, 766008960, 704549248, 194555008, <span class="keyword">...</span>
|
||||
0367 306383744, 496592512, 416020864, 655186816, 1032204928, <span class="keyword">...</span>
|
||||
0368 694773632, 577910144, 45797760, 910332544, 536014976, <span class="keyword">...</span>
|
||||
0369 675946368, 987635840, 788223872, 353993856, 96313472, <span class="keyword">...</span>
|
||||
0370 85248640]';
|
||||
0371 DIRECT(1:MAXDIM,24)=[
|
||||
0372 1073741760, 4210752, 12608, 744788544, 494377792, <span class="keyword">...</span>
|
||||
0373 115601344, 769248448, 990895808, 851706304, 979326784, <span class="keyword">...</span>
|
||||
0374 692061120, 429015104, 217132864, 736067008, 55694400, <span class="keyword">...</span>
|
||||
0375 456152640, 631601984, 787264192, 898599104, 478383808, <span class="keyword">...</span>
|
||||
0376 507774272, 458270272, 392995136, 872482496, 124824768, <span class="keyword">...</span>
|
||||
0377 1034161344, 362141632, 1053833280, 943810496, 428920128, <span class="keyword">...</span>
|
||||
0378 795835200, 835462848, 961843520, 606198080, 785652672, <span class="keyword">...</span>
|
||||
0379 154954432, 491617344, 297351232, 580735552, 634587968, <span class="keyword">...</span>
|
||||
0380 185277760, 141505600, 417673280, 106907456, 395575616, <span class="keyword">...</span>
|
||||
0381 566958656, 352651200, 415242688, 26635200, 1030317504, <span class="keyword">...</span>
|
||||
0382 247212992]';
|
||||
0383 DIRECT(1:MAXDIM,25)=[
|
||||
0384 1073741792, 543187040, 536882016, 981766752, 357858144, <span class="keyword">...</span>
|
||||
0385 810665952, 369083488, 613015520, 86115232, 845149216, <span class="keyword">...</span>
|
||||
0386 606076960, 1018241504, 35245536, 635403744, 236633696, <span class="keyword">...</span>
|
||||
0387 407451232, 427671904, 460141792, 116344544, 990246688, <span class="keyword">...</span>
|
||||
0388 1024892576, 883429408, 150655392, 173476896, 197666464, <span class="keyword">...</span>
|
||||
0389 1016740448, 605376608, 970487008, 1006881248, 598265632, <span class="keyword">...</span>
|
||||
0390 1022861728, 489055392, 216680608, 371439072, 53140576, <span class="keyword">...</span>
|
||||
0391 965114400, 98534112, 209692256, 264598496, 321437280, <span class="keyword">...</span>
|
||||
0392 545303840, 324119904, 876587488, 778239712, 802033120, <span class="keyword">...</span>
|
||||
0393 44406496, 665829024, 803213920, 309742112, 735181344, <span class="keyword">...</span>
|
||||
0394 1036125600]';
|
||||
0395 DIRECT(1:MAXDIM,26)=[
|
||||
0396 1073741808, 273698896, 805312112, 903123536, 153504624, <span class="keyword">...</span>
|
||||
0397 689632208, 432848944, 859888752, 510853776, 240805744, <span class="keyword">...</span>
|
||||
0398 250610192, 852489168, 139460144, 283082224, 222702928, <span class="keyword">...</span>
|
||||
0399 342181488, 922872432, 187528656, 360637424, 814514736, <span class="keyword">...</span>
|
||||
0400 301037840, 800872624, 272595184, 158627600, 238839088, <span class="keyword">...</span>
|
||||
0401 927181136, 710248688, 788854608, 1048376560, 484709072, <span class="keyword">...</span>
|
||||
0402 85709008, 1065469744, 429237328, 490778384, 848024144, <span class="keyword">...</span>
|
||||
0403 443114288, 687907504, 474573648, 45706416, 681465296, <span class="keyword">...</span>
|
||||
0404 805303216, 14567920, 369839504, 440402480, 797652624, <span class="keyword">...</span>
|
||||
0405 115959088, 929784560, 91226544, 205943056, 288358704, <span class="keyword">...</span>
|
||||
0406 950217296]';
|
||||
0407 DIRECT(1:MAXDIM,27)=[
|
||||
0408 1073741816, 947419256, 134232008, 460100200, 1073685336, <span class="keyword">...</span>
|
||||
0409 398354904, 1069834248, 686054696, 108299224, 273898840, <span class="keyword">...</span>
|
||||
0410 731382552, 938170664, 86812552, 677346808, 602208712, <span class="keyword">...</span>
|
||||
0411 652635752, 209797064, 323968376, 384078968, 561178056, <span class="keyword">...</span>
|
||||
0412 923399256, 996597176, 942777416, 885167400, 89791048, <span class="keyword">...</span>
|
||||
0413 956122504, 87393464, 987661336, 993412952, 827749496, <span class="keyword">...</span>
|
||||
0414 903211272, 33649816, 594875176, 65052056, 822835240, <span class="keyword">...</span>
|
||||
0415 625704888, 1065374584, 612232920, 536299720, 1046858504, <span class="keyword">...</span>
|
||||
0416 939518840, 160843032, 654656088, 744496936, 872197704, <span class="keyword">...</span>
|
||||
0417 219111576, 829112632, 455614152, 1064192952, 313010856, <span class="keyword">...</span>
|
||||
0418 820754920]';
|
||||
0419 DIRECT(1:MAXDIM,28)=[
|
||||
0420 1073741820, 71582788, 603989028, 37500, 120660, <span class="keyword">...</span>
|
||||
0421 182195932, 213921796, 473570692, 41763004, 156352828, <span class="keyword">...</span>
|
||||
0422 88343188, 698012780, 666108868, 337608156, 1054329884, <span class="keyword">...</span>
|
||||
0423 799472220, 641885244, 392104980, 502284340, 1002405628, <span class="keyword">...</span>
|
||||
0424 249907140, 75586228, 206587660, 565275348, 1021426548, <span class="keyword">...</span>
|
||||
0425 425987996, 598058580, 401940420, 919427316, 822049324, <span class="keyword">...</span>
|
||||
0426 115655868, 759299588, 562394644, 990942164, 1003212268, <span class="keyword">...</span>
|
||||
0427 598750292, 675334852, 675293340, 445665316, 903023756, <span class="keyword">...</span>
|
||||
0428 872412692, 172640916, 1051615436, 91229620, 94586692, <span class="keyword">...</span>
|
||||
0429 344873452, 7029156, 683421900, 434258804, 955002092, <span class="keyword">...</span>
|
||||
0430 436424380]';
|
||||
0431 DIRECT(1:MAXDIM,29)=[
|
||||
0432 1073741822, 644245094, 1040195102, 537039474, 537089354, <span class="keyword">...</span>
|
||||
0433 642656334, 73402402, 664239174, 1014620426, 500917234, <span class="keyword">...</span>
|
||||
0434 1042677826, 347788318, 1069154738, 373259762, 362587674, <span class="keyword">...</span>
|
||||
0435 239395914, 132283950, 903121466, 445210638, 968851198, <span class="keyword">...</span>
|
||||
0436 230153254, 935549622, 308815630, 861891286, 496995094, <span class="keyword">...</span>
|
||||
0437 670740382, 657311830, 573565382, 248331478, 1064650798, <span class="keyword">...</span>
|
||||
0438 338312798, 669059078, 1065190902, 379125622, 111897166, <span class="keyword">...</span>
|
||||
0439 520650422, 740300390, 1046483950, 66254898, 992513134, <span class="keyword">...</span>
|
||||
0440 234871606, 610553330, 450553866, 566758134, 787800806, <span class="keyword">...</span>
|
||||
0441 1071709866, 971732606, 528102354, 790919122, 917384366, <span class="keyword">...</span>
|
||||
0442 656244162]';
|
||||
0443 DIRECT(1:MAXDIM,30)=[
|
||||
0444 1073741823, 357913941, 50344755, 268538457, 805540473, <span class="keyword">...</span>
|
||||
0445 3487029, 3146769, 592038967, 729591963, 781578389, <span class="keyword">...</span>
|
||||
0446 66781679, 113956361, 331153483, 967802327, 935343371, <span class="keyword">...</span>
|
||||
0447 324351309, 609305915, 818137857, 131059769, 918519549, <span class="keyword">...</span>
|
||||
0448 827341719, 922770101, 456972047, 363883221, 1057014661, <span class="keyword">...</span>
|
||||
0449 900956063, 580478293, 520383687, 315470533, 227601711, <span class="keyword">...</span>
|
||||
0450 169598765, 909227271, 796983815, 349496709, 393974911, <span class="keyword">...</span>
|
||||
0451 378320037, 777004343, 927999269, 616377385, 345930959, <span class="keyword">...</span>
|
||||
0452 989849787, 627400495, 892675125, 260314121, 1041964063, <span class="keyword">...</span>
|
||||
0453 531367163, 195776757, 237309785, 949187605, 719002587, <span class="keyword">...</span>
|
||||
0454 495745187]';
|
||||
0455 <span class="keyword">end</span>
|
||||
0456
|
||||
0457 <span class="comment">%</span>
|
||||
0458 <span class="comment">% TRAP FOR A WRONG SUBROUTINE CALL</span>
|
||||
0459 <span class="comment">%</span>
|
||||
0460 <span class="keyword">if</span> ((I<0) | (N<1) | (I>MAXNUM) | (N>MAXDIM)),
|
||||
0461 disp(<span class="string">'LP-TAU CALL FAILED'</span>)
|
||||
0462 disp(<span class="string">' PRESS <ENTER> TO EXIT LPTAU'</span>)
|
||||
0463 pause
|
||||
0464 <span class="keyword">return</span>
|
||||
0465 <span class="keyword">end</span>
|
||||
0466 <span class="keyword">if</span> ((PRVNUM+1==I) & (N<=PRVDIM)),
|
||||
0467 <span class="comment">%</span>
|
||||
0468 <span class="comment">% RECURRENT GENERATION OF THE POINT</span>
|
||||
0469 <span class="comment">%</span>
|
||||
0470 <span class="comment">%</span>
|
||||
0471 <span class="comment">% SEARCH POSITION OF THE RIGHTMOST "1"</span>
|
||||
0472 <span class="comment">% IN THE BINARY REPRESENTATION OF I</span>
|
||||
0473 <span class="comment">%</span>
|
||||
0474 L=0;
|
||||
0475 POS=0;
|
||||
0476 <span class="keyword">while</span> L<QP & POS==0,
|
||||
0477 L=L+1;
|
||||
0478 POS=bitand(bitshift(I,-(L-1)),1);
|
||||
0479 <span class="keyword">end</span>
|
||||
0480 <span class="comment">%</span>
|
||||
0481 <span class="comment">% RIGHTMOST POSITION IS L</span>
|
||||
0482 <span class="comment">%</span>
|
||||
0483 <span class="keyword">for</span> J=1:N
|
||||
0484 MASKV(J)=bitxor(MASKV(J),DIRECT(J,L));
|
||||
0485 VECTOR(J)=MASKV(J)*SCALE;
|
||||
0486 <span class="keyword">end</span>
|
||||
0487 <span class="keyword">else</span>
|
||||
0488 <span class="comment">%</span>
|
||||
0489 <span class="comment">% GENERATION OF THE POINT FROM "I" AND "N"</span>
|
||||
0490 <span class="comment">%</span>
|
||||
0491 MASKV=zeros(1,N);
|
||||
0492 IM=bitxor(I,bitshift(I,-1));
|
||||
0493 M=0;
|
||||
0494 <span class="keyword">while</span> IM~=0 & M<QP,
|
||||
0495 M=M+1;
|
||||
0496 <span class="keyword">if</span> (bitand(IM,1)==1),
|
||||
0497 <span class="keyword">for</span> J=1:N
|
||||
0498 MASKV(J)=bitxor(MASKV(J),DIRECT(J,M));
|
||||
0499 <span class="keyword">end</span>
|
||||
0500 <span class="keyword">end</span>
|
||||
0501 IM=bitshift(IM,-1);
|
||||
0502 <span class="keyword">end</span>
|
||||
0503 <span class="keyword">for</span> J=1:N
|
||||
0504 VECTOR(J)=MASKV(J)*SCALE;
|
||||
0505 <span class="keyword">end</span>
|
||||
0506 <span class="keyword">end</span>
|
||||
0507 <span class="comment">%</span>
|
||||
0508 PRVNUM=I;
|
||||
0509 PRVDIM=N;
|
||||
0510 <span class="keyword">return</span>
|
||||
0511
|
||||
0512</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,198 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of MakeAllFigures</title>
|
||||
<meta name="keywords" content="MakeAllFigures">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [02-04-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > MakeAllFigures.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>MakeAllFigures
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [02-04-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function MakeAllFigures(NumberOfPlots,Caption,FigureProperties,Info) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [02-04-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function MakeAllFigures(NumberOfPlots,Caption,FigureProperties,Info)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [02-04-2005]</span>
|
||||
0003 <span class="keyword">global</span> M_ options_
|
||||
0004
|
||||
0005 FigHandle = figure(<span class="string">'Name'</span>,FigureProperties.Name);
|
||||
0006
|
||||
0007 NAMES = cell(NumberOfPlots,1);
|
||||
0008 <span class="keyword">if</span> options_.TeX
|
||||
0009 TeXNAMES = cell(NumberOfPlots,1);
|
||||
0010 <span class="keyword">end</span>
|
||||
0011
|
||||
0012 <span class="keyword">if</span> NumberOfPlots == 9
|
||||
0013 nr = 3;
|
||||
0014 nc = 3;
|
||||
0015 <span class="keyword">elseif</span> NumberOfPlots == 8
|
||||
0016 nr = 3;
|
||||
0017 nc = 3;
|
||||
0018 <span class="keyword">elseif</span> NumberOfPlots == 7
|
||||
0019 nr = 3;
|
||||
0020 nc = 3;
|
||||
0021 <span class="keyword">elseif</span> NumberOfPlots == 6
|
||||
0022 nr = 2;
|
||||
0023 nc = 3;
|
||||
0024 <span class="keyword">elseif</span> NumberOfPlots == 5
|
||||
0025 nr = 3;
|
||||
0026 nc = 2;
|
||||
0027 <span class="keyword">elseif</span> NumberOfPlots == 4
|
||||
0028 nr = 2;
|
||||
0029 nc = 2;
|
||||
0030 <span class="keyword">elseif</span> NumberOfPlots == 3
|
||||
0031 nr = 2;
|
||||
0032 nc = 2;
|
||||
0033 <span class="keyword">elseif</span> NumberOfPlots == 2
|
||||
0034 nr = 1;
|
||||
0035 nc = 2;
|
||||
0036 <span class="keyword">elseif</span> NumberOfPlots == 1
|
||||
0037 nr = 1;
|
||||
0038 nc = 1;
|
||||
0039 <span class="keyword">end</span>
|
||||
0040
|
||||
0041 <span class="keyword">for</span> plt = 1:NumberOfPlots
|
||||
0042 eval([<span class="string">'NumberOfCurves = Info.Box'</span> int2str(plt) <span class="string">'.Number;'</span>])
|
||||
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 <span class="keyword">for</span> curve = 1:NumberOfCurves
|
||||
0052 eval([<span class="string">'x{'</span> curve <span class="string">'} = Info.Box'</span> int2str(plt) <span class="string">'.Curve'</span> int2str(curve) <span class="string">'.xdata;'</span>])
|
||||
0053 eval([<span class="string">'y{'</span> curve <span class="string">'} = Info.Box'</span> int2str(plt) <span class="string">'.Curve'</span> int2str(curve) <span class="string">'.ydata;'</span>])
|
||||
0054 eval([<span class="string">'name = Info.Box'</span> int2str(plt) <span class="string">'.Curve'</span> int2str(curve) <span class="string">'.variablename;'</span>])
|
||||
0055 eval([<span class="string">'PltType{'</span> curve <span class="string">'} = Info.Box'</span> int2str(plt) <span class="string">'.Curve'</span> int2str(curve) <span class="string">'.type'</span>]);
|
||||
0056 <span class="keyword">if</span> length(x{curve})-length(y{curve})
|
||||
0057 disp(<span class="string">'MakeFigure :: The number of observations in x doesn''t match with '</span>)
|
||||
0058 disp([<span class="string">'the number of observation in y for '</span> name ])
|
||||
0059 <span class="keyword">return</span>
|
||||
0060 <span class="keyword">end</span>
|
||||
0061 <span class="keyword">if</span> Info.PlotProperties.CutTop
|
||||
0062 top(curve) = max(y{curve});
|
||||
0063 <span class="keyword">else</span> Info.PlotProperties.CutBottom
|
||||
0064 bottom(curve) = min(y{curve});
|
||||
0065 <span class="keyword">end</span>
|
||||
0066 binf(curve) = min(x{curve});
|
||||
0067 bsup(curve) = max(x{curve});
|
||||
0068 <span class="keyword">end</span>
|
||||
0069 ymax = max(top);
|
||||
0070 ymin = min(bottom);
|
||||
0071 xmin = min(binf);
|
||||
0072 xmax = max(bsup);
|
||||
0073 <span class="keyword">if</span> isnan(ymin(plt))
|
||||
0074 ymin = 0;
|
||||
0075 <span class="keyword">end</span>
|
||||
0076 eval([<span class="string">'NAMES{'</span> int2str(plt) <span class="string">'} = Info.Box'</span> int2str(plt) <span class="string">'.name;'</span>])
|
||||
0077 <span class="keyword">if</span> options_.TeX
|
||||
0078 eval([<span class="string">'TeXNAMES{'</span> int2str(plt) <span class="string">'} = Info.Box'</span> int2str(plt) <span class="string">'.texname;'</span>])
|
||||
0079 <span class="keyword">end</span>
|
||||
0080 subplot(nr,nc,plt)
|
||||
0081 hold on
|
||||
0082 <span class="keyword">for</span> curve = 1:NumberOfCurves
|
||||
0083 hh = plot(x{curve},y{curve});
|
||||
0084 <span class="keyword">if</span> strcmpi(PltType{curve},<span class="string">'PriorDensity'</span>)
|
||||
0085 set(hh,<span class="string">'Color'</span>,[0.7 0.7 0.7],<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0086 <span class="comment">%</span>
|
||||
0087 <span class="comment">%</span>
|
||||
0088 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'DensityEstimate'</span>)
|
||||
0089 set(hh,<span class="string">'Color'</span>,<span class="string">'k'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0090 <span class="comment">%</span>
|
||||
0091 <span class="comment">%</span>
|
||||
0092 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'ModeEstimate'</span>)
|
||||
0093 set(hh,<span class="string">'Color'</span>,<span class="string">'g'</span>,<span class="string">'LineStyle'</span>,<span class="string">'--'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0094 <span class="comment">%</span>
|
||||
0095 <span class="comment">%</span>
|
||||
0096 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'SmoothVariable'</span>)
|
||||
0097 set(hh,<span class="string">'Color'</span>,<span class="string">'k'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0098 <span class="comment">%</span>
|
||||
0099 <span class="comment">%</span>
|
||||
0100 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'Deciles'</span>)
|
||||
0101 set(hh,<span class="string">'Color'</span>,<span class="string">'g'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,1)
|
||||
0102 <span class="comment">%</span>
|
||||
0103 <span class="comment">%</span>
|
||||
0104 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'Forecasts'</span>)
|
||||
0105 set(hh,<span class="string">'Color'</span>,<span class="string">''</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0106 <span class="comment">%</span>
|
||||
0107 <span class="comment">%</span>
|
||||
0108 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'ForecastsHPD'</span>)
|
||||
0109 set(hh,<span class="string">'Color'</span>,<span class="string">'k'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,1)
|
||||
0110 <span class="comment">%</span>
|
||||
0111 <span class="comment">%</span>
|
||||
0112 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'ForecastsDeciles'</span>)
|
||||
0113 set(hh,<span class="string">'Color'</span>,<span class="string">'g'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,1)
|
||||
0114 <span class="comment">%</span>
|
||||
0115 <span class="comment">%</span>
|
||||
0116 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'DiagnosticWithin'</span>)
|
||||
0117 set(hh,<span class="string">'Color'</span>,<span class="string">'b'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0118 <span class="comment">%</span>
|
||||
0119 <span class="comment">%</span>
|
||||
0120 <span class="keyword">elseif</span> strcmpi(PltType{curve},<span class="string">'DiagnosticPooled'</span>)
|
||||
0121 set(hh,<span class="string">'Color'</span>,<span class="string">'r'</span>,<span class="string">'LineStyle'</span>,<span class="string">'-'</span>,<span class="string">'LineWidth'</span>,2)
|
||||
0122 <span class="comment">%</span>
|
||||
0123 <span class="comment">%</span>
|
||||
0124 <span class="keyword">end</span>
|
||||
0125 <span class="keyword">end</span>
|
||||
0126 axis([xmin xmax ymin ymax])
|
||||
0127 title(NAMES{plt})
|
||||
0128 drawnow
|
||||
0129 hold off
|
||||
0130 <span class="keyword">end</span>
|
||||
0131
|
||||
0132 <span class="keyword">if</span> Info.SaveFormat.Eps
|
||||
0133 <span class="keyword">if</span> isempty(Info.SaveFormat.Name)
|
||||
0134 eval([<span class="string">'print -depsc2 '</span> M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number)]);
|
||||
0135 <span class="keyword">else</span>
|
||||
0136 eval([<span class="string">'print -depsc2 '</span> M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name]);
|
||||
0137 <span class="keyword">end</span>
|
||||
0138 <span class="keyword">end</span>
|
||||
0139 <span class="keyword">if</span> Info.SaveFormat.Pdf
|
||||
0140 <span class="keyword">if</span> isempty(Info.SaveFormat.Name)
|
||||
0141 eval([<span class="string">'print -dpdf '</span> M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number)]);
|
||||
0142 <span class="keyword">else</span>
|
||||
0143 eval([<span class="string">'print -dpdf '</span> M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name]);
|
||||
0144 <span class="keyword">end</span>
|
||||
0145 <span class="keyword">end</span>
|
||||
0146 <span class="keyword">if</span> Info.SaveFormat.Fig
|
||||
0147 <span class="keyword">if</span> isempty(Info.SaveFormat.Name)
|
||||
0148 saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName int2str(Info.SaveFormat.Number) <span class="string">'.fig'</span>]);
|
||||
0149 <span class="keyword">else</span>
|
||||
0150 saveas(FigHandle,[M_.fname Info.SaveFormat.GenericName Info.SaveFormat.Name <span class="string">'.fig'</span>]);
|
||||
0151 <span class="keyword">end</span>
|
||||
0152 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,399 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of McMCDiagnostics</title>
|
||||
<meta name="keywords" content="McMCDiagnostics">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [06-04-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > McMCDiagnostics.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>McMCDiagnostics
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [06-04-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function McmcDiagnostic </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [06-04-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="get_the_name.html" class="code" title="function [nam,texnam] = get_the_name(k,TeX)">get_the_name</a> stephane.adjemian@cepremap.cnrs.fr [07-13-2004]</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function McmcDiagnostic</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [06-04-2005]</span>
|
||||
0003
|
||||
0004 <span class="keyword">global</span> options_ estim_params_ M_
|
||||
0005
|
||||
0006 DirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'Output'</span>);
|
||||
0007 MhDirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0008
|
||||
0009 TeX = options_.TeX;
|
||||
0010 nblck = options_.mh_nblck;
|
||||
0011 <span class="comment">% Brooks and Gelman tests need more than one block</span>
|
||||
0012 <span class="keyword">if</span> nblck == 1
|
||||
0013 <span class="keyword">return</span>;
|
||||
0014 <span class="keyword">end</span>
|
||||
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 <span class="string">'/'</span> M_.fname <span class="string">'_mh_history.mat'</span>])
|
||||
0023
|
||||
0024 mcfiles = [];
|
||||
0025 <span class="keyword">for</span> blck = 1:nblck
|
||||
0026 mcfiles = cat(3,mcfiles,dir([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh*_blck'</span> int2str(blck) <span class="string">'.mat'</span>]));
|
||||
0027 <span class="keyword">end</span>
|
||||
0028 NumberOfMcFilesPerBlock = size(mcfiles,1);
|
||||
0029
|
||||
0030
|
||||
0031 PastDraws = sum(record.MhDraws,1);
|
||||
0032 LastFileNumber = PastDraws(2);
|
||||
0033 LastLineNumber = record.MhDraws(<span class="keyword">end</span>,3);
|
||||
0034 NumberOfDraws = PastDraws(1);
|
||||
0035
|
||||
0036 Origin = 1000;
|
||||
0037 StepSize = ceil((NumberOfDraws-Origin)/100);<span class="comment">% So that the computational time does not</span>
|
||||
0038 ALPHA = 0.2; <span class="comment">% increase too much with the number of simulations.</span>
|
||||
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 <span class="keyword">if</span> NumberOfDraws < Origin
|
||||
0046 disp(<span class="string">'MCMC Diagnostics :: The number of simulations is to small to compute the MCMC convergence diagnostics.'</span>)
|
||||
0047 <span class="keyword">return</span>
|
||||
0048 <span class="keyword">end</span>
|
||||
0049
|
||||
0050 <span class="keyword">if</span> TeX
|
||||
0051 fidTeX = fopen([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_UnivariateDiagnostics.TeX'</span>],<span class="string">'w'</span>);
|
||||
0052 fprintf(fidTeX,<span class="string">'%% TeX eps-loader file generated by McmcDiagnostics.m (Dynare).\n'</span>);
|
||||
0053 fprintf(fidTeX,[<span class="string">'%% '</span> datestr(now,0) <span class="string">'\n'</span>]);
|
||||
0054 fprintf(fidTeX,<span class="string">' \n'</span>);
|
||||
0055 <span class="keyword">end</span>
|
||||
0056
|
||||
0057
|
||||
0058 disp(<span class="string">'MCMC Diagnostics: Univariate convergence diagnostic, Brooks and Gelman (1998):'</span>)
|
||||
0059 <span class="keyword">for</span> j=1:npar
|
||||
0060 fprintf(<span class="string">' Parameter %d... '</span>,j);
|
||||
0061 <span class="keyword">for</span> b = 1:nblck
|
||||
0062 startline = 0;
|
||||
0063 <span class="keyword">for</span> n = 1:NumberOfMcFilesPerBlock-1
|
||||
0064 <span class="comment">%load([MhDirectoryName '/' mcfiles(n,1,b).name],'x2');</span>
|
||||
0065 load([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh'</span>,int2str(n),<span class="string">'_blck'</span> int2str(b) <span class="string">'.mat'</span>],<span class="string">'x2'</span>);
|
||||
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 <span class="keyword">end</span>
|
||||
0070 <span class="comment">%load([MhDirectoryName '/' mcfiles(NumberOfMcFilesPerBlock,1,b).name],'x2');</span>
|
||||
0071 load([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh'</span>,int2str(NumberOfMcFilesPerBlock),<span class="string">'_blck'</span> int2str(b) <span class="string">'.mat'</span>],<span class="string">'x2'</span>);
|
||||
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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> 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));<span class="comment">%% Pooled mean.</span>
|
||||
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 <span class="keyword">for</span> 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); <span class="comment">%% Within mean.</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0100 <span class="keyword">end</span>
|
||||
0101 fprintf(<span class="string">'Done! \n'</span>);
|
||||
0102 <span class="keyword">end</span>
|
||||
0103 UDIAG(:,[2 4 6],:) = UDIAG(:,[2 4 6],:)/nblck;
|
||||
0104 disp(<span class="string">' '</span>)
|
||||
0105 clear pmet temp moyenne CSUP CINF csup cinf n linea iter tmp;
|
||||
0106 pages = floor(npar/3);
|
||||
0107 k = 0;
|
||||
0108 <span class="keyword">for</span> i = 1:pages
|
||||
0109 <span class="keyword">if</span> options_.nograph
|
||||
0110 h = figure(<span class="string">'Name'</span>,<span class="string">'MCMC univariate diagnostic (Brooks and Gelman,1998)'</span>,<span class="string">'Visible'</span>,<span class="string">'off'</span>);
|
||||
0111 <span class="keyword">else</span>
|
||||
0112 h = figure(<span class="string">'Name'</span>,<span class="string">'MCMC univariate diagnostic (Brooks and Gelman,1998)'</span>);
|
||||
0113 <span class="keyword">end</span>
|
||||
0114 boxplot = 1;
|
||||
0115 <span class="keyword">if</span> TeX
|
||||
0116 NAMES = [];
|
||||
0117 TEXNAMES = [];
|
||||
0118 <span class="keyword">end</span>
|
||||
0119 <span class="keyword">for</span> j = 1:3 <span class="comment">% Loop over parameters</span>
|
||||
0120 k = k+1;
|
||||
0121 [nam,namtex] = <a href="get_the_name.html" class="code" title="function [nam,texnam] = get_the_name(k,TeX)">get_the_name</a>(k,TeX);
|
||||
0122 <span class="keyword">for</span> crit = 1:3<span class="comment">% Loop over criteria</span>
|
||||
0123 <span class="keyword">if</span> crit == 1
|
||||
0124 plt1 = UDIAG(:,1,k);
|
||||
0125 plt2 = UDIAG(:,2,k);
|
||||
0126 namnam = [nam , <span class="string">' (Interval)'</span>];
|
||||
0127 <span class="keyword">elseif</span> crit == 2
|
||||
0128 plt1 = UDIAG(:,3,k);
|
||||
0129 plt2 = UDIAG(:,4,k);
|
||||
0130 namnam = [nam , <span class="string">' (m2)'</span>];
|
||||
0131 <span class="keyword">elseif</span> crit == 3
|
||||
0132 plt1 = UDIAG(:,5,k);
|
||||
0133 plt2 = UDIAG(:,6,k);
|
||||
0134 namnam = [nam , <span class="string">' (m3)'</span>];
|
||||
0135 <span class="keyword">end</span>
|
||||
0136 <span class="keyword">if</span> TeX
|
||||
0137 NAMES = strvcat(NAMES,deblank(namnam));
|
||||
0138 TEXNAMES = strvcat(TEXNAMES,deblank(namtex));
|
||||
0139 <span class="keyword">end</span>
|
||||
0140 subplot(3,3,boxplot);
|
||||
0141 plot(xx,plt1,<span class="string">'-b'</span>); <span class="comment">% Pooled</span>
|
||||
0142 hold on;
|
||||
0143 plot(xx,plt2,<span class="string">'-r'</span>); <span class="comment">% Within (mean)</span>
|
||||
0144 hold off;
|
||||
0145 xlim([xx(1) xx(NumberOfLines)])
|
||||
0146 title(namnam,<span class="string">'Interpreter'</span>,<span class="string">'none'</span>)
|
||||
0147 boxplot = boxplot + 1;
|
||||
0148 <span class="keyword">end</span>
|
||||
0149 <span class="keyword">end</span>
|
||||
0150 eval([<span class="string">'print -depsc2 '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_udiag'</span> int2str(i)]);
|
||||
0151 eval([<span class="string">'print -dpdf '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_udiag'</span> int2str(i)]);
|
||||
0152 <span class="keyword">if</span> options_.nograph, set(h,<span class="string">'visible'</span>,<span class="string">'on'</span>), <span class="keyword">end</span>
|
||||
0153 saveas(h,[DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_udiag'</span> int2str(i) <span class="string">'.fig'</span>]);
|
||||
0154 <span class="keyword">if</span> options_.nograph, close(h), <span class="keyword">end</span>
|
||||
0155 <span class="keyword">if</span> TeX
|
||||
0156 fprintf(fidTeX,<span class="string">'\\begin{figure}[H]\n'</span>);
|
||||
0157 <span class="keyword">for</span> jj = 1:size(NAMES,1)
|
||||
0158 fprintf(fidTeX,<span class="string">'\\psfrag{%s}[1][][0.5][0]{%s}\n'</span>,deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
|
||||
0159 <span class="keyword">end</span>
|
||||
0160 fprintf(fidTeX,<span class="string">'\\centering \n'</span>);
|
||||
0161 fprintf(fidTeX,<span class="string">'\\includegraphics[scale=0.5]{%s_udiag%s}\n'</span>,M_.fname,int2str(i));
|
||||
0162 fprintf(fidTeX,<span class="string">'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n'</span>);
|
||||
0163 fprintf(fidTeX,<span class="string">'The first, second and third columns are respectively the criteria based on\n'</span>);
|
||||
0164 fprintf(fidTeX,<span class="string">'the eighty percent interval, the second and third moments.}'</span>);
|
||||
0165 fprintf(fidTeX,<span class="string">'\\label{Fig:UnivariateDiagnostics:%s}\n'</span>,int2str(i));
|
||||
0166 fprintf(fidTeX,<span class="string">'\\end{figure}\n'</span>);
|
||||
0167 fprintf(fidTeX,<span class="string">'\n'</span>);
|
||||
0168 <span class="keyword">end</span>
|
||||
0169 <span class="keyword">end</span>
|
||||
0170 reste = npar-k;
|
||||
0171 <span class="keyword">if</span> reste
|
||||
0172 <span class="keyword">if</span> reste == 1
|
||||
0173 nr = 3;
|
||||
0174 nc = 1;
|
||||
0175 <span class="keyword">elseif</span> reste == 2;
|
||||
0176 nr = 2;
|
||||
0177 nc = 3;
|
||||
0178 <span class="keyword">end</span>
|
||||
0179 <span class="keyword">if</span> TeX
|
||||
0180 NAMES = [];
|
||||
0181 TEXNAMES = [];
|
||||
0182 <span class="keyword">end</span>
|
||||
0183 <span class="keyword">if</span> options_.nograph
|
||||
0184 h = figure(<span class="string">'Name'</span>,<span class="string">'MCMC univariate diagnostic (Brooks and Gelman, 1998)'</span>,<span class="string">'Visible'</span>,<span class="string">'off'</span>);
|
||||
0185 <span class="keyword">else</span>
|
||||
0186 h = figure(<span class="string">'Name'</span>,<span class="string">'MCMC univariate diagnostic (Brooks and Gelman, 1998)'</span>);
|
||||
0187 <span class="keyword">end</span>
|
||||
0188 boxplot = 1;
|
||||
0189 <span class="keyword">for</span> j = 1:reste
|
||||
0190 k = k+1;
|
||||
0191 [nam,namtex] = <a href="get_the_name.html" class="code" title="function [nam,texnam] = get_the_name(k,TeX)">get_the_name</a>(k,TeX);
|
||||
0192 <span class="keyword">for</span> crit = 1:3
|
||||
0193 <span class="keyword">if</span> crit == 1
|
||||
0194 plt1 = UDIAG(:,1,k);
|
||||
0195 plt2 = UDIAG(:,2,k);
|
||||
0196 namnam = [nam , <span class="string">' (Interval)'</span>];
|
||||
0197 <span class="keyword">elseif</span> crit == 2
|
||||
0198 plt1 = UDIAG(:,3,k);
|
||||
0199 plt2 = UDIAG(:,4,k);
|
||||
0200 namnam = [nam , <span class="string">' (m2)'</span>];
|
||||
0201 <span class="keyword">elseif</span> crit == 3
|
||||
0202 plt1 = UDIAG(:,5,k);
|
||||
0203 plt2 = UDIAG(:,6,k);
|
||||
0204 namnam = [nam , <span class="string">' (m3)'</span>];
|
||||
0205 <span class="keyword">end</span>
|
||||
0206 <span class="keyword">if</span> TeX
|
||||
0207 NAMES = strvcat(NAMES,deblank(namnam));
|
||||
0208 TEXNAMES = strvcat(TEXNAMES,deblank(namtex));
|
||||
0209 <span class="keyword">end</span>
|
||||
0210 subplot(nr,nc,boxplot);
|
||||
0211 plot(xx,plt1,<span class="string">'-b'</span>); <span class="comment">% Pooled</span>
|
||||
0212 hold on;
|
||||
0213 plot(xx,plt2,<span class="string">'-r'</span>); <span class="comment">% Within (mean)</span>
|
||||
0214 hold off;
|
||||
0215 xlim([xx(1) xx(NumberOfLines)]);
|
||||
0216 title(namnam,<span class="string">'Interpreter'</span>,<span class="string">'none'</span>);
|
||||
0217 boxplot = boxplot + 1;
|
||||
0218 <span class="keyword">end</span>
|
||||
0219 <span class="keyword">end</span>
|
||||
0220 eval([<span class="string">'print -depsc2 '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_udiag'</span> int2str(pages+1)]);
|
||||
0221 eval([<span class="string">'print -dpdf '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_udiag'</span> int2str(pages+1)]);
|
||||
0222 <span class="keyword">if</span> options_.nograph, set(h,<span class="string">'visible'</span>,<span class="string">'on'</span>), <span class="keyword">end</span>
|
||||
0223 saveas(h,[DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_udiag'</span> int2str(pages+1) <span class="string">'.fig'</span>]);
|
||||
0224 <span class="keyword">if</span> options_.nograph, close(h), <span class="keyword">end</span>
|
||||
0225 <span class="keyword">if</span> TeX
|
||||
0226 fprintf(fidTeX,<span class="string">'\\begin{figure}[H]\n'</span>);
|
||||
0227 <span class="keyword">for</span> jj = 1:size(NAMES,1);
|
||||
0228 fprintf(fidTeX,<span class="string">'\\psfrag{%s}[1][][0.5][0]{%s}\n'</span>,deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
|
||||
0229 <span class="keyword">end</span>
|
||||
0230 fprintf(fidTeX,<span class="string">'\\centering \n'</span>);
|
||||
0231 fprintf(fidTeX,<span class="string">'\\includegraphics[scale=0.5]{%s_udiag%s}\n'</span>,M_.fname,int2str(pages+1));
|
||||
0232 <span class="keyword">if</span> reste == 2
|
||||
0233 fprintf(fidTeX,<span class="string">'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n'</span>);
|
||||
0234 fprintf(fidTeX,<span class="string">'The first, second and third columns are respectively the criteria based on\n'</span>);
|
||||
0235 fprintf(fidTeX,<span class="string">'the eighty percent interval, the second and third moments.}'</span>);
|
||||
0236 <span class="keyword">elseif</span> reste == 1
|
||||
0237 fprintf(fidTeX,<span class="string">'\\caption{Univariate convergence diagnostics for the Metropolis-Hastings.\n'</span>);
|
||||
0238 fprintf(fidTeX,<span class="string">'The first, second and third rows are respectively the criteria based on\n'</span>);
|
||||
0239 fprintf(fidTeX,<span class="string">'the eighty percent interval, the second and third moments.}'</span>);
|
||||
0240 <span class="keyword">end</span>
|
||||
0241 fprintf(fidTeX,<span class="string">'\\label{Fig:UnivariateDiagnostics:%s}\n'</span>,int2str(pages+1));
|
||||
0242 fprintf(fidTeX,<span class="string">'\\end{figure}\n'</span>);
|
||||
0243 fprintf(fidTeX,<span class="string">'\n'</span>);
|
||||
0244 fprintf(fidTeX,<span class="string">'% End Of TeX file.'</span>);
|
||||
0245 fclose(fidTeX);
|
||||
0246 <span class="keyword">end</span>
|
||||
0247 <span class="keyword">end</span> <span class="comment">% if reste > 0</span>
|
||||
0248 clear UDIAG;
|
||||
0249 <span class="comment">%%</span>
|
||||
0250 <span class="comment">%% Multivariate diagnostic.</span>
|
||||
0251 <span class="comment">%%</span>
|
||||
0252 <span class="keyword">if</span> TeX
|
||||
0253 fidTeX = fopen([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_MultivariateDiagnostics.TeX'</span>],<span class="string">'w'</span>);
|
||||
0254 fprintf(fidTeX,<span class="string">'%% TeX eps-loader file generated by McmcDiagnostics.m (Dynare).\n'</span>);
|
||||
0255 fprintf(fidTeX,[<span class="string">'%% '</span> datestr(now,0) <span class="string">'\n'</span>]);
|
||||
0256 fprintf(fidTeX,<span class="string">' \n'</span>);
|
||||
0257 NAMES = [];
|
||||
0258 <span class="keyword">end</span>
|
||||
0259 tmp = zeros(NumberOfDraws*nblck,3);
|
||||
0260 MDIAG = zeros(NumberOfLines,6);
|
||||
0261 <span class="keyword">for</span> b = 1:nblck
|
||||
0262 startline = 0;
|
||||
0263 <span class="keyword">for</span> n = 1:NumberOfMcFilesPerBlock-1
|
||||
0264 <span class="comment">%load([MhDirectoryName '/' mcfiles(n,1,b).name],'logpo2');</span>
|
||||
0265 load([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh'</span>,int2str(n),<span class="string">'_blck'</span> int2str(b) <span class="string">'.mat'</span>],<span class="string">'logpo2'</span>);
|
||||
0266 tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+MAX_nruns*n,1) = logpo2;
|
||||
0267 startline = startline+MAX_nruns;
|
||||
0268 <span class="keyword">end</span>
|
||||
0269 <span class="comment">%load([MhDirectoryName '/' mcfiles(NumberOfMcFilesPerBlock,1,b).name],'logpo2');</span>
|
||||
0270 load([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh'</span>,int2str(NumberOfMcFilesPerBlock),<span class="string">'_blck'</span> int2str(b) <span class="string">'.mat'</span>],<span class="string">'logpo2'</span>);
|
||||
0271 tmp((b-1)*NumberOfDraws+startline+1:(b-1)*NumberOfDraws+ MAX_nruns*(LastFileNumber-1)+LastLineNumber,1) = logpo2;
|
||||
0272 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> 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));<span class="comment">%% Pooled mean.</span>
|
||||
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 <span class="keyword">for</span> 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); <span class="comment">%% Within mean.</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0298 <span class="keyword">end</span>
|
||||
0299 MDIAG(:,[2 4 6],:) = MDIAG(:,[2 4 6],:)/nblck;
|
||||
0300 <span class="keyword">if</span> options_.nograph
|
||||
0301 h = figure(<span class="string">'Name'</span>,<span class="string">'Multivatiate diagnostic'</span>,<span class="string">'Visible'</span>,<span class="string">'off'</span>);
|
||||
0302 <span class="keyword">else</span>
|
||||
0303 h = figure(<span class="string">'Name'</span>,<span class="string">'Multivatiate diagnostic'</span>);
|
||||
0304 <span class="keyword">end</span>
|
||||
0305 boxplot = 1;
|
||||
0306 <span class="keyword">for</span> crit = 1:3
|
||||
0307 <span class="keyword">if</span> crit == 1
|
||||
0308 plt1 = MDIAG(:,1);
|
||||
0309 plt2 = MDIAG(:,2);
|
||||
0310 namnam = <span class="string">'Interval'</span>;
|
||||
0311 <span class="keyword">elseif</span> crit == 2
|
||||
0312 plt1 = MDIAG(:,3);
|
||||
0313 plt2 = MDIAG(:,4);
|
||||
0314 namnam = <span class="string">'m2'</span>;
|
||||
0315 <span class="keyword">elseif</span> crit == 3
|
||||
0316 plt1 = MDIAG(:,5);
|
||||
0317 plt2 = MDIAG(:,6);
|
||||
0318 namnam = <span class="string">'m3'</span>;
|
||||
0319 <span class="keyword">end</span>
|
||||
0320 <span class="keyword">if</span> TeX
|
||||
0321 NAMES = strvcat(NAMES,namnam);
|
||||
0322 <span class="keyword">end</span>
|
||||
0323 subplot(3,1,boxplot);
|
||||
0324 plot(xx,plt1,<span class="string">'-b'</span>); <span class="comment">% Pooled</span>
|
||||
0325 hold on
|
||||
0326 plot(xx,plt2,<span class="string">'-r'</span>); <span class="comment">% Within (mean)</span>
|
||||
0327 hold off
|
||||
0328 xlim([xx(1) xx(NumberOfLines)])
|
||||
0329 title(namnam,<span class="string">'Interpreter'</span>,<span class="string">'none'</span>);
|
||||
0330 boxplot = boxplot + 1;
|
||||
0331 <span class="keyword">end</span>
|
||||
0332 eval([<span class="string">'print -depsc2 '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mdiag'</span>]);
|
||||
0333 eval([<span class="string">'print -dpdf '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mdiag'</span>]);
|
||||
0334 <span class="keyword">if</span> options_.nograph, set(h,<span class="string">'visible'</span>,<span class="string">'on'</span>), <span class="keyword">end</span>
|
||||
0335 saveas(h,[DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mdiag.fig'</span>]);
|
||||
0336 <span class="keyword">if</span> options_.nograph, close(h), <span class="keyword">end</span>
|
||||
0337 <span class="keyword">if</span> TeX
|
||||
0338 fprintf(fidTeX,<span class="string">'\\begin{figure}[H]\n'</span>);
|
||||
0339 <span class="keyword">for</span> jj = 1:3
|
||||
0340 fprintf(fidTeX,<span class="string">'\\psfrag{%s}[1][][0.5][0]{%s}\n'</span>,deblank(NAMES(jj,:)),<span class="string">' '</span>);
|
||||
0341 <span class="keyword">end</span>
|
||||
0342 fprintf(fidTeX,<span class="string">'\\centering \n'</span>);
|
||||
0343 fprintf(fidTeX,<span class="string">'\\includegraphics[scale=0.5]{%s_mdiag}\n'</span>,M_.fname);
|
||||
0344 fprintf(fidTeX,<span class="string">'\\caption{Multivariate convergence diagnostics for the Metropolis-Hastings.\n'</span>);
|
||||
0345 fprintf(fidTeX,<span class="string">'The first, second and third rows are respectively the criteria based on\n'</span>);
|
||||
0346 fprintf(fidTeX,<span class="string">'the eighty percent interval, the second and third moments. The different \n'</span>);
|
||||
0347 fprintf(fidTeX,<span class="string">'parameters are aggregated using the posterior kernel.}'</span>);
|
||||
0348 fprintf(fidTeX,<span class="string">'\\label{Fig:MultivariateDiagnostics}\n'</span>);
|
||||
0349 fprintf(fidTeX,<span class="string">'\\end{figure}\n'</span>);
|
||||
0350 fprintf(fidTeX,<span class="string">'\n'</span>);
|
||||
0351 fprintf(fidTeX,<span class="string">'% End Of TeX file.'</span>);
|
||||
0352 fclose(fidTeX);
|
||||
0353 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,178 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of PlotPosteriorDistributions</title>
|
||||
<meta name="keywords" content="PlotPosteriorDistributions">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-09-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > PlotPosteriorDistributions.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>PlotPosteriorDistributions
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-09-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function PlotPosteriorDistributions() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-09-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="draw_prior_density.html" class="code" title="function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);">draw_prior_density</a> stephane.adjemian@ens.fr [07-15-2004]</li><li><a href="get_the_name.html" class="code" title="function [nam,texnam] = get_the_name(k,TeX)">get_the_name</a> stephane.adjemian@cepremap.cnrs.fr [07-13-2004]</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function PlotPosteriorDistributions()</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-09-2005]</span>
|
||||
0003 <span class="keyword">global</span> estim_params_ M_ options_ bayestopt_ oo_
|
||||
0004
|
||||
0005 OutputDirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'Output'</span>);
|
||||
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;<span class="comment">% The square root must be an integer!</span>
|
||||
0017 nn = sqrt(MaxNumberOfPlotPerFigure);
|
||||
0018
|
||||
0019 figurename = <span class="string">'Priors and posteriors'</span>;
|
||||
0020
|
||||
0021 <span class="keyword">if</span> TeX
|
||||
0022 fidTeX = fopen([OutputDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_PriorsAndPosteriors.TeX'</span>],<span class="string">'w'</span>);
|
||||
0023 fprintf(fidTeX,<span class="string">'%% TeX eps-loader file generated by PlotPosteriorDistributions.m (Dynare).\n'</span>);
|
||||
0024 fprintf(fidTeX,[<span class="string">'%% '</span> datestr(now,0) <span class="string">'\n'</span>]);
|
||||
0025 fprintf(fidTeX,<span class="string">' \n'</span>);
|
||||
0026 <span class="keyword">end</span>
|
||||
0027
|
||||
0028 figunumber = 0;
|
||||
0029 subplotnum = 0;
|
||||
0030
|
||||
0031 <span class="keyword">for</span> i=1:npar
|
||||
0032 subplotnum = subplotnum+1;
|
||||
0033 <span class="keyword">if</span> subplotnum == 1
|
||||
0034 figunumber = figunumber+1;
|
||||
0035 <span class="keyword">if</span> options_.nograph
|
||||
0036 hfig = figure(<span class="string">'Name'</span>,figurename,<span class="string">'Visible'</span>,<span class="string">'off'</span>);
|
||||
0037 <span class="keyword">else</span>
|
||||
0038 hfig = figure(<span class="string">'Name'</span>,figurename);
|
||||
0039 <span class="keyword">end</span>
|
||||
0040 <span class="keyword">end</span>
|
||||
0041 <span class="keyword">if</span> subplotnum == 1
|
||||
0042 <span class="keyword">if</span> TeX
|
||||
0043 TeXNAMES = [];
|
||||
0044 <span class="keyword">end</span>
|
||||
0045 NAMES = [];
|
||||
0046 <span class="keyword">end</span>
|
||||
0047 [nam,texnam] = <a href="get_the_name.html" class="code" title="function [nam,texnam] = get_the_name(k,TeX)">get_the_name</a>(i,TeX);
|
||||
0048 NAMES = strvcat(NAMES,nam);
|
||||
0049 <span class="keyword">if</span> TeX
|
||||
0050 TeXNAMES = strvcat(TeXNAMES,texnam);
|
||||
0051 <span class="keyword">end</span>
|
||||
0052 [x2,f2,abscissa,dens,binf2,bsup2] = <a href="draw_prior_density.html" class="code" title="function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);">draw_prior_density</a>(i);
|
||||
0053 top2 = max(f2);
|
||||
0054 <span class="keyword">if</span> i <= nvx
|
||||
0055 name = deblank(M_.exo_names(estim_params_.var_exo(i,1),:));
|
||||
0056 eval([<span class="string">'x1 = oo_.posterior_density.shocks_std.'</span> name <span class="string">'(:,1);'</span>])
|
||||
0057 eval([<span class="string">'f1 = oo_.posterior_density.shocks_std.'</span> name <span class="string">'(:,2);'</span>])
|
||||
0058 eval([<span class="string">'pmode = oo_.posterior_mode.shocks_std.'</span> name <span class="string">';'</span>])
|
||||
0059 <span class="keyword">elseif</span> i <= nvx+nvn
|
||||
0060 name = deblank(options_.varobs(estim_params_.var_endo(i-nvx,1),:));
|
||||
0061 eval([<span class="string">'x1 = oo_.posterior_density.measurement_errors_std.'</span> name <span class="string">'(:,1);'</span>])
|
||||
0062 eval([<span class="string">'f1 = oo_.posterior_density.measurement_errors_std.'</span> name <span class="string">'(:,2);'</span>])
|
||||
0063 eval([<span class="string">'pmode = oo_.posterior_mode.measurement_errors_std.'</span> name <span class="string">';'</span>])
|
||||
0064 <span class="keyword">elseif</span> 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,:)) <span class="string">'_'</span> deblank(M_.exo_names(k2,:))];
|
||||
0069 eval([<span class="string">'x1 = oo_.posterior_density.shocks_corr.'</span> name <span class="string">'(:,1);'</span>])
|
||||
0070 eval([<span class="string">'f1 = oo_.posterior_density.shocks_corr.'</span> name <span class="string">'(:,2);'</span>])
|
||||
0071 eval([<span class="string">'pmode = oo_.posterior_mode.shocks_corr.'</span> name <span class="string">';'</span>])
|
||||
0072 <span class="keyword">elseif</span> 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,:)) <span class="string">'_'</span> deblank(M_.endo_names(k2,:))];
|
||||
0077 eval([<span class="string">'x1 = oo_.posterior_density.measurement_errors_corr.'</span> name <span class="string">'(:,1);'</span>])
|
||||
0078 eval([<span class="string">'f1 = oo_.posterior_density.measurement_errors_corr.'</span> name <span class="string">'(:,2);'</span>])
|
||||
0079 eval([<span class="string">'pmode = oo_.posterior_mode.measurement_errors_corr.'</span> name <span class="string">';'</span>])
|
||||
0080 <span class="keyword">else</span>
|
||||
0081 j = i - (nvx+nvn+ncx+ncn);
|
||||
0082 name = deblank(M_.param_names(estim_params_.param_vals(j,1),:));
|
||||
0083 eval([<span class="string">'x1 = oo_.posterior_density.'</span> name <span class="string">'(:,1);'</span>])
|
||||
0084 eval([<span class="string">'f1 = oo_.posterior_density.'</span> name <span class="string">'(:,2);'</span>])
|
||||
0085 eval([<span class="string">'pmode = oo_.posterior_mode.parameters.'</span> name <span class="string">';'</span>])
|
||||
0086 <span class="keyword">end</span>
|
||||
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,<span class="string">'-k'</span>,<span class="string">'linewidth'</span>,2);
|
||||
0095 set(hh,<span class="string">'color'</span>,[0.7 0.7 0.7]);
|
||||
0096 hold on;
|
||||
0097 plot(x1,f1,<span class="string">'-k'</span>,<span class="string">'linewidth'</span>,2);
|
||||
0098 plot( [pmode pmode], [0.0 1.1*top0], <span class="string">'--g'</span>, <span class="string">'linewidth'</span>, 2);
|
||||
0099 box on;
|
||||
0100 axis([borneinf bornesup 0 1.1*top0]);
|
||||
0101 title(nam,<span class="string">'Interpreter'</span>,<span class="string">'none'</span>);
|
||||
0102 hold off;
|
||||
0103 drawnow
|
||||
0104 <span class="keyword">if</span> subplotnum == MaxNumberOfPlotPerFigure | i == npar;
|
||||
0105 eval([<span class="string">'print -depsc2 '</span> OutputDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_PriorsAndPosteriors'</span> int2str(figunumber)]);
|
||||
0106 eval([<span class="string">'print -dpdf '</span> OutputDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_PriorsAndPosteriors'</span> int2str(figunumber)]);
|
||||
0107 <span class="keyword">if</span> options_.nograph,
|
||||
0108 set(hfig,<span class="string">'Visible'</span>,<span class="string">'on'</span>);
|
||||
0109 <span class="keyword">end</span>
|
||||
0110 saveas(hfig,[OutputDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_PriorsAndPosteriors'</span> int2str(figunumber) <span class="string">'.fig'</span>]);
|
||||
0111 <span class="keyword">if</span> TeX
|
||||
0112 fprintf(fidTeX,<span class="string">'\\begin{figure}[H]\n'</span>);
|
||||
0113 <span class="keyword">for</span> j = 1:size(NAMES,1)
|
||||
0114 fprintf(fidTeX,<span class="string">'\\psfrag{%s}[1][][0.5][0]{%s}\n'</span>,deblank(NAMES(j,:)),deblank(TeXNAMES(j,:)));
|
||||
0115 <span class="keyword">end</span>
|
||||
0116 fprintf(fidTeX,<span class="string">'\\centering\n'</span>);
|
||||
0117 fprintf(fidTeX,<span class="string">'\\includegraphics[scale=0.5]{%s_PriorsAndPosteriors%s}\n'</span>,M_.fname,int2str(figunumber));
|
||||
0118 fprintf(fidTeX,<span class="string">'\\caption{Priors and posteriors.}'</span>);
|
||||
0119 fprintf(fidTeX,<span class="string">'\\label{Fig:PriorsAndPosteriors:%s}\n'</span>,int2str(figunumber));
|
||||
0120 fprintf(fidTeX,<span class="string">'\\end{figure}\n'</span>);
|
||||
0121 fprintf(fidTeX,<span class="string">' \n'</span>);
|
||||
0122 <span class="keyword">if</span> i == npar
|
||||
0123 fprintf(fidTeX,<span class="string">'%% End of TeX file.\n'</span>);
|
||||
0124 fclose(fidTeX);
|
||||
0125 <span class="keyword">end</span>
|
||||
0126 <span class="keyword">end</span>
|
||||
0127 <span class="keyword">if</span> options_.nograph,
|
||||
0128 close(hfig),
|
||||
0129 <span class="keyword">end</span>
|
||||
0130 subplotnum = 0;
|
||||
0131 <span class="keyword">end</span>
|
||||
0132 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,288 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of PosteriorIRF</title>
|
||||
<meta name="keywords" content="PosteriorIRF">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-25-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > PosteriorIRF.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>PosteriorIRF
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-25-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function PosteriorIRF(type) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-25-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="GetOneDraw.html" class="code" title="function [xparams, logpost] = GetOneDraw(type)">GetOneDraw</a> stephane.adjemian@ens.fr [09-25-2005]</li><li><a href="ReshapeMatFiles.html" class="code" title="function ReshapeMatFiles(type)">ReshapeMatFiles</a> Reshape and sort (along the mcmc simulations) the mat files generated</li><li><a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> </li><li><a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li><li><a href="set_parameters.html" class="code" title="function set_parameters(xparam1)">set_parameters</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function PosteriorIRF(type)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-25-2005]</span>
|
||||
0003 <span class="keyword">global</span> 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 <span class="comment">%%</span>
|
||||
0012 MaxNumberOfPlotPerFigure = 9;<span class="comment">% The square root must be an integer!</span>
|
||||
0013 nn = sqrt(MaxNumberOfPlotPerFigure);
|
||||
0014 DirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'Output'</span>);
|
||||
0015 <span class="keyword">if</span> strcmpi(type,<span class="string">'posterior'</span>)
|
||||
0016 MhDirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0017 <span class="keyword">else</span>
|
||||
0018 MhDirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'prior'</span>);
|
||||
0019 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> strcmpi(type,<span class="string">'posterior'</span>)
|
||||
0024 load([ MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh_history'</span>])
|
||||
0025 TotalNumberOfMhDraws = sum(record.MhDraws(:,1));
|
||||
0026 NumberOfDraws = TotalNumberOfMhDraws-floor(options_.mh_drop*TotalNumberOfMhDraws);
|
||||
0027 <span class="keyword">else</span><span class="comment">% type = 'prior'</span>
|
||||
0028 NumberOfDraws = 500;
|
||||
0029 <span class="keyword">end</span>
|
||||
0030 B = min([round(.5*NumberOfDraws),500]); options_.B = B;
|
||||
0031 <span class="keyword">try</span> delete([MhDirectoryName <span class="string">'\'</span> M_.fname <span class="string">'_IRFs*'</span>]);
|
||||
0032 <span class="keyword">catch</span> disp(<span class="string">'No _IRFs files to be deleted!'</span>)
|
||||
0033 <span class="keyword">end</span>
|
||||
0034 irun = 0;
|
||||
0035 irun2 = 0;
|
||||
0036 NumberOfIRFfiles = 1;
|
||||
0037 ifil2 = 1;
|
||||
0038 <span class="keyword">if</span> strcmpi(type,<span class="string">'posterior'</span>)
|
||||
0039 h = waitbar(0,<span class="string">'Bayesian (posterior) IRFs...'</span>);
|
||||
0040 <span class="keyword">else</span>
|
||||
0041 h = waitbar(0,<span class="string">'Bayesian (prior) IRFs...'</span>);
|
||||
0042 <span class="keyword">end</span>
|
||||
0043 <span class="keyword">if</span> B <= MAX_nruns
|
||||
0044 stock_param = zeros(B, npar);
|
||||
0045 <span class="keyword">else</span>
|
||||
0046 stock_param = zeros(MAX_nruns, npar);
|
||||
0047 <span class="keyword">end</span>
|
||||
0048 <span class="keyword">if</span> B >= MAX_nirfs
|
||||
0049 stock_irf = zeros(options_.irf,M_.endo_nbr,M_.exo_nbr,MAX_nirfs);
|
||||
0050 <span class="keyword">else</span>
|
||||
0051 stock_irf = zeros(options_.irf,M_.endo_nbr,M_.exo_nbr,B);
|
||||
0052 <span class="keyword">end</span>
|
||||
0053 <span class="keyword">for</span> b=1:B
|
||||
0054 irun = irun+1;
|
||||
0055 irun2 = irun2+1;
|
||||
0056 deep = <a href="GetOneDraw.html" class="code" title="function [xparams, logpost] = GetOneDraw(type)">GetOneDraw</a>(type);
|
||||
0057 stock_param(irun2,:) = deep;
|
||||
0058 <a href="set_parameters.html" class="code" title="function set_parameters(xparam1)">set_parameters</a>(deep);
|
||||
0059 dr = <a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a>(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 <span class="keyword">for</span> i = 1:M_.exo_nbr
|
||||
0063 <span class="keyword">if</span> SS(i,i) > 1e-13
|
||||
0064 y=<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>(dr,SS(M_.exo_names_orig_ord,i), options_.irf, options_.drop,options_.replic,options_.order);
|
||||
0065 <span class="keyword">if</span> options_.relative_irf
|
||||
0066 y = 100*y/cs(i,i);
|
||||
0067 <span class="keyword">end</span>
|
||||
0068 <span class="keyword">for</span> j = 1:M_.endo_nbr
|
||||
0069 <span class="keyword">if</span> max(y(j,:)) - min(y(j,:)) > 1e-10
|
||||
0070 stock_irf(:,j,i,irun) = transpose(y(j,:));
|
||||
0071 <span class="keyword">end</span>
|
||||
0072 <span class="keyword">end</span>
|
||||
0073 <span class="keyword">end</span>
|
||||
0074 <span class="keyword">end</span>
|
||||
0075 <span class="keyword">if</span> irun == MAX_nirfs | irun == B | b == B
|
||||
0076 <span class="keyword">if</span> b == B
|
||||
0077 stock_irf = stock_irf(:,:,:,1:irun);
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 save([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_irf'</span> int2str(NumberOfIRFfiles)],<span class="string">'stock_irf'</span>);
|
||||
0080 NumberOfIRFfiles = NumberOfIRFfiles+1;
|
||||
0081 irun = 0;
|
||||
0082 <span class="keyword">end</span>
|
||||
0083 <span class="keyword">if</span> irun2 > MAX_nruns | b == B
|
||||
0084 <span class="keyword">if</span> b == B
|
||||
0085 stock_param = stock_param(1:irun2,:);
|
||||
0086 <span class="keyword">end</span>
|
||||
0087 stock = stock_param;
|
||||
0088 save([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_param_irf'</span> int2str(ifil2)],<span class="string">'stock'</span>);
|
||||
0089 ifil2 = ifil2 + 1;
|
||||
0090 irun2 = 1;
|
||||
0091 <span class="keyword">end</span>
|
||||
0092 waitbar(b/B,h);
|
||||
0093 <span class="keyword">end</span>
|
||||
0094 NumberOfIRFfiles = NumberOfIRFfiles-1;
|
||||
0095 ifil2 = ifil2-1;
|
||||
0096 close(h);
|
||||
0097
|
||||
0098 <a href="ReshapeMatFiles.html" class="code" title="function ReshapeMatFiles(type)">ReshapeMatFiles</a>(<span class="string">'irf'</span>)
|
||||
0099
|
||||
0100 varlist = options_.varlist;
|
||||
0101 <span class="keyword">if</span> isempty(varlist)
|
||||
0102 varlist = M_.endo_names;
|
||||
0103 SelecVariables = transpose(1:M_.endo_nbr);
|
||||
0104 nvar = M_.endo_nbr;
|
||||
0105 <span class="keyword">else</span>
|
||||
0106 nvar = size(varlist,1);
|
||||
0107 SelecVariables = [];
|
||||
0108 <span class="keyword">for</span> i=1:nvar
|
||||
0109 <span class="keyword">if</span> ~isempty(strmatch(varlist(i,:),M_.endo_names,<span class="string">'exact'</span>))
|
||||
0110 SelecVariables = [SelecVariables;strmatch(varlist(i,:),M_.endo_names,<span class="string">'exact'</span>)];
|
||||
0111 <span class="keyword">end</span>
|
||||
0112 <span class="keyword">end</span>
|
||||
0113 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> options_.TeX
|
||||
0122 varlist_TeX = [];
|
||||
0123 <span class="keyword">for</span> i=1:nvar
|
||||
0124 varlist_TeX = strvcat(varlist_TeX,M_.endo_names_tex(SelecVariables(i),:));
|
||||
0125 <span class="keyword">end</span>
|
||||
0126 <span class="keyword">end</span>
|
||||
0127
|
||||
0128 fprintf(<span class="string">'MH: Posterior IRFs...\n'</span>);
|
||||
0129 tit(M_.exo_names_orig_ord,:) = M_.exo_names;
|
||||
0130 kdx = 0;
|
||||
0131 <span class="keyword">for</span> file = 1:NumberOfIRFfiles
|
||||
0132 load([MhDirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_IRFs'</span> int2str(file)]);
|
||||
0133 <span class="keyword">for</span> i = 1:M_.exo_nbr
|
||||
0134 <span class="keyword">for</span> j = 1:nvar
|
||||
0135 <span class="keyword">for</span> 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)] = <span class="keyword">...</span>
|
||||
0138 <a href="posterior_moments.html" class="code" title="function [post_mean, post_median, post_var, hpd_interval, post_deciles, density] = posterior_moments(xx,info)">posterior_moments</a>(squeeze(STOCK_IRF(k,SelecVariables(j),i,:)),0);
|
||||
0139 <span class="keyword">end</span>
|
||||
0140 <span class="keyword">end</span>
|
||||
0141 <span class="keyword">end</span>
|
||||
0142 kdx = kdx + size(STOCK_IRF,1);
|
||||
0143 <span class="keyword">end</span>
|
||||
0144 clear STOCK_IRF;
|
||||
0145
|
||||
0146 <span class="keyword">for</span> i = 1:M_.exo_nbr
|
||||
0147 <span class="keyword">for</span> j = 1:nvar
|
||||
0148 name = [deblank(M_.endo_names(SelecVariables(j),:)) <span class="string">'_'</span> deblank(tit(i,:))];
|
||||
0149 eval([<span class="string">'oo_.PosteriorIRF.Mean.'</span> name <span class="string">' = MeanIRF(:,j,i);'</span>]);
|
||||
0150 eval([<span class="string">'oo_.PosteriorIRF.Median.'</span> name <span class="string">' = MedianIRF(:,j,i);'</span>]);
|
||||
0151 eval([<span class="string">'oo_.PosteriorIRF.Var.'</span> name <span class="string">' = VarIRF(:,j,i);'</span>]);
|
||||
0152 eval([<span class="string">'oo_.PosteriorIRF.Distribution.'</span> name <span class="string">' = DistribIRF(:,:,j,i);'</span>]);
|
||||
0153 eval([<span class="string">'oo_.PosteriorIRF.HPDinf.'</span> name <span class="string">' = HPDIRF(:,1,j,i);'</span>]);
|
||||
0154 eval([<span class="string">'oo_.PosteriorIRF.HPDsup.'</span> name <span class="string">' = HPDIRF(:,2,j,i);'</span>]);
|
||||
0155 <span class="keyword">end</span>
|
||||
0156 <span class="keyword">end</span>
|
||||
0157 <span class="comment">%%</span>
|
||||
0158 <span class="comment">%% Finally i build the plots.</span>
|
||||
0159 <span class="comment">%%</span>
|
||||
0160 <span class="keyword">if</span> options_.TeX
|
||||
0161 fidTeX = fopen([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_BayesianIRF.TeX'</span>],<span class="string">'w'</span>);
|
||||
0162 fprintf(fidTeX,<span class="string">'%% TeX eps-loader file generated by PosteriorIRF.m (Dynare).\n'</span>);
|
||||
0163 fprintf(fidTeX,[<span class="string">'%% '</span> datestr(now,0) <span class="string">'\n'</span>]);
|
||||
0164 fprintf(fidTeX,<span class="string">' \n'</span>);
|
||||
0165 titTeX(M_.exo_names_orig_ord,:) = M_.exo_names_tex;
|
||||
0166 <span class="keyword">end</span>
|
||||
0167 <span class="comment">%%</span>
|
||||
0168 subplotnum = 0;
|
||||
0169 <span class="keyword">for</span> i=1:M_.exo_nbr
|
||||
0170 NAMES = [];
|
||||
0171 <span class="keyword">if</span> options_.TeX
|
||||
0172 TEXNAMES = [];
|
||||
0173 <span class="keyword">end</span>
|
||||
0174 figunumber = 0;
|
||||
0175 <span class="keyword">for</span> j=1:nvar
|
||||
0176 <span class="keyword">if</span> max(abs(MeanIRF(:,j,i))) > 10^(-6)
|
||||
0177 subplotnum = subplotnum+1;
|
||||
0178 <span class="keyword">if</span> options_.nograph
|
||||
0179 <span class="keyword">if</span> subplotnum == 1 & options_.relative_irf
|
||||
0180 hh = figure(<span class="string">'Name'</span>,[<span class="string">'Relative response to orthogonalized shock to '</span> tit(i,:)],<span class="string">'Visible'</span>,<span class="string">'off'</span>);
|
||||
0181 <span class="keyword">elseif</span> subplotnum == 1 & ~options_.relative_irf
|
||||
0182 hh = figure(<span class="string">'Name'</span>,[<span class="string">'Orthogonalized shock to '</span> tit(i,:)],<span class="string">'Visible'</span>,<span class="string">'off'</span>);
|
||||
0183 <span class="keyword">end</span>
|
||||
0184 <span class="keyword">else</span>
|
||||
0185 <span class="keyword">if</span> subplotnum == 1 & options_.relative_irf
|
||||
0186 hh = figure(<span class="string">'Name'</span>,[<span class="string">'Relative response to orthogonalized shock to '</span> tit(i,:)]);
|
||||
0187 <span class="keyword">elseif</span> subplotnum == 1 & ~options_.relative_irf
|
||||
0188 hh = figure(<span class="string">'Name'</span>,[<span class="string">'Orthogonalized shock to '</span> tit(i,:)]);
|
||||
0189 <span class="keyword">end</span>
|
||||
0190 <span class="keyword">end</span>
|
||||
0191 set(0,<span class="string">'CurrentFigure'</span>,hh)
|
||||
0192 subplot(nn,nn,subplotnum);
|
||||
0193 plot([1 options_.irf],[0 0],<span class="string">'-r'</span>,<span class="string">'linewidth'</span>,0.5);
|
||||
0194 hold on
|
||||
0195 <span class="keyword">for</span> k = 1:9
|
||||
0196 plot(1:options_.irf,DistribIRF(:,k,j,i),<span class="string">'-g'</span>,<span class="string">'linewidth'</span>,0.5)
|
||||
0197 <span class="keyword">end</span>
|
||||
0198 plot(1:options_.irf,MeanIRF(:,j,i),<span class="string">'-k'</span>,<span class="string">'linewidth'</span>,1)
|
||||
0199 xlim([1 options_.irf]);
|
||||
0200 hold off
|
||||
0201 name = deblank(varlist(j,:));
|
||||
0202 NAMES = strvcat(NAMES,name);
|
||||
0203 <span class="keyword">if</span> options_.TeX
|
||||
0204 texname = deblank(varlist_TeX(j,:));
|
||||
0205 TEXNAMES = strvcat(TEXNAMES,[<span class="string">'$'</span> texname <span class="string">'$'</span>]);
|
||||
0206 <span class="keyword">end</span>
|
||||
0207 title(name,<span class="string">'Interpreter'</span>,<span class="string">'none'</span>)
|
||||
0208 <span class="keyword">end</span>
|
||||
0209 <span class="keyword">if</span> subplotnum == MaxNumberOfPlotPerFigure | (j == nvar & subplotnum>0)
|
||||
0210 figunumber = figunumber+1;
|
||||
0211 set(hh,<span class="string">'visible'</span>,<span class="string">'on'</span>)
|
||||
0212 eval([<span class="string">'print -depsc2 '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_Bayesian_IRF_'</span> deblank(tit(i,:)) <span class="string">'_'</span> int2str(figunumber)]);
|
||||
0213 eval([<span class="string">'print -dpdf '</span> DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_Bayesian_IRF_'</span> deblank(tit(i,:)) <span class="string">'_'</span> int2str(figunumber)]);
|
||||
0214 saveas(hh,[DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_Bayesian_IRF_'</span> deblank(tit(i,:)) <span class="string">'_'</span> int2str(figunumber) <span class="string">'.fig'</span>]);
|
||||
0215 set(hh,<span class="string">'visible'</span>,<span class="string">'off'</span>)
|
||||
0216 <span class="keyword">if</span> options_.nograph, close(hh), <span class="keyword">end</span>
|
||||
0217 <span class="keyword">if</span> options_.TeX
|
||||
0218 fprintf(fidTeX,<span class="string">'\\begin{figure}[H]\n'</span>);
|
||||
0219 <span class="keyword">for</span> jj = 1:size(TEXNAMES,1)
|
||||
0220 fprintf(fidTeX,[<span class="string">'\\psfrag{%s}[1][][0.5][0]{%s}\n'</span>],deblank(NAMES(jj,:)),deblank(TEXNAMES(jj,:)));
|
||||
0221 <span class="keyword">end</span>
|
||||
0222 fprintf(fidTeX,<span class="string">'\\centering \n'</span>);
|
||||
0223 fprintf(fidTeX,<span class="string">'\\includegraphics[scale=0.5]{%s_Bayesian_IRF_%s}\n'</span>,M_.fname,deblank(tit(i,:)));
|
||||
0224 <span class="keyword">if</span> options_.relative_irf
|
||||
0225 fprintf(fidTeX,[<span class="string">'\\caption{Bayesian relative IRF.}'</span>]);
|
||||
0226 <span class="keyword">else</span>
|
||||
0227 fprintf(fidTeX,<span class="string">'\\caption{Bayesian IRF.}'</span>);
|
||||
0228 <span class="keyword">end</span>
|
||||
0229 fprintf(fidTeX,<span class="string">'\\label{Fig:BayesianIRF:%s}\n'</span>,deblank(tit(i,:)));
|
||||
0230 fprintf(fidTeX,<span class="string">'\\end{figure}\n'</span>);
|
||||
0231 fprintf(fidTeX,<span class="string">' \n'</span>);
|
||||
0232 <span class="keyword">end</span>
|
||||
0233 subplotnum = 0;
|
||||
0234 <span class="keyword">end</span>
|
||||
0235 <span class="keyword">end</span><span class="comment">% loop over selected endo_var</span>
|
||||
0236 <span class="keyword">end</span><span class="comment">% loop over exo_var</span>
|
||||
0237 <span class="comment">%%</span>
|
||||
0238 <span class="keyword">if</span> options_.TeX
|
||||
0239 fprintf(fidTeX,<span class="string">'%% End of TeX file.\n'</span>);
|
||||
0240 fclose(fidTeX);
|
||||
0241 <span class="keyword">end</span>
|
||||
0242 fprintf(<span class="string">'MH: Posterior IRFs, done!\n'</span>);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,228 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of PosteriorSmoother</title>
|
||||
<meta name="keywords" content="PosteriorSmoother">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [09-25-2005]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > PosteriorSmoother.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>PosteriorSmoother
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [09-25-2005]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function PosteriorSmoother(Y,gend, type) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [09-25-2005]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li><li><a href="GetOneDraw.html" class="code" title="function [xparams, logpost] = GetOneDraw(type)">GetOneDraw</a> stephane.adjemian@ens.fr [09-25-2005]</li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li><li><a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function PosteriorSmoother(Y,gend, type)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [09-25-2005]</span>
|
||||
0003 <span class="keyword">global</span> 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 <span class="comment">%%</span>
|
||||
0014 MaxNumberOfPlotPerFigure = 4;<span class="comment">% The square root must be an integer!</span>
|
||||
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 <span class="comment">%%</span>
|
||||
0021 <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'Plots/'</span>);
|
||||
0022 DirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0023 load([ DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_mh_history'</span>])
|
||||
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 <span class="comment">%%</span>
|
||||
0036 B = round(0.25*NumberOfDraws);
|
||||
0037 <span class="comment">%%</span>
|
||||
0038 varlist = options_.varlist;
|
||||
0039 <span class="keyword">if</span> isempty(varlist)
|
||||
0040 varlist = M_.endo_names;
|
||||
0041 SelecVariables = transpose(1:M_.endo_nbr);
|
||||
0042 nvar = M_.endo_nbr;
|
||||
0043 <span class="keyword">else</span>
|
||||
0044 nvar = size(varlist,1);
|
||||
0045 SelecVariables = [];
|
||||
0046 <span class="keyword">for</span> i=1:nvar
|
||||
0047 <span class="keyword">if</span> ~isempty(strmatch(varlist(i,:),M_.endo_names,<span class="string">'exact'</span>))
|
||||
0048 SelecVariables = [SelecVariables;strmatch(varlist(i,:),M_.endo_names,<span class="string">'exact'</span>)];
|
||||
0049 <span class="keyword">end</span>
|
||||
0050 <span class="keyword">end</span>
|
||||
0051 <span class="keyword">end</span>
|
||||
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,<span class="string">'Bayesian smoother...'</span>);
|
||||
0064 <span class="keyword">if</span> B <= MAX_nruns
|
||||
0065 stock_param = zeros(B, npar);
|
||||
0066 stock_logpo = zeros(B,1);
|
||||
0067 stock_ys = zeros(B,endo_nbr);
|
||||
0068 <span class="keyword">else</span>
|
||||
0069 stock_param = zeros(MAX_nruns, npar);
|
||||
0070 stock_logpo = zeros(MAX_nruns,1);
|
||||
0071 stock_ys = zeros(MAX_nruns,endo_nbr);
|
||||
0072 <span class="keyword">end</span>
|
||||
0073 <span class="keyword">if</span> options_.smoother
|
||||
0074 <span class="keyword">if</span> B <= MAX_nsmoo
|
||||
0075 stock_smooth = zeros(endo_nbr,gend,B);
|
||||
0076 <span class="keyword">else</span>
|
||||
0077 stock_smooth = zeros(endo_nbr,gend,MAX_nsmoo);
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 <span class="keyword">if</span> B <= MAX_ninno
|
||||
0080 stock_innov = zeros(exo_nbr,gend,B);
|
||||
0081 <span class="keyword">else</span>
|
||||
0082 stock_innov = zeros(exo_nbr,gend,MAX_ninno);
|
||||
0083 <span class="keyword">end</span>
|
||||
0084 <span class="keyword">if</span> nvn & B <= MAX_nerro
|
||||
0085 stock_error = zeros(nvobs,gend,B);
|
||||
0086 <span class="keyword">else</span> nvn & B > MAX_nerro
|
||||
0087 stock_error = zeros(nvobs,gend,MAX_nerro);
|
||||
0088 <span class="keyword">end</span>
|
||||
0089 <span class="keyword">end</span>
|
||||
0090 <span class="keyword">if</span> options_.filter_step_ahead ~= 0
|
||||
0091 <span class="keyword">if</span> B <= MAX_naK
|
||||
0092 stock_filter = zeros(naK,endo_nbr,gend+options_.filter_step_ahead(end),B);
|
||||
0093 <span class="keyword">else</span>
|
||||
0094 stock_filter = zeros(naK,endo_nbr,gend+options_.filter_step_ahead(end),MAX_naK);
|
||||
0095 <span class="keyword">end</span>
|
||||
0096 <span class="keyword">end</span>
|
||||
0097 <span class="keyword">for</span> b=1:B
|
||||
0098 <span class="comment">%deep = GetOneDraw(NumberOfDraws,FirstMhFile,LastMhFile,FirstLine,MAX_nruns,DirectoryName);</span>
|
||||
0099 [deep, logpo] = <a href="GetOneDraw.html" class="code" title="function [xparams, logpost] = GetOneDraw(type)">GetOneDraw</a>(type);
|
||||
0100 <a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a>(deep);
|
||||
0101 dr = <a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a>(oo_.steady_state,0);
|
||||
0102 [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = <a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a>(deep,gend,Y);
|
||||
0103
|
||||
0104 stock_smooth(:,:,irun1) = alphahat(1:endo_nbr,:);
|
||||
0105 <span class="keyword">if</span> nvx
|
||||
0106 stock_innov(:,:,irun2) = etahat;
|
||||
0107 <span class="keyword">end</span>
|
||||
0108 <span class="keyword">if</span> nvn
|
||||
0109 stock_error(:,:,irun3) = epsilonhat;
|
||||
0110 <span class="keyword">end</span>
|
||||
0111 <span class="keyword">if</span> naK
|
||||
0112 stock_filter(:,:,:,irun4) = aK(options_.filter_step_ahead,1:endo_nbr,:);
|
||||
0113 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> irun1 > MAX_nsmoo | b == B
|
||||
0125 <span class="keyword">if</span> b == B
|
||||
0126 stock_smooth = stock_smooth(:,:,1:irun1-1);
|
||||
0127 <span class="keyword">end</span>
|
||||
0128 stock = stock_smooth;
|
||||
0129 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_smooth'</span> int2str(ifil1)],<span class="string">'stock'</span>);
|
||||
0130 ifil1 = ifil1 + 1;
|
||||
0131 irun1 = 1;
|
||||
0132 <span class="keyword">end</span>
|
||||
0133
|
||||
0134 <span class="keyword">if</span> nvx & (irun2 > MAX_ninno | b == B)
|
||||
0135 <span class="keyword">if</span> b == B
|
||||
0136 stock_innov = stock_innov(:,:,1:irun2-1);
|
||||
0137 <span class="keyword">end</span>
|
||||
0138 stock = stock_innov;
|
||||
0139 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_inno'</span> int2str(ifil2)],<span class="string">'stock'</span>);
|
||||
0140 ifil2 = ifil2 + 1;
|
||||
0141 irun2 = 1;
|
||||
0142 <span class="keyword">end</span>
|
||||
0143
|
||||
0144 <span class="keyword">if</span> nvn & (irun3 > MAX_error | b == B)
|
||||
0145 <span class="keyword">if</span> b == B
|
||||
0146 stock_error = stock_error(:,:,1:irun3-1);
|
||||
0147 <span class="keyword">end</span>
|
||||
0148 stock = stock_error;
|
||||
0149 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_error'</span> int2str(ifil3)],<span class="string">'stock'</span>);
|
||||
0150 ifil3 = ifil3 + 1;
|
||||
0151 irun3 = 1;
|
||||
0152 <span class="keyword">end</span>
|
||||
0153
|
||||
0154 <span class="keyword">if</span> naK & (irun4 > MAX_naK | b == B)
|
||||
0155 <span class="keyword">if</span> b == B
|
||||
0156 stock_filter = stock_filter(:,:,:,1:irun4-1);
|
||||
0157 <span class="keyword">end</span>
|
||||
0158 stock = stock_filter;
|
||||
0159 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_filter'</span> int2str(ifil4)],<span class="string">'stock'</span>);
|
||||
0160 ifil4 = ifil4 + 1;
|
||||
0161 irun4 = 1;
|
||||
0162 <span class="keyword">end</span>
|
||||
0163
|
||||
0164 <span class="keyword">if</span> irun5 > MAX_nruns | b == B
|
||||
0165 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0170 stock = stock_param;
|
||||
0171 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_param'</span> int2str(ifil5)],<span class="string">'stock'</span>,<span class="string">'stock_logpo'</span>,<span class="string">'stock_ys'</span>);
|
||||
0172 ifil5 = ifil5 + 1;
|
||||
0173 irun5 = 1;
|
||||
0174 <span class="keyword">end</span>
|
||||
0175
|
||||
0176 waitbar(b/B,h);
|
||||
0177 <span class="keyword">end</span>
|
||||
0178 close(h)
|
||||
0179
|
||||
0180 stock_gend=gend;
|
||||
0181 stock_data=Y;
|
||||
0182 save([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_data'</span>],<span class="string">'stock_gend'</span>,<span class="string">'stock_data'</span>);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,170 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of ReshapeMatFiles</title>
|
||||
<meta name="keywords" content="ReshapeMatFiles">
|
||||
<meta name="description" content="Reshape and sort (along the mcmc simulations) the mat files generated">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > ReshapeMatFiles.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>ReshapeMatFiles
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Reshape and sort (along the mcmc simulations) the mat files generated</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function ReshapeMatFiles(type) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Reshape and sort (along the mcmc simulations) the mat files generated
|
||||
by DYNARE.
|
||||
|
||||
4D-arrays are splitted along the first dimension.
|
||||
3D-arrays are splitted along the second dimension.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="PosteriorIRF.html" class="code" title="function PosteriorIRF(type)">PosteriorIRF</a> stephane.adjemian@ens.fr [09-25-2005]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function ReshapeMatFiles(type)</a>
|
||||
0002 <span class="comment">% Reshape and sort (along the mcmc simulations) the mat files generated</span>
|
||||
0003 <span class="comment">% by DYNARE.</span>
|
||||
0004 <span class="comment">%</span>
|
||||
0005 <span class="comment">% 4D-arrays are splitted along the first dimension.</span>
|
||||
0006 <span class="comment">% 3D-arrays are splitted along the second dimension.</span>
|
||||
0007 <span class="comment">%</span>
|
||||
0008 <span class="comment">%</span>
|
||||
0009 <span class="keyword">global</span> M_ options_
|
||||
0010
|
||||
0011 MhDirectoryName = [ <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>) <span class="string">'/'</span> ];
|
||||
0012
|
||||
0013 <span class="keyword">switch</span> type
|
||||
0014 <span class="keyword">case</span> <span class="string">'irf'</span>
|
||||
0015 CAPtype = <span class="string">'IRF'</span>;
|
||||
0016 TYPEsize = [ options_.irf , M_.endo_nbr , M_.exo_nbr ];
|
||||
0017 TYPEarray = 4;
|
||||
0018 <span class="keyword">case</span> <span class="string">'smooth'</span>
|
||||
0019 CAPtype = <span class="string">'SMOOTH'</span>;
|
||||
0020 TYPEsize = [ M_.endo_nbr , options_.nobs ];
|
||||
0021 TYPEarray = 3;
|
||||
0022 <span class="keyword">case</span> <span class="string">'filter'</span>
|
||||
0023 CAPtype = <span class="string">'FILTER'</span>;
|
||||
0024 TYPEsize = [ M_.endo_nbr , options_.nobs + 1 ];<span class="comment">% TO BE CHECKED!</span>
|
||||
0025 TYPEarray = 3;
|
||||
0026 <span class="keyword">case</span> <span class="string">'error'</span>
|
||||
0027 CAPtype = <span class="string">'ERROR'</span>;
|
||||
0028 TYPEsize = [ size(options_.varobs,1) , options_.nobs ];
|
||||
0029 TYPEarray = 3;
|
||||
0030 <span class="keyword">case</span> <span class="string">'innov'</span>
|
||||
0031 CAPtype = <span class="string">'INNOV'</span>;
|
||||
0032 TYPEsize = [ M_.exo_nbr , options_.nobs ];
|
||||
0033 TYPEarray = 3;
|
||||
0034 <span class="keyword">case</span> <span class="string">'forcst'</span>
|
||||
0035 CAPtype = <span class="string">'FORCST'</span>;
|
||||
0036 TYPEsize = [ M_.endo_nbr , options_.forecast ];
|
||||
0037 TYPEarray = 3;
|
||||
0038 <span class="keyword">case</span> <span class="string">'forcst1'</span>
|
||||
0039 CAPtype = <span class="string">'FORCST1'</span>;
|
||||
0040 TYPEsize = [ M_.endo_nbr , options_.forecast ];
|
||||
0041 TYPEarray = 3;
|
||||
0042 <span class="keyword">otherwise</span>
|
||||
0043 disp(<span class="string">'ReshapeMatFiles :: Unknown argument!'</span>)
|
||||
0044 <span class="keyword">return</span>
|
||||
0045 <span class="keyword">end</span>
|
||||
0046
|
||||
0047 TYPEfiles = dir([MhDirectoryName M_.fname <span class="string">'_'</span> type <span class="string">'*'</span>]);
|
||||
0048 NumberOfTYPEfiles = length(TYPEfiles);
|
||||
0049 B = options_.B;
|
||||
0050
|
||||
0051 <span class="keyword">switch</span> TYPEarray
|
||||
0052 <span class="keyword">case</span> 4
|
||||
0053 <span class="keyword">if</span> NumberOfTYPEfiles > 1
|
||||
0054 NumberOfPeriodsPerTYPEfiles = ceil(TYPEsize(1)/NumberOfTYPEfiles);
|
||||
0055 reste = TYPEsize(1)-NumberOfPeriodsPerTYPEfiles*(NumberOfTYPEfiles-1);
|
||||
0056 idx = 0;
|
||||
0057 jdx = 0;
|
||||
0058 <span class="keyword">for</span> f1=1:NumberOfTYPEfiles-1
|
||||
0059 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = zeros(NumberOfPeriodsPerTYPEfiles,TYPEsize(2),TYPEsize(3),B);'</span>])
|
||||
0060 <span class="keyword">for</span> f2 = 1:NumberOfTYPEfiles
|
||||
0061 load([MhDirectoryName M_.fname <span class="string">'_'</span> type int2str(f2)]);
|
||||
0062 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">'(:,:,:,idx+1:idx+size(stock_'</span> type <span class="string">',4))=stock_'</span> type <span class="string">'(jdx+1:jdx+NumberOfPeriodsPerTYPEfiles,:,:,:);'</span>])
|
||||
0063 eval([<span class="string">'idx = idx + size(stock_'</span> type <span class="string">',4);'</span>])
|
||||
0064 <span class="keyword">end</span>
|
||||
0065 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = sort(STOCK_'</span> CAPtype <span class="string">',4);'</span>])
|
||||
0066 save([MhDirectoryName M_.fname <span class="string">'_'</span> CAPtype <span class="string">'s'</span> int2str(f1)],[<span class="string">'STOCK_'</span> CAPtype]);
|
||||
0067 jdx = jdx + NumberOfPeriodsPerTYPEfiles;
|
||||
0068 idx = 0;
|
||||
0069 <span class="keyword">end</span>
|
||||
0070 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = zeros(reste,TYPEsize(2),TYPEsize(3),B);'</span>])
|
||||
0071 <span class="keyword">for</span> f2 = 1:NumberOfTYPEfiles
|
||||
0072 load([MhDirectoryName M_.fname <span class="string">'_'</span> type int2str(f2)]);
|
||||
0073 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">'(:,:,:,idx+1:idx+size(stock_'</span> type <span class="string">',4))=stock_'</span> type <span class="string">'(jdx+1:jdx+reste,:,:,:);'</span>])
|
||||
0074 eval([<span class="string">'idx = idx + size(stock_'</span> type <span class="string">',4);'</span>])
|
||||
0075 <span class="keyword">end</span>
|
||||
0076 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = sort(STOCK_'</span> CAPtype <span class="string">',4);'</span>])
|
||||
0077 save([MhDirectoryName M_.fname <span class="string">'_'</span> CAPtype <span class="string">'s'</span> int2str(NumberOfTYPEfiles)],[<span class="string">'STOCK_'</span> CAPtype]);
|
||||
0078 <span class="keyword">else</span>
|
||||
0079 load([MhDirectoryName M_.fname <span class="string">'_'</span> type <span class="string">'1'</span>]);
|
||||
0080 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = sort(stock_'</span> type <span class="string">',4);'</span>])
|
||||
0081 save([MhDirectoryName M_.fname <span class="string">'_'</span> CAPtype <span class="string">'s'</span> int2str(1)],[<span class="string">'STOCK_'</span> CAPtype ]);
|
||||
0082 <span class="keyword">end</span>
|
||||
0083 <span class="keyword">for</span> file = 1:NumberOfTYPEfiles
|
||||
0084 delete([MhDirectoryName M_.fname <span class="string">'_'</span> type int2str(file) <span class="string">'.mat'</span>])
|
||||
0085 <span class="keyword">end</span>
|
||||
0086 <span class="keyword">case</span> 3
|
||||
0087 <span class="keyword">if</span> NumberOfTYPEfiles>1
|
||||
0088 NumberOfPeriodsPerTYPEfiles = ceil( TYPEsize(2)/NumberOfTYPEfiles );
|
||||
0089 reste = TYPEsize(2)-NumberOfPeriodsPerTYPEfiles*(NumberOfTYPEfiles-1);
|
||||
0090 idx = 0;
|
||||
0091 jdx = 0;
|
||||
0092 <span class="keyword">for</span> f1=1:NumberOfTYPEfiles-1
|
||||
0093 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = zeros(TYPEsize(1),NumberOfPeriodsPerTYPEfiles,B);'</span>])
|
||||
0094 <span class="keyword">for</span> f2 = 1:NumberOfTYPEfiles
|
||||
0095 load([MhDirectoryName M_.fname <span class="string">'_'</span> type int2str(f2)]);
|
||||
0096 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">'(:,:,idx+1:idx+size(stock_ '</span> type <span class="string">',3))=stock_'</span> type <span class="string">'(:,jdx+1:jdx+NumberOfPeriodsPerTYPEfiles,:);'</span>])
|
||||
0097 eval([<span class="string">'idx = idx + size(stock_'</span> type <span class="string">',3);'</span>])
|
||||
0098 <span class="keyword">end</span>
|
||||
0099 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = sort(STOCK_'</span> CAPtype <span class="string">',3);'</span>])
|
||||
0100 save([MhDirectoryName M_.fname <span class="string">'_'</span> CAPtype <span class="string">'s'</span> int2str(f1)],[<span class="string">'STOCK_'</span> CAPtype]);
|
||||
0101 jdx = jdx + NumberOfPeriodsPerTYPEfiles;
|
||||
0102 idx = 0;
|
||||
0103 <span class="keyword">end</span>
|
||||
0104 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = zeros(TYPEsize(1),reste,B);'</span>])
|
||||
0105 <span class="keyword">for</span> f2 = 1:NumberOfTYPEfiles
|
||||
0106 load([MhDirectoryName M_.fname <span class="string">'_'</span> type int2str(f2)]);
|
||||
0107 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">'(:,:,idx+1:idx+size(stock_'</span> type <span class="string">',3))=stock_'</span> type <span class="string">'(:,jdx+1:jdx+reste,:);'</span>])
|
||||
0108 eval([<span class="string">'idx = idx + size(stock_'</span> type <span class="string">',3);'</span>])
|
||||
0109 <span class="keyword">end</span>
|
||||
0110 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = sort(STOCK_'</span> CAPtype <span class="string">',3);'</span>])
|
||||
0111 save([MhDirectoryName M_.fname <span class="string">'_'</span> CAPtype <span class="string">'s'</span> int2str(NumberOfTYPEfiles)],[<span class="string">'STOCK_'</span> CAPtype]);
|
||||
0112 <span class="keyword">else</span>
|
||||
0113 load([MhDirectoryName M_.fname <span class="string">'_'</span> type <span class="string">'1'</span>]);
|
||||
0114 eval([<span class="string">'STOCK_'</span> CAPtype <span class="string">' = sort(stock_'</span> type <span class="string">',3);'</span>])
|
||||
0115 save([MhDirectoryName M_.fname <span class="string">'_'</span> CAPtype <span class="string">'s'</span> int2str(1)],[<span class="string">'STOCK_'</span> CAPtype ]);
|
||||
0116 <span class="keyword">end</span>
|
||||
0117 <span class="keyword">for</span> file = 1:NumberOfTYPEfiles
|
||||
0118 delete([MhDirectoryName M_.fname <span class="string">'_'</span> type int2str(file) <span class="string">'.mat'</span>])
|
||||
0119 <span class="keyword">end</span>
|
||||
0120 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,178 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of UnivariateSpectralDensity</title>
|
||||
<meta name="keywords" content="UnivariateSpectralDensity">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > UnivariateSpectralDensity.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>UnivariateSpectralDensity
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [omega,f] = UnivariateSpectralDensity(dr,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr
|
||||
This function computes the theoretical spectral density of each
|
||||
endogenous variable declared in var_list. Results are stored in
|
||||
oo_ and may be plotted.
|
||||
|
||||
Adapted from th_autocovariances.m.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="kalman_transition_matrix.html" class="code" title="function [A,B] = kalman_transition_matrix(dr)">kalman_transition_matrix</a> makes transition matrices out of ghx and ghu for Kalman filter</li><li><a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a> solves x-a*x*a'=b for b (and then x) symmetrical</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% stephane.adjemian@ens.fr</span>
|
||||
0002 <a name="_sub0" href="#_subfunctions" class="code">function [omega,f] = UnivariateSpectralDensity(dr,var_list)</a>
|
||||
0003 <span class="comment">% This function computes the theoretical spectral density of each</span>
|
||||
0004 <span class="comment">% endogenous variable declared in var_list. Results are stored in</span>
|
||||
0005 <span class="comment">% oo_ and may be plotted.</span>
|
||||
0006 <span class="comment">%</span>
|
||||
0007 <span class="comment">% Adapted from th_autocovariances.m.</span>
|
||||
0008 <span class="keyword">global</span> options_ oo_ M_
|
||||
0009
|
||||
0010 omega = []; f = [];
|
||||
0011
|
||||
0012 <span class="keyword">if</span> options_.order > 1
|
||||
0013 disp(<span class="string">'UnivariateSpectralDensity :: I Cannot compute the theoretical spectral density'</span>)
|
||||
0014 disp(<span class="string">'with a second order approximation of the DSGE model!'</span>)
|
||||
0015 disp(<span class="string">'Set order = 1.'</span>)
|
||||
0016 <span class="keyword">return</span>
|
||||
0017 <span class="keyword">end</span>
|
||||
0018
|
||||
0019 pltinfo = 1;<span class="comment">%options_.SpectralDensity.Th.plot;</span>
|
||||
0020 cutoff = 100;<span class="comment">%options_.SpectralDensity.Th.cutoff;</span>
|
||||
0021 sdl = 0.1;<span class="comment">%options_.SepctralDensity.Th.sdl;</span>
|
||||
0022 omega = (0:sdl:pi)';
|
||||
0023 GridSize = length(omega);
|
||||
0024 exo_names_orig_ord = M_.exo_names_orig_ord;
|
||||
0025 <span class="keyword">if</span> sscanf(version(<span class="string">'-release'</span>),<span class="string">'%d'</span>) < 13
|
||||
0026 warning off
|
||||
0027 <span class="keyword">else</span>
|
||||
0028 eval(<span class="string">'warning off MATLAB:dividebyzero'</span>)
|
||||
0029 <span class="keyword">end</span>
|
||||
0030 <span class="keyword">if</span> nargin<2
|
||||
0031 var_list = [];
|
||||
0032 <span class="keyword">end</span>
|
||||
0033 nvar = size(var_list,1);
|
||||
0034 <span class="keyword">if</span> nvar == 0
|
||||
0035 nvar = length(dr.order_var);
|
||||
0036 ivar = [1:nvar]';
|
||||
0037 <span class="keyword">else</span>
|
||||
0038 ivar=zeros(nvar,1);
|
||||
0039 <span class="keyword">for</span> i=1:nvar
|
||||
0040 i_tmp = strmatch(var_list(i,:),M_.endo_names,<span class="string">'exact'</span>);
|
||||
0041 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0042 error ([<span class="string">'One of the variable specified does not exist'</span>]) ;
|
||||
0043 <span class="keyword">else</span>
|
||||
0044 ivar(i) = i_tmp;
|
||||
0045 <span class="keyword">end</span>
|
||||
0046 <span class="keyword">end</span>
|
||||
0047 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> 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 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0076 AS(:,j1) = AS(:,j1)+ghx(:,i1);
|
||||
0077 i0 = i1;
|
||||
0078 <span class="keyword">end</span>
|
||||
0079 b = ghu1*M_.Sigma_e*ghu1';
|
||||
0080 [A,B] = <a href="kalman_transition_matrix.html" class="code" title="function [A,B] = kalman_transition_matrix(dr)">kalman_transition_matrix</a>(dr);
|
||||
0081 <span class="comment">% index of predetermined variables in A</span>
|
||||
0082 i_pred = [nstatic+(1:npred) M_.endo_nbr+1:length(A)];
|
||||
0083 A = A(i_pred,i_pred);
|
||||
0084 [vx, ns_var] = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(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 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0107 H = 1:cutoff;
|
||||
0108 <span class="keyword">for</span> i=1:nvar
|
||||
0109 f(i,:) = Gamma(i,1)/(2*pi) + Gamma(i,H+1)*cos(H'*omega')/pi;
|
||||
0110 <span class="keyword">end</span>
|
||||
0111
|
||||
0112 <span class="keyword">if</span> sscanf(version(<span class="string">'-release'</span>),<span class="string">'%d'</span>) < 13
|
||||
0113 warning on
|
||||
0114 <span class="keyword">else</span>
|
||||
0115 eval(<span class="string">'warning on MATLAB:dividebyzero'</span>)
|
||||
0116 <span class="keyword">end</span>
|
||||
0117
|
||||
0118 <span class="keyword">if</span> pltinfo
|
||||
0119 <span class="keyword">for</span> i= 1:nvar
|
||||
0120 figure(<span class="string">'Name'</span>,[<span class="string">'Spectral Density of '</span> deblank(M_.endo_names(ivar(i),:)) <span class="string">'.'</span>])
|
||||
0121 plot(omega,f(i,:),<span class="string">'-k'</span>,<span class="string">'linewidth'</span>,2)
|
||||
0122 xlabel(<span class="string">'0 \leq \omega \leq \pi'</span>)
|
||||
0123 ylabel(<span class="string">'f(\omega)'</span>)
|
||||
0124 box on
|
||||
0125 axis tight
|
||||
0126 <span class="keyword">end</span>
|
||||
0127 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 273 B |
|
@ -1,364 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of asamin</title>
|
||||
<meta name="keywords" content="asamin">
|
||||
<meta name="description" content="ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > asamin.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>asamin
|
||||
<img src="../{MEXTYPE}.png" alt="Windows" border="0" title="Windows"></h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>This is a script file. </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)
|
||||
|
||||
ASAMIN is a matlab gateway function to Lester Ingber's Adaptive
|
||||
Simulated Annealing (ASA)
|
||||
|
||||
Copyright (c) 1999-2001 Shinichi Sakata. All Rights Reserved.
|
||||
|
||||
$Id: asamin.m,v 1.1.2.1 2004/03/27 14:41:06 michel Exp $
|
||||
|
||||
Usage:
|
||||
|
||||
asamin ('set')
|
||||
|
||||
lists the current value of each option.
|
||||
|
||||
asamin ('set', opt_name)
|
||||
|
||||
shows the current value of the option given by a character string
|
||||
opt_name; e.g.,
|
||||
|
||||
asamin ('set', 'seed')
|
||||
|
||||
asamin ('set', opt_name, opt_value)
|
||||
|
||||
set the value opt_value to the option opt_name; e.g.,
|
||||
|
||||
asamin ('set', 'seed', 654342)
|
||||
asamin ('set', 'asa_out_file', 'example.log')
|
||||
|
||||
The valid options in these commands are:
|
||||
|
||||
rand_seed
|
||||
test_in_cost_func
|
||||
use_rejected_cost
|
||||
asa_out_file
|
||||
limit_acceptances
|
||||
limit_generated
|
||||
limit_invalid
|
||||
accepted_to_generated_ratio
|
||||
cost_precision
|
||||
maximum_cost_repeat
|
||||
number_cost_samples
|
||||
temperature_ratio_scale
|
||||
cost_parameter_scale
|
||||
temperature_anneal_scale
|
||||
include_integer_parameters
|
||||
user_initial_parameters
|
||||
sequential_parameters
|
||||
initial_parameter_temperature
|
||||
acceptance_frequency_modulus
|
||||
generated_frequency_modulus
|
||||
reanneal_cost
|
||||
reanneal_parameters
|
||||
delta_x
|
||||
|
||||
rand_seed is the seed of the random number generation in ASA.
|
||||
|
||||
If test_in_cost_func is set to zero, the cost function should
|
||||
simply return the value of the objective function. When
|
||||
test_in_cost_func is set to one, asamin () calls the cost
|
||||
function with a threshold value as well as the parameter
|
||||
value. The cost function needs to judge if the value of the cost
|
||||
function exceeds the threshold as well as compute the value of
|
||||
the cost function when asamin () requires. (See COST FUNCTION
|
||||
below for details.)
|
||||
|
||||
All other items but use_rejected_cost belong to structure
|
||||
USER_OPTIONS in ASA. See ASA_README in the ASA package for
|
||||
details. The default value of use_rejected_cost is zero. If you
|
||||
set this option to one, ASA uses the current cost value to
|
||||
compute certain indices, even if the current state is rejected by
|
||||
the user cost function, provided that the current cost value is
|
||||
lower than the cost value of the past best state. (See COST
|
||||
FUNCTION below about the user cost function.)
|
||||
|
||||
asamin ('reset')
|
||||
resets all option values to the hard-coded default values.
|
||||
|
||||
[fstar,xstar,grad,hessian,state] = ...
|
||||
asamin ('minimize', func, xinit, xmin, xmax, xtype,...
|
||||
parm1, parm2, ...)
|
||||
|
||||
minimizes the cost function func (also see COST FUNCTION below).
|
||||
The argument xinit specifies the initial value of the arguments
|
||||
of the cost function. Each element of the vectors xmin and xmax
|
||||
specify the lower and upper bounds of the corresponding
|
||||
argument. The vector xtype indicates the types of the
|
||||
arguments. If xtype(i) is -1 if the i'th argument is real;
|
||||
xtype(i) is 1 if the i'th argument is integer. If this argument
|
||||
should be ignored in reannealing, multiply the corresponding
|
||||
element of xtype by 2 so that the element is 2 or -2. All
|
||||
parameters following xtype are optional and simply passed to the
|
||||
cost function each time the cost function is called.
|
||||
|
||||
This way of calling asamin returns the following values:
|
||||
|
||||
fstar
|
||||
The value of the objective function at xstar.
|
||||
xstar
|
||||
The argument vector at the exit from the ASA routine. If things go
|
||||
well, xstar should be the minimizer of "func".
|
||||
grad
|
||||
The gradient of "func" at xstar.
|
||||
hessian
|
||||
The Hessian of "func" at xstar.
|
||||
state
|
||||
The vector containing the information on the exit state.
|
||||
state(1) is the exit_code, and state(2) is the cost flag. See
|
||||
ASA_README for details.
|
||||
|
||||
|
||||
|
||||
COST FUNCTION
|
||||
|
||||
If test_in_cost_func is set to zero, asamin () calls the "cost
|
||||
function" (say, cost_func) with one argument, say x (the real cost
|
||||
function is evaluated at this point). Cost_func is expected to
|
||||
return the value of the objective function and cost_flag, the
|
||||
latter of which must be zero if any constraint (if any) is
|
||||
violated; otherwise one.
|
||||
|
||||
When test_in_cost_func is equal to one, asamin () calls the "cost
|
||||
function" (say, cost_func) with three arguments, say, x (at which
|
||||
the real cost function is evaluated), critical_cost_value, and
|
||||
no_test_flag. Asamin expects cost_func to return three scalar
|
||||
values, say, cost_value, cost_flag, and user_acceptance_flag in the
|
||||
following manner.
|
||||
|
||||
1. The function cost_func first checks if x satisfies the
|
||||
constraints of the minimization problem. If any of the
|
||||
constraints is not satisfied, cost_func sets zero to cost_flag
|
||||
and return. (user_acceptance_flag and cost_value will not be used
|
||||
by asamin () in this case.) If all constraints are satisfied, set
|
||||
one to cost_flag, and proceed to the next step.
|
||||
|
||||
2. If asamin () calls cost_func with no_test_flag==1, cost_func
|
||||
must compute the value of the cost function, set it to cost_value
|
||||
and return. When no_test_flag==0, cost_func is expected to judge
|
||||
if the value of the cost function is greater than
|
||||
critical_cost_value. If the value of the cost function is found
|
||||
greater than critical_cost_value, cost_func must set zero to
|
||||
user_acceptance_flag and return. (asamin () will not use
|
||||
cost_value in this case.) On the other hand, if the value of the
|
||||
cost function is found no greater than critical_cost_value,
|
||||
cost_func must compute the cost function at x, set it to
|
||||
cost_value, and set one to user_acceptance_flag.
|
||||
|
||||
Remark: To understand the usefulness of test_in_cost_func == 1,
|
||||
note that it is sometimes easier to check if the value of the cost
|
||||
function is greater than critical_cost_value than compute the value
|
||||
of the cost function. For example, suppose that the cost function g
|
||||
is implicitly defined by an equation f(g(x),x)=0, where f is
|
||||
strictly increasing in the first argument, and evaluation of g(x)
|
||||
is computationally expensive (e.g., requiring an iterative method
|
||||
to find a solution to f(y,x)=0). But we can easily show that
|
||||
f(critical_cost_value,x) < 0 if and only if g(x) >
|
||||
critical_cost_value. We can judge if g(x) > critical_cost_value by
|
||||
computing f(critical_cost_value,x). The value of g(x) is not
|
||||
necessary.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% ASAMIN A gateway function to Adaptive Simulated Annealing (ASA)</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <span class="comment">% ASAMIN is a matlab gateway function to Lester Ingber's Adaptive</span>
|
||||
0004 <span class="comment">% Simulated Annealing (ASA)</span>
|
||||
0005 <span class="comment">%</span>
|
||||
0006 <span class="comment">% Copyright (c) 1999-2001 Shinichi Sakata. All Rights Reserved.</span>
|
||||
0007 <span class="comment">%</span>
|
||||
0008 <span class="comment">% $Id: asamin.m,v 1.1.2.1 2004/03/27 14:41:06 michel Exp $</span>
|
||||
0009 <span class="comment">%</span>
|
||||
0010 <span class="comment">% Usage:</span>
|
||||
0011 <span class="comment">%</span>
|
||||
0012 <span class="comment">% asamin ('set')</span>
|
||||
0013 <span class="comment">%</span>
|
||||
0014 <span class="comment">% lists the current value of each option.</span>
|
||||
0015 <span class="comment">%</span>
|
||||
0016 <span class="comment">% asamin ('set', opt_name)</span>
|
||||
0017 <span class="comment">%</span>
|
||||
0018 <span class="comment">% shows the current value of the option given by a character string</span>
|
||||
0019 <span class="comment">% opt_name; e.g.,</span>
|
||||
0020 <span class="comment">%</span>
|
||||
0021 <span class="comment">% asamin ('set', 'seed')</span>
|
||||
0022 <span class="comment">%</span>
|
||||
0023 <span class="comment">% asamin ('set', opt_name, opt_value)</span>
|
||||
0024 <span class="comment">%</span>
|
||||
0025 <span class="comment">% set the value opt_value to the option opt_name; e.g.,</span>
|
||||
0026 <span class="comment">%</span>
|
||||
0027 <span class="comment">% asamin ('set', 'seed', 654342)</span>
|
||||
0028 <span class="comment">% asamin ('set', 'asa_out_file', 'example.log')</span>
|
||||
0029 <span class="comment">%</span>
|
||||
0030 <span class="comment">% The valid options in these commands are:</span>
|
||||
0031 <span class="comment">%</span>
|
||||
0032 <span class="comment">% rand_seed</span>
|
||||
0033 <span class="comment">% test_in_cost_func</span>
|
||||
0034 <span class="comment">% use_rejected_cost</span>
|
||||
0035 <span class="comment">% asa_out_file</span>
|
||||
0036 <span class="comment">% limit_acceptances</span>
|
||||
0037 <span class="comment">% limit_generated</span>
|
||||
0038 <span class="comment">% limit_invalid</span>
|
||||
0039 <span class="comment">% accepted_to_generated_ratio</span>
|
||||
0040 <span class="comment">% cost_precision</span>
|
||||
0041 <span class="comment">% maximum_cost_repeat</span>
|
||||
0042 <span class="comment">% number_cost_samples</span>
|
||||
0043 <span class="comment">% temperature_ratio_scale</span>
|
||||
0044 <span class="comment">% cost_parameter_scale</span>
|
||||
0045 <span class="comment">% temperature_anneal_scale</span>
|
||||
0046 <span class="comment">% include_integer_parameters</span>
|
||||
0047 <span class="comment">% user_initial_parameters</span>
|
||||
0048 <span class="comment">% sequential_parameters</span>
|
||||
0049 <span class="comment">% initial_parameter_temperature</span>
|
||||
0050 <span class="comment">% acceptance_frequency_modulus</span>
|
||||
0051 <span class="comment">% generated_frequency_modulus</span>
|
||||
0052 <span class="comment">% reanneal_cost</span>
|
||||
0053 <span class="comment">% reanneal_parameters</span>
|
||||
0054 <span class="comment">% delta_x</span>
|
||||
0055 <span class="comment">%</span>
|
||||
0056 <span class="comment">% rand_seed is the seed of the random number generation in ASA.</span>
|
||||
0057 <span class="comment">%</span>
|
||||
0058 <span class="comment">% If test_in_cost_func is set to zero, the cost function should</span>
|
||||
0059 <span class="comment">% simply return the value of the objective function. When</span>
|
||||
0060 <span class="comment">% test_in_cost_func is set to one, asamin () calls the cost</span>
|
||||
0061 <span class="comment">% function with a threshold value as well as the parameter</span>
|
||||
0062 <span class="comment">% value. The cost function needs to judge if the value of the cost</span>
|
||||
0063 <span class="comment">% function exceeds the threshold as well as compute the value of</span>
|
||||
0064 <span class="comment">% the cost function when asamin () requires. (See COST FUNCTION</span>
|
||||
0065 <span class="comment">% below for details.)</span>
|
||||
0066 <span class="comment">%</span>
|
||||
0067 <span class="comment">% All other items but use_rejected_cost belong to structure</span>
|
||||
0068 <span class="comment">% USER_OPTIONS in ASA. See ASA_README in the ASA package for</span>
|
||||
0069 <span class="comment">% details. The default value of use_rejected_cost is zero. If you</span>
|
||||
0070 <span class="comment">% set this option to one, ASA uses the current cost value to</span>
|
||||
0071 <span class="comment">% compute certain indices, even if the current state is rejected by</span>
|
||||
0072 <span class="comment">% the user cost function, provided that the current cost value is</span>
|
||||
0073 <span class="comment">% lower than the cost value of the past best state. (See COST</span>
|
||||
0074 <span class="comment">% FUNCTION below about the user cost function.)</span>
|
||||
0075 <span class="comment">%</span>
|
||||
0076 <span class="comment">% asamin ('reset')</span>
|
||||
0077 <span class="comment">% resets all option values to the hard-coded default values.</span>
|
||||
0078 <span class="comment">%</span>
|
||||
0079 <span class="comment">% [fstar,xstar,grad,hessian,state] = ...</span>
|
||||
0080 <span class="comment">% asamin ('minimize', func, xinit, xmin, xmax, xtype,...</span>
|
||||
0081 <span class="comment">% parm1, parm2, ...)</span>
|
||||
0082 <span class="comment">%</span>
|
||||
0083 <span class="comment">% minimizes the cost function func (also see COST FUNCTION below).</span>
|
||||
0084 <span class="comment">% The argument xinit specifies the initial value of the arguments</span>
|
||||
0085 <span class="comment">% of the cost function. Each element of the vectors xmin and xmax</span>
|
||||
0086 <span class="comment">% specify the lower and upper bounds of the corresponding</span>
|
||||
0087 <span class="comment">% argument. The vector xtype indicates the types of the</span>
|
||||
0088 <span class="comment">% arguments. If xtype(i) is -1 if the i'th argument is real;</span>
|
||||
0089 <span class="comment">% xtype(i) is 1 if the i'th argument is integer. If this argument</span>
|
||||
0090 <span class="comment">% should be ignored in reannealing, multiply the corresponding</span>
|
||||
0091 <span class="comment">% element of xtype by 2 so that the element is 2 or -2. All</span>
|
||||
0092 <span class="comment">% parameters following xtype are optional and simply passed to the</span>
|
||||
0093 <span class="comment">% cost function each time the cost function is called.</span>
|
||||
0094 <span class="comment">%</span>
|
||||
0095 <span class="comment">% This way of calling asamin returns the following values:</span>
|
||||
0096 <span class="comment">%</span>
|
||||
0097 <span class="comment">% fstar</span>
|
||||
0098 <span class="comment">% The value of the objective function at xstar.</span>
|
||||
0099 <span class="comment">% xstar</span>
|
||||
0100 <span class="comment">% The argument vector at the exit from the ASA routine. If things go</span>
|
||||
0101 <span class="comment">% well, xstar should be the minimizer of "func".</span>
|
||||
0102 <span class="comment">% grad</span>
|
||||
0103 <span class="comment">% The gradient of "func" at xstar.</span>
|
||||
0104 <span class="comment">% hessian</span>
|
||||
0105 <span class="comment">% The Hessian of "func" at xstar.</span>
|
||||
0106 <span class="comment">% state</span>
|
||||
0107 <span class="comment">% The vector containing the information on the exit state.</span>
|
||||
0108 <span class="comment">% state(1) is the exit_code, and state(2) is the cost flag. See</span>
|
||||
0109 <span class="comment">% ASA_README for details.</span>
|
||||
0110 <span class="comment">%</span>
|
||||
0111 <span class="comment">%</span>
|
||||
0112 <span class="comment">%</span>
|
||||
0113 <span class="comment">% COST FUNCTION</span>
|
||||
0114 <span class="comment">%</span>
|
||||
0115 <span class="comment">% If test_in_cost_func is set to zero, asamin () calls the "cost</span>
|
||||
0116 <span class="comment">% function" (say, cost_func) with one argument, say x (the real cost</span>
|
||||
0117 <span class="comment">% function is evaluated at this point). Cost_func is expected to</span>
|
||||
0118 <span class="comment">% return the value of the objective function and cost_flag, the</span>
|
||||
0119 <span class="comment">% latter of which must be zero if any constraint (if any) is</span>
|
||||
0120 <span class="comment">% violated; otherwise one.</span>
|
||||
0121 <span class="comment">%</span>
|
||||
0122 <span class="comment">% When test_in_cost_func is equal to one, asamin () calls the "cost</span>
|
||||
0123 <span class="comment">% function" (say, cost_func) with three arguments, say, x (at which</span>
|
||||
0124 <span class="comment">% the real cost function is evaluated), critical_cost_value, and</span>
|
||||
0125 <span class="comment">% no_test_flag. Asamin expects cost_func to return three scalar</span>
|
||||
0126 <span class="comment">% values, say, cost_value, cost_flag, and user_acceptance_flag in the</span>
|
||||
0127 <span class="comment">% following manner.</span>
|
||||
0128 <span class="comment">%</span>
|
||||
0129 <span class="comment">% 1. The function cost_func first checks if x satisfies the</span>
|
||||
0130 <span class="comment">% constraints of the minimization problem. If any of the</span>
|
||||
0131 <span class="comment">% constraints is not satisfied, cost_func sets zero to cost_flag</span>
|
||||
0132 <span class="comment">% and return. (user_acceptance_flag and cost_value will not be used</span>
|
||||
0133 <span class="comment">% by asamin () in this case.) If all constraints are satisfied, set</span>
|
||||
0134 <span class="comment">% one to cost_flag, and proceed to the next step.</span>
|
||||
0135 <span class="comment">%</span>
|
||||
0136 <span class="comment">% 2. If asamin () calls cost_func with no_test_flag==1, cost_func</span>
|
||||
0137 <span class="comment">% must compute the value of the cost function, set it to cost_value</span>
|
||||
0138 <span class="comment">% and return. When no_test_flag==0, cost_func is expected to judge</span>
|
||||
0139 <span class="comment">% if the value of the cost function is greater than</span>
|
||||
0140 <span class="comment">% critical_cost_value. If the value of the cost function is found</span>
|
||||
0141 <span class="comment">% greater than critical_cost_value, cost_func must set zero to</span>
|
||||
0142 <span class="comment">% user_acceptance_flag and return. (asamin () will not use</span>
|
||||
0143 <span class="comment">% cost_value in this case.) On the other hand, if the value of the</span>
|
||||
0144 <span class="comment">% cost function is found no greater than critical_cost_value,</span>
|
||||
0145 <span class="comment">% cost_func must compute the cost function at x, set it to</span>
|
||||
0146 <span class="comment">% cost_value, and set one to user_acceptance_flag.</span>
|
||||
0147 <span class="comment">%</span>
|
||||
0148 <span class="comment">% Remark: To understand the usefulness of test_in_cost_func == 1,</span>
|
||||
0149 <span class="comment">% note that it is sometimes easier to check if the value of the cost</span>
|
||||
0150 <span class="comment">% function is greater than critical_cost_value than compute the value</span>
|
||||
0151 <span class="comment">% of the cost function. For example, suppose that the cost function g</span>
|
||||
0152 <span class="comment">% is implicitly defined by an equation f(g(x),x)=0, where f is</span>
|
||||
0153 <span class="comment">% strictly increasing in the first argument, and evaluation of g(x)</span>
|
||||
0154 <span class="comment">% is computationally expensive (e.g., requiring an iterative method</span>
|
||||
0155 <span class="comment">% to find a solution to f(y,x)=0). But we can easily show that</span>
|
||||
0156 <span class="comment">% f(critical_cost_value,x) < 0 if and only if g(x) ></span>
|
||||
0157 <span class="comment">% critical_cost_value. We can judge if g(x) > critical_cost_value by</span>
|
||||
0158 <span class="comment">% computing f(critical_cost_value,x). The value of g(x) is not</span>
|
||||
0159 <span class="comment">% necessary.</span>
|
||||
0160 <span class="comment">%</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,91 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of beta_rnd</title>
|
||||
<meta name="keywords" content="beta_rnd">
|
||||
<meta name="description" content="PURPOSE: random draws from the beta(a,b) distribution">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > beta_rnd.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>beta_rnd
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>PURPOSE: random draws from the beta(a,b) distribution</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function rnd = beta_rnd (n, a, b) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> PURPOSE: random draws from the beta(a,b) distribution
|
||||
--------------------------------------------------------------
|
||||
USAGE: rnd = beta_rnd(n,a,b)
|
||||
where: n = size of the vector of draws
|
||||
a = beta distribution parameter, a = scalar
|
||||
b = beta distribution parameter b = scalar
|
||||
NOTE: mean = a/(a+b), variance = ab/((a+b)*(a+b)*(a+b+1))
|
||||
--------------------------------------------------------------
|
||||
RETURNS: n-vector of random draws from the beta(a,b) distribution
|
||||
--------------------------------------------------------------
|
||||
SEE ALSO: beta_d, beta_pdf, beta_inv, <a href="beta_rnd.html" class="code" title="function rnd = beta_rnd (n, a, b)">beta_rnd</a>
|
||||
--------------------------------------------------------------</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="gamm_rnd.html" class="code" title="function gb = gamm_rnd(nrow,m,k)">gamm_rnd</a> PURPOSE: a matrix of random draws from the gamma distribution</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="rndprior.html" class="code" title="function y = rndprior(bayestopt_)">rndprior</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function rnd = beta_rnd (n, a, b)</a>
|
||||
0002 <span class="comment">% PURPOSE: random draws from the beta(a,b) distribution</span>
|
||||
0003 <span class="comment">%--------------------------------------------------------------</span>
|
||||
0004 <span class="comment">% USAGE: rnd = beta_rnd(n,a,b)</span>
|
||||
0005 <span class="comment">% where: n = size of the vector of draws</span>
|
||||
0006 <span class="comment">% a = beta distribution parameter, a = scalar</span>
|
||||
0007 <span class="comment">% b = beta distribution parameter b = scalar</span>
|
||||
0008 <span class="comment">% NOTE: mean = a/(a+b), variance = ab/((a+b)*(a+b)*(a+b+1))</span>
|
||||
0009 <span class="comment">%--------------------------------------------------------------</span>
|
||||
0010 <span class="comment">% RETURNS: n-vector of random draws from the beta(a,b) distribution</span>
|
||||
0011 <span class="comment">%--------------------------------------------------------------</span>
|
||||
0012 <span class="comment">% SEE ALSO: beta_d, beta_pdf, beta_inv, beta_rnd</span>
|
||||
0013 <span class="comment">%--------------------------------------------------------------</span>
|
||||
0014
|
||||
0015 <span class="comment">% written by:</span>
|
||||
0016 <span class="comment">% James P. LeSage, Dept of Economics</span>
|
||||
0017 <span class="comment">% University of Toledo</span>
|
||||
0018 <span class="comment">% 2801 W. Bancroft St,</span>
|
||||
0019 <span class="comment">% Toledo, OH 43606</span>
|
||||
0020 <span class="comment">% jlesage@spatial-econometrics.com</span>
|
||||
0021
|
||||
0022
|
||||
0023 <span class="keyword">if</span> (nargin ~= 3)
|
||||
0024 error(<span class="string">'Wrong # of arguments to beta_rnd'</span>);
|
||||
0025 <span class="keyword">end</span>;
|
||||
0026
|
||||
0027 <span class="keyword">if</span> any(any((a<=0)|(b<=0)))
|
||||
0028 error(<span class="string">'Parameter a or b is nonpositive'</span>)
|
||||
0029 <span class="keyword">end</span>
|
||||
0030
|
||||
0031 a1n = <a href="gamm_rnd.html" class="code" title="function gb = gamm_rnd(nrow,m,k)">gamm_rnd</a>(n,a,1);
|
||||
0032 a1d = <a href="gamm_rnd.html" class="code" title="function gb = gamm_rnd(nrow,m,k)">gamm_rnd</a>(n,b,1);
|
||||
0033 rnd = a1n./(a1n+a1d);
|
||||
0034</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,76 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of bfgsi</title>
|
||||
<meta name="keywords" content="bfgsi">
|
||||
<meta name="description" content="H = bfgsi(H0,dg,dx)">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > bfgsi.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>bfgsi
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>H = bfgsi(H0,dg,dx)</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function H = bfgsi(H0,dg,dx) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> H = bfgsi(H0,dg,dx)
|
||||
dg is previous change in gradient; dx is previous change in x;
|
||||
6/8/93 version that updates inverse hessian instead of hessian
|
||||
itself.
|
||||
Copyright by Christopher Sims 1996. This material may be freely
|
||||
reproduced and modified.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="csminwel.html" class="code" title="function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)">csminwel</a> [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function H = bfgsi(H0,dg,dx)</a>
|
||||
0002 <span class="comment">% H = bfgsi(H0,dg,dx)</span>
|
||||
0003 <span class="comment">% dg is previous change in gradient; dx is previous change in x;</span>
|
||||
0004 <span class="comment">% 6/8/93 version that updates inverse hessian instead of hessian</span>
|
||||
0005 <span class="comment">% itself.</span>
|
||||
0006 <span class="comment">% Copyright by Christopher Sims 1996. This material may be freely</span>
|
||||
0007 <span class="comment">% reproduced and modified.</span>
|
||||
0008 <span class="keyword">if</span> size(dg,2)>1
|
||||
0009 dg=dg';
|
||||
0010 <span class="keyword">end</span>
|
||||
0011 <span class="keyword">if</span> size(dx,2)>1
|
||||
0012 dx=dx';
|
||||
0013 <span class="keyword">end</span>
|
||||
0014 Hdg = H0*dg;
|
||||
0015 dgdx = dg'*dx;
|
||||
0016 <span class="keyword">if</span> (abs(dgdx) >1e-12)
|
||||
0017 H = H0 + (1+(dg'*Hdg)/dgdx)*(dx*dx')/dgdx - (dx*Hdg'+Hdg*dx')/dgdx;
|
||||
0018 <span class="keyword">else</span>
|
||||
0019 disp(<span class="string">'bfgs update failed.'</span>)
|
||||
0020 disp([<span class="string">'|dg| = '</span> num2str(sqrt(dg'*dg)) <span class="string">'|dx| = '</span> num2str(sqrt(dx'*dx))]);
|
||||
0021 disp([<span class="string">'dg''*dx = '</span> num2str(dgdx)])
|
||||
0022 disp([<span class="string">'|H*dg| = '</span> num2str(Hdg'*Hdg)])
|
||||
0023 H=H0;
|
||||
0024 <span class="keyword">end</span>
|
||||
0025 save H.dat H</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,78 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of bicgstab</title>
|
||||
<meta name="keywords" content="bicgstab">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > bicgstab.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>bicgstab
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [x,status]=bicgstab(func,b,x,tole,kmax,varargin) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="calib_obj.html" class="code" title="function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)">calib_obj</a> targets and iy order: 1) variances 2) correlations</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [x,status]=bicgstab(func,b,x,tole,kmax,varargin)</a>
|
||||
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 <span class="keyword">while</span> 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 <span class="keyword">end</span>
|
||||
0029 <span class="keyword">if</span> k == kmax
|
||||
0030 status = 1;
|
||||
0031 warning(sprintf(<span class="string">'BICSTABN didn''t converge after %d iterations: norm(r) = %g'</span>,kmax,norm(r)));
|
||||
0032 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,95 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of bksup</title>
|
||||
<meta name="keywords" content="bksup">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > bksup.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>bksup
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function d1 = bksupk(ny,fid,jcf,icc1) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> </li><li><a href="selif.html" class="code" title="function x = selif(a,b)">selif</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function d1 = bksupk(ny,fid,jcf,icc1)</a>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> M_ options_ c ncc
|
||||
0006
|
||||
0007 icf = [1:jcf-1] ;
|
||||
0008 ir = [(options_.periods-1)*ny+1:ny*options_.periods] ;
|
||||
0009 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = 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],<span class="string">'float64'</span>) ;
|
||||
0015 c = c' ;
|
||||
0016
|
||||
0017 d1(ir) = c(:,jcf) ;
|
||||
0018 ir = ir-ny ;
|
||||
0019
|
||||
0020 i = 2 ;
|
||||
0021
|
||||
0022 <span class="keyword">while</span> i <= M_.maximum_lead | i <= options_.periods
|
||||
0023 irf1 = <a href="selif.html" class="code" title="function x = selif(a,b)">selif</a>(<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>,<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a><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],<span class="string">'float64'</span>) ;
|
||||
0028 c = c' ;
|
||||
0029
|
||||
0030 d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
|
||||
0031 ir = ir - ny ;
|
||||
0032 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> - ny ;
|
||||
0033 i = i + 1 ;
|
||||
0034 <span class="keyword">end</span>
|
||||
0035
|
||||
0036 <span class="keyword">while</span> 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],<span class="string">'float64'</span>) ;
|
||||
0041 c = c' ;
|
||||
0042
|
||||
0043 d1(ir) = c(:,jcf)-c(:,icf)*d1(<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>) ;
|
||||
0044 ir = ir-ny ;
|
||||
0045 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>-ny ;
|
||||
0046 i = i+1;
|
||||
0047 <span class="keyword">end</span>
|
||||
0048
|
||||
0049 <span class="keyword">return</span> ;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,65 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of bksup1</title>
|
||||
<meta name="keywords" content="bksup1">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > bksup1.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>bksup1
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function d = bksup1(ny,jcf) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="sim1.html" class="code" title="function sim1">sim1</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function d = bksup1(ny,jcf)</a>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> options_ iyf c
|
||||
0006
|
||||
0007 ir = [(options_.periods-2)*ny+1:ny+(options_.periods-2)*ny] ;
|
||||
0008 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = iyf+(options_.periods-1)*ny ;
|
||||
0009 icf = [1:size(iyf,2)] ;
|
||||
0010
|
||||
0011 <span class="keyword">for</span> i = 2:options_.periods
|
||||
0012 c(ir,jcf) = c(ir,jcf)-c(ir,icf)*c(<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>,jcf) ;
|
||||
0013 ir = ir-ny ;
|
||||
0014 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>-ny ;
|
||||
0015 <span class="keyword">end</span>
|
||||
0016
|
||||
0017 d = c(:,jcf) ;
|
||||
0018
|
||||
0019 <span class="keyword">return</span> ;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,90 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of bksupk</title>
|
||||
<meta name="keywords" content="bksupk">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > bksupk.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>bksupk
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function d1 = bksupk(ny,fid,jcf,icc1) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> </li><li><a href="selif.html" class="code" title="function x = selif(a,b)">selif</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="simk.html" class="code" title="function simk">simk</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function d1 = bksupk(ny,fid,jcf,icc1)</a>
|
||||
0002
|
||||
0003 <span class="keyword">global</span> M_ options_
|
||||
0004
|
||||
0005 icf = [1:jcf-1] ;
|
||||
0006 ir = [(options_.periods-1)*ny+1:ny*options_.periods] ;
|
||||
0007 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = 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],<span class="string">'float64'</span>) ;
|
||||
0013
|
||||
0014 d1(ir) = c(:,jcf) ;
|
||||
0015 ir = ir-ny ;
|
||||
0016
|
||||
0017 i = 2 ;
|
||||
0018
|
||||
0019 <span class="keyword">while</span> i <= M_.maximum_lead | i <= options_.periods
|
||||
0020 irf1 = <a href="selif.html" class="code" title="function x = selif(a,b)">selif</a>(<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>,<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a><=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],<span class="string">'float64'</span>) ;
|
||||
0025
|
||||
0026 d1(ir) = c(:,jcf) - c(:,1:size(irf1,1))*d1(irf1) ;
|
||||
0027 ir = ir - ny ;
|
||||
0028 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> - ny ;
|
||||
0029 i = i + 1 ;
|
||||
0030 <span class="keyword">end</span>
|
||||
0031
|
||||
0032 <span class="keyword">while</span> 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],<span class="string">'float64'</span>) ;
|
||||
0037
|
||||
0038 d1(ir) = c(:,jcf)-c(:,icf)*d1(<a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>) ;
|
||||
0039 ir = ir-ny ;
|
||||
0040 <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a> = <a href="irf.html" class="code" title="function y = irf(dr, e1, long, drop, replic, iorder)">irf</a>-ny ;
|
||||
0041 i = i+1;
|
||||
0042 <span class="keyword">end</span>
|
||||
0043
|
||||
0044 <span class="keyword">return</span> ;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,79 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of bseastr</title>
|
||||
<meta name="keywords" content="bseastr">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > bseastr.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>bseastr
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function x = bseastr(s1,s2) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dcompare.html" class="code" title="function dcompare(s1)">dcompare</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function x = bseastr(s1,s2)</a>
|
||||
0004
|
||||
0005 m = size(s1,1) ;
|
||||
0006 x = zeros(m,1) ;
|
||||
0007 s1=upper(deblank(s1));
|
||||
0008 s2=upper(deblank(s2));
|
||||
0009
|
||||
0010 <span class="keyword">for</span> im = 1:m
|
||||
0011 key = s1(im,:) ;
|
||||
0012 h = size(s2,1) ;
|
||||
0013 l = 1 ;
|
||||
0014 <span class="keyword">while</span> l <= h
|
||||
0015 mid = round((h+l)/2) ;
|
||||
0016 temp = s2(mid,:) ;
|
||||
0017 <span class="keyword">if</span> ~ strcmp(key,temp)
|
||||
0018 <span class="keyword">for</span> i = 1:min(length(key),length(temp))
|
||||
0019 <span class="keyword">if</span> temp(i) > key(i)
|
||||
0020 h = mid - 1 ;
|
||||
0021 <span class="keyword">break</span>
|
||||
0022 <span class="keyword">else</span>
|
||||
0023 l = mid + 1 ;
|
||||
0024 <span class="keyword">break</span>
|
||||
0025 <span class="keyword">end</span>
|
||||
0026 <span class="keyword">end</span>
|
||||
0027 <span class="keyword">else</span>
|
||||
0028 x(im) = mid ;
|
||||
0029 <span class="keyword">break</span>
|
||||
0030 <span class="keyword">end</span>
|
||||
0031 <span class="keyword">end</span>
|
||||
0032 <span class="keyword">end</span>
|
||||
0033</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 327 B |
BIN
matlab/doc/c.png
Before Width: | Height: | Size: 252 B |
|
@ -1,221 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of calib</title>
|
||||
<meta name="keywords" content="calib">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > calib.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>calib
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function M_.Sigma_e = calib(var_indices,targets,var_weights,nar,cova,M_.Sigma_e) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="calib_obj.html" class="code" title="function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)">calib_obj</a> targets and iy order: 1) variances 2) correlations</li><li><a href="calib_obj2.html" class="code" title="function objective=calib_obj2(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)">calib_obj2</a> targets and iy order: 1) variances 2) correlations</li><li><a href="indnv.html" class="code" title="function a=indnv(x,y)">indnv</a> Copyright (C) 2001 Michel Juillard</li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li><li><a href="union.html" class="code" title="function x = union(a,b)">union</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function M_.Sigma_e = calib(var_indices,targets,var_weights,nar,cova,M_.Sigma_e)</a>
|
||||
0002 <span class="keyword">global</span> oo_ M_ vx
|
||||
0003
|
||||
0004 ncstr = 0;
|
||||
0005 ni = size(var_indices,1);
|
||||
0006 <span class="keyword">for</span> i=1:nar+3
|
||||
0007 ncstr = ncstr + size(var_indices{i},1);
|
||||
0008 <span class="keyword">end</span>
|
||||
0009 <span class="keyword">if</span> cova
|
||||
0010 <span class="keyword">if</span> ncstr < M_.exo_nbr*(M_.exo_nbr+1)/2
|
||||
0011 error([<span class="string">'number of preset variances is smaller than number of shock'</span> <span class="keyword">...</span>
|
||||
0012 <span class="string">' variances and covariances to be estimated !'</span>])
|
||||
0013 <span class="keyword">end</span>
|
||||
0014 <span class="keyword">else</span>
|
||||
0015 <span class="keyword">if</span> ncstr < M_.exo_nbr
|
||||
0016 error([<span class="string">'number of preset variances is smaller than number of shock'</span> <span class="keyword">...</span>
|
||||
0017 <span class="string">' variances to be estimated !'</span>])
|
||||
0018 <span class="keyword">end</span>
|
||||
0019 <span class="keyword">end</span>
|
||||
0020
|
||||
0021 <span class="comment">% computes approximate solution at order 1</span>
|
||||
0022 dr = <a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a>(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 <span class="keyword">for</span> i=M_.maximum_lag:-1:2
|
||||
0043 i1 = find(kstate(:,2) == i);
|
||||
0044 n1 = size(i1,1);
|
||||
0045 j = zeros(n1,1);
|
||||
0046 <span class="keyword">for</span> j1 = 1:n1
|
||||
0047 j(j1) = find(kstate(i0,1)==kstate(i1(j1),1));
|
||||
0048 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0055 ghu1 = [ghu(ikx,:);zeros(nx-npred,M_.exo_nbr)];
|
||||
0056 <span class="comment">% IA = speye(nx*nx)-kron(A,A);</span>
|
||||
0057 <span class="comment">% kron_ghu = kron(ghu1,ghu1);</span>
|
||||
0058
|
||||
0059 <span class="comment">% vx1 such that vec(sigma_x) = vx1 * vec(M_.Sigma_e) (predetermined vars)</span>
|
||||
0060 vx1 = [];
|
||||
0061 <span class="comment">% vx1 = IA\kron_ghu;</span>
|
||||
0062 IA = [];
|
||||
0063 kron_ghu = [];
|
||||
0064
|
||||
0065 <span class="comment">% computes required variables and indices among required variables</span>
|
||||
0066 iiy = [];
|
||||
0067 <span class="keyword">for</span> i=1:nar+3
|
||||
0068 <span class="keyword">if</span> i ~= 3 & ~isempty(var_indices{i})
|
||||
0069 iiy = <a href="union.html" class="code" title="function x = union(a,b)">union</a>(iiy, iv(var_indices{i}(:,1)));
|
||||
0070 <span class="keyword">end</span>
|
||||
0071 <span class="keyword">end</span>
|
||||
0072 <span class="keyword">if</span> ~isempty(var_indices{2})
|
||||
0073 iiy = <a href="union.html" class="code" title="function x = union(a,b)">union</a>(iiy, iv(var_indices{2}(:,2)));
|
||||
0074 <span class="keyword">end</span>
|
||||
0075 ny = size(iiy,1);
|
||||
0076
|
||||
0077 <span class="keyword">for</span> i=1:nar+3
|
||||
0078 <span class="keyword">if</span> i ~= 3 & ~isempty(var_indices{i})
|
||||
0079 var_indices{i}(:,1) = <a href="indnv.html" class="code" title="function a=indnv(x,y)">indnv</a>(iv(var_indices{i}(:,1)),iiy);
|
||||
0080 <span class="keyword">end</span>
|
||||
0081 <span class="keyword">if</span> i ~= 2 & i ~= 3 & ~isempty(var_indices{i})
|
||||
0082 var_indices{i} = sub2ind([ny ny],var_indices{i},var_indices{i});
|
||||
0083 <span class="keyword">end</span>
|
||||
0084 <span class="keyword">end</span>
|
||||
0085 <span class="keyword">if</span> ~isempty(var_indices{2})
|
||||
0086 var_indices{2}(:,2) = <a href="indnv.html" class="code" title="function a=indnv(x,y)">indnv</a>(iv(var_indices{2}(:,2)),iiy);
|
||||
0087 var_indices{2} = sub2ind([ny ny],var_indices{2}(:,1),var_indices{2}(:,2));
|
||||
0088 <span class="keyword">end</span>
|
||||
0089 <span class="keyword">if</span> ~isempty(var_indices{3})
|
||||
0090 var_indices{3} = sub2ind([M_.exo_nbr M_.exo_nbr],var_indices{3}(:,1),var_indices{3}(:,2));
|
||||
0091 <span class="keyword">end</span>
|
||||
0092 <span class="keyword">if</span> isempty(M_.Sigma_e)
|
||||
0093 M_.Sigma_e = 0.01*eye(M_.exo_nbr);
|
||||
0094 b = 0.1*ghu1*ghu1';
|
||||
0095 <span class="keyword">else</span>
|
||||
0096 b = ghu1*M_.Sigma_e*ghu1';
|
||||
0097 M_.Sigma_e = chol(M_.Sigma_e+1e-14*eye(M_.exo_nbr));
|
||||
0098 <span class="keyword">end</span>
|
||||
0099 options=optimset(<span class="string">'LargeScale'</span>,<span class="string">'on'</span>,<span class="string">'MaxFunEvals'</span>,20000*ny,<span class="string">'TolX'</span>,1e-4, <span class="keyword">...</span>
|
||||
0100 <span class="string">'TolFun'</span>,1e-4,<span class="string">'Display'</span>,<span class="string">'Iter'</span>,<span class="string">'MaxIter'</span>,10000);
|
||||
0101 <span class="comment">% [M_.Sigma_e,f]=fminunc(@calib_obj,M_.Sigma_e,options,A,ghu1,ghx(iiy,:),ghu(iiy,:),targets,var_weights,var_indices,nar);</span>
|
||||
0102 [M_.Sigma_e,f]=fmincon(@<a href="calib_obj.html" class="code" title="function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)">calib_obj</a>,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 = <a href="calib_obj2.html" class="code" title="function objective=calib_obj2(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)">calib_obj2</a>(diag(M_.Sigma_e),A,ghu1,ghx(iiy,:),ghu(iiy,:),targets,var_weights,var_indices,nar);
|
||||
0106 disp(<span class="string">'CALIBRATION'</span>)
|
||||
0107 disp(<span class="string">''</span>)
|
||||
0108 <span class="keyword">if</span> ~isempty(var_indices{1})
|
||||
0109 disp(sprintf(<span class="string">'%16s %14s %14s %14s %14s'</span>,<span class="string">'Std. Dev'</span>,<span class="string">'Target'</span>,<span class="string">'Obtained'</span>,<span class="string">'Diff'</span>));
|
||||
0110 str = <span class="string">' '</span>;
|
||||
0111 <span class="keyword">for</span> i=1:size(var_indices{1},1)
|
||||
0112 [i1,i2] = ind2sub([ny ny],var_indices{1}(i));
|
||||
0113 str = sprintf(<span class="string">'%16s: %14.2f %14.2f %14.2f'</span>,M_.endo_names(order(iiy(i1)),:),targets{1}(i),objective{1}(i),objective{1}(i)-targets{1}(i));
|
||||
0114 disp(str);
|
||||
0115 <span class="keyword">end</span>
|
||||
0116 <span class="keyword">end</span>
|
||||
0117 <span class="keyword">if</span> ~isempty(var_indices{2})
|
||||
0118 disp(sprintf(<span class="string">'%32s %14s %14s'</span>,<span class="string">'Correlations'</span>,<span class="string">'Target'</span>,<span class="string">'Obtained'</span>,<span class="string">'Diff'</span>));
|
||||
0119 str = <span class="string">' '</span>;
|
||||
0120 <span class="keyword">for</span> i=1:size(var_indices{2},1)
|
||||
0121 [i1,i2]=ind2sub([ny ny],var_indices{2}(i));
|
||||
0122 str = sprintf(<span class="string">'%16s,%16s: %14.2f %14.2f %14.2f'</span>,M_.endo_names(order(iiy(i1)),:), <span class="keyword">...</span>
|
||||
0123 M_.endo_names(order(iiy(i2)),:),targets{2}(i),objective{2}(i),objective{2}(i)-targets{2}(i));
|
||||
0124 disp(str);
|
||||
0125 <span class="keyword">end</span>
|
||||
0126 <span class="keyword">end</span>
|
||||
0127 <span class="keyword">if</span> ~isempty(var_indices{3})
|
||||
0128 disp(sprintf(<span class="string">'%32s %16s %16s'</span>,<span class="string">'Constrained shocks (co)variances'</span>,<span class="string">'Target'</span>,<span class="string">'Obtained'</span>));
|
||||
0129 str = <span class="string">' '</span>;
|
||||
0130 <span class="keyword">for</span> i=1:size(var_indices{3},1)
|
||||
0131 [i1,i2]=ind2sub([M_.exo_nbr M_.exo_nbr],var_indices{3}(i));
|
||||
0132 <span class="keyword">if</span> i1 == i2
|
||||
0133 str = sprintf(<span class="string">'%32s: %16.4f %16.4f'</span>,M_.exo_name(order(i1),:), <span class="keyword">...</span>
|
||||
0134 targets{3}(i),objective{3}(i));
|
||||
0135 <span class="keyword">else</span>
|
||||
0136 str = sprintf(<span class="string">'%16s,%16s: %16.4f %16.4f'</span>,M_.exo_name(order(i1),:), <span class="keyword">...</span>
|
||||
0137 M_.exo_name(order(i2), :),targets{3}(i),objective{3}(i));
|
||||
0138 <span class="keyword">end</span>
|
||||
0139 disp(str);
|
||||
0140 <span class="keyword">end</span>
|
||||
0141 <span class="keyword">end</span>
|
||||
0142 flag = 1;
|
||||
0143 <span class="keyword">for</span> j=4:nar+3
|
||||
0144 <span class="keyword">if</span> ~isempty(var_indices{j})
|
||||
0145 <span class="keyword">if</span> flag
|
||||
0146 disp(sprintf(<span class="string">'%16s %16s %16s'</span>,<span class="string">'Autocorrelations'</span>,<span class="string">'Target'</span>,<span class="string">'Obtained'</span>));
|
||||
0147 str = <span class="string">' '</span>;
|
||||
0148 flag = 0;
|
||||
0149 <span class="keyword">end</span>
|
||||
0150 <span class="keyword">for</span> i=1:size(var_indices{j},1)
|
||||
0151 [i1,i2] = ind2sub([ny ny],var_indices{j}(i));
|
||||
0152 str = sprintf(<span class="string">'%16s(%d): %16.4f %16.4f'</span>,M_.endo_names(order(iiy(i1)),:), <span class="keyword">...</span>
|
||||
0153 j-3,targets{j}(i),objective{j}(i));
|
||||
0154 disp(str);
|
||||
0155 <span class="keyword">end</span>
|
||||
0156 <span class="keyword">end</span>
|
||||
0157 <span class="keyword">end</span>
|
||||
0158
|
||||
0159 disp(<span class="string">''</span>);
|
||||
0160 disp(<span class="string">'Calibrated variances'</span>)
|
||||
0161 str = <span class="string">' '</span>;
|
||||
0162 <span class="keyword">for</span> i=1:M_.exo_nbr
|
||||
0163 str = [str sprintf(<span class="string">'%16s'</span>,M_.exo_name(i,:))];
|
||||
0164 <span class="keyword">end</span>
|
||||
0165 disp(str);
|
||||
0166 disp(<span class="string">''</span>);
|
||||
0167 str = <span class="string">' '</span>;
|
||||
0168 <span class="keyword">for</span> i=1:M_.exo_nbr
|
||||
0169 str = [str sprintf(<span class="string">'%16f'</span>,M_.Sigma_e(i,i))];
|
||||
0170 <span class="keyword">end</span>
|
||||
0171 disp(str);
|
||||
0172
|
||||
0173
|
||||
0174
|
||||
0175 <span class="comment">% 10/9/02 MJ</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,114 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of calib_obj</title>
|
||||
<meta name="keywords" content="calib_obj">
|
||||
<meta name="description" content="targets and iy order: 1) variances 2) correlations">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > calib_obj.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>calib_obj
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>targets and iy order: 1) variances 2) correlations</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> targets and iy order: 1) variances 2) correlations
|
||||
3) constraints on M_.Sigma_e itself 4) autocorrelations</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="bicgstab.html" class="code" title="function [x,status]=bicgstab(func,b,x,tole,kmax,varargin)">bicgstab</a> </li><li><a href="f_var.html" class="code" title="function b=f_var(x,a,nx)">f_var</a> </li><li><a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a> solves x-a*x*a'=b for b (and then x) symmetrical</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="calib.html" class="code" title="function M_.Sigma_e = calib(var_indices,targets,var_weights,nar,cova,M_.Sigma_e)">calib</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% targets and iy order: 1) variances 2) correlations</span>
|
||||
0002 <span class="comment">% 3) constraints on M_.Sigma_e itself 4) autocorrelations</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)</a>
|
||||
0004 <span class="keyword">global</span> vx fold
|
||||
0005
|
||||
0006 oo_.gamma_y = cell(nar+1,1);
|
||||
0007 <span class="comment">% M_.Sigma_e = M_.Sigma_e'*M_.Sigma_e;</span>
|
||||
0008 M_.Sigma_e=diag(M_.Sigma_e);
|
||||
0009 nx = size(ghx,2);
|
||||
0010 b=ghu1*M_.Sigma_e*ghu1';
|
||||
0011 vx = [];
|
||||
0012 <span class="keyword">if</span> isempty(vx)
|
||||
0013 vx = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(A,b);
|
||||
0014 <span class="keyword">else</span>
|
||||
0015 [vx,status] = <a href="bicgstab.html" class="code" title="function [x,status]=bicgstab(func,b,x,tole,kmax,varargin)">bicgstab</a>(@<a href="f_var.html" class="code" title="function b=f_var(x,a,nx)">f_var</a>,b(:),vx(:),1e-8,50,A,nx);
|
||||
0016 <span class="keyword">if</span> status
|
||||
0017 vx = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(A,b);
|
||||
0018 <span class="keyword">else</span>
|
||||
0019 vx=reshape(vx,nx,nx);
|
||||
0020 <span class="keyword">end</span>
|
||||
0021 <span class="keyword">end</span>
|
||||
0022 oo_.gamma_y{1} = ghx*vx*ghx'+ ghu*M_.Sigma_e*ghu';
|
||||
0023 f = 0;
|
||||
0024 <span class="keyword">if</span> ~isempty(targets{1})
|
||||
0025 e = targets{1}-sqrt(oo_.gamma_y{1}(iy{1}));
|
||||
0026 f = e'*(var_weights{1}.*e);
|
||||
0027 <span class="keyword">end</span>
|
||||
0028
|
||||
0029 sy = sqrt(diag(oo_.gamma_y{1}));
|
||||
0030 sy = sy *sy';
|
||||
0031 <span class="keyword">if</span> ~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 <span class="keyword">end</span>
|
||||
0035
|
||||
0036 <span class="keyword">if</span> ~isempty(targets{3})
|
||||
0037 e = targets{3}-sqrt(M_.Sigma_e(iy{3}));
|
||||
0038 f = f+e'*(var_weights{3}.*e);
|
||||
0039 <span class="keyword">end</span>
|
||||
0040
|
||||
0041 <span class="comment">% autocorrelations</span>
|
||||
0042 <span class="keyword">if</span> nar > 0
|
||||
0043 vxy = (A*vx*ghx'+ghu1*M_.Sigma_e*ghu');
|
||||
0044
|
||||
0045 oo_.gamma_y{2} = ghx*vxy./(sy+1e-10);
|
||||
0046 <span class="keyword">if</span> ~isempty(targets{4})
|
||||
0047 e = targets{4}-oo_.gamma_y{2}(iy{4});
|
||||
0048 f = f+e'*(var_weights{4}.*e);
|
||||
0049 <span class="keyword">end</span>
|
||||
0050
|
||||
0051 <span class="keyword">for</span> i=2:nar
|
||||
0052 vxy = A*vxy;
|
||||
0053 oo_.gamma_y{i+1} = ghx*vxy./(sy+1e-10);
|
||||
0054 <span class="keyword">if</span> ~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 <span class="keyword">end</span>
|
||||
0058 <span class="keyword">end</span>
|
||||
0059 <span class="keyword">end</span>
|
||||
0060 <span class="keyword">if</span> isempty(fold) | f < 2*fold
|
||||
0061 fold = f;
|
||||
0062 vxold = vx;
|
||||
0063 <span class="keyword">end</span>
|
||||
0064 <span class="comment">% 11/04/02 MJ generalized for correlations, autocorrelations and</span>
|
||||
0065 <span class="comment">% constraints on M_.Sigma_e</span>
|
||||
0066 <span class="comment">% 01/25/03 MJ targets std. dev. instead of variances</span>
|
||||
0067</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,93 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of calib_obj2</title>
|
||||
<meta name="keywords" content="calib_obj2">
|
||||
<meta name="description" content="targets and iy order: 1) variances 2) correlations">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > calib_obj2.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>calib_obj2
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>targets and iy order: 1) variances 2) correlations</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function objective=calib_obj2(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> targets and iy order: 1) variances 2) correlations
|
||||
3) constraints on M_.Sigma_e itself 4) autocorrelations</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a> solves x-a*x*a'=b for b (and then x) symmetrical</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="calib.html" class="code" title="function M_.Sigma_e = calib(var_indices,targets,var_weights,nar,cova,M_.Sigma_e)">calib</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% targets and iy order: 1) variances 2) correlations</span>
|
||||
0002 <span class="comment">% 3) constraints on M_.Sigma_e itself 4) autocorrelations</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function objective=calib_obj2(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)</a>
|
||||
0004 <span class="keyword">global</span> 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 = <a href="lyapunov_symm.html" class="code" title="function [x,ns_var]=lyapunov_symm(a,b)">lyapunov_symm</a>(A,b);
|
||||
0012 oo_.gamma_y{1} = ghx*vx*ghx'+ ghu*M_.Sigma_e*ghu';
|
||||
0013 <span class="keyword">if</span> ~isempty(targets{1})
|
||||
0014 objective{1} = sqrt(oo_.gamma_y{1}(iy{1}));
|
||||
0015 <span class="keyword">end</span>
|
||||
0016
|
||||
0017 sy = sqrt(diag(oo_.gamma_y{1}));
|
||||
0018 sy = sy *sy';
|
||||
0019 <span class="keyword">if</span> ~isempty(targets{2})
|
||||
0020 objective{2} = oo_.gamma_y{1}(iy{2})./(sy(iy{2})+1e-10);
|
||||
0021 <span class="keyword">end</span>
|
||||
0022
|
||||
0023 <span class="keyword">if</span> ~isempty(targets{3})
|
||||
0024 objective{3} = M_.Sigma_e(iy{3});
|
||||
0025 <span class="keyword">end</span>
|
||||
0026
|
||||
0027 <span class="comment">% autocorrelations</span>
|
||||
0028 <span class="keyword">if</span> nar > 0
|
||||
0029 vxy = (A*vx*ghx'+ghu1*M_.Sigma_e*ghu');
|
||||
0030
|
||||
0031 oo_.gamma_y{2} = ghx*vxy./(sy+1e-10);
|
||||
0032 <span class="keyword">if</span> ~isempty(targets{4})
|
||||
0033 objective{4} = oo_.gamma_y{2}(iy{4});
|
||||
0034 <span class="keyword">end</span>
|
||||
0035
|
||||
0036 <span class="keyword">for</span> i=2:nar
|
||||
0037 vxy = A*vxy;
|
||||
0038 oo_.gamma_y{i+1} = ghx*vxy./(sy+1e-10);
|
||||
0039 <span class="keyword">if</span> ~isempty(targets{i+3})
|
||||
0040 objecitve{i+3} = oo_.gamma_y{i+1}(iy{i+3});
|
||||
0041 <span class="keyword">end</span>
|
||||
0042 <span class="keyword">end</span>
|
||||
0043 <span class="keyword">end</span>
|
||||
0044
|
||||
0045 <span class="comment">% 11/04/02 MJ generalized for correlations, autocorrelations and</span>
|
||||
0046 <span class="comment">% constraints on M_.Sigma_e</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,115 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of check</title>
|
||||
<meta name="keywords" content="check">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > check.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>check
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function result = check </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="print_info.html" class="code" title="function print_info(info)">print_info</a> Copyright (C) 2005 Michel Juillard</li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li><li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="lnsrch.html" class="code" title="function [x,f,fvec,check]=lnsrch(xold,fold,g,p,stpmax,func,varargin)">lnsrch</a> Copyright (C) 2001 Michel Juillard</li><li><a href="lnsrch1.html" class="code" title="function [x,f,fvec,check]=lnsrch(xold,fold,g,p,stpmax,func,j1,j2,varargin)">lnsrch1</a> Copyright (C) 2001 Michel Juillard</li><li><a href="newrat.html" class="code" title="function [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin)">newrat</a> </li><li><a href="olr1.html" class="code" title="function dr = olr1(ys,algo,olr_inst,bet,obj_var,W)">olr1</a> Copyright (C) 2001 Michel Juillard</li><li><a href="osr1.html" class="code" title="function oo_.dr=osr1(params,weights)">osr1</a> </li><li><a href="simult_.html" class="code" title="function y_=simult_(y0,dr,ex_,iorder)">simult_</a> Copyright (C) 2001 Michel Juillard</li><li><a href="solve1.html" class="code" title="function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)">solve1</a> Copyright (C) 2001 Michel Juillard</li><li><a href="steady_.html" class="code" title="function steady_()">steady_</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003
|
||||
0004 <a name="_sub0" href="#_subfunctions" class="code">function result = check</a>
|
||||
0005 <span class="keyword">global</span> M_ options_ oo_
|
||||
0006 <span class="keyword">global</span> it_
|
||||
0007
|
||||
0008 temp_options = options_;
|
||||
0009 tempex = oo_.exo_simul;
|
||||
0010 <span class="keyword">if</span> ~options_.initval_file
|
||||
0011 oo_.exo_simul = ones(M_.maximum_lead+M_.maximum_lag+1,1)*oo_.exo_steady_state';
|
||||
0012 <span class="keyword">end</span>
|
||||
0013
|
||||
0014 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'noprint'</span>,0);
|
||||
0015 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'order'</span>,1);
|
||||
0016 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'linear'</span>,0);
|
||||
0017 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'dr_algo'</span>,0);
|
||||
0018
|
||||
0019 [dr, info] = <a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a>(oo_.steady_state,1);
|
||||
0020
|
||||
0021 <span class="keyword">if</span> info(1) ~= 0 & info(1) ~= 3 & info(1) ~= 4
|
||||
0022 <a href="print_info.html" class="code" title="function print_info(info)">print_info</a>(info);
|
||||
0023 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> options_.noprint == 0
|
||||
0032 disp(<span class="string">' '</span>)
|
||||
0033 disp(<span class="string">'EIGENVALUES:'</span>)
|
||||
0034 disp(sprintf(<span class="string">'%16s %16s %16s\n'</span>,<span class="string">'Modulus'</span>,<span class="string">'Real'</span>,<span class="string">'Imaginary'</span>))
|
||||
0035 z=[m_lambda real(eigenvalues_(i)) imag(eigenvalues_(i))]';
|
||||
0036 disp(sprintf(<span class="string">'%16.4g %16.4g %16.4g\n'</span>,z))
|
||||
0037 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'qz_criterium'</span>,1.000001);
|
||||
0038 disp(sprintf(<span class="string">'\nThere are %d eigenvalue(s) larger than 1 in modulus '</span>, <span class="keyword">...</span>
|
||||
0039 nnz(abs(eigenvalues_) > options_.qz_criterium)));
|
||||
0040 disp(sprintf(<span class="string">'for %d forward-looking variable(s)'</span>,nyf));
|
||||
0041 disp(<span class="string">' '</span>)
|
||||
0042 <span class="keyword">if</span> info(1) == 0
|
||||
0043 <span class="keyword">if</span> dr.rank == nyf
|
||||
0044 disp(<span class="string">'The rank condition is verified.'</span>)
|
||||
0045 <span class="keyword">else</span>
|
||||
0046 disp(<span class="string">'The rank conditions ISN''T verified!'</span>)
|
||||
0047 <span class="keyword">end</span>
|
||||
0048 disp(<span class="string">' '</span>)
|
||||
0049 <span class="keyword">end</span>
|
||||
0050 <span class="keyword">end</span>
|
||||
0051
|
||||
0052 <span class="comment">% keep lambda_ for backward compatibility</span>
|
||||
0053 lambda_ = eigenvalues_;
|
||||
0054
|
||||
0055 options_ = temp_options;
|
||||
0056
|
||||
0057 <span class="comment">% 2/9/99 MJ: line 15, added test for absence of exogenous variable.</span>
|
||||
0058 <span class="comment">% 8/27/2000 MJ: change JACOB call. Added ...,1 to cumsum()</span>
|
||||
0059 <span class="comment">% 6/24/01 MJ: added count of abs(eigenvalues) > 1</span>
|
||||
0060 <span class="comment">% 2/21/02 MJ: count eigenvalues > 1[+1e-5]</span>
|
||||
0061 <span class="comment">% 01/22/03 MJ: warning(warning_state) needs parentheses for Matlab 6.5</span>
|
||||
0062 <span class="comment">% name conflicts with parameters</span>
|
||||
0063 <span class="comment">% 05/21/03 MJ: replace computation by dr1.m and add rank check</span>
|
||||
0064 <span class="comment">% 06/05/03 MJ: corrected bug when M_.maximum_lag > 0</span>
|
||||
0065
|
||||
0066
|
||||
0067
|
||||
0068
|
||||
0069</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,70 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of check_mh</title>
|
||||
<meta name="keywords" content="check_mh">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > check_mh.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>check_mh
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function check_mh(fname) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="my_subplot.html" class="code" title="function my_subplot(i,imax,irow,icol,fig_title)">my_subplot</a> spreads subplots on several figures according to a maximum number of</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function check_mh(fname)</a>
|
||||
0002 eval([<span class="string">'load '</span> 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 <span class="keyword">for</span> i=1:np
|
||||
0011 y1 = zeros(size(x),nb);
|
||||
0012 <span class="keyword">for</span> k=1:nb
|
||||
0013 <span class="keyword">for</span> j=1:length(x)
|
||||
0014 y1(j,k) = mean(x2(1:x(j),i,k));
|
||||
0015 <span class="keyword">end</span>
|
||||
0016 <span class="keyword">end</span>
|
||||
0017 <a href="my_subplot.html" class="code" title="function my_subplot(i,imax,irow,icol,fig_title)">my_subplot</a>(i,np,4,5,<span class="string">'MH convergence'</span>);
|
||||
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 <span class="keyword">end</span>
|
||||
0023 disp(z)
|
||||
0024</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,64 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of check_model</title>
|
||||
<meta name="keywords" content="check_model">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > check_model.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>check_model
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function check_model() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function check_model()</a>
|
||||
0002 <span class="keyword">global</span> M_
|
||||
0003
|
||||
0004 xlen = M_.maximum_exo_lag+M_.maximum_exo_lead + 1;
|
||||
0005 <span class="keyword">if</span> ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
|
||||
0006 error (<span class="string">'RESOL: Error in model specification: some variables don"t appear as current'</span>) ;
|
||||
0007 <span class="keyword">end</span>
|
||||
0008
|
||||
0009 <span class="keyword">if</span> xlen > 1
|
||||
0010 error ([<span class="string">'RESOL: stochastic exogenous variables must appear only at the'</span> <span class="keyword">...</span>
|
||||
0011 <span class="string">' current period. Use additional endogenous variables'</span>]) ;
|
||||
0012 <span class="keyword">end</span>
|
||||
0013
|
||||
0014 <span class="keyword">if</span> (M_.exo_det_nbr > 0) & (M_.maximum_lag > 1 | M_.maximum_lead > 1)
|
||||
0015 error([<span class="string">'Exogenous deterministic variables are currently only allowed in'</span> <span class="keyword">...</span>
|
||||
0016 <span class="string">' models with leads and lags on only one period'</span>])
|
||||
0017 <span class="keyword">end</span>
|
||||
0018</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,217 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of compDist</title>
|
||||
<meta name="keywords" content="compDist">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > compDist.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>compDist
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function compdist(xparam1, x2, pltopt, figurename) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="lpdfgam.html" class="code" title="function ldens = lpdfgam(x,a,b);">lpdfgam</a> log GAMMA PDF</li><li><a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a> MJ_QGAMMA The gamma inverse distribution function</li><li><a href="posterior_density_estimate.html" class="code" title="function [abscissa,f,h] = posterior_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">posterior_density_estimate</a> %</li><li><a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a> QBETA The beta inverse distribution function</li><li><a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a> QGAMMA The gamma inverse distribution function</li><li><a href="qnorm.html" class="code" title="function x = qnorm(p,m,s)">qnorm</a> QNORM The normal inverse distribution function</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function compdist(xparam1, x2, pltopt, figurename)</a>
|
||||
0002 <span class="keyword">global</span> bayestopt_ estim_params_ M_ options_
|
||||
0003
|
||||
0004 <span class="comment">% NOTE: If pltopt ~= 'All' compdist.m just draws prior densities.</span>
|
||||
0005
|
||||
0006 <span class="comment">%% Set density estimation parameters:</span>
|
||||
0007 number_of_grid_points = 2^9; <span class="comment">% 2^9 = 512 !... Must be a power of two.</span>
|
||||
0008 bandwidth = 0; <span class="comment">% Rule of thumb optimal bandwidth parameter.</span>
|
||||
0009 kernel_function = <span class="string">'gaussian'</span>; <span class="comment">% You can switch to: 'epanechnikov', 'quartic', 'triangle',</span>
|
||||
0010 <span class="comment">% 'triweight', 'uniform' or 'cosinus' kernels (iff bandwidth=0, see posterior_density_estimate.m).</span>
|
||||
0011 truncprior = 10^(-3);
|
||||
0012
|
||||
0013
|
||||
0014 npar=length(xparam1);
|
||||
0015 nruns=length(x2);
|
||||
0016 icol=ceil(sqrt(npar));
|
||||
0017 iraw=icol;
|
||||
0018 <span class="keyword">if</span> (icol-1)*(icol-2)>=npar
|
||||
0019 iraw = icol-2;
|
||||
0020 icol=icol-1;
|
||||
0021 <span class="keyword">elseif</span> (icol)*(icol-2)>=npar
|
||||
0022 iraw = icol-2;
|
||||
0023 <span class="keyword">elseif</span> icol*(icol-1)>=npar
|
||||
0024 iraw=icol-1;
|
||||
0025 <span class="keyword">end</span>
|
||||
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(<span class="string">'Name'</span>,figurename)
|
||||
0035 <span class="keyword">for</span> i=1:npar;
|
||||
0036 <span class="keyword">if</span> i<=estim_params_.nvx
|
||||
0037 vname = deblank(M_.exo_name(estim_params_.var_exo(i,1),:));
|
||||
0038 nam=[<span class="string">'SE_{'</span>,vname,<span class="string">'}'</span>];
|
||||
0039 <span class="keyword">elseif</span> i<=(estim_params_.nvx+estim_params_.nvn)
|
||||
0040 deblank(options_.varobs(estim_params_.var_endo(i-estim_params_.nvx,1),:));
|
||||
0041 nam=[<span class="string">'SE_{EOBS_'</span>,vname,<span class="string">'}'</span>];
|
||||
0042 <span class="keyword">elseif</span> 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,:)) <span class="string">','</span> deblank(M_.exo_name(k2,:))];
|
||||
0047 nam=[<span class="string">'CC_{'</span>,vname,<span class="string">'}'</span>];
|
||||
0048 <span class="keyword">elseif</span> i<=(estim_params_.nvx+estim_params_.nvn+estim_params_.ncx+ <span class="keyword">...</span>
|
||||
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,:)) <span class="string">','</span> deblank(M_.exo_name(k2,:))];
|
||||
0054 nam=[<span class="string">'CC_{EOBS_'</span>,vname,<span class="string">'}'</span>];
|
||||
0055 <span class="keyword">else</span>
|
||||
0056 j = i - (estim_params_.nvx+estim_params_.nvn+estim_params_.ncx+ <span class="keyword">...</span>
|
||||
0057 estim_params_.ncn);
|
||||
0058 nam = deblank(estim_params_.param_names(j,:));
|
||||
0059 <span class="keyword">end</span>
|
||||
0060 subplot(iraw, icol, i);
|
||||
0061 <span class="keyword">if</span> strcmpi(pltopt,<span class="string">'all'</span>); <span class="comment">% Estimation of the density...</span>
|
||||
0062 [abscissa,ff,h] = <a href="posterior_density_estimate.html" class="code" title="function [abscissa,f,h] = posterior_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">posterior_density_estimate</a>(x2(round(options_.mh_drop*nruns):<span class="keyword">end</span>,i),<span class="keyword">...</span>
|
||||
0063 number_of_grid_points,bandwidth,kernel_function);
|
||||
0064 plot(abscissa,ff,<span class="string">'-k'</span>,<span class="string">'linewidth'</span>,2);
|
||||
0065 <span class="keyword">end</span>;
|
||||
0066 a = 0;
|
||||
0067 b = 0;
|
||||
0068 <span class="keyword">if</span> pshape(i) == 1; <span class="comment">%/* BETA Prior */</span>
|
||||
0069 density = inline(<span class="string">'((1-x).^(b-1)).*x.^(a-1)./beta(a,b)'</span>,<span class="string">'x'</span>,<span class="string">'a'</span>,<span class="string">'b'</span>);
|
||||
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 = <a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a>(truncprior,a,b);
|
||||
0075 supbound = <a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a>(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 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0081 top = max([max(ff);max(f)]);
|
||||
0082 <span class="keyword">end</span>;
|
||||
0083 <span class="keyword">elseif</span> pshape(i) == 2; <span class="comment">%/* GAMMA PRIOR */</span>
|
||||
0084 <span class="comment">% density =</span>
|
||||
0085 <span class="comment">% inline('((x/b).^(a-1)).*exp(-x/b)*inv(b*gamma(a))','x','a','b');</span>
|
||||
0086 mu = p1(i)-p3(i);
|
||||
0087 b = p2(i)^2/mu;
|
||||
0088 a = mu/b;
|
||||
0089 infbound = <a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(truncprior,a)*b;
|
||||
0090 supbound = <a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(1-truncprior,a)*b;
|
||||
0091 stepsize = (supbound-infbound)/200;
|
||||
0092 abscissa = infbound:stepsize:supbound;
|
||||
0093 f = exp(<a href="lpdfgam.html" class="code" title="function ldens = lpdfgam(x,a,b);">lpdfgam</a>(abscissa,a,b));
|
||||
0094 abscissa = abscissa + p3(i);
|
||||
0095 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0096 top = max([max(ff);max(f)]);
|
||||
0097 <span class="keyword">end</span>;
|
||||
0098 <span class="keyword">elseif</span> pshape(i) == 3; <span class="comment">%/* GAUSSIAN PRIOR */</span>
|
||||
0099 density = inline(<span class="string">'inv(sqrt(2*pi)*b)*exp(-0.5*((x-a)/b).^2)'</span>,<span class="string">'x'</span>,<span class="string">'a'</span>,<span class="string">'b'</span>);
|
||||
0100 a = p1(i);
|
||||
0101 b = p2(i);
|
||||
0102 infbound = <a href="qnorm.html" class="code" title="function x = qnorm(p,m,s)">qnorm</a>(truncprior,a,b);
|
||||
0103 supbound = <a href="qnorm.html" class="code" title="function x = qnorm(p,m,s)">qnorm</a>(1-truncprior,a,b);
|
||||
0104 stepsize = (supbound-infbound)/200;
|
||||
0105 abscissa = infbound:stepsize:supbound;
|
||||
0106 f = density(abscissa,a,b);
|
||||
0107 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0108 top = max([max(ff);max(f)]);
|
||||
0109 <span class="keyword">end</span>;
|
||||
0110 <span class="keyword">elseif</span> pshape(i) == 4; <span class="comment">%/* INVGAMMA PRIOR type 1 */</span>
|
||||
0111 density = inline(<span class="string">'2*inv(gamma(nu/2))*(x.^(-nu-1))*((s/2)^(nu/2)).*exp(-s./(2*x.^2))'</span>,<span class="string">'x'</span>,<span class="string">'s'</span>,<span class="string">'nu'</span>);
|
||||
0112 nu = p2(i);
|
||||
0113 s = p1(i);
|
||||
0114 a = nu/2;
|
||||
0115 b = 2/s;
|
||||
0116 infbound = 1/sqrt(<a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(1-10*truncprior,a)*b);
|
||||
0117 supbound = 1/sqrt(<a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(10*truncprior,a)*b);
|
||||
0118 stepsize = (supbound-infbound)/200;
|
||||
0119 abscissa = infbound:stepsize:supbound;
|
||||
0120 f = density(abscissa,s,nu);
|
||||
0121 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0122 top = max([max(ff);max(f)]);
|
||||
0123 <span class="keyword">end</span>;
|
||||
0124 <span class="keyword">elseif</span> pshape(i) == 5; <span class="comment">%/* UNIFORM PRIOR */</span>
|
||||
0125 density = inline(<span class="string">'(x.^0)/(b-a)'</span>,<span class="string">'x'</span>,<span class="string">'a'</span>,<span class="string">'b'</span>);
|
||||
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 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0134 top = max([max(ff);max(f)]);
|
||||
0135 <span class="keyword">end</span>;
|
||||
0136 <span class="keyword">elseif</span> pshape(i) == 6; <span class="comment">%/* INVGAMMA PRIOR type 2 */</span>
|
||||
0137 density = inline(<span class="string">'inv(gamma(nu/2))*(x.^(-.5(nu+2)))*((s/2)^(nu/2)).*exp(-s./(2*x))'</span>,<span class="string">'x'</span>,<span class="string">'s'</span>,<span class="string">'nu'</span>);
|
||||
0138 nu = p2(i);
|
||||
0139 s = p1(i);
|
||||
0140 a = nu/2;
|
||||
0141 b = 2/s;
|
||||
0142 infbound = 1/(<a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a>(1-truncprior,a)*b);
|
||||
0143 supbound = 1/(<a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a>(truncprior,a)*b);
|
||||
0144 stepsize = (supbound-infbound)/200;
|
||||
0145 abscissa = infbound:stepsize:supbound;
|
||||
0146 f = density(abscissa,s,nu);
|
||||
0147 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0148 top = max([max(ff);max(f)]);
|
||||
0149 <span class="keyword">end</span>;
|
||||
0150 <span class="keyword">end</span>;
|
||||
0151 hold on;
|
||||
0152 k = [1:length(f)];
|
||||
0153 <span class="keyword">if</span> pshape(i) ~= 5
|
||||
0154 [junk,k1] = max(f);
|
||||
0155 <span class="keyword">if</span> k1 == 1 | k1 == length(f)
|
||||
0156 k = find(f < 10);
|
||||
0157 <span class="keyword">end</span>
|
||||
0158 <span class="keyword">end</span>
|
||||
0159 hh = plot(abscissa(k),f(k),<span class="string">'-k'</span>,<span class="string">'linewidth'</span>,2);
|
||||
0160 set(hh,<span class="string">'color'</span>,[0.7 0.7 0.7]);
|
||||
0161 <span class="comment">%hold on; %% ?!</span>
|
||||
0162 <span class="keyword">if</span> strcmp(pltopt,<span class="string">'all'</span>);
|
||||
0163 plot( [xparam1(i) xparam1(i)], [0,top], <span class="string">'--g'</span>, <span class="string">'linewidth'</span>, 2);
|
||||
0164 <span class="keyword">end</span>;
|
||||
0165 title(nam,<span class="string">'Interpreter'</span>,<span class="string">'none'</span>);
|
||||
0166 hold off;
|
||||
0167 <span class="keyword">end</span>;
|
||||
0168 drawnow
|
||||
0169
|
||||
0170 <span class="comment">% 12/01/03 MJ adapted from M. Ratto's version</span>
|
||||
0171</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,257 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of csminit</title>
|
||||
<meta name="keywords" content="csminit">
|
||||
<meta name="description" content="[fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > csminit.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>csminit
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>[fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...
|
||||
P1,P2,P3,P4,P5,P6,P7,P8)
|
||||
retcodes: 0, normal step. 5, largest step still improves too fast.
|
||||
4,2 back and forth adjustment of stepsize didn't finish. 3, smallest
|
||||
stepsize still improves too slow. 6, no improvement found. 1, zero
|
||||
gradient.
|
||||
---------------------
|
||||
Modified 7/22/96 to omit variable-length P list, for efficiency and compilation.
|
||||
Places where the number of P's need to be altered or the code could be returned to
|
||||
its old form are marked with ARGLIST comments.
|
||||
|
||||
Fixed 7/17/93 to use inverse-hessian instead of hessian itself in bfgs
|
||||
update.
|
||||
|
||||
Fixed 7/19/93 to flip eigenvalues of H to get better performance when
|
||||
it's not psd.
|
||||
|
||||
tailstr = ')';
|
||||
for i=nargin-6:-1:1
|
||||
tailstr=[ ',P' num2str(i) tailstr];
|
||||
end
|
||||
ANGLE = .03;</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="csminwel.html" class="code" title="function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)">csminwel</a> [fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)</li><li><a href="mr_gstep.html" class="code" title="function [f0, x] = mr_gstep(func0,x,htol0,varargin)">mr_gstep</a> Copyright (C) 2005 Marco Ratto</li><li><a href="newrat.html" class="code" title="function [xparam1, hh, gg, fval, igg] = newrat(func0, x, hh, gg, igg, ftol0, nit, flagg, varargin)">newrat</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)</a>
|
||||
0002 <span class="comment">% [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...</span>
|
||||
0003 <span class="comment">% P1,P2,P3,P4,P5,P6,P7,P8)</span>
|
||||
0004 <span class="comment">% retcodes: 0, normal step. 5, largest step still improves too fast.</span>
|
||||
0005 <span class="comment">% 4,2 back and forth adjustment of stepsize didn't finish. 3, smallest</span>
|
||||
0006 <span class="comment">% stepsize still improves too slow. 6, no improvement found. 1, zero</span>
|
||||
0007 <span class="comment">% gradient.</span>
|
||||
0008 <span class="comment">%---------------------</span>
|
||||
0009 <span class="comment">% Modified 7/22/96 to omit variable-length P list, for efficiency and compilation.</span>
|
||||
0010 <span class="comment">% Places where the number of P's need to be altered or the code could be returned to</span>
|
||||
0011 <span class="comment">% its old form are marked with ARGLIST comments.</span>
|
||||
0012 <span class="comment">%</span>
|
||||
0013 <span class="comment">% Fixed 7/17/93 to use inverse-hessian instead of hessian itself in bfgs</span>
|
||||
0014 <span class="comment">% update.</span>
|
||||
0015 <span class="comment">%</span>
|
||||
0016 <span class="comment">% Fixed 7/19/93 to flip eigenvalues of H to get better performance when</span>
|
||||
0017 <span class="comment">% it's not psd.</span>
|
||||
0018 <span class="comment">%</span>
|
||||
0019 <span class="comment">%tailstr = ')';</span>
|
||||
0020 <span class="comment">%for i=nargin-6:-1:1</span>
|
||||
0021 <span class="comment">% tailstr=[ ',P' num2str(i) tailstr];</span>
|
||||
0022 <span class="comment">%end</span>
|
||||
0023 <span class="comment">%ANGLE = .03;</span>
|
||||
0024 ANGLE = .005;
|
||||
0025 <span class="comment">%THETA = .03;</span>
|
||||
0026 THETA = .3; <span class="comment">%(0<THETA<.5) THETA near .5 makes long line searches, possibly fewer iterations.</span>
|
||||
0027 FCHANGE = 1000;
|
||||
0028 MINLAMB = 1e-9;
|
||||
0029 <span class="comment">% fixed 7/15/94</span>
|
||||
0030 <span class="comment">% MINDX = .0001;</span>
|
||||
0031 <span class="comment">% MINDX = 1e-6;</span>
|
||||
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 <span class="comment">%</span>
|
||||
0041 <span class="keyword">if</span> (gnorm < 1.e-12) & ~badg <span class="comment">% put ~badg 8/4/94</span>
|
||||
0042 retcode =1;
|
||||
0043 dxnorm=0;
|
||||
0044 <span class="comment">% gradient convergence</span>
|
||||
0045 <span class="keyword">else</span>
|
||||
0046 <span class="comment">% with badg true, we don't try to match rate of improvement to directional</span>
|
||||
0047 <span class="comment">% derivative. We're satisfied just to get some improvement in f.</span>
|
||||
0048 <span class="comment">%</span>
|
||||
0049 <span class="comment">%if(badg)</span>
|
||||
0050 <span class="comment">% dx = -g*FCHANGE/(gnorm*gnorm);</span>
|
||||
0051 <span class="comment">% dxnorm = norm(dx);</span>
|
||||
0052 <span class="comment">% if dxnorm > 1e12</span>
|
||||
0053 <span class="comment">% disp('Bad, small gradient problem.')</span>
|
||||
0054 <span class="comment">% dx = dx*FCHANGE/dxnorm;</span>
|
||||
0055 <span class="comment">% end</span>
|
||||
0056 <span class="comment">%else</span>
|
||||
0057 <span class="comment">% Gauss-Newton step;</span>
|
||||
0058 <span class="comment">%---------- Start of 7/19/93 mod ---------------</span>
|
||||
0059 <span class="comment">%[v d] = eig(H0);</span>
|
||||
0060 <span class="comment">%toc</span>
|
||||
0061 <span class="comment">%d=max(1e-10,abs(diag(d)));</span>
|
||||
0062 <span class="comment">%d=abs(diag(d));</span>
|
||||
0063 <span class="comment">%dx = -(v.*(ones(size(v,1),1)*d'))*(v'*g);</span>
|
||||
0064 <span class="comment">% toc</span>
|
||||
0065 dx = -H0*g;
|
||||
0066 <span class="comment">% toc</span>
|
||||
0067 dxnorm = norm(dx);
|
||||
0068 <span class="keyword">if</span> dxnorm > 1e12
|
||||
0069 disp(<span class="string">'Near-singular H problem.'</span>)
|
||||
0070 dx = dx*FCHANGE/dxnorm;
|
||||
0071 <span class="keyword">end</span>
|
||||
0072 dfhat = dx'*g0;
|
||||
0073 <span class="comment">%end</span>
|
||||
0074 <span class="comment">%</span>
|
||||
0075 <span class="comment">%</span>
|
||||
0076 <span class="keyword">if</span> ~badg
|
||||
0077 <span class="comment">% test for alignment of dx with gradient and fix if necessary</span>
|
||||
0078 a = -dfhat/(gnorm*dxnorm);
|
||||
0079 <span class="keyword">if</span> a<ANGLE
|
||||
0080 dx = dx - (ANGLE*dxnorm/gnorm+dfhat/(gnorm*gnorm))*g;
|
||||
0081 dfhat = dx'*g;
|
||||
0082 dxnorm = norm(dx);
|
||||
0083 disp(sprintf(<span class="string">'Correct for low angle: %g'</span>,a))
|
||||
0084 <span class="keyword">end</span>
|
||||
0085 <span class="keyword">end</span>
|
||||
0086 disp(sprintf(<span class="string">'Predicted improvement: %18.9f'</span>,-dfhat/2))
|
||||
0087 <span class="comment">%</span>
|
||||
0088 <span class="comment">% Have OK dx, now adjust length of step (lambda) until min and</span>
|
||||
0089 <span class="comment">% max improvement rate criteria are met.</span>
|
||||
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 <span class="keyword">while</span> ~done
|
||||
0099 <span class="keyword">if</span> size(x0,2)>1
|
||||
0100 dxtest=x0+dx'*lambda;
|
||||
0101 <span class="keyword">else</span>
|
||||
0102 dxtest=x0+dx*lambda;
|
||||
0103 <span class="keyword">end</span>
|
||||
0104 <span class="comment">% home</span>
|
||||
0105 f = eval([fcn <span class="string">'(dxtest,varargin{:})'</span>]);
|
||||
0106 <span class="comment">%ARGLIST</span>
|
||||
0107 <span class="comment">%f = feval(fcn,dxtest,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13);</span>
|
||||
0108 <span class="comment">% f = feval(fcn,x0+dx*lambda,P1,P2,P3,P4,P5,P6,P7,P8);</span>
|
||||
0109 disp(sprintf(<span class="string">'lambda = %10.5g; f = %20.7f'</span>,lambda,f ))
|
||||
0110 <span class="comment">%debug</span>
|
||||
0111 <span class="comment">%disp(sprintf('Improvement too great? f0-f: %g, criterion: %g',f0-f,-(1-THETA)*dfhat*lambda))</span>
|
||||
0112 <span class="keyword">if</span> f<fhat
|
||||
0113 fhat=f;
|
||||
0114 xhat=dxtest;
|
||||
0115 lambdahat = lambda;
|
||||
0116 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> shrinkSignal & ( (lambda>lambdaPeak) | (lambda<0) )
|
||||
0121 <span class="keyword">if</span> (lambda>0) & ((~shrink) | (lambda/factor <= lambdaPeak))
|
||||
0122 shrink=1;
|
||||
0123 factor=factor^.6;
|
||||
0124 <span class="keyword">while</span> lambda/factor <= lambdaPeak
|
||||
0125 factor=factor^.6;
|
||||
0126 <span class="keyword">end</span>
|
||||
0127 <span class="comment">%if (abs(lambda)*(factor-1)*dxnorm < MINDX) | (abs(lambda)*(factor-1) < MINLAMB)</span>
|
||||
0128 <span class="keyword">if</span> abs(factor-1)<MINDFAC
|
||||
0129 <span class="keyword">if</span> abs(lambda)<4
|
||||
0130 retcode=2;
|
||||
0131 <span class="keyword">else</span>
|
||||
0132 retcode=7;
|
||||
0133 <span class="keyword">end</span>
|
||||
0134 done=1;
|
||||
0135 <span class="keyword">end</span>
|
||||
0136 <span class="keyword">end</span>
|
||||
0137 <span class="keyword">if</span> (lambda<lambdaMax) & (lambda>lambdaPeak)
|
||||
0138 lambdaMax=lambda;
|
||||
0139 <span class="keyword">end</span>
|
||||
0140 lambda=lambda/factor;
|
||||
0141 <span class="keyword">if</span> abs(lambda) < MINLAMB
|
||||
0142 <span class="keyword">if</span> (lambda > 0) & (f0 <= fhat)
|
||||
0143 <span class="comment">% try going against gradient, which may be inaccurate</span>
|
||||
0144 lambda = -lambda*factor^6
|
||||
0145 <span class="keyword">else</span>
|
||||
0146 <span class="keyword">if</span> lambda < 0
|
||||
0147 retcode = 6;
|
||||
0148 <span class="keyword">else</span>
|
||||
0149 retcode = 3;
|
||||
0150 <span class="keyword">end</span>
|
||||
0151 done = 1;
|
||||
0152 <span class="keyword">end</span>
|
||||
0153 <span class="keyword">end</span>
|
||||
0154 <span class="keyword">elseif</span> (growSignal & lambda>0) | (shrinkSignal & ((lambda <= lambdaPeak) & (lambda>0)))
|
||||
0155 <span class="keyword">if</span> shrink
|
||||
0156 shrink=0;
|
||||
0157 factor = factor^.6;
|
||||
0158 <span class="comment">%if ( abs(lambda)*(factor-1)*dxnorm< MINDX ) | ( abs(lambda)*(factor-1)< MINLAMB)</span>
|
||||
0159 <span class="keyword">if</span> abs(factor-1)<MINDFAC
|
||||
0160 <span class="keyword">if</span> abs(lambda)<4
|
||||
0161 retcode=4;
|
||||
0162 <span class="keyword">else</span>
|
||||
0163 retcode=7;
|
||||
0164 <span class="keyword">end</span>
|
||||
0165 done=1;
|
||||
0166 <span class="keyword">end</span>
|
||||
0167 <span class="keyword">end</span>
|
||||
0168 <span class="keyword">if</span> ( f<fPeak ) & (lambda>0)
|
||||
0169 fPeak=f;
|
||||
0170 lambdaPeak=lambda;
|
||||
0171 <span class="keyword">if</span> lambdaMax<=lambdaPeak
|
||||
0172 lambdaMax=lambdaPeak*factor*factor;
|
||||
0173 <span class="keyword">end</span>
|
||||
0174 <span class="keyword">end</span>
|
||||
0175 lambda=lambda*factor;
|
||||
0176 <span class="keyword">if</span> abs(lambda) > 1e20;
|
||||
0177 retcode = 5;
|
||||
0178 done =1;
|
||||
0179 <span class="keyword">end</span>
|
||||
0180 <span class="keyword">else</span>
|
||||
0181 done=1;
|
||||
0182 <span class="keyword">if</span> factor < 1.2
|
||||
0183 retcode=7;
|
||||
0184 <span class="keyword">else</span>
|
||||
0185 retcode=0;
|
||||
0186 <span class="keyword">end</span>
|
||||
0187 <span class="keyword">end</span>
|
||||
0188 <span class="keyword">end</span>
|
||||
0189 <span class="keyword">end</span>
|
||||
0190 disp(sprintf(<span class="string">'Norm of dx %10.5g'</span>, dxnorm))</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,337 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of csminwel</title>
|
||||
<meta name="keywords" content="csminwel">
|
||||
<meta name="description" content="[fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > csminwel.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>csminwel
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>[fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(fcn,x0,H0,grad,crit,nit,varargin) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">[fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)
|
||||
fcn: string naming the objective function to be minimized
|
||||
x0: initial value of the parameter vector
|
||||
H0: initial value for the inverse Hessian. Must be positive definite.
|
||||
grad: Either a string naming a function that calculates the gradient, or the null matrix.
|
||||
If it's null, the program calculates a numerical gradient. In this case fcn must
|
||||
be written so that it can take a matrix argument and produce a row vector of values.
|
||||
crit: Convergence criterion. Iteration will cease when it proves impossible to improve the
|
||||
function value by more than crit.
|
||||
nit: Maximum number of iterations.
|
||||
varargin: A list of optional length of additional parameters that get handed off to fcn each
|
||||
time it is called.
|
||||
Note that if the program ends abnormally, it is possible to retrieve the current x,
|
||||
f, and H from the files g1.mat and H.mat that are written at each iteration and at each
|
||||
hessian update, respectively. (When the routine hits certain kinds of difficulty, it
|
||||
write g2.mat and g3.mat as well. If all were written at about the same time, any of them
|
||||
may be a decent starting point. One can also start from the one with best function value.)</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="bfgsi.html" class="code" title="function H = bfgsi(H0,dg,dx)">bfgsi</a> H = bfgsi(H0,dg,dx)</li><li><a href="csminit.html" class="code" title="function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)">csminit</a> [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,...</li><li><a href="numgrad.html" class="code" title="function [g, badg] = numgrad(fcn,x,varargin)">numgrad</a> function [g badg] = numgrad(fcn,xvarargin)</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [fh,xh,gh,H,itct,fcount,retcodeh] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)</a>
|
||||
0002 <span class="comment">%[fhat,xhat,ghat,Hhat,itct,fcount,retcodehat] = csminwel(fcn,x0,H0,grad,crit,nit,varargin)</span>
|
||||
0003 <span class="comment">% fcn: string naming the objective function to be minimized</span>
|
||||
0004 <span class="comment">% x0: initial value of the parameter vector</span>
|
||||
0005 <span class="comment">% H0: initial value for the inverse Hessian. Must be positive definite.</span>
|
||||
0006 <span class="comment">% grad: Either a string naming a function that calculates the gradient, or the null matrix.</span>
|
||||
0007 <span class="comment">% If it's null, the program calculates a numerical gradient. In this case fcn must</span>
|
||||
0008 <span class="comment">% be written so that it can take a matrix argument and produce a row vector of values.</span>
|
||||
0009 <span class="comment">% crit: Convergence criterion. Iteration will cease when it proves impossible to improve the</span>
|
||||
0010 <span class="comment">% function value by more than crit.</span>
|
||||
0011 <span class="comment">% nit: Maximum number of iterations.</span>
|
||||
0012 <span class="comment">% varargin: A list of optional length of additional parameters that get handed off to fcn each</span>
|
||||
0013 <span class="comment">% time it is called.</span>
|
||||
0014 <span class="comment">% Note that if the program ends abnormally, it is possible to retrieve the current x,</span>
|
||||
0015 <span class="comment">% f, and H from the files g1.mat and H.mat that are written at each iteration and at each</span>
|
||||
0016 <span class="comment">% hessian update, respectively. (When the routine hits certain kinds of difficulty, it</span>
|
||||
0017 <span class="comment">% write g2.mat and g3.mat as well. If all were written at about the same time, any of them</span>
|
||||
0018 <span class="comment">% may be a decent starting point. One can also start from the one with best function value.)</span>
|
||||
0019 <span class="keyword">global</span> 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 <span class="comment">%tailstr = ')';</span>
|
||||
0029 <span class="comment">%stailstr = [];</span>
|
||||
0030 <span class="comment">% Lines below make the number of Pi's optional. This is inefficient, though, and precludes</span>
|
||||
0031 <span class="comment">% use of the matlab compiler. Without them, we use feval and the number of Pi's must be</span>
|
||||
0032 <span class="comment">% changed with the editor for each application. Places where this is required are marked</span>
|
||||
0033 <span class="comment">% with ARGLIST comments</span>
|
||||
0034 <span class="comment">%for i=nargin-6:-1:1</span>
|
||||
0035 <span class="comment">% tailstr=[ ',P' num2str(i) tailstr];</span>
|
||||
0036 <span class="comment">% stailstr=[' P' num2str(i) stailstr];</span>
|
||||
0037 <span class="comment">%end</span>
|
||||
0038 f0 = feval(fcn,x0,varargin{:});
|
||||
0039 <span class="comment">%ARGLIST</span>
|
||||
0040 <span class="comment">%f0 = feval(fcn,x0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13);</span>
|
||||
0041 <span class="comment">% disp('first fcn in csminwel.m ----------------') % Jinill on 9/5/95</span>
|
||||
0042 <span class="keyword">if</span> f0 > 1e50, disp(<span class="string">'Bad initial parameter.'</span>), <span class="keyword">return</span>, <span class="keyword">end</span>
|
||||
0043 <span class="keyword">if</span> NumGrad
|
||||
0044 <span class="keyword">if</span> length(grad)==0
|
||||
0045 [g badg] = <a href="numgrad.html" class="code" title="function [g, badg] = numgrad(fcn,x,varargin)">numgrad</a>(fcn,x0, varargin{:});
|
||||
0046 <span class="comment">%ARGLIST</span>
|
||||
0047 <span class="comment">%[g badg] = numgrad(fcn,x0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13);</span>
|
||||
0048 <span class="keyword">else</span>
|
||||
0049 badg=any(find(grad==0));
|
||||
0050 g=grad;
|
||||
0051 <span class="keyword">end</span>
|
||||
0052 <span class="comment">%numgrad(fcn,x0,P1,P2,P3,P4);</span>
|
||||
0053 <span class="keyword">else</span>
|
||||
0054 [g badg] = feval(grad,x0,varargin{:});
|
||||
0055 <span class="comment">%ARGLIST</span>
|
||||
0056 <span class="comment">%[g badg] = feval(grad,x0,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13);</span>
|
||||
0057 <span class="keyword">end</span>
|
||||
0058 retcode3=101;
|
||||
0059 x=x0;
|
||||
0060 f=f0;
|
||||
0061 H=H0;
|
||||
0062 cliff=0;
|
||||
0063 <span class="keyword">while</span> ~done
|
||||
0064 bayestopt_.penalty = f;
|
||||
0065 g1=[]; g2=[]; g3=[];
|
||||
0066 <span class="comment">%addition fj. 7/6/94 for control</span>
|
||||
0067 disp(<span class="string">'-----------------'</span>)
|
||||
0068 disp(<span class="string">'-----------------'</span>)
|
||||
0069 <span class="comment">%disp('f and x at the beginning of new iteration')</span>
|
||||
0070 disp(sprintf(<span class="string">'f at the beginning of new iteration, %20.10f'</span>,f))
|
||||
0071 <span class="comment">%-----------Comment out this line if the x vector is long----------------</span>
|
||||
0072 <span class="comment">% disp([sprintf('x = ') sprintf('%15.8g %15.8g %15.8g %15.8g\n',x)]);</span>
|
||||
0073 <span class="comment">%-------------------------</span>
|
||||
0074 itct=itct+1;
|
||||
0075 [f1 x1 fc retcode1] = <a href="csminit.html" class="code" title="function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)">csminit</a>(fcn,x,f,g,badg,H,varargin{:});
|
||||
0076 <span class="comment">%ARGLIST</span>
|
||||
0077 <span class="comment">%[f1 x1 fc retcode1] = csminit(fcn,x,f,g,badg,H,P1,P2,P3,P4,P5,P6,P7,...</span>
|
||||
0078 <span class="comment">% P8,P9,P10,P11,P12,P13);</span>
|
||||
0079 <span class="comment">% itct=itct+1;</span>
|
||||
0080 fcount = fcount+fc;
|
||||
0081 <span class="comment">% erased on 8/4/94</span>
|
||||
0082 <span class="comment">% if (retcode == 1) | (abs(f1-f) < crit)</span>
|
||||
0083 <span class="comment">% done=1;</span>
|
||||
0084 <span class="comment">% end</span>
|
||||
0085 <span class="comment">% if itct > nit</span>
|
||||
0086 <span class="comment">% done = 1;</span>
|
||||
0087 <span class="comment">% retcode = -retcode;</span>
|
||||
0088 <span class="comment">% end</span>
|
||||
0089 <span class="keyword">if</span> retcode1 ~= 1
|
||||
0090 <span class="keyword">if</span> retcode1==2 | retcode1==4
|
||||
0091 wall1=1; badg1=1;
|
||||
0092 <span class="keyword">else</span>
|
||||
0093 <span class="keyword">if</span> NumGrad
|
||||
0094 [g1 badg1] = <a href="numgrad.html" class="code" title="function [g, badg] = numgrad(fcn,x,varargin)">numgrad</a>(fcn, x1,varargin{:});
|
||||
0095 <span class="comment">%ARGLIST</span>
|
||||
0096 <span class="comment">%[g1 badg1] = numgrad(fcn, x1,P1,P2,P3,P4,P5,P6,P7,P8,P9,...</span>
|
||||
0097 <span class="comment">% P10,P11,P12,P13);</span>
|
||||
0098 <span class="keyword">else</span>
|
||||
0099 [g1 badg1] = feval(grad,x1,varargin{:});
|
||||
0100 <span class="comment">%ARGLIST</span>
|
||||
0101 <span class="comment">%[g1 badg1] = feval(grad, x1,P1,P2,P3,P4,P5,P6,P7,P8,P9,...</span>
|
||||
0102 <span class="comment">% P10,P11,P12,P13);</span>
|
||||
0103 <span class="keyword">end</span>
|
||||
0104 wall1=badg1;
|
||||
0105 <span class="comment">% g1</span>
|
||||
0106 save g1 g1 x1 f1 varargin;
|
||||
0107 <span class="comment">%ARGLIST</span>
|
||||
0108 <span class="comment">%save g1 g1 x1 f1 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;</span>
|
||||
0109 <span class="keyword">end</span>
|
||||
0110 <span class="keyword">if</span> wall1 <span class="comment">% & (~done) by Jinill</span>
|
||||
0111 <span class="comment">% Bad gradient or back and forth on step length. Possibly at</span>
|
||||
0112 <span class="comment">% cliff edge. Try perturbing search direction.</span>
|
||||
0113 <span class="comment">%</span>
|
||||
0114 <span class="comment">%fcliff=fh;xcliff=xh;</span>
|
||||
0115 Hcliff=H+diag(diag(H).*rand(nx,1));
|
||||
0116 disp(<span class="string">'Cliff. Perturbing search direction.'</span>)
|
||||
0117 [f2 x2 fc retcode2] = <a href="csminit.html" class="code" title="function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)">csminit</a>(fcn,x,f,g,badg,Hcliff,varargin{:});
|
||||
0118 <span class="comment">%ARGLIST</span>
|
||||
0119 <span class="comment">%[f2 x2 fc retcode2] = csminit(fcn,x,f,g,badg,Hcliff,P1,P2,P3,P4,...</span>
|
||||
0120 <span class="comment">% P5,P6,P7,P8,P9,P10,P11,P12,P13);</span>
|
||||
0121 fcount = fcount+fc; <span class="comment">% put by Jinill</span>
|
||||
0122 <span class="keyword">if</span> f2 < f
|
||||
0123 <span class="keyword">if</span> retcode2==2 | retcode2==4
|
||||
0124 wall2=1; badg2=1;
|
||||
0125 <span class="keyword">else</span>
|
||||
0126 <span class="keyword">if</span> NumGrad
|
||||
0127 [g2 badg2] = <a href="numgrad.html" class="code" title="function [g, badg] = numgrad(fcn,x,varargin)">numgrad</a>(fcn, x2,varargin{:});
|
||||
0128 <span class="comment">%ARGLIST</span>
|
||||
0129 <span class="comment">%[g2 badg2] = numgrad(fcn, x2,P1,P2,P3,P4,P5,P6,P7,P8,...</span>
|
||||
0130 <span class="comment">% P9,P10,P11,P12,P13);</span>
|
||||
0131 <span class="keyword">else</span>
|
||||
0132 [g2 badg2] = feval(grad,x2,varargin{:});
|
||||
0133 <span class="comment">%ARGLIST</span>
|
||||
0134 <span class="comment">%[g2 badg2] = feval(grad,x2,P1,P2,P3,P4,P5,P6,P7,P8,...</span>
|
||||
0135 <span class="comment">% P9,P10,P11,P12,P13);</span>
|
||||
0136 <span class="keyword">end</span>
|
||||
0137 wall2=badg2;
|
||||
0138 <span class="comment">% g2</span>
|
||||
0139 badg2
|
||||
0140 save g2 g2 x2 f2 varargin
|
||||
0141 <span class="comment">%ARGLIST</span>
|
||||
0142 <span class="comment">%save g2 g2 x2 f2 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;</span>
|
||||
0143 <span class="keyword">end</span>
|
||||
0144 <span class="keyword">if</span> wall2
|
||||
0145 disp(<span class="string">'Cliff again. Try traversing'</span>)
|
||||
0146 <span class="keyword">if</span> norm(x2-x1) < 1e-13
|
||||
0147 f3=f; x3=x; badg3=1;retcode3=101;
|
||||
0148 <span class="keyword">else</span>
|
||||
0149 gcliff=((f2-f1)/((norm(x2-x1))^2))*(x2-x1);
|
||||
0150 <span class="keyword">if</span>(size(x0,2)>1), gcliff=gcliff', <span class="keyword">end</span>
|
||||
0151 [f3 x3 fc retcode3] = <a href="csminit.html" class="code" title="function [fhat,xhat,fcount,retcode] = csminit(fcn,x0,f0,g0,badg,H0,varargin)">csminit</a>(fcn,x,f,gcliff,0,eye(nx),varargin{:});
|
||||
0152 <span class="comment">%ARGLIST</span>
|
||||
0153 <span class="comment">%[f3 x3 fc retcode3] = csminit(fcn,x,f,gcliff,0,eye(nx),P1,P2,P3,...</span>
|
||||
0154 <span class="comment">% P4,P5,P6,P7,P8,...</span>
|
||||
0155 <span class="comment">% P9,P10,P11,P12,P13);</span>
|
||||
0156 fcount = fcount+fc; <span class="comment">% put by Jinill</span>
|
||||
0157 <span class="keyword">if</span> retcode3==2 | retcode3==4
|
||||
0158 wall3=1; badg3=1;
|
||||
0159 <span class="keyword">else</span>
|
||||
0160 <span class="keyword">if</span> NumGrad
|
||||
0161 [g3 badg3] = <a href="numgrad.html" class="code" title="function [g, badg] = numgrad(fcn,x,varargin)">numgrad</a>(fcn, x3,varargin{:});
|
||||
0162 <span class="comment">%ARGLIST</span>
|
||||
0163 <span class="comment">%[g3 badg3] = numgrad(fcn, x3,P1,P2,P3,P4,P5,P6,P7,P8,...</span>
|
||||
0164 <span class="comment">% P9,P10,P11,P12,P13);</span>
|
||||
0165 <span class="keyword">else</span>
|
||||
0166 [g3 badg3] = feval(grad,x3,varargin{:});
|
||||
0167 <span class="comment">%ARGLIST</span>
|
||||
0168 <span class="comment">%[g3 badg3] = feval(grad,x3,P1,P2,P3,P4,P5,P6,P7,P8,...</span>
|
||||
0169 <span class="comment">% P9,P10,P11,P12,P13);</span>
|
||||
0170 <span class="keyword">end</span>
|
||||
0171 wall3=badg3;
|
||||
0172 <span class="comment">% g3</span>
|
||||
0173 badg3
|
||||
0174 save g3 g3 x3 f3 varargin;
|
||||
0175 <span class="comment">%ARGLIST</span>
|
||||
0176 <span class="comment">%save g3 g3 x3 f3 P1 P2 P3 P4 P5 P6 P7 P8 P9 P10 P11 P12 P13;</span>
|
||||
0177 <span class="keyword">end</span>
|
||||
0178 <span class="keyword">end</span>
|
||||
0179 <span class="keyword">else</span>
|
||||
0180 f3=f; x3=x; badg3=1; retcode3=101;
|
||||
0181 <span class="keyword">end</span>
|
||||
0182 <span class="keyword">else</span>
|
||||
0183 f3=f; x3=x; badg3=1;retcode3=101;
|
||||
0184 <span class="keyword">end</span>
|
||||
0185 <span class="keyword">else</span>
|
||||
0186 <span class="comment">% normal iteration, no walls, or else we're finished here.</span>
|
||||
0187 f2=f; f3=f; badg2=1; badg3=1; retcode2=101; retcode3=101;
|
||||
0188 <span class="keyword">end</span>
|
||||
0189 <span class="keyword">else</span>
|
||||
0190 f2=f;f3=f;f1=f;retcode2=retcode1;retcode3=retcode1;
|
||||
0191 <span class="keyword">end</span>
|
||||
0192 <span class="comment">%how to pick gh and xh</span>
|
||||
0193 <span class="keyword">if</span> f3 < f - crit & badg3==0
|
||||
0194 ih=3
|
||||
0195 fh=f3;xh=x3;gh=g3;badgh=badg3;retcodeh=retcode3;
|
||||
0196 <span class="keyword">elseif</span> f2 < f - crit & badg2==0
|
||||
0197 ih=2
|
||||
0198 fh=f2;xh=x2;gh=g2;badgh=badg2;retcodeh=retcode2;
|
||||
0199 <span class="keyword">elseif</span> f1 < f - crit & badg1==0
|
||||
0200 ih=1
|
||||
0201 fh=f1;xh=x1;gh=g1;badgh=badg1;retcodeh=retcode1;
|
||||
0202 <span class="keyword">else</span>
|
||||
0203 [fh,ih] = min([f1,f2,f3]);
|
||||
0204 disp(sprintf(<span class="string">'ih = %d'</span>,ih))
|
||||
0205 <span class="comment">%eval(['xh=x' num2str(ih) ';'])</span>
|
||||
0206 <span class="keyword">switch</span> ih
|
||||
0207 <span class="keyword">case</span> 1
|
||||
0208 xh=x1;
|
||||
0209 <span class="keyword">case</span> 2
|
||||
0210 xh=x2;
|
||||
0211 <span class="keyword">case</span> 3
|
||||
0212 xh=x3;
|
||||
0213 <span class="keyword">end</span> <span class="comment">%case</span>
|
||||
0214 <span class="comment">%eval(['gh=g' num2str(ih) ';'])</span>
|
||||
0215 <span class="comment">%eval(['retcodeh=retcode' num2str(ih) ';'])</span>
|
||||
0216 retcodei=[retcode1,retcode2,retcode3];
|
||||
0217 retcodeh=retcodei(ih);
|
||||
0218 <span class="keyword">if</span> exist(<span class="string">'gh'</span>)
|
||||
0219 nogh=isempty(gh);
|
||||
0220 <span class="keyword">else</span>
|
||||
0221 nogh=1;
|
||||
0222 <span class="keyword">end</span>
|
||||
0223 <span class="keyword">if</span> nogh
|
||||
0224 <span class="keyword">if</span> NumGrad
|
||||
0225 [gh badgh] = <a href="numgrad.html" class="code" title="function [g, badg] = numgrad(fcn,x,varargin)">numgrad</a>(fcn,xh,varargin{:});
|
||||
0226 <span class="keyword">else</span>
|
||||
0227 [gh badgh] = feval(grad, xh,varargin{:});
|
||||
0228 <span class="keyword">end</span>
|
||||
0229 <span class="keyword">end</span>
|
||||
0230 badgh=1;
|
||||
0231 <span class="keyword">end</span>
|
||||
0232 <span class="comment">%end of picking</span>
|
||||
0233 <span class="comment">%ih</span>
|
||||
0234 <span class="comment">%fh</span>
|
||||
0235 <span class="comment">%xh</span>
|
||||
0236 <span class="comment">%gh</span>
|
||||
0237 <span class="comment">%badgh</span>
|
||||
0238 stuck = (abs(fh-f) < crit);
|
||||
0239 <span class="keyword">if</span> (~badg)&(~badgh)&(~stuck)
|
||||
0240 H = <a href="bfgsi.html" class="code" title="function H = bfgsi(H0,dg,dx)">bfgsi</a>(H,gh-g,xh-x);
|
||||
0241 <span class="keyword">end</span>
|
||||
0242 <span class="keyword">if</span> Verbose
|
||||
0243 disp(<span class="string">'----'</span>)
|
||||
0244 disp(sprintf(<span class="string">'Improvement on iteration %d = %18.9f'</span>,itct,f-fh))
|
||||
0245 <span class="keyword">end</span>
|
||||
0246 <span class="comment">% if Verbose</span>
|
||||
0247 <span class="keyword">if</span> itct > nit
|
||||
0248 disp(<span class="string">'iteration count termination'</span>)
|
||||
0249 done = 1;
|
||||
0250 <span class="keyword">elseif</span> stuck
|
||||
0251 disp(<span class="string">'improvement < crit termination'</span>)
|
||||
0252 done = 1;
|
||||
0253 <span class="keyword">end</span>
|
||||
0254 rc=retcodeh;
|
||||
0255 <span class="keyword">if</span> rc == 1
|
||||
0256 disp(<span class="string">'zero gradient'</span>)
|
||||
0257 <span class="keyword">elseif</span> rc == 6
|
||||
0258 disp(<span class="string">'smallest step still improving too slow, reversed gradient'</span>)
|
||||
0259 <span class="keyword">elseif</span> rc == 5
|
||||
0260 disp(<span class="string">'largest step still improving too fast'</span>)
|
||||
0261 <span class="keyword">elseif</span> (rc == 4) | (rc==2)
|
||||
0262 disp(<span class="string">'back and forth on step length never finished'</span>)
|
||||
0263 <span class="keyword">elseif</span> rc == 3
|
||||
0264 disp(<span class="string">'smallest step still improving too slow'</span>)
|
||||
0265 <span class="keyword">elseif</span> rc == 7
|
||||
0266 disp(<span class="string">'warning: possible inaccuracy in H matrix'</span>)
|
||||
0267 <span class="keyword">end</span>
|
||||
0268 <span class="comment">% end</span>
|
||||
0269 f=fh;
|
||||
0270 x=xh;
|
||||
0271 g=gh;
|
||||
0272 badg=badgh;
|
||||
0273 <span class="keyword">end</span>
|
||||
0274 <span class="comment">% what about making an m-file of 10 lines including numgrad.m</span>
|
||||
0275 <span class="comment">% since it appears three times in csminwel.m</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,61 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of cumplot</title>
|
||||
<meta name="keywords" content="cumplot">
|
||||
<meta name="description" content="function h =cumplot(x)">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > cumplot.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>cumplot
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function h =cumplot(x)</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function h = cumplot(x); </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">function h =cumplot(x)
|
||||
Copyright (C) 2005 Marco Ratto</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="filt_mc_.html" class="code" title="function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)">filt_mc_</a> copyright Marco Ratto 2006</li><li><a href="stab_map_1.html" class="code" title="function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)">stab_map_1</a> function [proba, dproba] = stab_map_1(lpmat, ibehaviour, inonbehaviour, aname, iplot, ipar, dirname)</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function h = cumplot(x);</a>
|
||||
0002 <span class="comment">%function h =cumplot(x)</span>
|
||||
0003 <span class="comment">% Copyright (C) 2005 Marco Ratto</span>
|
||||
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 <span class="keyword">if</span> nargout,
|
||||
0013 h=h0;
|
||||
0014 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,95 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of datatomfile</title>
|
||||
<meta name="keywords" content="datatomfile">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > datatomfile.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>datatomfile
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function datatomfile (s,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
DYNATYPE : DYNATYPE ( [ 'filename' ] )
|
||||
This optional command saves the simulation
|
||||
results in a text file. The name of each
|
||||
variable preceeds the corresponding results.
|
||||
This command must follow SIMUL.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function datatomfile (s,var_list)</a>
|
||||
0004 <span class="comment">% DYNATYPE : DYNATYPE ( [ 'filename' ] )</span>
|
||||
0005 <span class="comment">% This optional command saves the simulation</span>
|
||||
0006 <span class="comment">% results in a text file. The name of each</span>
|
||||
0007 <span class="comment">% variable preceeds the corresponding results.</span>
|
||||
0008 <span class="comment">% This command must follow SIMUL.</span>
|
||||
0009
|
||||
0010 <span class="keyword">global</span> M_ oo_
|
||||
0011
|
||||
0012 <span class="comment">%fid=fopen([s,'.m'],'w') ;</span>
|
||||
0013 sm=[s,<span class="string">'.m'</span>];
|
||||
0014 fid=fopen(sm,<span class="string">'w'</span>) ;
|
||||
0015
|
||||
0016 n = size(var_list,1);
|
||||
0017 <span class="keyword">if</span> n == 0
|
||||
0018 n = M_.endo_nbr;
|
||||
0019 ivar = [1:n]';
|
||||
0020 var_list = M_.endo_names;
|
||||
0021 <span class="keyword">else</span>
|
||||
0022 ivar=zeros(n,1);
|
||||
0023 <span class="keyword">for</span> i=1:n
|
||||
0024 i_tmp = strmatch(var_list(i,:),M_.endo_names,<span class="string">'exact'</span>);
|
||||
0025 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0026 error ([<span class="string">'One of the specified variables does not exist'</span>]) ;
|
||||
0027 <span class="keyword">else</span>
|
||||
0028 ivar(i) = i_tmp;
|
||||
0029 <span class="keyword">end</span>
|
||||
0030 <span class="keyword">end</span>
|
||||
0031 <span class="keyword">end</span>
|
||||
0032
|
||||
0033
|
||||
0034 <span class="keyword">for</span> i = 1:n
|
||||
0035 fprintf(fid,[M_.endo_names(ivar(i),:), <span class="string">'=['</span>],<span class="string">'\n'</span>) ;
|
||||
0036 fprintf(fid,<span class="string">'\n'</span>) ;
|
||||
0037 fprintf(fid,<span class="string">'%15.8g\n'</span>,oo_.endo_simul(ivar(i),:)') ;
|
||||
0038 fprintf(fid,<span class="string">'\n'</span>) ;
|
||||
0039 fprintf(fid,<span class="string">'];\n'</span>) ;
|
||||
0040 fprintf(fid,<span class="string">'\n'</span>) ;
|
||||
0041 <span class="keyword">end</span>
|
||||
0042 fclose(fid) ;
|
||||
0043</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,64 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dbeta</title>
|
||||
<meta name="keywords" content="dbeta">
|
||||
<meta name="description" content="DBETA The beta density function">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dbeta.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dbeta
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>DBETA The beta density function</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function d = dbeta(x,a,b) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">DBETA The beta density function
|
||||
|
||||
f = dbeta(x,a,b)</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a> QBETA The beta inverse distribution function</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function d = dbeta(x,a,b)</a>
|
||||
0002 <span class="comment">%DBETA The beta density function</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% f = dbeta(x,a,b)</span>
|
||||
0005
|
||||
0006 <span class="comment">% Anders Holtsberg, 18-11-93</span>
|
||||
0007 <span class="comment">% Copyright (c) Anders Holtsberg</span>
|
||||
0008
|
||||
0009 <span class="keyword">if</span> any(any((a<=0)|(b<=0)))
|
||||
0010 error(<span class="string">'Parameter a or b is nonpositive'</span>)
|
||||
0011 <span class="keyword">end</span>
|
||||
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;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,87 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dcompare</title>
|
||||
<meta name="keywords" content="dcompare">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dcompare.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dcompare
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dcompare(s1) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="bseastr.html" class="code" title="function x = bseastr(s1,s2)">bseastr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="ftest.html" class="code" title="function ftest (s1,s2)">ftest</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function dcompare(s1)</a>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> options_ nvx nvy x y lag1
|
||||
0006
|
||||
0007 <a href="ftest.html" class="code" title="function ftest (s1,s2)">ftest</a>(s1,0) ;
|
||||
0008
|
||||
0009 i = [lag1(1):size(x,2)-lag1(2)+1]' ;
|
||||
0010
|
||||
0011 <span class="keyword">if</span> size(options_.smpl,1) == 1
|
||||
0012 error([<span class="string">'DSAMPLE not specified.'</span>]) ;
|
||||
0013 <span class="keyword">end</span>
|
||||
0014
|
||||
0015 <span class="keyword">if</span> options_.smpl(3) > 0
|
||||
0016 <span class="keyword">if</span> options_.smpl(3) == 2
|
||||
0017 <span class="keyword">if</span> options_.smpl(1)<0 | options_.smpl(2)>size(x,2)-lag1(2)
|
||||
0018 error (<span class="string">'Wrong sample.'</span>) ;
|
||||
0019 <span class="keyword">end</span>
|
||||
0020 i = [options_.smpl(1)+lag1(1):options_.smpl(2)+lag1(1)]' ;
|
||||
0021 <span class="keyword">elseif</span> options_.smpl(3) == 1
|
||||
0022 <span class="keyword">if</span> options_.smpl(1)>size(x,2)-lag1(2)
|
||||
0023 error (<span class="string">'Wrong sample.'</span>) ;
|
||||
0024 <span class="keyword">end</span>
|
||||
0025 i = [lag1(1):options_.smpl(1)+lag1(1)]' ;
|
||||
0026 <span class="keyword">end</span>
|
||||
0027 <span class="keyword">end</span>
|
||||
0028
|
||||
0029 j = <a href="bseastr.html" class="code" title="function x = bseastr(s1,s2)">bseastr</a>(nvx,nvy) ;
|
||||
0030
|
||||
0031 <span class="keyword">if</span> stop
|
||||
0032 <span class="keyword">return</span> ;
|
||||
0033 <span class="keyword">end</span>
|
||||
0034
|
||||
0035 z = mean(mean(abs(x(j,i)-y(j,i)))) ;
|
||||
0036
|
||||
0037 disp ([<span class="string">'The mean absolute difference between set '</span> s1(1,:) <span class="string">'and set '</span> s1(2,:)]) ;
|
||||
0038 disp ([<span class="string">'is : '</span> num2str(z)]) ;
|
||||
0039 <span class="keyword">return</span> ;
|
||||
0040
|
||||
0041</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 214 B |
|
@ -1,63 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dgamma</title>
|
||||
<meta name="keywords" content="dgamma">
|
||||
<meta name="description" content="DGAMMA The gamma density function">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dgamma.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dgamma
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>DGAMMA The gamma density function</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function f = dgamma(x,a,b) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">DGAMMA The gamma density function
|
||||
|
||||
f = dgamma(x,a)</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a> QGAMMA The gamma inverse distribution function</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function f = dgamma(x,a,b)</a>
|
||||
0002 <span class="comment">%DGAMMA The gamma density function</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% f = dgamma(x,a)</span>
|
||||
0005
|
||||
0006 <span class="comment">% Anders Holtsberg, 18-11-93</span>
|
||||
0007 <span class="comment">% Copyright (c) Anders Holtsberg</span>
|
||||
0008
|
||||
0009 <span class="keyword">if</span> any(any(a<=0))
|
||||
0010 error(<span class="string">'Parameter a is wrong'</span>)
|
||||
0011 <span class="keyword">end</span>
|
||||
0012
|
||||
0013 f = (x./b) .^ (a-1) .* exp(-x./b) ./ (b.*gamma(a));
|
||||
0014 I0 = find(x<0);
|
||||
0015 f(I0) = zeros(size(I0));</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,246 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of disp_dr</title>
|
||||
<meta name="keywords" content="disp_dr">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > disp_dr.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>disp_dr
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function disp_dr(dr,order,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="olr.html" class="code" title="function olr(var_list,olr_inst,obj_var,W)">olr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="osr.html" class="code" title="function osr(var_list,params,W)">osr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function disp_dr(dr,order,var_list)</a>
|
||||
0004 <span class="keyword">global</span> 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 <span class="keyword">if</span> nvar == 0
|
||||
0015 nvar = length(k1);
|
||||
0016 ivar = [1:nvar];
|
||||
0017 <span class="keyword">else</span>
|
||||
0018 ivar=zeros(nvar,1);
|
||||
0019 <span class="keyword">for</span> i=1:nvar
|
||||
0020 i_tmp = strmatch(var_list(i,:),M_.endo_names(k1,:),<span class="string">'exact'</span>);
|
||||
0021 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0022 disp(var_list(i,:));
|
||||
0023 error ([<span class="string">'One of the variable specified does not exist'</span>]) ;
|
||||
0024 <span class="keyword">else</span>
|
||||
0025 ivar(i) = i_tmp;
|
||||
0026 <span class="keyword">end</span>
|
||||
0027 <span class="keyword">end</span>
|
||||
0028 <span class="keyword">end</span>
|
||||
0029 disp(<span class="string">'POLICY AND TRANSITION FUNCTIONS'</span>)
|
||||
0030 <span class="comment">% variable names</span>
|
||||
0031 str = <span class="string">' '</span>;
|
||||
0032 <span class="keyword">for</span> i=1:nvar
|
||||
0033 str = [str sprintf(<span class="string">'%16s'</span>,M_.endo_names(k1(ivar(i)),:))];
|
||||
0034 <span class="keyword">end</span>
|
||||
0035 disp(str);
|
||||
0036 <span class="comment">%</span>
|
||||
0037 <span class="comment">% constant</span>
|
||||
0038 <span class="comment">%</span>
|
||||
0039 str = <span class="string">'Constant '</span>;
|
||||
0040 flag = 0;
|
||||
0041 <span class="keyword">for</span> i=1:nvar
|
||||
0042 x = dr.ys(k1(ivar(i)));
|
||||
0043 <span class="keyword">if</span> order > 1
|
||||
0044 x = x + dr.ghs2(ivar(i))/2;
|
||||
0045 <span class="keyword">end</span>
|
||||
0046 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0047 flag = 1;
|
||||
0048 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0049 <span class="keyword">else</span>
|
||||
0050 str = [str <span class="string">' 0'</span>];
|
||||
0051 <span class="keyword">end</span>
|
||||
0052 <span class="keyword">end</span>
|
||||
0053 <span class="keyword">if</span> flag
|
||||
0054 disp(str)
|
||||
0055 <span class="keyword">end</span>
|
||||
0056 <span class="keyword">if</span> order > 1
|
||||
0057 str = <span class="string">'(correction) '</span>;
|
||||
0058 flag = 0;
|
||||
0059 <span class="keyword">for</span> i=1:nvar
|
||||
0060 x = dr.ghs2(ivar(i))/2;
|
||||
0061 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0062 flag = 1;
|
||||
0063 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0064 <span class="keyword">else</span>
|
||||
0065 str = [str <span class="string">' 0'</span>];
|
||||
0066 <span class="keyword">end</span>
|
||||
0067 <span class="keyword">end</span>
|
||||
0068 <span class="keyword">if</span> flag
|
||||
0069 disp(str)
|
||||
0070 <span class="keyword">end</span>
|
||||
0071 <span class="keyword">end</span>
|
||||
0072 <span class="comment">%</span>
|
||||
0073 <span class="comment">% ghx</span>
|
||||
0074 <span class="comment">%</span>
|
||||
0075 <span class="keyword">for</span> k=1:nx
|
||||
0076 flag = 0;
|
||||
0077 str1 = sprintf(<span class="string">'%s(%d)'</span>,M_.endo_names(k1(klag(k,1)),:),klag(k,2)-M_.maximum_lag-2);
|
||||
0078 str = sprintf(<span class="string">'%-20s'</span>,str1);
|
||||
0079 <span class="keyword">for</span> i=1:nvar
|
||||
0080 x = dr.ghx(ivar(i),k);
|
||||
0081 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0082 flag = 1;
|
||||
0083 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0084 <span class="keyword">else</span>
|
||||
0085 str = [str <span class="string">' 0'</span>];
|
||||
0086 <span class="keyword">end</span>
|
||||
0087 <span class="keyword">end</span>
|
||||
0088 <span class="keyword">if</span> flag
|
||||
0089 disp(str)
|
||||
0090 <span class="keyword">end</span>
|
||||
0091 <span class="keyword">end</span>
|
||||
0092 <span class="comment">%</span>
|
||||
0093 <span class="comment">% ghu</span>
|
||||
0094 <span class="comment">%</span>
|
||||
0095 <span class="keyword">for</span> k=1:nu
|
||||
0096 flag = 0;
|
||||
0097 str = sprintf(<span class="string">'%-20s'</span>,M_.exo_names(k,:));
|
||||
0098 <span class="keyword">for</span> i=1:nvar
|
||||
0099 x = dr.ghu(ivar(i),k);
|
||||
0100 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0101 flag = 1;
|
||||
0102 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0103 <span class="keyword">else</span>
|
||||
0104 str = [str <span class="string">' 0'</span>];
|
||||
0105 <span class="keyword">end</span>
|
||||
0106 <span class="keyword">end</span>
|
||||
0107 <span class="keyword">if</span> flag
|
||||
0108 disp(str)
|
||||
0109 <span class="keyword">end</span>
|
||||
0110 <span class="keyword">end</span>
|
||||
0111
|
||||
0112 <span class="keyword">if</span> order > 1
|
||||
0113 <span class="comment">% ghxx</span>
|
||||
0114 <span class="keyword">for</span> k = 1:nx
|
||||
0115 <span class="keyword">for</span> j = 1:k
|
||||
0116 flag = 0;
|
||||
0117 str1 = sprintf(<span class="string">'%s(%d),%s(%d)'</span>,M_.endo_names(k1(klag(k,1)),:),klag(k,2)-M_.maximum_lag-2, <span class="keyword">...</span>
|
||||
0118 M_.endo_names(k1(klag(j,1)),:),klag(j,2)-M_.maximum_lag-2);
|
||||
0119 str = sprintf(<span class="string">'%-20s'</span>,str1);
|
||||
0120 <span class="keyword">for</span> i=1:nvar
|
||||
0121 <span class="keyword">if</span> k == j
|
||||
0122 x = dr.ghxx(ivar(i),(k-1)*nx+j)/2;
|
||||
0123 <span class="keyword">else</span>
|
||||
0124 x = dr.ghxx(ivar(i),(k-1)*nx+j);
|
||||
0125 <span class="keyword">end</span>
|
||||
0126 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0127 flag = 1;
|
||||
0128 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0129 <span class="keyword">else</span>
|
||||
0130 str = [str <span class="string">' 0'</span>];
|
||||
0131 <span class="keyword">end</span>
|
||||
0132 <span class="keyword">end</span>
|
||||
0133 <span class="keyword">if</span> flag
|
||||
0134 disp(str)
|
||||
0135 <span class="keyword">end</span>
|
||||
0136 <span class="keyword">end</span>
|
||||
0137 <span class="keyword">end</span>
|
||||
0138 <span class="comment">%</span>
|
||||
0139 <span class="comment">% ghuu</span>
|
||||
0140 <span class="comment">%</span>
|
||||
0141 <span class="keyword">for</span> k = 1:nu
|
||||
0142 <span class="keyword">for</span> j = 1:k
|
||||
0143 flag = 0;
|
||||
0144 str = sprintf(<span class="string">'%-20s'</span>,[M_.exo_names(k,:) <span class="string">','</span> M_.exo_names(j,:)] );
|
||||
0145 <span class="keyword">for</span> i=1:nvar
|
||||
0146 <span class="keyword">if</span> k == j
|
||||
0147 x = dr.ghuu(ivar(i),(k-1)*nu+j)/2;
|
||||
0148 <span class="keyword">else</span>
|
||||
0149 x = dr.ghuu(ivar(i),(k-1)*nu+j);
|
||||
0150 <span class="keyword">end</span>
|
||||
0151 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0152 flag = 1;
|
||||
0153 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0154 <span class="keyword">else</span>
|
||||
0155 str = [str <span class="string">' 0'</span>];
|
||||
0156 <span class="keyword">end</span>
|
||||
0157 <span class="keyword">end</span>
|
||||
0158 <span class="keyword">if</span> flag
|
||||
0159 disp(str)
|
||||
0160 <span class="keyword">end</span>
|
||||
0161 <span class="keyword">end</span>
|
||||
0162 <span class="keyword">end</span>
|
||||
0163 <span class="comment">%</span>
|
||||
0164 <span class="comment">% ghxu</span>
|
||||
0165 <span class="comment">%</span>
|
||||
0166 <span class="keyword">for</span> k = 1:nx
|
||||
0167 <span class="keyword">for</span> j = 1:nu
|
||||
0168 flag = 0;
|
||||
0169 str1 = sprintf(<span class="string">'%s(%d),%s'</span>,M_.endo_names(k1(klag(k,1)),:),klag(k,2)-M_.maximum_lag-2, <span class="keyword">...</span>
|
||||
0170 M_.exo_names(j,:));
|
||||
0171 str = sprintf(<span class="string">'%-20s'</span>,str1);
|
||||
0172 <span class="keyword">for</span> i=1:nvar
|
||||
0173 x = dr.ghxu(ivar(i),(k-1)*nu+j);
|
||||
0174 <span class="keyword">if</span> abs(x) > 1e-6
|
||||
0175 flag = 1;
|
||||
0176 str = [str sprintf(<span class="string">'%16.6f'</span>,x)];
|
||||
0177 <span class="keyword">else</span>
|
||||
0178 str = [str <span class="string">' 0'</span>];
|
||||
0179 <span class="keyword">end</span>
|
||||
0180 <span class="keyword">end</span>
|
||||
0181 <span class="keyword">if</span> flag
|
||||
0182 disp(str)
|
||||
0183 <span class="keyword">end</span>
|
||||
0184 <span class="keyword">end</span>
|
||||
0185 <span class="keyword">end</span>
|
||||
0186 <span class="keyword">end</span>
|
||||
0187
|
||||
0188 <span class="comment">% $$$ dr.ghx</span>
|
||||
0189 <span class="comment">% $$$ dr.ghu</span>
|
||||
0190 <span class="comment">% $$$ dr.ghxx</span>
|
||||
0191 <span class="comment">% $$$ dr.ghuu</span>
|
||||
0192 <span class="comment">% $$$ dr.ghxu</span>
|
||||
0193
|
||||
0194 <span class="comment">% 01/08/2001 MJ added test for order in printing quadratic terms</span>
|
||||
0195 <span class="comment">% 02/21/2001 MJ pass all variable names through deblank()</span>
|
||||
0196 <span class="comment">% 02/21/2001 MJ changed from f to g format to write numbers</span>
|
||||
0197 <span class="comment">% 10/09/2002 MJ corrected error on constant whith subset of variables</span>
|
||||
0198
|
||||
0199
|
||||
0200</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,128 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of disp_moments</title>
|
||||
<meta name="keywords" content="disp_moments">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > disp_moments.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>disp_moments
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function disp_moments(y,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li><li><a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a> Copyright (C) 2002 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="olr.html" class="code" title="function olr(var_list,olr_inst,obj_var,W)">olr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="osr.html" class="code" title="function osr(var_list,params,W)">osr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function disp_moments(y,var_list)</a>
|
||||
0004 <span class="keyword">global</span> M_ options_ oo_
|
||||
0005
|
||||
0006 warning off
|
||||
0007 nvar = size(var_list,1);
|
||||
0008 <span class="keyword">if</span> nvar == 0
|
||||
0009 nvar = M_.endo_nbr;
|
||||
0010 ivar = [1:nvar]';
|
||||
0011 <span class="keyword">else</span>
|
||||
0012 ivar=zeros(nvar,1);
|
||||
0013 <span class="keyword">for</span> i=1:nvar
|
||||
0014 i_tmp = strmatch(var_list(i,:),M_.endo_names,<span class="string">'exact'</span>);
|
||||
0015 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0016 error ([<span class="string">'One of the variable specified does not exist'</span>]) ;
|
||||
0017 <span class="keyword">else</span>
|
||||
0018 ivar(i) = i_tmp;
|
||||
0019 <span class="keyword">end</span>
|
||||
0020 <span class="keyword">end</span>
|
||||
0021 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> options_.nomoments == 0
|
||||
0034 z = [ m' s' s2' (mean(y.^3)./s2.^1.5)' (mean(y.^4)./(s2.*s2)-3)' ];
|
||||
0035
|
||||
0036 title=<span class="string">'MOMENTS OF SIMULATED VARIABLES'</span>;
|
||||
0037 <span class="keyword">if</span> options_.hp_filter > 1
|
||||
0038 title = [title <span class="string">' (HP filter, lambda = '</span> <span class="keyword">...</span>
|
||||
0039 int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0040 <span class="keyword">end</span>
|
||||
0041 headers=strvcat(<span class="string">'VARIABLE'</span>,<span class="string">'MEAN'</span>,<span class="string">'STD. DEV.'</span>,<span class="string">'VARIANCE'</span>,<span class="string">'SKEWNESS'</span>, <span class="keyword">...</span>
|
||||
0042 <span class="string">'KURTOSIS'</span>);
|
||||
0043 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,labels,z,size(labels,2)+2,16,6);
|
||||
0044 <span class="keyword">end</span>
|
||||
0045
|
||||
0046 <span class="keyword">if</span> options_.nocorr == 0
|
||||
0047 corr = (y'*y/size(y,1))./(s'*s);
|
||||
0048 title = <span class="string">'CORRELATION OF SIMULATED VARIABLES'</span>;
|
||||
0049 <span class="keyword">if</span> options_.hp_filter > 1
|
||||
0050 title = [title <span class="string">' (HP filter, lambda = '</span> <span class="keyword">...</span>
|
||||
0051 int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0052 <span class="keyword">end</span>
|
||||
0053 headers = strvcat(<span class="string">'VARIABLE'</span>,M_.endo_names(ivar,:));
|
||||
0054 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,labels,corr,size(labels,2)+2,8,4);
|
||||
0055 <span class="keyword">end</span>
|
||||
0056
|
||||
0057 ar = options_.ar;
|
||||
0058 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'ar'</span>,5);
|
||||
0059 ar = options_.ar;
|
||||
0060 <span class="keyword">if</span> ar > 0
|
||||
0061 autocorr = [];
|
||||
0062 <span class="keyword">for</span> i=1:ar
|
||||
0063 oo_.autocorr{i} = y(ar+1:<span class="keyword">end</span>,:)'*y(ar+1-i:end-i,:)./((size(y,1)-ar)*s'*s);
|
||||
0064 autocorr = [ autocorr diag(oo_.autocorr{i}) ];
|
||||
0065 <span class="keyword">end</span>
|
||||
0066 title = <span class="string">'AUTOCORRELATION OF SIMULATED VARIABLES'</span>;
|
||||
0067 <span class="keyword">if</span> options_.hp_filter > 1
|
||||
0068 title = [title <span class="string">' (HP filter, lambda = '</span> <span class="keyword">...</span>
|
||||
0069 int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0070 <span class="keyword">end</span>
|
||||
0071 headers = strvcat(<span class="string">'VARIABLE'</span>,int2str([1:ar]'));
|
||||
0072 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,labels,autocorr,size(labels,2)+2,8,4);
|
||||
0073 <span class="keyword">end</span>
|
||||
0074
|
||||
0075 warning on
|
||||
0076 <span class="comment">% 10/03/02 MJ corrected order std. dev var in printed report.</span>
|
||||
0077 <span class="comment">% 01/02/03 MJ added correlation and autocorrelation</span>
|
||||
0078 <span class="comment">% 01/19/03 MJ corrected variable name truncation</span>
|
||||
0079 <span class="comment">% 02/18/03 MJ added subtitle for HP filter</span>
|
||||
0080 <span class="comment">% 03/02/03 MJ added M_.maximum_lag to the number of entries of y</span>
|
||||
0081 <span class="comment">% 04/28/03 MJ modified handling of options_</span>
|
||||
0082 <span class="comment">% 06/23/03 MJ added warning off</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,142 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of disp_th_moments</title>
|
||||
<meta name="keywords" content="disp_th_moments">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > disp_th_moments.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>disp_th_moments
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function disp_th_moments(dr,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a> Copyright (C) 2002 Michel Juillard</li><li><a href="th_autocovariances.html" class="code" title="function [Gamma_y,ivar]=th_autocovariances(dr,ivar)">th_autocovariances</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="olr.html" class="code" title="function olr(var_list,olr_inst,obj_var,W)">olr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="osr.html" class="code" title="function osr(var_list,params,W)">osr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function disp_th_moments(dr,var_list)</a>
|
||||
0004 <span class="keyword">global</span> M_ oo_ options_
|
||||
0005
|
||||
0006 nvar = size(var_list,1);
|
||||
0007 <span class="keyword">if</span> nvar == 0
|
||||
0008 nvar = length(dr.order_var);
|
||||
0009 ivar = [1:nvar]';
|
||||
0010 <span class="keyword">else</span>
|
||||
0011 ivar=zeros(nvar,1);
|
||||
0012 <span class="keyword">for</span> i=1:nvar
|
||||
0013 i_tmp = strmatch(var_list(i,:),M_.endo_names,<span class="string">'exact'</span>);
|
||||
0014 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0015 error ([<span class="string">'One of the variable specified does not exist'</span>]) ;
|
||||
0016 <span class="keyword">else</span>
|
||||
0017 ivar(i) = i_tmp;
|
||||
0018 <span class="keyword">end</span>
|
||||
0019 <span class="keyword">end</span>
|
||||
0020 <span class="keyword">end</span>
|
||||
0021
|
||||
0022 m = dr.ys(ivar);
|
||||
0023
|
||||
0024 oo_.gamma_y = <a href="th_autocovariances.html" class="code" title="function [Gamma_y,ivar]=th_autocovariances(dr,ivar)">th_autocovariances</a>(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 <span class="keyword">if</span> options_.order == 2
|
||||
0030 m = m+oo_.gamma_y{options_.ar+3};
|
||||
0031 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> options_.nomoments == 0
|
||||
0039 title=<span class="string">'THEORETICAL MOMENTS'</span>;
|
||||
0040 <span class="keyword">if</span> options_.hp_filter == 1
|
||||
0041 title = [title <span class="string">' (HP filter, lambda = '</span> int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0042 <span class="keyword">end</span>
|
||||
0043 headers=strvcat(<span class="string">'VARIABLE'</span>,<span class="string">'MEAN'</span>,<span class="string">'STD. DEV.'</span>,<span class="string">'VARIANCE'</span>);
|
||||
0044 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,deblank(M_.endo_names(ivar,:)),z,lh,11,4);
|
||||
0045 <span class="keyword">if</span> M_.exo_nbr > 1
|
||||
0046 disp(<span class="string">' '</span>)
|
||||
0047 title=<span class="string">'VARIANCE DECOMPOSITION (in percent)'</span>;
|
||||
0048 <span class="keyword">if</span> options_.hp_filter == 1
|
||||
0049 title = [title <span class="string">' (HP filter, lambda = '</span> <span class="keyword">...</span>
|
||||
0050 int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0051 <span class="keyword">end</span>
|
||||
0052 headers = M_.exo_names;
|
||||
0053 headers(M_.exo_names_orig_ord,:) = headers;
|
||||
0054 headers = strvcat(<span class="string">' '</span>,headers);
|
||||
0055 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,deblank(M_.endo_names(ivar(i1),:)),100*oo_.gamma_y{options_.ar+2}(i1,:), <span class="keyword">...</span>
|
||||
0056 lh,8,2);
|
||||
0057 <span class="keyword">end</span>
|
||||
0058 <span class="keyword">end</span>
|
||||
0059
|
||||
0060 <span class="keyword">if</span> options_.nocorr == 0
|
||||
0061 disp(<span class="string">' '</span>)
|
||||
0062 title=<span class="string">'MATRIX OF CORRELATIONS'</span>;
|
||||
0063 <span class="keyword">if</span> options_.hp_filter == 1
|
||||
0064 title = [title <span class="string">' (HP filter, lambda = '</span> int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0065 <span class="keyword">end</span>
|
||||
0066 labels = deblank(M_.endo_names(ivar,:));
|
||||
0067 headers = strvcat(<span class="string">'Variables'</span>,labels(i1,:));
|
||||
0068 corr = oo_.gamma_y{1}(i1,i1)./(sd(i1)*sd(i1)');
|
||||
0069 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,labels(i1,:),corr,lh,8,4);
|
||||
0070 <span class="keyword">end</span>
|
||||
0071
|
||||
0072 <span class="keyword">if</span> options_.ar > 0
|
||||
0073 disp(<span class="string">' '</span>)
|
||||
0074 title=<span class="string">'COEFFICIENTS OF AUTOCORRELATION'</span>;
|
||||
0075 <span class="keyword">if</span> options_.hp_filter == 1
|
||||
0076 title = [title <span class="string">' (HP filter, lambda = '</span> int2str(options_.hp_filter) <span class="string">')'</span>];
|
||||
0077 <span class="keyword">end</span>
|
||||
0078 labels = deblank(M_.endo_names(ivar(i1),:));
|
||||
0079 headers = strvcat(<span class="string">'Order '</span>,int2str([1:options_.ar]'));
|
||||
0080 z=[];
|
||||
0081 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0085 <a href="table.html" class="code" title="function table(title,headers,labels,values,label_width,val_width,val_precis)">table</a>(title,headers,labels,z,0,8,4);
|
||||
0086 <span class="keyword">end</span>
|
||||
0087
|
||||
0088 <span class="comment">% 10/09/02 MJ</span>
|
||||
0089 <span class="comment">% 10/18/02 MJ added th_autocovariances() and provided for lags on several</span>
|
||||
0090 <span class="comment">% periods</span>
|
||||
0091 <span class="comment">% 10/30/02 MJ added correlations and autocorrelations, uses table()</span>
|
||||
0092 <span class="comment">% oo_.gamma_y is now a cell array.</span>
|
||||
0093 <span class="comment">% 02/18/03 MJ added subtitles for HP filter</span>
|
||||
0094 <span class="comment">% 05/01/03 MJ corrected options_.hp_filter</span>
|
||||
0095 <span class="comment">% 05/21/03 MJ variance decomposition: test M_.exo_nbr > 1</span>
|
||||
0096 <span class="comment">% 05/21/03 MJ displays only variables with positive variance</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,64 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dlognorm</title>
|
||||
<meta name="keywords" content="dlognorm">
|
||||
<meta name="description" content="DLOGNORM The log-normal density function">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dlognorm.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dlognorm
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>DLOGNORM The log-normal density function</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function f = dlognorm(x,lambda,zeta) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">DLOGNORM The log-normal density function
|
||||
|
||||
f = dlognorm(x,lambda,zeta)</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dnorm.html" class="code" title="function f = dnorm(x,m,s)">dnorm</a> DNORM The normal density function</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function f = dlognorm(x,lambda,zeta)</a>
|
||||
0002 <span class="comment">%DLOGNORM The log-normal density function</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% f = dlognorm(x,lambda,zeta)</span>
|
||||
0005
|
||||
0006 <span class="comment">% Copyright (c) Halfdan Grage, Anders Holtsberg</span>
|
||||
0007
|
||||
0008 <span class="keyword">if</span> any(any(zeta<=0))
|
||||
0009 error(<span class="string">'Parameter zeta is wrong'</span>)
|
||||
0010 <span class="keyword">end</span>
|
||||
0011
|
||||
0012 neg = find(x <= 0);
|
||||
0013 [n1,n2] = size(neg);
|
||||
0014 x(neg) = ones(n1,n2);
|
||||
0015 f = <a href="dnorm.html" class="code" title="function f = dnorm(x,m,s)">dnorm</a>(log(x),lambda,zeta)./x;
|
||||
0016 f(neg) = zeros(n1,n2);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,59 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dnorm</title>
|
||||
<meta name="keywords" content="dnorm">
|
||||
<meta name="description" content="DNORM The normal density function">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dnorm.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dnorm
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>DNORM The normal density function</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function f = dnorm(x,m,s) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment">DNORM The normal density function
|
||||
|
||||
f = dnorm(x,Mean,StandardDeviation)</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dlognorm.html" class="code" title="function f = dlognorm(x,lambda,zeta)">dlognorm</a> DLOGNORM The log-normal density function</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function f = dnorm(x,m,s)</a>
|
||||
0002 <span class="comment">%DNORM The normal density function</span>
|
||||
0003 <span class="comment">%</span>
|
||||
0004 <span class="comment">% f = dnorm(x,Mean,StandardDeviation)</span>
|
||||
0005
|
||||
0006 <span class="comment">% Anders Holtsberg, 18-11-93</span>
|
||||
0007 <span class="comment">% Copyright (c) Anders Holtsberg</span>
|
||||
0008
|
||||
0009 <span class="keyword">if</span> nargin<3, s=1; <span class="keyword">end</span>
|
||||
0010 <span class="keyword">if</span> nargin<2, m=0; <span class="keyword">end</span>
|
||||
0011 f = exp(-0.5*((x-m)./s).^2)./(sqrt(2*pi)*s);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 133 B |
|
@ -1,698 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dr1</title>
|
||||
<meta name="keywords" content="dr1">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dr1.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dr1
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [dr,info]=dr1(dr,task) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a> Copyright (C) 2001 Michel Juillard</li><li><a href="qzdiv.html" class="code" title="function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)">qzdiv</a> from Chris Sims web site</li><li><a href="resid.html" class="code" title="function resid(period)">resid</a> Copyright (C) 2001 Michel Juillard</li><li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li><li><a href="set_state_space.html" class="code" title="function dr=set_state_space(dr)">set_state_space</a> Copyright (C) 2001 Michel Juillard</li><li><a href="sylvester3.html" class="code" title="function x=sylvester3(a,b,c,d)">sylvester3</a> solves a*x+b*x*c=d</li><li><a href="sylvester3a.html" class="code" title="function x=sylvester3a(x0,a,b,c,d)">sylvester3a</a> solves iteratively ax+bxc=d</li><li><a href="transition_matrix.html" class="code" title="function [A,B] = transition_matrix(dr)">transition_matrix</a> makes transition matrices out of ghx and ghu</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dr2.html" class="code" title="function ghs2=dr2(ys,dr)">dr2</a> Copyright (C) 2001 Michel Juillard</li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function [dr,info]=dr1(dr,task)</a>
|
||||
0004 <span class="keyword">global</span> M_ options_ oo_
|
||||
0005
|
||||
0006 <span class="keyword">global</span> olr_state
|
||||
0007 <span class="comment">% info = 1: the model doesn't define current variables uniquely</span>
|
||||
0008 <span class="comment">% info = 2: problem in mjdgges.dll info(2) contains error code</span>
|
||||
0009 <span class="comment">% info = 3: BK order condition not satisfied info(2) contains "distance"</span>
|
||||
0010 <span class="comment">% absence of stable trajectory</span>
|
||||
0011 <span class="comment">% info = 4: BK order condition not satisfied info(2) contains "distance"</span>
|
||||
0012 <span class="comment">% indeterminacy</span>
|
||||
0013 <span class="comment">% info = 5: BK rank condition not satisfied</span>
|
||||
0014
|
||||
0015
|
||||
0016
|
||||
0017 info = 0;
|
||||
0018
|
||||
0019 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'loglinear'</span>,0);
|
||||
0020 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'noprint'</span>,0);
|
||||
0021 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'olr'</span>,0);
|
||||
0022 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'olr_beta'</span>,1);
|
||||
0023 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'qz_criterium'</span>,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 <span class="keyword">if</span> M_.exo_nbr == 0
|
||||
0033 oo_.exo_steady_state = [] ;
|
||||
0034 <span class="keyword">end</span>
|
||||
0035
|
||||
0036 tempex = oo_.exo_simul;
|
||||
0037
|
||||
0038 it_ = M_.maximum_lag + 1;
|
||||
0039 <span class="keyword">if</span> options_.olr
|
||||
0040 z = repmat(zeros(M_.endo_nbr,1),1,klen);
|
||||
0041 <span class="keyword">else</span>
|
||||
0042 z = repmat(dr.ys,1,klen);
|
||||
0043 <span class="keyword">end</span>
|
||||
0044 z = z(iyr0) ;
|
||||
0045 <span class="keyword">if</span> options_.order == 1
|
||||
0046 [junk,jacobia_] = feval([M_.fname <span class="string">'_dynamic'</span>],z,tempex);
|
||||
0047 <span class="keyword">elseif</span> options_.order == 2
|
||||
0048 [junk,jacobia_,<a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>] = feval([M_.fname <span class="string">'_dynamic'</span>],z,<span class="keyword">...</span>
|
||||
0049 [oo_.exo_simul <span class="keyword">...</span>
|
||||
0050 oo_.exo_det_simul]);
|
||||
0051 <span class="keyword">end</span>
|
||||
0052
|
||||
0053 oo_.exo_simul = tempex ;
|
||||
0054 tempex = [];
|
||||
0055
|
||||
0056 <span class="comment">% expanding system for Optimal Linear Regulator</span>
|
||||
0057 <span class="keyword">if</span> options_.olr
|
||||
0058 bet = options_.olr_beta;
|
||||
0059 jacobia1 = [];
|
||||
0060 n_inst = size(options_.olr_inst,1);
|
||||
0061
|
||||
0062 <span class="keyword">if</span> ~isfield(olr_state_,<span class="string">'done'</span>)
|
||||
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 <span class="keyword">for</span> i=1:M_.endo_nbr
|
||||
0070 temp = [<span class="string">'mult_'</span> int2str(i)];
|
||||
0071 lgoo_.endo_simul = strvcat(lgoo_.endo_simul,temp);
|
||||
0072 <span class="keyword">end</span>
|
||||
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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> i=1:2*M_.maximum_lag+1
|
||||
0083 <span class="keyword">if</span> 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 <span class="keyword">if</span> i == M_.maximum_lag+1
|
||||
0086 jacobia1 = [jacobia1 [jacobia_(:,k2); 2*options_.olr_w]];
|
||||
0087 <span class="keyword">else</span>
|
||||
0088 jacobia1 = [jacobia1 [jacobia_(:,k2); <span class="keyword">...</span>
|
||||
0089 zeros(olr_state_.old_M_.endo_nbr,length(k1))]];
|
||||
0090 <span class="keyword">end</span>
|
||||
0091 newiy(i,k1) = ones(1,length(k1));
|
||||
0092 <span class="keyword">end</span>
|
||||
0093 i1 = 2*M_.maximum_lag+2-i;
|
||||
0094 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0102 <span class="keyword">end</span>
|
||||
0103 jacobia1 = [jacobia1 [jacobia_(:,end-M_.exo_nbr+1:end); <span class="keyword">...</span>
|
||||
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 <span class="comment">% computes steady state</span>
|
||||
0113 <a href="resid.html" class="code" title="function resid(period)">resid</a> = feval([M_.fname <span class="string">'_steady'</span>],zeros(olr_state_.old_M_.endo_nbr,1));
|
||||
0114 <span class="keyword">if</span> <a href="resid.html" class="code" title="function resid(period)">resid</a>'*<a href="resid.html" class="code" title="function resid(period)">resid</a> < 1e-12
|
||||
0115 dr.ys =[dr.ys; zeros(nj,1)];
|
||||
0116 <span class="keyword">else</span>
|
||||
0117 AA = zeros(M_.endo_nbr,M_.endo_nbr);
|
||||
0118 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0122 dr.ys = -AA\[<a href="resid.html" class="code" title="function resid(period)">resid</a>; zeros(nj,1)];
|
||||
0123 <span class="keyword">end</span>
|
||||
0124 <span class="keyword">end</span>
|
||||
0125 <span class="comment">% end of code section for Optimal Linear Regulator</span>
|
||||
0126
|
||||
0127 klen = M_.maximum_lag + M_.maximum_lead + 1;
|
||||
0128 dr=<a href="set_state_space.html" class="code" title="function dr=set_state_space(dr)">set_state_space</a>(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 <span class="keyword">if</span> M_.maximum_lead == 0; <span class="comment">% backward models</span>
|
||||
0147 a = jacobia_(:,nonzeros(k1'));
|
||||
0148 dr.ghx = zeros(size(a));
|
||||
0149 m = 0;
|
||||
0150 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0155 <span class="keyword">if</span> M_.exo_nbr
|
||||
0156 dr.ghu = -b\jacobia_(:,nz+1:end);
|
||||
0157 <span class="keyword">end</span>
|
||||
0158 dr.eigval = eig(<a href="transition_matrix.html" class="code" title="function [A,B] = transition_matrix(dr)">transition_matrix</a>(dr));
|
||||
0159 dr.rank = 0;
|
||||
0160 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0167 <span class="keyword">return</span>;
|
||||
0168 <span class="keyword">end</span>
|
||||
0169
|
||||
0170 <span class="comment">%forward--looking models</span>
|
||||
0171 <span class="keyword">if</span> nstatic > 0
|
||||
0172 [Q,R] = qr(b(:,1:nstatic));
|
||||
0173 aa = Q'*jacobia_;
|
||||
0174 <span class="keyword">else</span>
|
||||
0175 aa = jacobia_;
|
||||
0176 <span class="keyword">end</span>
|
||||
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:<span class="keyword">end</span>,nstatic+1:end);
|
||||
0182 <span class="keyword">if</span> any(isinf(a(:)))
|
||||
0183 info = 1;
|
||||
0184 <span class="keyword">return</span>
|
||||
0185 <span class="keyword">end</span>
|
||||
0186 <span class="keyword">if</span> M_.exo_nbr
|
||||
0187 fu = aa(:,nz+(1:M_.exo_nbr));
|
||||
0188 <span class="keyword">end</span>
|
||||
0189 clear aa;
|
||||
0190
|
||||
0191 <span class="comment">% buildind D and E</span>
|
||||
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:<span class="keyword">end</span>,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:<span class="keyword">end</span>,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 <span class="keyword">if</span> ~isempty(kad)
|
||||
0206 <span class="keyword">for</span> j = 1:size(kad,1)
|
||||
0207 d(sdyn+j,kad(j)) = 1 ;
|
||||
0208 e(sdyn+j,kae(j)) = 1 ;
|
||||
0209 <span class="keyword">end</span>
|
||||
0210 <span class="keyword">end</span>
|
||||
0211
|
||||
0212 <span class="keyword">if</span> ~exist(<span class="string">'mjdgges'</span>)
|
||||
0213 <span class="comment">% using Chris Sim's routines</span>
|
||||
0214 use_qzdiv = 1;
|
||||
0215 [ss,tt,qq,w] = qz(e,d);
|
||||
0216 [tt,ss,qq,w] = <a href="qzdiv.html" class="code" title="function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)">qzdiv</a>(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 <span class="keyword">else</span>
|
||||
0225 use_qzdiv = 0;
|
||||
0226 [ss,tt,w,sdim,dr.eigval,info1] = mjdgges(e,d,options_.qz_criterium);
|
||||
0227 <span class="keyword">if</span> info1
|
||||
0228 info(1) = 2;
|
||||
0229 info(2) = info1;
|
||||
0230 <span class="keyword">return</span>
|
||||
0231 <span class="keyword">end</span>
|
||||
0232 nba = nd-sdim;
|
||||
0233 <span class="keyword">end</span>
|
||||
0234
|
||||
0235 nyf = sum(kstate(:,2) > M_.maximum_lag+1);
|
||||
0236
|
||||
0237 <span class="keyword">if</span> task == 1
|
||||
0238 dr.rank = rank(w(1:nyf,nd-nyf+1:end));
|
||||
0239 dr.eigval = eig(e,d);
|
||||
0240 <span class="keyword">return</span>
|
||||
0241 <span class="keyword">end</span>
|
||||
0242
|
||||
0243 <span class="keyword">if</span> nba ~= nyf
|
||||
0244 temp = sort(abs(dr.eigval));
|
||||
0245 <span class="keyword">if</span> nba > nyf
|
||||
0246 temp = temp(nd-nba+1:nd-nyf)-1-options_.qz_criterium;
|
||||
0247 info(1) = 3;
|
||||
0248 <span class="keyword">elseif</span> nba < nyf;
|
||||
0249 temp = temp(nd-nyf+1:nd-nba)-1-options_.qz_criterium;
|
||||
0250 info(1) = 4;
|
||||
0251 <span class="keyword">end</span>
|
||||
0252 info(2) = temp'*temp;
|
||||
0253 <span class="keyword">return</span>
|
||||
0254 <span class="keyword">end</span>
|
||||
0255
|
||||
0256 np = nd - nyf;
|
||||
0257 n2 = np + 1;
|
||||
0258 n3 = nyf;
|
||||
0259 n4 = n3 + 1;
|
||||
0260 <span class="comment">% derivatives with respect to dynamic state variables</span>
|
||||
0261 <span class="comment">% forward variables</span>
|
||||
0262 w1 =w(1:n3,n2:nd);
|
||||
0263 <span class="keyword">if</span> condest(w1) > 1e9;
|
||||
0264 info(1) = 5;
|
||||
0265 info(2) = condest(w1);
|
||||
0266 <span class="keyword">return</span>;
|
||||
0267 <span class="keyword">else</span>
|
||||
0268 gx = -w1'\w(n4:nd,n2:nd)';
|
||||
0269 <span class="keyword">end</span>
|
||||
0270
|
||||
0271 <span class="comment">% predetermined variables</span>
|
||||
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 <span class="comment">%lead variables actually present in the model</span>
|
||||
0280 j3 = nonzeros(kstate(:,3));
|
||||
0281 j4 = find(kstate(:,3));
|
||||
0282 <span class="comment">% derivatives with respect to exogenous variables</span>
|
||||
0283 <span class="keyword">if</span> M_.exo_nbr
|
||||
0284 a1 = b;
|
||||
0285 aa1 = [];
|
||||
0286 <span class="keyword">if</span> nstatic > 0
|
||||
0287 aa1 = a1(:,1:nstatic);
|
||||
0288 <span class="keyword">end</span>
|
||||
0289 dr.ghu = -[aa1 a(:,j3)*gx(j4,1:npred)+a1(:,nstatic+1:nstatic+ <span class="keyword">...</span>
|
||||
0290 npred) a1(:,nstatic+npred+1:end)]\fu;
|
||||
0291 <span class="keyword">end</span>
|
||||
0292
|
||||
0293 <span class="comment">% static variables</span>
|
||||
0294 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0302
|
||||
0303 <span class="keyword">if</span> 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.* <span class="keyword">...</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0312
|
||||
0313 <span class="comment">%necessary when using Sims' routines</span>
|
||||
0314 <span class="keyword">if</span> use_qzdiv
|
||||
0315 gx = real(gx);
|
||||
0316 hx = real(hx);
|
||||
0317 dr.ghx = real(dr.ghx);
|
||||
0318 dr.ghu = real(dr.ghu);
|
||||
0319 <span class="keyword">end</span>
|
||||
0320
|
||||
0321 <span class="comment">%exogenous deterministic variables</span>
|
||||
0322 <span class="keyword">if</span> M_.exo_det_nbr > 0
|
||||
0323 f1 = sparse(jacobia_(:,nonzeros(M_.lead_lag_incidence(M_.maximum_lag+2:<span class="keyword">end</span>,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 <span class="keyword">for</span> i = 2:M_.exo_det_length
|
||||
0331 dr.ghud{i} = -M2*dr.ghud{i-1}(end-nyf+1:<span class="keyword">end</span>,:);
|
||||
0332 <span class="keyword">end</span>
|
||||
0333 <span class="keyword">end</span>
|
||||
0334
|
||||
0335 <span class="keyword">if</span> options_.order == 1
|
||||
0336 <span class="keyword">return</span>
|
||||
0337 <span class="keyword">end</span>
|
||||
0338
|
||||
0339 <span class="comment">% Second order</span>
|
||||
0340 <span class="comment">%tempex = oo_.exo_simul ;</span>
|
||||
0341
|
||||
0342 <span class="comment">%hessian = real(hessext('ff1_',[z; oo_.exo_steady_state]))' ;</span>
|
||||
0343 kk = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+1:<span class="keyword">end</span>,order_var)),1));
|
||||
0344 <span class="keyword">if</span> M_.maximum_lag > 0
|
||||
0345 kk = [cumsum(M_.lead_lag_incidence(1:M_.maximum_lag,order_var),1); kk];
|
||||
0346 <span class="keyword">end</span>
|
||||
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 <span class="comment">%[junk,junk,hessian] = feval([M_.fname '_dynamic'],z, oo_.exo_steady_state);</span>
|
||||
0360 <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>(:,kk1(:)) = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>;
|
||||
0361
|
||||
0362 <span class="comment">%oo_.exo_simul = tempex ;</span>
|
||||
0363 <span class="comment">%clear tempex</span>
|
||||
0364
|
||||
0365 n1 = 0;
|
||||
0366 n2 = np;
|
||||
0367 zx = zeros(np,np);
|
||||
0368 zu=zeros(np,M_.exo_nbr);
|
||||
0369 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0375 kk = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+1:<span class="keyword">end</span>,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 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> n1*n1*n2*n2 > 1e7
|
||||
0393 rhs = zeros(M_.endo_nbr,n2*n2);
|
||||
0394 k1 = 1;
|
||||
0395 <span class="keyword">for</span> i1 = 1:n2
|
||||
0396 <span class="keyword">for</span> i2 = 1:n2
|
||||
0397 rhs(:,k1) = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zx(:,i1),zx(:,i2));
|
||||
0398 k1 = k1 + 1;
|
||||
0399 <span class="keyword">end</span>
|
||||
0400 <span class="keyword">end</span>
|
||||
0401 <span class="keyword">else</span>
|
||||
0402 rhs = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zx,zx);
|
||||
0403 <span class="keyword">end</span>
|
||||
0404 rhs = -rhs;
|
||||
0405
|
||||
0406 <span class="comment">%lhs</span>
|
||||
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 <span class="comment">% variables with the highest lead</span>
|
||||
0412 k1 = find(kstate(:,2) == M_.maximum_lag+M_.maximum_lead+1);
|
||||
0413 <span class="keyword">if</span> 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 <span class="keyword">else</span>
|
||||
0417 k2 = [1:M_.endo_nbr];
|
||||
0418 k3 = kstate(k1,1);
|
||||
0419 <span class="keyword">end</span>
|
||||
0420 <span class="comment">% Jacobian with respect to the variables with the highest lead</span>
|
||||
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 <span class="keyword">for</span> 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 <span class="keyword">if</span> i == 1
|
||||
0436 [junk,junk,k4]=intersect(kstate(k1,1),[1:M_.endo_nbr]);
|
||||
0437 <span class="keyword">else</span>
|
||||
0438 [junk,junk,k4]=intersect(kstate(k1,1),kstate(k0,1));
|
||||
0439 <span class="keyword">end</span>
|
||||
0440 i1 = offset-n0+n1;
|
||||
0441 B(offset+[1:n1],offset-n0+[1:n0]) = -E(k4,:);
|
||||
0442 k0 = k1;
|
||||
0443 offset = offset + n1;
|
||||
0444 <span class="keyword">end</span>
|
||||
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)=<span class="keyword">...</span>
|
||||
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 <span class="keyword">if</span> exist(<span class="string">'gensylv'</span>)
|
||||
0452 dr.ghxx = gensylv(2,A,B,C,D);
|
||||
0453 <span class="keyword">else</span>
|
||||
0454 C = kron(hx,hx);
|
||||
0455 x0 = <a href="sylvester3.html" class="code" title="function x=sylvester3(a,b,c,d)">sylvester3</a>(A,B,C,D);
|
||||
0456 dr.ghxx = <a href="sylvester3a.html" class="code" title="function x=sylvester3a(x0,a,b,c,d)">sylvester3a</a>(x0,A,B,C,D);
|
||||
0457 <span class="keyword">end</span>
|
||||
0458
|
||||
0459 <span class="comment">%ghxu</span>
|
||||
0460 <span class="comment">%rhs</span>
|
||||
0461 hu = dr.ghu(nstatic+1:nstatic+npred,:);
|
||||
0462 <span class="comment">%kk = reshape([1:np*np],np,np);</span>
|
||||
0463 <span class="comment">%kk = kk(1:npred,1:npred);</span>
|
||||
0464 <span class="comment">%rhs = -hessian*kron(zx,zu)-f1*dr.ghxx(end-nyf+1:end,kk(:))*kron(hx(1:npred,:),hu(1:npred,:));</span>
|
||||
0465 <span class="keyword">if</span> n1*n1*n2*M_.exo_nbr > 1e7
|
||||
0466 rhs = zeros(M_.endo_nbr,n2*M_.exo_nbr);
|
||||
0467 k1 = 1;
|
||||
0468 <span class="keyword">for</span> i1 = 1:n2
|
||||
0469 <span class="keyword">for</span> i2 = 1:M_.exo_nbr
|
||||
0470 rhs(:,k1) = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zx(:,i1),zu(:,i2));
|
||||
0471 k1 = k1 + 1;
|
||||
0472 <span class="keyword">end</span>
|
||||
0473 <span class="keyword">end</span>
|
||||
0474 <span class="keyword">else</span>
|
||||
0475 rhs = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zx,zu);
|
||||
0476 <span class="keyword">end</span>
|
||||
0477 nyf1 = sum(kstate(:,2) == M_.maximum_lag+2);
|
||||
0478 hu1 = [hu;zeros(np-npred,M_.exo_nbr)];
|
||||
0479 <span class="comment">%B1 = [B(1:M_.endo_nbr,:);zeros(size(A,1)-M_.endo_nbr,size(B,2))];</span>
|
||||
0480 rhs = -[rhs; zeros(n-M_.endo_nbr,size(rhs,2))]-B*dr.ghxx*kron(hx,hu1);
|
||||
0481
|
||||
0482
|
||||
0483 <span class="comment">%lhs</span>
|
||||
0484 dr.ghxu = A\rhs;
|
||||
0485
|
||||
0486 <span class="comment">%ghuu</span>
|
||||
0487 <span class="comment">%rhs</span>
|
||||
0488 kk = reshape([1:np*np],np,np);
|
||||
0489 kk = kk(1:npred,1:npred);
|
||||
0490 <span class="keyword">if</span> 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 <span class="keyword">for</span> i1 = 1:M_.exo_nbr
|
||||
0494 <span class="keyword">for</span> i2 = 1:M_.exo_nbr
|
||||
0495 rhs(:,k1) = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zu(:,i1),zu(:,i2));
|
||||
0496 k1 = k1 + 1;
|
||||
0497 <span class="keyword">end</span>
|
||||
0498 <span class="keyword">end</span>
|
||||
0499 <span class="keyword">else</span>
|
||||
0500 rhs = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zu,zu);
|
||||
0501 <span class="keyword">end</span>
|
||||
0502
|
||||
0503 rhs = -[rhs; zeros(n-M_.endo_nbr,size(rhs,2))]-B*dr.ghxx*kron(hu1,hu1);
|
||||
0504
|
||||
0505 <span class="comment">%lhs</span>
|
||||
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 <span class="comment">% dr.ghs2</span>
|
||||
0514 <span class="comment">% derivatives of F with respect to forward variables</span>
|
||||
0515 <span class="comment">% reordering predetermined variables in diminishing lag order</span>
|
||||
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:<span class="keyword">end</span>,order_var)),1));
|
||||
0527 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> i=1:M_.maximum_lead
|
||||
0541 <span class="keyword">for</span> 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,:)+<a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>(:,kh(k3,k3))* <span class="keyword">...</span>
|
||||
0545 kron(gu(k3a,:),gu(k3a,:));
|
||||
0546 <span class="keyword">end</span>
|
||||
0547
|
||||
0548 <span class="comment">% LHS</span>
|
||||
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 <span class="keyword">if</span> i == M_.maximum_lead
|
||||
0553 <span class="keyword">break</span>
|
||||
0554 <span class="keyword">end</span>
|
||||
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:<span class="keyword">end</span>,:) = Guu(end-npred+1:<span class="keyword">end</span>,:) + hxx*GuGu;
|
||||
0563
|
||||
0564 H = E1 + hx*H;
|
||||
0565 <span class="keyword">end</span>
|
||||
0566 RHS = RHS*M_.Sigma_e(:);
|
||||
0567 dr.fuu = RHS;
|
||||
0568 RHS = -RHS-dr.fbias;
|
||||
0569 dr.ghs2 = LHS\RHS;
|
||||
0570
|
||||
0571 <span class="comment">% deterministic exogenous variables</span>
|
||||
0572 <span class="keyword">if</span> 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 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*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 <span class="keyword">for</span> 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 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*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 <span class="keyword">end</span>
|
||||
0587 R1 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*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 <span class="keyword">for</span> 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 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zu,zudi);
|
||||
0597 dr.ghuud{i} = -M2*dr.ghxud{i-1}(kf,:)*kron(hu,Eud)-M1*R2;
|
||||
0598 <span class="keyword">end</span>
|
||||
0599 R1 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*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 <span class="keyword">for</span> 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 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zudi,zudi);
|
||||
0606 dr.ghudud{i,i} = -M2*(dr.ghudud{i-1,i-1}(kf,:)+<span class="keyword">...</span>
|
||||
0607 2*dr.ghxud{i-1}(kf,:)*kron(hudi,Eud) <span class="keyword">...</span>
|
||||
0608 +dr.ghxx(kf,:)*kron(hudi,hudi))-M1*R2;
|
||||
0609 R2 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zud,zudi);
|
||||
0610 dr.ghudud{1,i} = -M2*(dr.ghxud{i-1}(kf,:)*kron(hud,Eud)+<span class="keyword">...</span>
|
||||
0611 dr.ghxx(kf,:)*kron(hud,hudi))<span class="keyword">...</span>
|
||||
0612 -M1*R2;
|
||||
0613 <span class="keyword">for</span> 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 = <a href="hessian.html" class="code" title="function hessian_mat = hessian(func,x,varargin)">hessian</a>*kron(zudj,zudi);
|
||||
0617 dr.ghudud{j,i} = -M2*(dr.ghudud{j-1,i-1}(kf,:)+dr.ghxud{j-1}(kf,:)* <span class="keyword">...</span>
|
||||
0618 kron(hudi,Eud)+dr.ghxud{i-1}(kf,:)* <span class="keyword">...</span>
|
||||
0619 kron(hudj,Eud)+dr.ghxx(kf,:)*kron(hudj,hudi))-M1*R2;
|
||||
0620 <span class="keyword">end</span>
|
||||
0621
|
||||
0622 <span class="keyword">end</span>
|
||||
0623 <span class="keyword">end</span>
|
||||
0624 <span class="comment">% 01/08/2001 MJ put return on iorder == 1 after defining dr.kstate and dr.kdyn</span>
|
||||
0625 <span class="comment">% 01/17/2001 MJ added dr.delta_s: correction factor for order = 2</span>
|
||||
0626 <span class="comment">% 01/21/2001 FC correction of delta_s for more than 1 shock</span>
|
||||
0627 <span class="comment">% 01/23/2001 MJ suppression of redundant sum() in delta_s formula</span>
|
||||
0628 <span class="comment">% 02/22/2001 MJ stderr_ replaced by Sigma_e_</span>
|
||||
0629 <span class="comment">% 08/24/2001 MJ changed the order of the variables, separates static</span>
|
||||
0630 <span class="comment">% variables and handles only one instance of variables both</span>
|
||||
0631 <span class="comment">% in lead and lag</span>
|
||||
0632 <span class="comment">% 08/24/2001 MJ added sigma to state variables as in Schmitt-Grohe and</span>
|
||||
0633 <span class="comment">% Uribe (2001)</span>
|
||||
0634 <span class="comment">% 10/20/2002 MJ corrected lags on several periods bug</span>
|
||||
0635 <span class="comment">% 10/30/2002 MJ corrected lags on several periods bug on static when some</span>
|
||||
0636 <span class="comment">% intermediary lags are missing</span>
|
||||
0637 <span class="comment">% 12/08/2002 MJ uses sylvester3 to solve for dr.ghxx</span>
|
||||
0638 <span class="comment">% 01/01/2003 MJ added dr.fbias for iterative for dr_algo == 1</span>
|
||||
0639 <span class="comment">% 02/21/2003 MJ corrected bug for models without lagged variables</span>
|
||||
0640 <span class="comment">% 03/02/2003 MJ fixed second order for lag on several periods</span>
|
||||
0641 <span class="comment">% 05/21/2003 MJ add check call argument and make computation for CHECK</span>
|
||||
0642 <span class="comment">% 06/01/2003 MJ added a test for M_.maximum_lead > 1 and order > 1</span>
|
||||
0643 <span class="comment">% 08/28/2003 MJ corrected bug in computation of 2nd order (ordering of</span>
|
||||
0644 <span class="comment">% forward variable in LHS)</span>
|
||||
0645 <span class="comment">% 08/29/2003 MJ use Sims routine if mjdgges isn't available</span>
|
||||
0646
|
||||
0647
|
||||
0648
|
||||
0649
|
||||
0650
|
||||
0651
|
||||
0652</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,301 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dr11</title>
|
||||
<meta name="keywords" content="dr11">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dr11.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dr11
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dr=dr11(iorder,dr,cheik) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="qzdiv.html" class="code" title="function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)">qzdiv</a> from Chris Sims web site</li><li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li><li><a href="set_state_space.html" class="code" title="function dr=set_state_space(dr)">set_state_space</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="resol1.html" class="code" title="function dr=resol1(ys,algo,linear,iorder)">resol1</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function dr=dr11(iorder,dr,cheik)</a>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> M_ options_ oo_
|
||||
0006 <span class="keyword">global</span> it_ stdexo_ means_ dr1_test_ bayestopt_
|
||||
0007
|
||||
0008 <span class="comment">% hack for Bayes</span>
|
||||
0009 <span class="keyword">global</span> dr1_test_ bayestopt_
|
||||
0010
|
||||
0011 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'loglinear'</span>,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 <span class="keyword">if</span> M_.exo_nbr == 0
|
||||
0022 oo_.exo_steady_state = [] ;
|
||||
0023 <span class="keyword">end</span>
|
||||
0024
|
||||
0025 <span class="keyword">if</span> ~ M_.lead_lag_incidence(M_.maximum_lag+1,:) > 0
|
||||
0026 error (<span class="string">'Error in model specification: some variables don"t appear as current'</span>) ;
|
||||
0027 <span class="keyword">end</span>
|
||||
0028
|
||||
0029 <span class="keyword">if</span> ~cheik
|
||||
0030 <span class="comment">% if xlen > 1</span>
|
||||
0031 <span class="comment">% error (['SS: stochastic exogenous variables must appear only at the' ...</span>
|
||||
0032 <span class="comment">% ' current period. Use additional endogenous variables']) ;</span>
|
||||
0033 <span class="comment">% end</span>
|
||||
0034 <span class="keyword">end</span>
|
||||
0035
|
||||
0036 <span class="keyword">if</span> M_.maximum_lead > 1 & iorder > 1
|
||||
0037 error ([<span class="string">'Models with leads on more than one period can only be solved'</span> <span class="keyword">...</span>
|
||||
0038 <span class="string">' at order 1'</span>])
|
||||
0039 <span class="keyword">end</span>
|
||||
0040
|
||||
0041 dr=<a href="set_state_space.html" class="code" title="function dr=set_state_space(dr)">set_state_space</a>(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 <span class="comment">%M_.jacobia=real(diffext('ff1_',[z; oo_.exo_steady_state])) ;</span>
|
||||
0061 <span class="comment">%M_.jacobia=real(jacob_a('ff1_',[z; oo_.exo_steady_state])) ;</span>
|
||||
0062 [junk,M_.jacobia] = feval([M_.fname <span class="string">'_dynamic'</span>],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 <span class="keyword">if</span> any(isinf(a(:)))
|
||||
0071 dr1_test_(1) = 5;
|
||||
0072 dr1_test_(2) = bayestopt_.penalty;
|
||||
0073 <span class="keyword">end</span>
|
||||
0074 <span class="keyword">if</span> M_.exo_nbr
|
||||
0075 fu = b\M_.jacobia(:,nz+1:end);
|
||||
0076 <span class="keyword">end</span>
|
||||
0077
|
||||
0078 <span class="keyword">if</span> M_.maximum_lead == 0 & M_.maximum_lag == 1; <span class="comment">% backward model with one lag</span>
|
||||
0079 dr.ghx = -a;
|
||||
0080 dr.ghu = -fu;
|
||||
0081 <span class="keyword">return</span>;
|
||||
0082 <span class="keyword">elseif</span> M_.maximum_lead == 0 & M_.maximum_lag > 1 <span class="comment">% backward model with lags on more than</span>
|
||||
0083 <span class="comment">% one period</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0090
|
||||
0091 <span class="comment">% buildind D and E</span>
|
||||
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:<span class="keyword">end</span>,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:<span class="keyword">end</span>,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 <span class="keyword">if</span> ~isempty(kad)
|
||||
0107 <span class="keyword">for</span> j = 1:size(kad,1)
|
||||
0108 d(sdyn+j,kad(j)) = 1 ;
|
||||
0109 e(sdyn+j,kae(j)) = 1 ;
|
||||
0110 <span class="keyword">end</span>
|
||||
0111 <span class="keyword">end</span>
|
||||
0112 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'qz_criterium'</span>,1.000001);
|
||||
0113
|
||||
0114 <span class="keyword">if</span> ~exist(<span class="string">'mjdgges'</span>)
|
||||
0115 <span class="comment">% using Chris Sim's routines</span>
|
||||
0116 use_qzdiv = 1;
|
||||
0117 [ss,tt,qq,w] = qz(e,d);
|
||||
0118 [tt,ss,qq,w] = <a href="qzdiv.html" class="code" title="function [A,B,Q,Z] = qzdiv(stake,A,B,Q,Z)">qzdiv</a>(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 <span class="keyword">else</span>
|
||||
0127 use_qzdiv = 0;
|
||||
0128 [ss,tt,w,sdim,oo_.eigenvalues,info] = mjdgges(e,d,options_.qz_criterium);
|
||||
0129 <span class="keyword">if</span> info & info ~= nd+2;
|
||||
0130 error([<span class="string">'ERROR'</span> info <span class="string">' in MJDGGES.DLL'</span>]);
|
||||
0131 <span class="keyword">end</span>
|
||||
0132 nba = nd-sdim;
|
||||
0133 <span class="keyword">end</span>
|
||||
0134
|
||||
0135 nyf = sum(kstate(:,2) > M_.maximum_lag+1);
|
||||
0136
|
||||
0137 <span class="keyword">if</span> cheik
|
||||
0138 dr.rank = rank(w(1:nyf,nd-nyf+1:end));
|
||||
0139 <span class="comment">% dr.eigval = oo_.eigenvalues;</span>
|
||||
0140 <span class="keyword">return</span>
|
||||
0141 <span class="keyword">end</span>
|
||||
0142
|
||||
0143 eigenvalues = sort(oo_.eigenvalues);
|
||||
0144
|
||||
0145 <span class="keyword">if</span> nba > nyf;
|
||||
0146 <span class="comment">% disp('Instability !');</span>
|
||||
0147 dr1_test_(1) = 3; <span class="comment">%% More eigenvalues superior to unity than forward variables ==> instability.</span>
|
||||
0148 dr1_test_(2) = (abs(eigenvalues(nd-nba+1:nd-nyf))-1-1e-5)'*<span class="keyword">...</span>
|
||||
0149 (abs(eigenvalues(nd-nba+1:nd-nyf))-1-1e-5);<span class="comment">% Distance to Blanchard-Khan conditions (penalty)</span>
|
||||
0150 <span class="keyword">return</span>
|
||||
0151 <span class="keyword">elseif</span> nba < nyf;
|
||||
0152 <span class="comment">% disp('Indeterminacy !');</span>
|
||||
0153 dr1_test_(1) = 2; <span class="comment">%% ==> Indeterminacy.</span>
|
||||
0154 dr1_test_(2) = (abs(eigenvalues(nd-nyf+1:nd-nba))-1-1e-5)'*<span class="keyword">...</span>
|
||||
0155 (abs(eigenvalues(nd-nyf+1:nd-nba))-1-1e-5);<span class="comment">% Distance to Blanchard-Khan conditions (penality)</span>
|
||||
0156 <span class="comment">%% warning('DR1: Blanchard-Kahn conditions are not satisfied. Run CHEIK to learn more!');</span>
|
||||
0157 <span class="keyword">return</span>
|
||||
0158 <span class="keyword">end</span>
|
||||
0159
|
||||
0160 np = nd - nyf;
|
||||
0161 n2 = np + 1;
|
||||
0162 n3 = nyf;
|
||||
0163 n4 = n3 + 1;
|
||||
0164 <span class="comment">% derivatives with respect to dynamic state variables</span>
|
||||
0165 <span class="comment">% forward variables</span>
|
||||
0166
|
||||
0167 <span class="keyword">if</span> condest(w(1:n3,n2:nd)) > 1e9
|
||||
0168 <span class="comment">% disp('Indeterminacy !!');</span>
|
||||
0169 dr1_test_(1) = 2;
|
||||
0170 dr1_test_(2) = 1;
|
||||
0171 <span class="keyword">return</span>
|
||||
0172 <span class="keyword">end</span>
|
||||
0173
|
||||
0174 warning_state = warning;
|
||||
0175 lastwarn(<span class="string">''</span>);
|
||||
0176 warning off;
|
||||
0177 gx = -w(1:n3,n2:nd)'\w(n4:nd,n2:nd)';
|
||||
0178
|
||||
0179 <span class="keyword">if</span> length(lastwarn) > 0;
|
||||
0180 <span class="comment">% disp('Indeterminacy !!');</span>
|
||||
0181 dr1_test_(1) = 2;
|
||||
0182 dr1_test_(2) = 1;
|
||||
0183 warning(warning_state);
|
||||
0184 <span class="keyword">return</span>
|
||||
0185 <span class="keyword">end</span>
|
||||
0186
|
||||
0187 <span class="comment">% predetermined variables</span>
|
||||
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(<span class="string">''</span>);
|
||||
0192 <span class="keyword">if</span> length(lastwarn) > 0;
|
||||
0193 <span class="comment">% disp('Singularity problem in dr11.m');</span>
|
||||
0194 dr1_test_(1) = 2;
|
||||
0195 dr1_test_(2) = 1;
|
||||
0196 warning(warning_state);
|
||||
0197 <span class="keyword">return</span>
|
||||
0198 <span class="keyword">end</span>
|
||||
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 <span class="comment">%lead variables actually present in the model</span>
|
||||
0205 j3 = nonzeros(kstate(:,3));
|
||||
0206 j4 = find(kstate(:,3));
|
||||
0207 <span class="comment">% derivatives with respect to exogenous variables</span>
|
||||
0208 <span class="keyword">if</span> M_.exo_nbr
|
||||
0209 a1 = eye(M_.endo_nbr);
|
||||
0210 aa1 = [];
|
||||
0211 <span class="keyword">if</span> nstatic > 0
|
||||
0212 aa1 = a1(:,1:nstatic);
|
||||
0213 <span class="keyword">end</span>
|
||||
0214 dr.ghu = -[aa1 a(:,j3)*gx(j4,1:npred)+a1(:,nstatic+1:nstatic+ <span class="keyword">...</span>
|
||||
0215 npred) a1(:,nstatic+npred+1:end)]\fu;
|
||||
0216
|
||||
0217
|
||||
0218 lastwarn(<span class="string">''</span>);
|
||||
0219 <span class="keyword">if</span> length(lastwarn) > 0;
|
||||
0220 <span class="comment">% disp('Singularity problem in dr11.m');</span>
|
||||
0221 dr1_test_(1) = 2;
|
||||
0222 dr1_test_(2) = 1;
|
||||
0223 <span class="keyword">return</span>
|
||||
0224 <span class="keyword">end</span>
|
||||
0225 <span class="keyword">end</span>
|
||||
0226 warning(warning_state);
|
||||
0227
|
||||
0228 <span class="comment">% static variables</span>
|
||||
0229 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
0236
|
||||
0237 <span class="keyword">if</span> 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.* <span class="keyword">...</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0246
|
||||
0247 <span class="comment">% necessary when using Sims' routines</span>
|
||||
0248 <span class="keyword">if</span> use_qzdiv
|
||||
0249 gx = real(gx);
|
||||
0250 hx = real(hx);
|
||||
0251 dr.ghx = real(dr.ghx);
|
||||
0252 dr.ghu = real(dr.ghu);
|
||||
0253 <span class="keyword">end</span>
|
||||
0254
|
||||
0255</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,59 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dr2</title>
|
||||
<meta name="keywords" content="dr2">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dr2.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dr2
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function ghs2=dr2(ys,dr) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
function used for dr_algo == 1</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dr1.html" class="code" title="function [dr,info]=dr1(dr,task)">dr1</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <span class="comment">% function used for dr_algo == 1</span>
|
||||
0004 <a name="_sub0" href="#_subfunctions" class="code">function ghs2=dr2(ys,dr)</a>
|
||||
0005 <span class="keyword">global</span> M_
|
||||
0006
|
||||
0007 dr.ys = ys;
|
||||
0008 fh = str2func([M_.fname <span class="string">'_static'</span>]);
|
||||
0009 dr.fbias = 2*feval(fh,dr.ys);
|
||||
0010 dr=<a href="dr1.html" class="code" title="function [dr,info]=dr1(dr,task)">dr1</a>(dr,0);
|
||||
0011 ghs2 = dr.ghs2;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,136 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of draw_prior_density</title>
|
||||
<meta name="keywords" content="draw_prior_density">
|
||||
<meta name="description" content="stephane.adjemian@ens.fr [07-15-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > draw_prior_density.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>draw_prior_density
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@ens.fr [07-15-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx); </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@ens.fr [07-15-2004]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="lpdfgam.html" class="code" title="function ldens = lpdfgam(x,a,b);">lpdfgam</a> log GAMMA PDF</li><li><a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a> MJ_QGAMMA The gamma inverse distribution function</li><li><a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a> QBETA The beta inverse distribution function</li><li><a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a> QGAMMA The gamma inverse distribution function</li><li><a href="qnorm.html" class="code" title="function x = qnorm(p,m,s)">qnorm</a> QNORM The normal inverse distribution function</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="PlotPosteriorDistributions.html" class="code" title="function PlotPosteriorDistributions()">PlotPosteriorDistributions</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="plot_priors.html" class="code" title="function plot_priors">plot_priors</a> stephane.adjemian@cepremap.cnrs.fr [07-31-2004]</li><li><a href="posterior_distribution.html" class="code" title="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);">posterior_distribution</a> stephane.adjemian@cepremap.cnrs.fr [07-15-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [x,f,abscissa,dens,binf,bsup] = draw_prior_density(indx);</a>
|
||||
0002 <span class="comment">% stephane.adjemian@ens.fr [07-15-2004]</span>
|
||||
0003
|
||||
0004 <span class="keyword">global</span> 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 <span class="keyword">if</span> pshape(indx) == 1 <span class="comment">%/* BETA Prior */</span>
|
||||
0016 density = inline(<span class="string">'((bb-x).^(b-1)).*(x-aa).^(a-1)./(beta(a,b)*(bb-aa)^(a+b-1))'</span>,<span class="string">'x'</span>,<span class="string">'a'</span>,<span class="string">'b'</span>,<span class="string">'aa'</span>,<span class="string">'bb'</span>);
|
||||
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 = <a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a>(truncprior,a,b)*(bb-aa)+aa;
|
||||
0024 supbound = <a href="qbeta.html" class="code" title="function x = qbeta(p,a,b)">qbeta</a>(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 <span class="keyword">elseif</span> pshape(indx) == 2 <span class="comment">%/* GAMMA PRIOR */</span>
|
||||
0029 mu = p1(indx)-p3(indx);
|
||||
0030 b = p2(indx)^2/mu;
|
||||
0031 a = mu/b;
|
||||
0032 infbound = <a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(truncprior,a)*b;
|
||||
0033 supbound = <a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(1-truncprior,a)*b;
|
||||
0034 stepsize = (supbound-infbound)/200;
|
||||
0035 abscissa = infbound:stepsize:supbound;
|
||||
0036 dens = exp(<a href="lpdfgam.html" class="code" title="function ldens = lpdfgam(x,a,b);">lpdfgam</a>(abscissa,a,b));
|
||||
0037 abscissa = abscissa + p3(indx);
|
||||
0038 <span class="keyword">elseif</span> pshape(indx) == 3 <span class="comment">%/* GAUSSIAN PRIOR */</span>
|
||||
0039 density = inline(<span class="string">'inv(sqrt(2*pi)*b)*exp(-0.5*((x-a)/b).^2)'</span>,<span class="string">'x'</span>,<span class="string">'a'</span>,<span class="string">'b'</span>);
|
||||
0040 a = p1(indx);
|
||||
0041 b = p2(indx);
|
||||
0042 infbound = <a href="qnorm.html" class="code" title="function x = qnorm(p,m,s)">qnorm</a>(truncprior,a,b);
|
||||
0043 supbound = <a href="qnorm.html" class="code" title="function x = qnorm(p,m,s)">qnorm</a>(1-truncprior,a,b);
|
||||
0044 stepsize = (supbound-infbound)/200;
|
||||
0045 abscissa = infbound:stepsize:supbound;
|
||||
0046 dens = density(abscissa,a,b);
|
||||
0047 <span class="keyword">elseif</span> pshape(indx) == 4 <span class="comment">%/* INVGAMMA PRIOR type 1 */</span>
|
||||
0048 density = inline(<span class="string">'2*inv(gamma(nu/2))*(x.^(-nu-1))*((s/2)^(nu/2)).*exp(-s./(2*x.^2))'</span>,<span class="string">'x'</span>,<span class="string">'s'</span>,<span class="string">'nu'</span>);
|
||||
0049 nu = p2(indx);
|
||||
0050 s = p1(indx);
|
||||
0051 a = nu/2;
|
||||
0052 b = 2/s;
|
||||
0053 infbound = 1/sqrt(<a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(1-10*truncprior,a)*b);
|
||||
0054 supbound = 1/sqrt(<a href="mj_qgamma.html" class="code" title="function x = mj_qgamma(p,a)">mj_qgamma</a>(10*truncprior,a)*b);
|
||||
0055 stepsize = (supbound-infbound)/200;
|
||||
0056 abscissa = infbound:stepsize:supbound;
|
||||
0057 dens = density(abscissa,s,nu);
|
||||
0058 <span class="keyword">elseif</span> pshape(indx) == 5 <span class="comment">%/* UNIFORM PRIOR */</span>
|
||||
0059 density = inline(<span class="string">'(x.^0)/(b-a)'</span>,<span class="string">'x'</span>,<span class="string">'a'</span>,<span class="string">'b'</span>);
|
||||
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 <span class="keyword">elseif</span> pshape(indx) == 6 <span class="comment">%/* INVGAMMA PRIOR type 2 */</span>
|
||||
0068 density = inline(<span class="string">'inv(gamma(nu/2))*(x.^(-.5(nu+2)))*((s/2)^(nu/2)).*exp(-s./(2*x))'</span>,<span class="string">'x'</span>,<span class="string">'s'</span>,<span class="string">'nu'</span>);
|
||||
0069 nu = p2(indx);
|
||||
0070 s = p1(indx);
|
||||
0071 a = nu/2;
|
||||
0072 b = 2/s;
|
||||
0073 infbound = 1/(<a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a>(1-truncprior,a)*b);
|
||||
0074 supbound = 1/(<a href="qgamma.html" class="code" title="function x = qgamma(p,a)">qgamma</a>(truncprior,a)*b);
|
||||
0075 stepsize = (supbound-infbound)/200;
|
||||
0076 abscissa = infbound:stepsize:supbound;
|
||||
0077 dens = density(abscissa,s,nu);
|
||||
0078 <span class="keyword">end</span>
|
||||
0079
|
||||
0080 k = [1:length(dens)];
|
||||
0081 <span class="keyword">if</span> pshape(indx) ~= 5
|
||||
0082 [junk,k1] = max(dens);
|
||||
0083 <span class="keyword">if</span> k1 == 1 | k1 == length(dens)
|
||||
0084 k = find(dens < 10);
|
||||
0085 <span class="keyword">end</span>
|
||||
0086 <span class="keyword">end</span>
|
||||
0087 binf = abscissa(k(1));
|
||||
0088 bsup = abscissa(k(length(k)));
|
||||
0089 x = abscissa(k);
|
||||
0090 f = dens(k);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,93 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dsample</title>
|
||||
<meta name="keywords" content="dsample">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dsample.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dsample
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dsample(s1,s2) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
DSAMPLE : DSAMPLE(d1,d2)
|
||||
This optional command permits to reduce the number of
|
||||
periods considered in following output commands.
|
||||
If only one argument is
|
||||
provided, output is from period 1 to the period
|
||||
specified in the DSAMPLE command. If two arguments are
|
||||
present output is done for the interval between the
|
||||
two periods.
|
||||
DSAMPLE without arguments reset the sample to the one
|
||||
specified by PERIODS</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function dsample(s1,s2)</a>
|
||||
0004 <span class="comment">% DSAMPLE : DSAMPLE(d1,d2)</span>
|
||||
0005 <span class="comment">% This optional command permits to reduce the number of</span>
|
||||
0006 <span class="comment">% periods considered in following output commands.</span>
|
||||
0007 <span class="comment">% If only one argument is</span>
|
||||
0008 <span class="comment">% provided, output is from period 1 to the period</span>
|
||||
0009 <span class="comment">% specified in the DSAMPLE command. If two arguments are</span>
|
||||
0010 <span class="comment">% present output is done for the interval between the</span>
|
||||
0011 <span class="comment">% two periods.</span>
|
||||
0012 <span class="comment">% DSAMPLE without arguments reset the sample to the one</span>
|
||||
0013 <span class="comment">% specified by PERIODS</span>
|
||||
0014
|
||||
0015 <span class="keyword">global</span> options_
|
||||
0016
|
||||
0017 options_.smpl = zeros(2,1) ;
|
||||
0018
|
||||
0019 <span class="keyword">if</span> s1 > options_.periods | s2 > options_.periods
|
||||
0020 t = [<span class="string">'DYNARE dsample error: one of the arguments is larger than the one'</span> <span class="keyword">...</span>
|
||||
0021 <span class="string">' specified in PERIODS'</span>];
|
||||
0022 error(t);
|
||||
0023 <span class="keyword">end</span>
|
||||
0024
|
||||
0025 <span class="keyword">if</span> nargin == 0
|
||||
0026 options_.smpl(1) = 1 ;
|
||||
0027 options_.smpl(2) = options_.periods ;
|
||||
0028 <span class="keyword">elseif</span> nargin == 1
|
||||
0029 options_.smpl(1) = 1 ;
|
||||
0030 options_.smpl(2) = s1 ;
|
||||
0031 <span class="keyword">else</span>
|
||||
0032 options_.smpl(1) = s1 ;
|
||||
0033 options_.smpl(2) = s2 ;
|
||||
0034 <span class="keyword">end</span>
|
||||
0035
|
||||
0036 <span class="comment">% 02/23/01 MJ added error checking</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,52 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dy_date</title>
|
||||
<meta name="keywords" content="dy_date">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dy_date.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dy_date
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function y=dy_date(year,period) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="initvalf_.html" class="code" title="function initvalf_(fname,period,varargin)">initvalf_</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function y=dy_date(year,period)</a>
|
||||
0002 <span class="keyword">global</span> M_
|
||||
0003
|
||||
0004 y = M_.freq*(year-M_.start_date(1))+period-M_.start_date(2)+1;
|
||||
0005
|
||||
0006</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,105 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dyn2vec</title>
|
||||
<meta name="keywords" content="dyn2vec">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dyn2vec.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dyn2vec
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [z,zss]=dyn2vec(s1,s2); </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="olr.html" class="code" title="function olr(var_list,olr_inst,obj_var,W)">olr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="osr.html" class="code" title="function osr(var_list,params,W)">osr</a> Copyright (C) 2001 Michel Juillard</li><li><a href="simul.html" class="code" title="function simul(dr)">simul</a> Copyright (C) 2001 Michel Juillard</li><li><a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function [z,zss]=dyn2vec(s1,s2);</a>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> M_ oo_ options_
|
||||
0006
|
||||
0007 <span class="keyword">if</span> options_.smpl == 0
|
||||
0008 k = [1:size(oo_.y_simul,2)];
|
||||
0009 <span class="keyword">else</span>
|
||||
0010 k = [M_.maximum_lag+options_.smpl(1):M_.maximum_lag+options_.smpl(2)];
|
||||
0011 <span class="keyword">end</span>
|
||||
0012
|
||||
0013 <span class="keyword">if</span> nargin == 0
|
||||
0014 <span class="keyword">if</span> nargout > 0
|
||||
0015 t = [<span class="string">'DYNARE dyn2vec error: the function doesn''t return values when'</span> <span class="keyword">...</span>
|
||||
0016 <span class="string">' used without input argument'</span>];
|
||||
0017 error(t);
|
||||
0018 <span class="keyword">end</span>
|
||||
0019 <span class="keyword">for</span> i=1:size(oo_.y_simul,1)
|
||||
0020 assignin(<span class="string">'base'</span>,deblank(M_.endo_names(i,:)),oo_.y_simul(i,k)');
|
||||
0021 <span class="keyword">end</span>
|
||||
0022 <span class="keyword">return</span>
|
||||
0023 <span class="keyword">else</span>
|
||||
0024 j = strmatch(s1,M_.endo_names,<span class="string">'exact'</span>);
|
||||
0025 <span class="keyword">if</span> ~ isempty(j)
|
||||
0026 z = oo_.y_simul(j,k)';
|
||||
0027 <span class="keyword">else</span>
|
||||
0028 j = strmatch(s1,M_.exo_names,<span class="string">'exact'</span>);
|
||||
0029 <span class="keyword">if</span> ~ isempty(j)
|
||||
0030 <span class="keyword">if</span> options_.smpl == 0
|
||||
0031 z = oo_.exo_simul(:,j);
|
||||
0032 <span class="keyword">else</span>
|
||||
0033 z = oo_.exo_simul(M_.maximum_lag+options_.smpl(1):M_.maximum_lag+options_.smpl(2));
|
||||
0034 <span class="keyword">end</span>
|
||||
0035 <span class="keyword">else</span>
|
||||
0036 t = [<span class="string">'DYNARE dyn2vec error: variable '</span> deblank(s1(i,:)) <span class="string">' doesn''t'</span> <span class="keyword">...</span>
|
||||
0037 <span class="string">' exist.'</span>] ;
|
||||
0038 error (t) ;
|
||||
0039 <span class="keyword">end</span>
|
||||
0040 <span class="keyword">end</span>
|
||||
0041 <span class="keyword">end</span>
|
||||
0042
|
||||
0043 <span class="keyword">if</span> nargout == 0
|
||||
0044 <span class="keyword">if</span> nargin == 1
|
||||
0045 assignin(<span class="string">'base'</span>,s1,z);
|
||||
0046 <span class="keyword">elseif</span> nargin == 2
|
||||
0047 assignin(<span class="string">'base'</span>,s2,z);
|
||||
0048 <span class="keyword">end</span>
|
||||
0049 <span class="keyword">else</span>
|
||||
0050 zss=oo_.steady_state(j);
|
||||
0051 <span class="keyword">end</span>
|
||||
0052
|
||||
0053 <span class="comment">% 02/23/01 MJ redone, incorporating FC's improvements</span>
|
||||
0054 <span class="comment">% 08/24/01 MJ replaced globlize by internal assignin</span>
|
||||
0055 <span class="comment">% 08/24/01 MJ added 'exact' to strmatch (thanks to David Vavra)</span>
|
||||
0056 <span class="comment">% 01/31/03 MJ added provision for alternative name of variable</span>
|
||||
0057
|
||||
0058
|
||||
0059</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,109 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynare</title>
|
||||
<meta name="keywords" content="dynare">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynare.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynare
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dynare(fname, varargin) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
DYNARE ( 'Filename' )
|
||||
This command runs dynare with specified model file in argument
|
||||
Filename.
|
||||
The name of model file begins with an alphabetic character,
|
||||
and has a filename extension of .mod or .dyn.
|
||||
When extension is omitted, a model file with .mod extension
|
||||
is processed.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function dynare(fname, varargin)</a>
|
||||
0004 <span class="comment">% DYNARE ( 'Filename' )</span>
|
||||
0005 <span class="comment">% This command runs dynare with specified model file in argument</span>
|
||||
0006 <span class="comment">% Filename.</span>
|
||||
0007 <span class="comment">% The name of model file begins with an alphabetic character,</span>
|
||||
0008 <span class="comment">% and has a filename extension of .mod or .dyn.</span>
|
||||
0009 <span class="comment">% When extension is omitted, a model file with .mod extension</span>
|
||||
0010 <span class="comment">% is processed.</span>
|
||||
0011
|
||||
0012 <span class="keyword">if</span> ~isstr(fname)
|
||||
0013 error (<span class="string">'The argument in DYNARE must be a text string.'</span>) ;
|
||||
0014 <span class="keyword">end</span>
|
||||
0015 <span class="comment">% Testing if file have extension</span>
|
||||
0016 <span class="comment">% If no extension defalut .mod is added</span>
|
||||
0017 <span class="keyword">if</span> isempty(strfind(fname,<span class="string">'.'</span>))
|
||||
0018 fname1 = [fname <span class="string">'.dyn'</span>];
|
||||
0019 d = dir(fname1);
|
||||
0020 <span class="keyword">if</span> length(d) == 0
|
||||
0021 fname1 = [fname <span class="string">'.mod'</span>];
|
||||
0022 <span class="keyword">end</span>
|
||||
0023 fname = fname1;
|
||||
0024 <span class="comment">% Checking file extension</span>
|
||||
0025 <span class="keyword">else</span>
|
||||
0026 <span class="keyword">if</span> ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),<span class="string">'.MOD'</span>) <span class="keyword">...</span>
|
||||
0027 && ~strcmp(upper(fname(size(fname,2)-3:size(fname,2))),<span class="string">'.DYN'</span>)
|
||||
0028 error (<span class="string">'Argument is a file name with .mod or .dyn extension'</span>);
|
||||
0029 <span class="keyword">end</span>;
|
||||
0030 <span class="keyword">end</span>;
|
||||
0031 d = dir(fname);
|
||||
0032 <span class="keyword">if</span> length(d) == 0
|
||||
0033 disp([<span class="string">'DYNARE: can''t open '</span> fname])
|
||||
0034 <span class="keyword">return</span>
|
||||
0035 <span class="keyword">end</span>
|
||||
0036 dynareroot = strrep(which(<span class="string">'dynare.m'</span>),<span class="string">'dynare.m'</span>,<span class="string">''</span>);
|
||||
0037 command = [dynareroot <span class="string">'dynare_m '</span> fname] ;
|
||||
0038 <span class="keyword">for</span> i=2:nargin
|
||||
0039 command = [command <span class="string">' '</span> varargin{i-1}];
|
||||
0040 <span class="keyword">end</span>
|
||||
0041 [status, result] = system(command);
|
||||
0042 <span class="keyword">if</span> status
|
||||
0043 error(result)
|
||||
0044 <span class="keyword">end</span>
|
||||
0045
|
||||
0046 <span class="keyword">if</span> ~ isempty(find(abs(fname) == 46))
|
||||
0047 fname = fname(:,1:find(abs(fname) == 46)-1) ;
|
||||
0048 <span class="keyword">end</span>
|
||||
0049 evalin(<span class="string">'base'</span>,fname) ;
|
||||
0050
|
||||
0051
|
||||
0052 <span class="comment">% MJ 2/9/99: replace clear function by clear ff_</span>
|
||||
0053 <span class="comment">% MJ 4/7/00: change the path of dynare_m</span>
|
||||
0054 <span class="comment">% MJ 02/26/01: replaced local variable x by fname</span>
|
||||
0055 <span class="comment">% MJ 09/19/01: evaluates mod script in 'base' workspace</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,302 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynare_MC</title>
|
||||
<meta name="keywords" content="dynare_MC">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynare_MC.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynare_MC
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dynare_MC(var_list_) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li><li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li><li><a href="prior_bounds.html" class="code" title="function bounds = prior_bounds(bayestopt)">prior_bounds</a> </li><li><a href="read_variables.html" class="code" title="function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sheet,xls_range)">read_variables</a> Copyright (C) 2005 Michel Juillard</li><li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li><li><a href="set_prior.html" class="code" title="function [xparam1,estim_params_,bayestopt_,lb,ub]=set_prior(estim_params_)">set_prior</a> </li><li><a href="set_state_space.html" class="code" title="function dr=set_state_space(dr)">set_state_space</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_sensitivity.html" class="code" title="function x0=dynare_sensitivity()">dynare_sensitivity</a> copyright Marco Ratto 2006</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function dynare_MC(var_list_)</a>
|
||||
0002
|
||||
0003 <span class="keyword">global</span> M_ options_ oo_ estim_params_
|
||||
0004 <span class="keyword">global</span> bayestopt_
|
||||
0005
|
||||
0006 options_.varlist = var_list_;
|
||||
0007 options_.lgyidx2varobs = zeros(size(M_.endo_names,1),1);
|
||||
0008 <span class="keyword">for</span> i = 1:size(M_.endo_names,1)
|
||||
0009 tmp = strmatch(deblank(M_.endo_names(i,:)),options_.varobs,<span class="string">'exact'</span>);
|
||||
0010 <span class="keyword">if</span> ~isempty(tmp)
|
||||
0011 options_.lgyidx2varobs(i,1) = tmp;
|
||||
0012 <span class="keyword">end</span>
|
||||
0013 <span class="keyword">end</span>
|
||||
0014
|
||||
0015 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'first_obs'</span>,1);
|
||||
0016 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'prefilter'</span>,0);
|
||||
0017 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'presample'</span>,0);
|
||||
0018 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'lik_algo'</span>,1);
|
||||
0019 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'lik_init'</span>,1);
|
||||
0020 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'nograph'</span>,0);
|
||||
0021 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_conf_sig'</span>,0.90);
|
||||
0022 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_replic'</span>,20000);
|
||||
0023 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_drop'</span>,0.5);
|
||||
0024 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_jscale'</span>,0.2);
|
||||
0025 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_init_scale'</span>,2*options_.mh_jscale);
|
||||
0026 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mode_file'</span>,<span class="string">''</span>);
|
||||
0027 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mode_compute'</span>,4);
|
||||
0028 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mode_check'</span>,0);
|
||||
0029 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'prior_trunc'</span>,1e-10);
|
||||
0030 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_mode'</span>,1);
|
||||
0031 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'mh_nblck'</span>,2);
|
||||
0032 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'load_mh_file'</span>,0);
|
||||
0033 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'nodiagnostic'</span>,0);
|
||||
0034 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'loglinear'</span>,0);
|
||||
0035 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'unit_root_vars'</span>,[]);
|
||||
0036 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'XTick'</span>,[]);
|
||||
0037 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'XTickLabel'</span>,[]);
|
||||
0038 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'bayesian_irf'</span>,0);
|
||||
0039 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'bayesian_th_moments'</span>,0);
|
||||
0040 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'TeX'</span>,0);
|
||||
0041 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'irf'</span>,0);
|
||||
0042 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'relative_irf'</span>,0);
|
||||
0043 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'order'</span>,1);
|
||||
0044 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'ar'</span>,5);
|
||||
0045 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'dr_algo'</span>,0);
|
||||
0046 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'linear'</span>,0);
|
||||
0047 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'drop'</span>,0);
|
||||
0048 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'replic'</span>,1);
|
||||
0049 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'hp_filter'</span>,0);
|
||||
0050 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'forecast'</span>,0);
|
||||
0051 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'smoother'</span>,0);
|
||||
0052 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'moments_varendo'</span>,0);
|
||||
0053 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'filtered_vars'</span>,0);
|
||||
0054 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'kalman_algo'</span>,1);
|
||||
0055 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'kalman_tol'</span>,10^(-12));
|
||||
0056 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'posterior_mode_estimation'</span>,1);
|
||||
0057 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'MaxNumberOfBytes'</span>,1e6);
|
||||
0058 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'xls_sheet'</span>,<span class="string">''</span>);
|
||||
0059 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'xls_range'</span>,<span class="string">''</span>);
|
||||
0060
|
||||
0061 <span class="comment">%% Add something to the parser ++></span>
|
||||
0062 M_.dname = M_.fname; <span class="comment">% The user should be able to choose another name</span>
|
||||
0063 <span class="comment">% for the directory...</span>
|
||||
0064
|
||||
0065
|
||||
0066 pnames = [<span class="string">' '</span>;<span class="string">'beta '</span>;<span class="string">'gamm '</span>;<span class="string">'norm '</span>;<span class="string">'invg '</span>;<span class="string">'unif '</span>;<span class="string">'invg2'</span>];
|
||||
0067 n_varobs = size(options_.varobs,1);
|
||||
0068
|
||||
0069 [xparam1,estim_params_,bayestopt_,lb,ub] = <a href="set_prior.html" class="code" title="function [xparam1,estim_params_,bayestopt_,lb,ub]=set_prior(estim_params_)">set_prior</a>(estim_params_);
|
||||
0070
|
||||
0071 options_.mh_replic = 0;
|
||||
0072
|
||||
0073 bounds = <a href="prior_bounds.html" class="code" title="function bounds = prior_bounds(bayestopt)">prior_bounds</a>(bayestopt_);
|
||||
0074 bounds(:,1)=max(bounds(:,1),lb);
|
||||
0075 bounds(:,2)=min(bounds(:,2),ub);
|
||||
0076
|
||||
0077 <span class="keyword">if</span> any(xparam1 < bounds(:,1)) | any(xparam1 > bounds(:,2))
|
||||
0078 find(xparam1 < bounds(:,1))
|
||||
0079 find(xparam1 > bounds(:,2))
|
||||
0080 error(<span class="string">'Initial parameter values are outside parameter bounds'</span>)
|
||||
0081 <span class="keyword">end</span>
|
||||
0082 lb = bounds(:,1);
|
||||
0083 ub = bounds(:,2);
|
||||
0084 bayestopt_.lb = lb;
|
||||
0085 bayestopt_.ub = ub;
|
||||
0086
|
||||
0087 <span class="keyword">if</span> ~isfield(options_,<span class="string">'trend_coeffs'</span>)
|
||||
0088 bayestopt_.with_trend = 0;
|
||||
0089 <span class="keyword">else</span>
|
||||
0090 bayestopt_.with_trend = 1;
|
||||
0091 bayestopt_.trend_coeff = {};
|
||||
0092 trend_coeffs = options_.trend_coeffs;
|
||||
0093 nt = length(trend_coeffs);
|
||||
0094 <span class="keyword">for</span> i=1:n_varobs
|
||||
0095 <span class="keyword">if</span> i > length(trend_coeffs)
|
||||
0096 bayestopt_.trend_coeff{i} = <span class="string">'0'</span>;
|
||||
0097 <span class="keyword">else</span>
|
||||
0098 bayestopt_.trend_coeff{i} = trend_coeffs{i};
|
||||
0099 <span class="keyword">end</span>
|
||||
0100 <span class="keyword">end</span>
|
||||
0101 <span class="keyword">end</span>
|
||||
0102
|
||||
0103 bayestopt_.penalty = 1e8; <span class="comment">% penalty</span>
|
||||
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 <span class="comment">%% Static solver</span>
|
||||
0113 <span class="keyword">if</span> exist([M_.fname <span class="string">'_steadystate'</span>])
|
||||
0114 bayestopt_.static_solve = [M_.fname <span class="string">'_steadystate'</span>];
|
||||
0115 <span class="keyword">else</span>
|
||||
0116 bayestopt_.static_solve = <span class="string">'dynare_solve'</span>;
|
||||
0117 <span class="keyword">end</span>
|
||||
0118
|
||||
0119 dr = <a href="set_state_space.html" class="code" title="function dr=set_state_space(dr)">set_state_space</a>([]);
|
||||
0120
|
||||
0121 <span class="comment">%% Initialization with unit-root variables</span>
|
||||
0122 <span class="keyword">if</span> ~isempty(options_.unit_root_vars)
|
||||
0123 n_ur = size(options_.unit_root_vars,1);
|
||||
0124 i_ur = zeros(n_ur,1);
|
||||
0125 <span class="keyword">for</span> i=1:n_ur
|
||||
0126 i1 = strmatch(deblank(options_.unit_root_vars(i,:)),M_.endo_names(dr.order_var,:),<span class="string">'exact'</span>);
|
||||
0127 <span class="keyword">if</span> isempty(i1)
|
||||
0128 error(<span class="string">'Undeclared variable in unit_root_vars statement'</span>)
|
||||
0129 <span class="keyword">end</span>
|
||||
0130 i_ur(i) = i1;
|
||||
0131 <span class="keyword">end</span>
|
||||
0132 <span class="keyword">if</span> 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 <span class="keyword">else</span>
|
||||
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 <span class="keyword">end</span>
|
||||
0158 options_.lik_init = 3;
|
||||
0159 <span class="keyword">end</span> <span class="comment">% if ~isempty(options_.unit_root_vars)</span>
|
||||
0160
|
||||
0161 <span class="keyword">if</span> isempty(options_.datafile)
|
||||
0162 error(<span class="string">'ESTIMATION: datafile option is missing'</span>)
|
||||
0163 <span class="keyword">end</span>
|
||||
0164
|
||||
0165 <span class="keyword">if</span> isempty(options_.varobs)
|
||||
0166 error(<span class="string">'ESTIMATION: VAROBS is missing'</span>)
|
||||
0167 <span class="keyword">end</span>
|
||||
0168
|
||||
0169
|
||||
0170 <span class="comment">%% If jscale isn't specified for an estimated parameter, use</span>
|
||||
0171 <span class="comment">%% global option options_.jscale, set to 0.2, by default</span>
|
||||
0172 k = find(isnan(bayestopt_.jscale));
|
||||
0173 bayestopt_.jscale(k) = options_.mh_jscale;
|
||||
0174
|
||||
0175 <span class="comment">%% Read and demean data</span>
|
||||
0176 rawdata = <a href="read_variables.html" class="code" title="function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sheet,xls_range)">read_variables</a>(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
|
||||
0177
|
||||
0178 k = [];
|
||||
0179 k1 = [];
|
||||
0180 <span class="keyword">for</span> i=1:n_varobs
|
||||
0181 k = [k strmatch(deblank(options_.varobs(i,:)),M_.endo_names(dr.order_var,:), <span class="keyword">...</span>
|
||||
0182 <span class="string">'exact'</span>)];
|
||||
0183 k1 = [k1 strmatch(deblank(options_.varobs(i,:)),M_.endo_names, <span class="string">'exact'</span>)];
|
||||
0184 <span class="keyword">end</span>
|
||||
0185
|
||||
0186 bayestopt_.mf = k;
|
||||
0187 bayestopt_.mfys = k1;
|
||||
0188 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'nobs'</span>,size(rawdata,1)-options_.first_obs+1);
|
||||
0189 gend = options_.nobs;
|
||||
0190
|
||||
0191 rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
|
||||
0192 <span class="keyword">if</span> options_.loglinear == 1
|
||||
0193 rawdata = log(rawdata);
|
||||
0194 <span class="keyword">end</span>
|
||||
0195 <span class="keyword">if</span> options_.prefilter == 1
|
||||
0196 bayestopt_.mean_varobs = mean(rawdata,1);
|
||||
0197 data = transpose(rawdata-ones(gend,1)*bayestopt_.mean_varobs);
|
||||
0198 <span class="keyword">else</span>
|
||||
0199 data = transpose(rawdata);
|
||||
0200 <span class="keyword">end</span>
|
||||
0201
|
||||
0202 <span class="keyword">if</span> ~isreal(rawdata)
|
||||
0203 error([<span class="string">'There are complex values in the data. Probably a wrong'</span> <span class="keyword">...</span>
|
||||
0204 <span class="string">' transformation'</span>])
|
||||
0205 <span class="keyword">end</span>
|
||||
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_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'opt_gsa'</span>,1);
|
||||
0217 options_gsa_ = options_.opt_gsa;
|
||||
0218
|
||||
0219 <span class="keyword">if</span> options_gsa_.pprior,
|
||||
0220 load([fname_,<span class="string">'_prior'</span>])
|
||||
0221 namfile=[fname_,<span class="string">'_prior'</span>];
|
||||
0222 <span class="keyword">else</span>
|
||||
0223 load([fname_,<span class="string">'_mc'</span>])
|
||||
0224 namfile=[fname_,<span class="string">'_mc'</span>];
|
||||
0225 <span class="keyword">end</span>
|
||||
0226 load(options_.mode_file)
|
||||
0227 <span class="comment">%%</span>
|
||||
0228 <span class="comment">%%</span>
|
||||
0229 <span class="comment">%%</span>
|
||||
0230 x=[lpmat0(istable,:) lpmat(istable,:)];
|
||||
0231 clear lpmat lpmat0 istable iunstable egg yys T
|
||||
0232 B = size(x,1);
|
||||
0233 <span class="keyword">if</span> 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 <span class="keyword">else</span>
|
||||
0237 n1 = M_.endo_nbr;
|
||||
0238 <span class="keyword">end</span>
|
||||
0239 stock_smooth = zeros(gend,n1,B);
|
||||
0240 stock_filter = zeros(gend+1,n1,B);
|
||||
0241 stock_ys = zeros(M_.endo_nbr,B);
|
||||
0242 <span class="comment">%%</span>
|
||||
0243 h = waitbar(0,<span class="string">'MC smoother ...'</span>);
|
||||
0244 <span class="keyword">for</span> b=1:B
|
||||
0245 deep = x(b,:);
|
||||
0246 <span class="comment">%deep(1:offset) = xparam1(1:offset);</span>
|
||||
0247 logpo2(b) = <a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a>(deep',gend,data);
|
||||
0248 [atT,innov,measurement_error,filtered_state_vector,ys,trend_coeff] = <a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a>(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,[<span class="string">'MC smoother ...'</span>,num2str(b),<span class="string">'/'</span>,num2str(B)]);
|
||||
0253 <span class="keyword">end</span>
|
||||
0254 close(h)
|
||||
0255
|
||||
0256 save(namfile,<span class="string">'x'</span>,<span class="string">'logpo2'</span>,<span class="string">'stock_smooth'</span>,<span class="string">'stock_filter'</span>,<span class="string">'stock_ys'</span>,<span class="string">'-append'</span>)</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,60 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynare_resolve</title>
|
||||
<meta name="keywords" content="dynare_resolve">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynare_resolve.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynare_resolve
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [A,B,ys,info] = dynare_resolve() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="kalman_transition_matrix.html" class="code" title="function [A,B] = kalman_transition_matrix(dr)">kalman_transition_matrix</a> makes transition matrices out of ghx and ghu for Kalman filter</li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="DsgeLikelihood.html" class="code" title="function [fval,cost_flag,ys,trend_coeff,info] = DsgeLikelihood(xparam1,gend,data)">DsgeLikelihood</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li><li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [A,B,ys,info] = dynare_resolve()</a>
|
||||
0002 <span class="keyword">global</span> oo_
|
||||
0003
|
||||
0004 [oo_.dr,info] = <a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a>(oo_.steady_state,0);
|
||||
0005
|
||||
0006 <span class="keyword">if</span> info(1) > 0
|
||||
0007 A = [];
|
||||
0008 B = [];
|
||||
0009 ys = [];
|
||||
0010 <span class="keyword">return</span>
|
||||
0011 <span class="keyword">end</span>
|
||||
0012
|
||||
0013 [A,B] = <a href="kalman_transition_matrix.html" class="code" title="function [A,B] = kalman_transition_matrix(dr)">kalman_transition_matrix</a>(oo_.dr);
|
||||
0014 ys = oo_.dr.ys;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,241 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynare_sensitivity</title>
|
||||
<meta name="keywords" content="dynare_sensitivity">
|
||||
<meta name="description" content="copyright Marco Ratto 2006">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynare_sensitivity.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynare_sensitivity
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>copyright Marco Ratto 2006</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function x0=dynare_sensitivity() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> copyright Marco Ratto 2006</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="dynare_MC.html" class="code" title="function dynare_MC(var_list_)">dynare_MC</a> </li><li><a href="filt_mc_.html" class="code" title="function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)">filt_mc_</a> copyright Marco Ratto 2006</li><li><a href="read_variables.html" class="code" title="function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sheet,xls_range)">read_variables</a> Copyright (C) 2005 Michel Juillard</li><li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li><li><a href="stab_map_.html" class="code" title="function x0 = stab_map_(Nsam, fload, ksstat, alpha2, prepSA, pprior, ilptau, OutputDirectoryName)">stab_map_</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function x0=dynare_sensitivity()</a>
|
||||
0002 <span class="comment">% copyright Marco Ratto 2006</span>
|
||||
0003
|
||||
0004 <span class="keyword">global</span> M_ options_ oo_ bayestopt_
|
||||
0005
|
||||
0006 fname_ = M_.fname;
|
||||
0007 lgy_ = M_.endo_names;
|
||||
0008 x0=[];
|
||||
0009
|
||||
0010 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'opt_gsa'</span>,1);
|
||||
0011 options_gsa_ = options_.opt_gsa;
|
||||
0012
|
||||
0013 <span class="comment">% map stability</span>
|
||||
0014 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'stab'</span>,1);
|
||||
0015 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'redform'</span>,0);
|
||||
0016 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'pprior'</span>,1);
|
||||
0017 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'ppost'</span>,0);
|
||||
0018 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'ilptau'</span>,1);
|
||||
0019 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'Nsam'</span>,2048);
|
||||
0020 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'load_stab'</span>,0);
|
||||
0021 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'alpha2_stab'</span>,0.3);
|
||||
0022 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'ksstat'</span>,0.1);
|
||||
0023 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'load_mh'</span>,0);
|
||||
0024
|
||||
0025 OutputDirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'GSA'</span>);
|
||||
0026
|
||||
0027
|
||||
0028 <span class="keyword">if</span> options_gsa_.stab & ~options_gsa_.load_mh,
|
||||
0029 x0 = <a href="stab_map_.html" class="code" title="function x0 = stab_map_(Nsam, fload, ksstat, alpha2, prepSA, pprior, ilptau, OutputDirectoryName)">stab_map_</a>(options_gsa_.Nsam, options_gsa_.load_stab, options_gsa_.ksstat, options_gsa_.alpha2_stab, <span class="keyword">...</span>
|
||||
0030 options_gsa_.redform, options_gsa_.pprior, options_gsa_.ilptau, OutputDirectoryName);
|
||||
0031 <span class="keyword">end</span>
|
||||
0032
|
||||
0033 <span class="comment">% reduced form</span>
|
||||
0034 <span class="comment">% redform_map(namendo, namlagendo, namexo, icomp, pprior, ilog, threshold)</span>
|
||||
0035 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'load_redform'</span>,0);
|
||||
0036 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'logtrans_redform'</span>,0);
|
||||
0037 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'threshold_redform'</span>,[]);
|
||||
0038 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'ksstat_redform'</span>,0.1);
|
||||
0039 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'alpha2_redform'</span>,0.3);
|
||||
0040 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'namendo'</span>,[]);
|
||||
0041 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'namlagendo'</span>,[]);
|
||||
0042 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'namexo'</span>,[]);
|
||||
0043
|
||||
0044 <span class="keyword">if</span> options_gsa_.redform & ~isempty(options_gsa_.namendo) & ~options_gsa_.load_mh,
|
||||
0045 redform_map(options_gsa_.namendo, options_gsa_.namlagendo, options_gsa_.namexo, <span class="keyword">...</span>
|
||||
0046 options_gsa_.load_redform, options_gsa_.pprior, options_gsa_.logtrans_redform, <span class="keyword">...</span>
|
||||
0047 options_gsa_.threshold_redform, options_gsa_.ksstat_redform, <span class="keyword">...</span>
|
||||
0048 options_gsa_.alpha2_redform, OutputDirectoryName);
|
||||
0049 <span class="keyword">end</span>
|
||||
0050 <span class="comment">% RMSE mapping</span>
|
||||
0051 <span class="comment">% function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2)</span>
|
||||
0052 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'rmse'</span>,0);
|
||||
0053 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'var_rmse'</span>,options_.varobs);
|
||||
0054 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'load_rmse'</span>,0);
|
||||
0055 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'pfilt_rmse'</span>,0.1);
|
||||
0056 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'istart_rmse'</span>,1);
|
||||
0057 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'alpha_rmse'</span>,0.002);
|
||||
0058 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'alpha2_rmse'</span>,0.5);
|
||||
0059 options_.opt_gsa = options_gsa_;
|
||||
0060 <span class="keyword">if</span> options_gsa_.rmse,
|
||||
0061 <span class="keyword">if</span> options_gsa_.pprior
|
||||
0062 a=load([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_prior'</span>]);
|
||||
0063 <span class="keyword">else</span>
|
||||
0064 a=load([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_mc'</span>]);
|
||||
0065 <span class="keyword">end</span>
|
||||
0066 <span class="keyword">if</span> ~isfield(a,<span class="string">'stock_filter'</span>),
|
||||
0067 <a href="dynare_MC.html" class="code" title="function dynare_MC(var_list_)">dynare_MC</a>([],OutputDirectoryName);
|
||||
0068 options_gsa_.load_rmse=0;
|
||||
0069 <span class="keyword">end</span>
|
||||
0070 <a href="filt_mc_.html" class="code" title="function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)">filt_mc_</a>(options_gsa_.var_rmse, options_gsa_.load_rmse, options_gsa_.pfilt_rmse, <span class="keyword">...</span>
|
||||
0071 options_gsa_.alpha_rmse, options_gsa_.alpha2_rmse, OutputDirectoryName, <span class="keyword">...</span>
|
||||
0072 options_gsa_.istart_rmse);
|
||||
0073 <span class="keyword">end</span>
|
||||
0074
|
||||
0075
|
||||
0076 options_gsa_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_gsa_,<span class="string">'glue'</span>,0);
|
||||
0077 <span class="keyword">if</span> options_gsa_.glue,
|
||||
0078 dr_ = oo_.dr;
|
||||
0079 <span class="keyword">if</span> options_gsa_.ppost
|
||||
0080 load([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_post'</span>]);
|
||||
0081 DirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0082 <span class="keyword">else</span>
|
||||
0083 <span class="keyword">if</span> options_gsa_.pprior
|
||||
0084 load([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_prior'</span>]);
|
||||
0085 <span class="keyword">else</span>
|
||||
0086 load([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_mc'</span>]);
|
||||
0087 <span class="keyword">end</span>
|
||||
0088 <span class="keyword">end</span>
|
||||
0089 nruns=size(x,1);
|
||||
0090 gend = options_.nobs;
|
||||
0091 rawdata = <a href="read_variables.html" class="code" title="function dyn_data_01=read_variables(file_name_01,var_names_01,dyn_data_01,xls_sheet,xls_range)">read_variables</a>(options_.datafile,options_.varobs,[],options_.xls_sheet,options_.xls_range);
|
||||
0092 rawdata = rawdata(options_.first_obs:options_.first_obs+gend-1,:);
|
||||
0093 <span class="keyword">if</span> options_.loglinear == 1
|
||||
0094 rawdata = log(rawdata);
|
||||
0095 <span class="keyword">end</span>
|
||||
0096 <span class="keyword">if</span> options_.prefilter == 1
|
||||
0097 data = transpose(rawdata-ones(gend,1)*bayestopt_.mean_varobs);
|
||||
0098 <span class="keyword">else</span>
|
||||
0099 data = transpose(rawdata);
|
||||
0100 <span class="keyword">end</span>
|
||||
0101
|
||||
0102 Obs.data = data;
|
||||
0103 Obs.time = [1:gend];
|
||||
0104 Obs.num = gend;
|
||||
0105 <span class="keyword">for</span> 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,:),<span class="string">'exact'</span>);
|
||||
0110 js = strmatch(vj,lgy_,<span class="string">'exact'</span>);
|
||||
0111 <span class="keyword">if</span> ~options_gsa_.ppost
|
||||
0112 y0=zeros(gend+1,nruns);
|
||||
0113 nb = size(stock_filter,3);
|
||||
0114 y0 = squeeze(stock_filter(:,jxj,:)) + <span class="keyword">...</span>
|
||||
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 <span class="keyword">else</span>
|
||||
0119 Out(j).data = jxj;
|
||||
0120 Out(j).time = [pwd,<span class="string">'\'</span>,DirectoryName];
|
||||
0121 <span class="keyword">end</span>
|
||||
0122 Out(j).name = vj;
|
||||
0123 Out(j).ini = <span class="string">'yes'</span>;
|
||||
0124 Lik(j).name = [<span class="string">'rmse_'</span>,vj];
|
||||
0125 Lik(j).ini = <span class="string">'yes'</span>;
|
||||
0126 Lik(j).isam = 1;
|
||||
0127 Lik(j).data = rmse_MC(:,j)';
|
||||
0128
|
||||
0129 <span class="keyword">if</span> ~options_gsa_.ppost
|
||||
0130 y0 = squeeze(stock_smooth(:,jxj,:)) + <span class="keyword">...</span>
|
||||
0131 kron(stock_ys(js,:),ones(size(stock_smooth,1),1));
|
||||
0132 Out1(j).name = vj;
|
||||
0133 Out1(j).ini = <span class="string">'yes'</span>;
|
||||
0134 Out1(j).time = [1:size(y0,1)];
|
||||
0135 Out1(j).data = y0';
|
||||
0136 <span class="keyword">else</span>
|
||||
0137 Out1=Out;
|
||||
0138 <span class="keyword">end</span>
|
||||
0139 ismoo(j)=jxj;
|
||||
0140
|
||||
0141 <span class="keyword">end</span>
|
||||
0142 jsmoo = size(options_.varobs,1);
|
||||
0143 <span class="keyword">for</span> j=1:M_.endo_nbr,
|
||||
0144 <span class="keyword">if</span> ~ismember(j,ismoo),
|
||||
0145 jsmoo=jsmoo+1;
|
||||
0146 vj=deblank(M_.endo_names(dr_.order_var(j),:));
|
||||
0147 <span class="keyword">if</span> ~options_gsa_.ppost
|
||||
0148 y0 = squeeze(stock_smooth(:,j,:)) + <span class="keyword">...</span>
|
||||
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 <span class="keyword">else</span>
|
||||
0153 Out1(jsmoo).data = j;
|
||||
0154 Out1(jsmoo).time = [pwd,<span class="string">'\'</span>,DirectoryName];
|
||||
0155 <span class="keyword">end</span>
|
||||
0156 Out1(jsmoo).name = vj;
|
||||
0157 Out1(jsmoo).ini = <span class="string">'yes'</span>;
|
||||
0158 <span class="keyword">end</span>
|
||||
0159 <span class="keyword">end</span>
|
||||
0160 tit(M_.exo_names_orig_ord,:) = M_.exo_names;
|
||||
0161 <span class="keyword">for</span> j=1:M_.exo_nbr,
|
||||
0162 Exo(j).name = deblank(tit(j,:));
|
||||
0163 <span class="keyword">end</span>
|
||||
0164 <span class="keyword">if</span> ~options_gsa_.ppost
|
||||
0165 Lik(size(options_.varobs,1)+1).name = <span class="string">'logpo'</span>;
|
||||
0166 Lik(size(options_.varobs,1)+1).ini = <span class="string">'yes'</span>;
|
||||
0167 Lik(size(options_.varobs,1)+1).isam = 1;
|
||||
0168 Lik(size(options_.varobs,1)+1).data = -logpo2;
|
||||
0169 <span class="keyword">end</span>
|
||||
0170 Sam.name = bayestopt_.name;
|
||||
0171 Sam.dim = [size(x) 0];
|
||||
0172 Sam.data = [x];
|
||||
0173
|
||||
0174 Rem.id = <span class="string">'Original'</span>;
|
||||
0175 Rem.ind= [1:size(x,1)];
|
||||
0176
|
||||
0177 <span class="keyword">if</span> options_gsa_.ppost
|
||||
0178 Info.dynare=M_.fname;
|
||||
0179 Out=Out1;
|
||||
0180 save([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_post_glue'</span>], <span class="string">'Out'</span>, <span class="string">'Sam'</span>, <span class="string">'Lik'</span>, <span class="string">'Obs'</span>, <span class="string">'Rem'</span>,<span class="string">'Info'</span>, <span class="string">'Exo'</span>)
|
||||
0181 <span class="comment">%save([fname_,'_post_glue_smooth'], 'Out', 'Sam', 'Lik', 'Obs', 'Rem','Info')</span>
|
||||
0182
|
||||
0183 <span class="keyword">else</span>
|
||||
0184 <span class="keyword">if</span> options_gsa_.pprior
|
||||
0185 save([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_prior_glue'</span>], <span class="string">'Out'</span>, <span class="string">'Sam'</span>, <span class="string">'Lik'</span>, <span class="string">'Obs'</span>, <span class="string">'Rem'</span>)
|
||||
0186 Out=Out1;
|
||||
0187 save([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_prior_glue_smooth'</span>], <span class="string">'Out'</span>, <span class="string">'Sam'</span>, <span class="string">'Lik'</span>, <span class="string">'Obs'</span>, <span class="string">'Rem'</span>)
|
||||
0188 <span class="keyword">else</span>
|
||||
0189 save([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_mc_glue'</span>], <span class="string">'Out'</span>, <span class="string">'Sam'</span>, <span class="string">'Lik'</span>, <span class="string">'Obs'</span>, <span class="string">'Rem'</span>)
|
||||
0190 Out=Out1;
|
||||
0191 save([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_mc_glue_smooth'</span>], <span class="string">'Out'</span>, <span class="string">'Sam'</span>, <span class="string">'Lik'</span>, <span class="string">'Obs'</span>, <span class="string">'Rem'</span>)
|
||||
0192 <span class="keyword">end</span>
|
||||
0193 <span class="keyword">end</span>
|
||||
0194
|
||||
0195 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,131 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynare_solve</title>
|
||||
<meta name="keywords" content="dynare_solve">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynare_solve.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynare_solve
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [x,cheik] = dynare_solve(func,x,jacobian_flag,varargin) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a> </li><li><a href="solve1.html" class="code" title="function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)">solve1</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="olr1.html" class="code" title="function dr = olr1(ys,algo,olr_inst,bet,obj_var,W)">olr1</a> Copyright (C) 2001 Michel Juillard</li><li><a href="osr1.html" class="code" title="function oo_.dr=osr1(params,weights)">osr1</a> </li><li><a href="resol.html" class="code" title="function [dr,info]=resol(ys,check_flag)">resol</a> Copyright (C) 2001 Michel Juillard</li><li><a href="resol1.html" class="code" title="function dr=resol1(ys,algo,linear,iorder)">resol1</a> Copyright (C) 2001 Michel Juillard</li><li><a href="simult_.html" class="code" title="function y_=simult_(y0,dr,ex_,iorder)">simult_</a> Copyright (C) 2001 Michel Juillard</li><li><a href="steady_.html" class="code" title="function steady_()">steady_</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function [x,cheik] = dynare_solve(func,x,jacobian_flag,varargin)</a>
|
||||
0004 <span class="keyword">global</span> options_
|
||||
0005
|
||||
0006 options_ = <a href="set_default_option.html" class="code" title="function options=set_default_option(options,field,default)">set_default_option</a>(options_,<span class="string">'solve_algo'</span>,2);
|
||||
0007 cheik = 0;
|
||||
0008 <span class="keyword">if</span> options_.solve_algo == 0
|
||||
0009 <span class="keyword">if</span> ~isempty(which(<span class="string">'fsolve'</span>)) & sscanf(version(<span class="string">'-release'</span>),<span class="string">'%d'</span>) >= 13;
|
||||
0010 options=optimset(<span class="string">'fsolve'</span>);
|
||||
0011 options.MaxFunEvals = 20000;
|
||||
0012 options.TolFun=1e-8;
|
||||
0013 options.Display = <span class="string">'off'</span>;
|
||||
0014 <span class="keyword">if</span> jacobian_flag
|
||||
0015 options.Jacobian = <span class="string">'on'</span>;
|
||||
0016 <span class="keyword">else</span>
|
||||
0017 options.Jacobian = <span class="string">'on'</span>;
|
||||
0018 <span class="keyword">end</span>
|
||||
0019 [x,fval,exitval,output] = fsolve(func,x,options,varargin{:});
|
||||
0020 <span class="keyword">if</span> exitval > 0
|
||||
0021 cheik = 0;
|
||||
0022 <span class="keyword">else</span>
|
||||
0023 cheik = 1;
|
||||
0024 <span class="keyword">end</span>
|
||||
0025 <span class="keyword">return</span>
|
||||
0026 <span class="keyword">else</span>
|
||||
0027 options_.solve_algo = 1;
|
||||
0028 <span class="keyword">end</span>
|
||||
0029 <span class="keyword">end</span>
|
||||
0030
|
||||
0031 <span class="keyword">if</span> options_.solve_algo == 1
|
||||
0032 nn = size(x,1) ;
|
||||
0033 [x,cheik]=<a href="solve1.html" class="code" title="function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)">solve1</a>(func,x,1:nn,1:nn,jacobian_flag,varargin{:});
|
||||
0034 <span class="keyword">elseif</span> options_.solve_algo == 2
|
||||
0035 nn = size(x,1) ;
|
||||
0036 tolf = eps^(2/3) ;
|
||||
0037
|
||||
0038 <span class="keyword">if</span> jacobian_flag
|
||||
0039 [fvec,fjac] = feval(func,x,varargin{:});
|
||||
0040 <span class="keyword">else</span>
|
||||
0041 fvec = feval(func,x,varargin{:});
|
||||
0042 fjac = zeros(nn,nn) ;
|
||||
0043 <span class="keyword">end</span>
|
||||
0044
|
||||
0045 i = find(~isfinite(fvec));
|
||||
0046
|
||||
0047 <span class="keyword">if</span> ~isempty(i)
|
||||
0048 disp([<span class="string">'STEADY: numerical initial values incompatible with the following'</span> <span class="keyword">...</span>
|
||||
0049 <span class="string">' equations'</span>])
|
||||
0050 disp(i')
|
||||
0051 error(<span class="string">'exiting ...'</span>)
|
||||
0052 <span class="keyword">end</span>
|
||||
0053
|
||||
0054 f = 0.5*fvec'*fvec ;
|
||||
0055
|
||||
0056 <span class="keyword">if</span> max(abs(fvec)) < 0.01*tolf
|
||||
0057 <span class="keyword">return</span> ;
|
||||
0058 <span class="keyword">end</span>
|
||||
0059
|
||||
0060 <span class="keyword">if</span> ~jacobian_flag
|
||||
0061 fjac = zeros(nn,nn) ;
|
||||
0062 dh = max(abs(x),options_.gstep*ones(nn,1))*eps^(1/3);
|
||||
0063 <span class="keyword">for</span> j = 1:nn
|
||||
0064 xdh = x ;
|
||||
0065 xdh(j) = xdh(j)+dh(j) ;
|
||||
0066 fjac(:,j) = (feval(func,xdh,varargin{:}) - fvec)./dh(j) ;
|
||||
0067 <span class="keyword">end</span>
|
||||
0068 <span class="keyword">end</span>
|
||||
0069
|
||||
0070 [j1,j2,r,s] = dmperm(fjac);
|
||||
0071
|
||||
0072 <span class="keyword">for</span> i=length(r)-1:-1:1
|
||||
0073 [x,cheik]=<a href="solve1.html" class="code" title="function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)">solve1</a>(func,x,j1(r(i):r(i+1)-1),j2(r(i):r(i+1)-1),jacobian_flag,varargin{:});
|
||||
0074 <span class="keyword">if</span> cheik
|
||||
0075 error(sprintf(<span class="string">'Solve block = %d check = %d\n'</span>,i,cheik));
|
||||
0076 <span class="keyword">end</span>
|
||||
0077 <span class="keyword">end</span>
|
||||
0078 [x,cheik]=<a href="solve1.html" class="code" title="function [x,check] = solve1(func,x,j1,j2,jacobian_flag,varargin)">solve1</a>(func,x,1:nn,1:nn,jacobian_flag,varargin{:});
|
||||
0079
|
||||
0080 <span class="keyword">end</span>
|
||||
0081 <span class="comment">% fvec1 = feval(func,x,varargin{:})</span>
|
||||
0082
|
||||
0083 <span class="comment">% 08/28/03 MJ add a final call to solve1 for solve_algo == 1 in case</span>
|
||||
0084 <span class="comment">% initvals generates 'false' zeros in the Jacobian</span>
|
||||
0085</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,87 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynasave</title>
|
||||
<meta name="keywords" content="dynasave">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynasave.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynasave
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dynasave(s,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
DYNASAVE : DYNASAVE ( [ 'filename' ] )
|
||||
This optional command saves the simulation results
|
||||
in a .MAT file.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function dynasave(s,var_list)</a>
|
||||
0004 <span class="comment">% DYNASAVE : DYNASAVE ( [ 'filename' ] )</span>
|
||||
0005 <span class="comment">% This optional command saves the simulation results</span>
|
||||
0006 <span class="comment">% in a .MAT file.</span>
|
||||
0007
|
||||
0008 <span class="keyword">global</span> M_ oo_
|
||||
0009
|
||||
0010 n = size(var_list,1);
|
||||
0011 <span class="keyword">if</span> n == 0
|
||||
0012 n = M_.endo_nbr;
|
||||
0013 ivar = [1:n]';
|
||||
0014 var_list = M_.endo_names;
|
||||
0015 <span class="keyword">else</span>
|
||||
0016 ivar=zeros(n,1);
|
||||
0017 <span class="keyword">for</span> i=1:n
|
||||
0018 i_tmp = strmatch(var_list(i,:),M_.endo_names,<span class="string">'exact'</span>);
|
||||
0019 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0020 error ([<span class="string">'One of the specified variables does not exist'</span>]) ;
|
||||
0021 <span class="keyword">else</span>
|
||||
0022 ivar(i) = i_tmp;
|
||||
0023 <span class="keyword">end</span>
|
||||
0024 <span class="keyword">end</span>
|
||||
0025 <span class="keyword">end</span>
|
||||
0026
|
||||
0027
|
||||
0028 <span class="comment">% dyn2vec(var_list(1),var_list(1));</span>
|
||||
0029 eval([var_list(1) <span class="string">'=oo_.y_simul(ivar(1),:)'';'</span>])
|
||||
0030 eval([<span class="string">'save '</span> s <span class="string">' '</span> var_list(1) <span class="string">' -mat'</span>])
|
||||
0031 <span class="keyword">for</span> i = 2:n
|
||||
0032 <span class="comment">% dyn2vec(var_list(i),var_list(i));</span>
|
||||
0033 eval([var_list(i) <span class="string">'=oo_.y_simul(ivar(i),:)'';'</span>])
|
||||
0034 eval([<span class="string">'save '</span> s <span class="string">' '</span> var_list(i) <span class="string">' -append -mat'</span>])
|
||||
0035 <span class="keyword">end</span>
|
||||
0036
|
||||
0037</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,91 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of dynatype</title>
|
||||
<meta name="keywords" content="dynatype">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > dynatype.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>dynatype
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function dynatype (s,var_list) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
DYNATYPE : DYNATYPE ( [ 'filename' ] )
|
||||
This optional command saves the simulation
|
||||
results in a text file. The name of each
|
||||
variable preceeds the corresponding results.
|
||||
This command must follow SIMUL.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function dynatype (s,var_list)</a>
|
||||
0004 <span class="comment">% DYNATYPE : DYNATYPE ( [ 'filename' ] )</span>
|
||||
0005 <span class="comment">% This optional command saves the simulation</span>
|
||||
0006 <span class="comment">% results in a text file. The name of each</span>
|
||||
0007 <span class="comment">% variable preceeds the corresponding results.</span>
|
||||
0008 <span class="comment">% This command must follow SIMUL.</span>
|
||||
0009
|
||||
0010 <span class="keyword">global</span> M_ oo_
|
||||
0011
|
||||
0012 fid=fopen(s,<span class="string">'w'</span>) ;
|
||||
0013
|
||||
0014 n = size(var_list,1);
|
||||
0015 <span class="keyword">if</span> n == 0
|
||||
0016 n = M_.endo_nbr;
|
||||
0017 ivar = [1:n]';
|
||||
0018 var_list = M_.endo_names;
|
||||
0019 <span class="keyword">else</span>
|
||||
0020 ivar=zeros(n,1);
|
||||
0021 <span class="keyword">for</span> i=1:n
|
||||
0022 i_tmp = strmatch(var_list(i,:),M_.endo_names,<span class="string">'exact'</span>);
|
||||
0023 <span class="keyword">if</span> isempty(i_tmp)
|
||||
0024 error ([<span class="string">'One of the specified variables does not exist'</span>]) ;
|
||||
0025 <span class="keyword">else</span>
|
||||
0026 ivar(i) = i_tmp;
|
||||
0027 <span class="keyword">end</span>
|
||||
0028 <span class="keyword">end</span>
|
||||
0029 <span class="keyword">end</span>
|
||||
0030
|
||||
0031
|
||||
0032 <span class="keyword">for</span> i = 1:n
|
||||
0033 fprintf(fid,M_.endo_names(ivar(i),:),<span class="string">'\n'</span>) ;
|
||||
0034 fprintf(fid,<span class="string">'\n'</span>) ;
|
||||
0035 fprintf(fid,<span class="string">'%15.8g\n'</span>,oo_.y_simul(ivar(i),:)') ;
|
||||
0036 <span class="keyword">end</span>
|
||||
0037 fclose(fid) ;
|
||||
0038
|
||||
0039 <span class="keyword">return</span> ;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,50 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of f_var</title>
|
||||
<meta name="keywords" content="f_var">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > f_var.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>f_var
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function b=f_var(x,a,nx) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="calib_obj.html" class="code" title="function f=calib_obj(M_.Sigma_e,A,ghu1,ghx,ghu,targets,var_weights,iy,nar)">calib_obj</a> targets and iy order: 1) variances 2) correlations</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function b=f_var(x,a,nx)</a>
|
||||
0002 x=reshape(x,nx,nx);
|
||||
0003 b=x-a*x*a';
|
||||
0004 b=b(:);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,52 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of fbeta</title>
|
||||
<meta name="keywords" content="fbeta">
|
||||
<meta name="description" content="must restrict p2 such that a>0 and b>0 ....">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > fbeta.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>fbeta
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>must restrict p2 such that a>0 and b>0 ....</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function e = fbeta(p2,p,p1,perc) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> must restrict p2 such that a>0 and b>0 ....</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="p2toperc.html" class="code" title="function y=p2toperc(x)">p2toperc</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function e = fbeta(p2,p,p1,perc)</a>
|
||||
0002 <span class="comment">% must restrict p2 such that a>0 and b>0 ....</span>
|
||||
0003 a = (1-p1)*p1^2/p2^2 - p1;
|
||||
0004 b = a*(1/p1 - 1);
|
||||
0005
|
||||
0006 e = p - pbeta(perc,a,b);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,58 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of ff1_</title>
|
||||
<meta name="keywords" content="ff1_">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > ff1_.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>ff1_
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function y=ff1_(x) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function y=ff1_(x)</a>
|
||||
0004 <span class="keyword">global</span> 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 <span class="string">'_static'</span>]);
|
||||
0009 y=feval(fh,x(1:n1),oo_.exo_simul);
|
||||
0010
|
||||
0011
|
||||
0012</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,70 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of ffill</title>
|
||||
<meta name="keywords" content="ffill">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > ffill.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>ffill
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [a,b] = ffill(x,ixc,y) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="simk.html" class="code" title="function simk">simk</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function [a,b] = ffill(x,ixc,y)</a>
|
||||
0004
|
||||
0005 xc = size(x,1) ;
|
||||
0006
|
||||
0007 <span class="keyword">if</span> isempty(y)
|
||||
0008 b = [ixc; 0];
|
||||
0009 a = [x zeros(size(x,1),1)];
|
||||
0010 <span class="keyword">else</span>
|
||||
0011 yc = size(y,1) ;
|
||||
0012 b = [ixc;yc] ;
|
||||
0013
|
||||
0014 <span class="keyword">if</span> xc > yc
|
||||
0015 a = [x [y;zeros(xc-yc,size(y,2))]] ;
|
||||
0016 <span class="keyword">elseif</span> yc > xc
|
||||
0017 a = [[x;zeros(yc-xc,size(x,2))] y] ;
|
||||
0018 <span class="keyword">else</span>
|
||||
0019 a = [x y] ;
|
||||
0020 <span class="keyword">end</span>
|
||||
0021
|
||||
0022 <span class="keyword">end</span>
|
||||
0023
|
||||
0024 <span class="comment">% 2001/09/1 MJ corrected for absent lags</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,50 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of fgamma</title>
|
||||
<meta name="keywords" content="fgamma">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > fgamma.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>fgamma
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function e = fgamma(p2,p,p1,perc) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="pgamma.html" class="code" title="function F = pgamma(x,a)">pgamma</a> PGAMMA The gamma distribution function</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="p2toperc.html" class="code" title="function y=p2toperc(x)">p2toperc</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function e = fgamma(p2,p,p1,perc)</a>
|
||||
0002 b = p2^2/p1;
|
||||
0003 a = p1/b;
|
||||
0004 e = p - <a href="pgamma.html" class="code" title="function F = pgamma(x,a)">pgamma</a>(perc,a,b);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of figamm</title>
|
||||
<meta name="keywords" content="figamm">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > figamm.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>figamm
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function e = figamm(p2,p,p1,perc) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="pgamma.html" class="code" title="function F = pgamma(x,a)">pgamma</a> PGAMMA The gamma distribution function</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="p2toperc.html" class="code" title="function y=p2toperc(x)">p2toperc</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function e = figamm(p2,p,p1,perc)</a>
|
||||
0002 e = p - <a href="pgamma.html" class="code" title="function F = pgamma(x,a)">pgamma</a>(1/perc,p2/2,2/p1);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,647 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of filt_mc_</title>
|
||||
<meta name="keywords" content="filt_mc_">
|
||||
<meta name="description" content="copyright Marco Ratto 2006">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > filt_mc_.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>filt_mc_
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>copyright Marco Ratto 2006</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> copyright Marco Ratto 2006</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a> 06-03-2005</li><li><a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a> stephane.adjemian@cepremap.cnrs.fr [09-07-2004]</li><li><a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a> function h =cumplot(x)</li><li><a href="kernel_density_estimate.html" class="code" title="function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">kernel_density_estimate</a> % This function aims at estimating a continuous density. A kernel density</li><li><a href="mh_optimal_bandwidth.html" class="code" title="function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)">mh_optimal_bandwidth</a> % This function gives the optimal bandwidth parameter of a kernel estimator</li><li><a href="priordens.html" class="code" title="function lnprior = priordens(para, pshape, p1, p2, p3, p4)">priordens</a> This procedure computes a prior density for</li><li><a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a> </li><li><a href="smirnov.html" class="code" title="function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )">smirnov</a> Smirnov test for 2 distributions</li><li><a href="stab_map_2.html" class="code" title="function stab_map_2(x,alpha2,fnam, dirname)">stab_map_2</a> function stab_map_2(x,alpha2,istab,fnam)</li><li><a href="steady_.html" class="code" title="function steady_()">steady_</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_sensitivity.html" class="code" title="function x0=dynare_sensitivity()">dynare_sensitivity</a> copyright Marco Ratto 2006</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [rmse_MC, ixx] = filt_mc_(vvarvecm, loadSA, pfilt, alpha, alpha2, OutDir, istart, alphaPC)</a>
|
||||
0002 <span class="comment">% copyright Marco Ratto 2006</span>
|
||||
0003 <span class="keyword">global</span> bayestopt_ estim_params_ M_ options_ oo_
|
||||
0004
|
||||
0005 <span class="keyword">if</span> nargin<1 | isempty(vvarvecm),
|
||||
0006 vvarvecm = options_.varobs;
|
||||
0007 <span class="keyword">end</span>
|
||||
0008 <span class="keyword">if</span> nargin<2,
|
||||
0009 loadSA=0;
|
||||
0010 <span class="keyword">end</span>
|
||||
0011 <span class="keyword">if</span> nargin<3 | isempty(pfilt),
|
||||
0012 pfilt=0.1; <span class="comment">% cut the best 10% of runs</span>
|
||||
0013 <span class="keyword">end</span>
|
||||
0014 <span class="keyword">if</span> nargin<4 | isempty(alpha),
|
||||
0015 alpha=0.002;
|
||||
0016 <span class="keyword">end</span>
|
||||
0017 <span class="keyword">if</span> nargin<5 | isempty(alpha2),
|
||||
0018 alpha2=0.5;
|
||||
0019 <span class="keyword">end</span>
|
||||
0020 <span class="keyword">if</span> nargin<7 | isempty(istart),
|
||||
0021 istart=1;
|
||||
0022 <span class="keyword">end</span>
|
||||
0023 <span class="keyword">if</span> nargin<8,
|
||||
0024 alphaPC=0.5;
|
||||
0025 <span class="keyword">end</span>
|
||||
0026
|
||||
0027 fname_ = M_.fname;
|
||||
0028 lgy_ = M_.endo_names;
|
||||
0029 dr_ = oo_.dr;
|
||||
0030
|
||||
0031 disp(<span class="string">' '</span>)
|
||||
0032 disp(<span class="string">' '</span>)
|
||||
0033 disp(<span class="string">'Starting sensitivity analysis'</span>)
|
||||
0034 disp(<span class="string">'for the fit of EACH observed series ...'</span>)
|
||||
0035 disp(<span class="string">' '</span>)
|
||||
0036 disp(<span class="string">'Deleting old SA figures...'</span>)
|
||||
0037 a=dir([OutDir,<span class="string">'\*.*'</span>]);
|
||||
0038 <span class="keyword">if</span> options_.opt_gsa.ppost,
|
||||
0039 tmp=[<span class="string">'_SA_fit_post'</span>];
|
||||
0040 <span class="keyword">else</span>
|
||||
0041 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0042 tmp=[<span class="string">'_SA_fit_prior'</span>];
|
||||
0043 <span class="keyword">else</span>
|
||||
0044 tmp=[<span class="string">'_SA_fit_mc'</span>];
|
||||
0045 <span class="keyword">end</span>
|
||||
0046 <span class="keyword">end</span>
|
||||
0047 <span class="keyword">for</span> j=1:length(a),
|
||||
0048 <span class="keyword">if</span> strmatch([fname_,tmp],a(j).name),
|
||||
0049 disp(a(j).name)
|
||||
0050 delete([OutDir,<span class="string">'\'</span>,a(j).name])
|
||||
0051 <span class="keyword">end</span>,
|
||||
0052 <span class="keyword">end</span>
|
||||
0053 disp(<span class="string">'done !'</span>)
|
||||
0054
|
||||
0055
|
||||
0056 nshock=estim_params_.nvx + estim_params_.nvn + estim_params_.ncx + estim_params_.ncn;
|
||||
0057 npar=estim_params_.np;
|
||||
0058 <span class="keyword">for</span> j=1:npar+nshock,
|
||||
0059 <span class="keyword">if</span> j>nshock
|
||||
0060 <span class="keyword">if</span> isfield(oo_,<span class="string">'posterior_mode'</span>),
|
||||
0061 xparam1(j)=oo_.posterior_mode.parameters.(bayestopt_.name{j});
|
||||
0062 <span class="keyword">end</span>
|
||||
0063 <span class="keyword">if</span> isfield(oo_,<span class="string">'posterior_mean'</span>),
|
||||
0064 xparam1_mean(j)=oo_.posterior_mean.parameters.(bayestopt_.name{j});
|
||||
0065 <span class="keyword">end</span>
|
||||
0066 <span class="keyword">else</span>
|
||||
0067 <span class="keyword">if</span> isfield(oo_,<span class="string">'posterior_mode'</span>),
|
||||
0068 xparam1(j)=oo_.posterior_mode.shocks_std.(bayestopt_.name{j});
|
||||
0069 <span class="keyword">end</span>
|
||||
0070 <span class="keyword">if</span> isfield(oo_,<span class="string">'posterior_mean'</span>),
|
||||
0071 xparam1_mean(j)=oo_.posterior_mean.shocks_std.(bayestopt_.name{j});
|
||||
0072 <span class="keyword">end</span>
|
||||
0073 <span class="keyword">end</span>
|
||||
0074 <span class="keyword">end</span>
|
||||
0075
|
||||
0076 <span class="keyword">if</span> options_.opt_gsa.ppost,
|
||||
0077 fnamtmp=[fname_,<span class="string">'_post'</span>];
|
||||
0078 DirectoryName = <a href="CheckPath.html" class="code" title="function DirectoryName = CheckPath(type)">CheckPath</a>(<span class="string">'metropolis'</span>);
|
||||
0079 <span class="keyword">else</span>
|
||||
0080 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0081 fnamtmp=[fname_,<span class="string">'_prior'</span>];
|
||||
0082 <span class="keyword">else</span>
|
||||
0083 fnamtmp=[fname_,<span class="string">'_mc'</span>];
|
||||
0084 <span class="keyword">end</span>
|
||||
0085 <span class="keyword">end</span>
|
||||
0086 <span class="keyword">if</span> ~loadSA,
|
||||
0087 <span class="keyword">if</span> exist(<span class="string">'xparam1'</span>,<span class="string">'var'</span>)
|
||||
0088 <a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a>(xparam1);
|
||||
0089 <a href="steady_.html" class="code" title="function steady_()">steady_</a>;
|
||||
0090 ys_mode=oo_.steady_state;
|
||||
0091 <span class="keyword">end</span>
|
||||
0092 <span class="keyword">if</span> exist(<span class="string">'xparam1_mean'</span>,<span class="string">'var'</span>)
|
||||
0093 <a href="set_all_parameters.html" class="code" title="function set_all_parameters(xparam1)">set_all_parameters</a>(xparam1_mean);
|
||||
0094 <a href="steady_.html" class="code" title="function steady_()">steady_</a>;
|
||||
0095 ys_mean=oo_.steady_state;
|
||||
0096 <span class="keyword">end</span>
|
||||
0097 eval(options_.datafile)
|
||||
0098 <span class="keyword">if</span> ~options_.opt_gsa.ppost
|
||||
0099 load([OutDir,<span class="string">'\'</span>,fnamtmp]);
|
||||
0100 <span class="keyword">else</span>
|
||||
0101 load([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_data.mat'</span>]);
|
||||
0102 filfilt = dir([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_filter*.mat'</span>]);
|
||||
0103 filparam = dir([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_param*.mat'</span>]);
|
||||
0104 x=[];
|
||||
0105 logpo2=[];
|
||||
0106 sto_ys=[];
|
||||
0107 <span class="keyword">for</span> j=1:length(filparam),
|
||||
0108 <span class="comment">%load([DirectoryName '/' M_.fname '_param',int2str(j),'.mat']);</span>
|
||||
0109 <span class="keyword">if</span> isempty(strmatch([M_.fname <span class="string">'_param_irf'</span>],filparam(j).name))
|
||||
0110 load([DirectoryName <span class="string">'/'</span> 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 <span class="keyword">end</span>
|
||||
0116 <span class="keyword">end</span>
|
||||
0117 logpo2=-logpo2;
|
||||
0118 <span class="keyword">end</span>
|
||||
0119 nruns=size(x,1);
|
||||
0120 nfilt=floor(pfilt*nruns);
|
||||
0121 disp(<span class="string">' '</span>)
|
||||
0122 disp(<span class="string">'Computing RMSE''s...'</span>)
|
||||
0123 fobs = options_.first_obs;
|
||||
0124 nobs=options_.nobs;
|
||||
0125 <span class="keyword">for</span> i=1:size(vvarvecm,1),
|
||||
0126 vj=deblank(vvarvecm(i,:));
|
||||
0127 <span class="keyword">if</span> options_.prefilter == 1
|
||||
0128 eval([vj,<span class="string">'='</span>,vj,<span class="string">'-bayestopt_.mean_varobs(i);'</span>])
|
||||
0129 <span class="keyword">end</span>
|
||||
0130
|
||||
0131 jxj = strmatch(vj,lgy_(dr_.order_var,:),<span class="string">'exact'</span>);
|
||||
0132 js = strmatch(vj,lgy_,<span class="string">'exact'</span>);
|
||||
0133 <span class="keyword">if</span> exist(<span class="string">'xparam1'</span>,<span class="string">'var'</span>)
|
||||
0134 eval([<span class="string">'rmse_mode(i) = sqrt(mean(('</span>,vj,<span class="string">'(fobs-1+istart:fobs-1+nobs)-oo_.steady_state(js)-oo_.FilteredVariables.'</span>,vj,<span class="string">'(istart:end-1)).^2));'</span>])
|
||||
0135 <span class="keyword">end</span>
|
||||
0136 y0=zeros(nobs+1,nruns);
|
||||
0137 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0138 nbb=0;
|
||||
0139 <span class="keyword">for</span> j=1:length(filfilt),
|
||||
0140 load([DirectoryName <span class="string">'/'</span> M_.fname <span class="string">'_filter'</span>,num2str(j),<span class="string">'.mat'</span>]);
|
||||
0141 nb = size(stock,4);
|
||||
0142 y0(:,nbb+1:nbb+nb)=squeeze(stock(1,jxj,:,:)); + <span class="keyword">...</span>
|
||||
0143 kron(sto_ys(nbb+1:nbb+nb,js)',ones(size(stock,3),1));
|
||||
0144 <span class="comment">%y0(:,:,size(y0,3):size(y0,3)+size(stock,3))=stock;</span>
|
||||
0145 nbb=nbb+nb;
|
||||
0146 clear stock;
|
||||
0147 <span class="keyword">end</span>
|
||||
0148 <span class="keyword">else</span>
|
||||
0149 y0 = squeeze(stock_filter(:,jxj,:)) + <span class="keyword">...</span>
|
||||
0150 kron(stock_ys(js,:),ones(size(stock_filter,1),1));
|
||||
0151 <span class="keyword">end</span>
|
||||
0152 y0M=mean(y0,2);
|
||||
0153 <span class="keyword">for</span> j=1:nruns,
|
||||
0154 eval([<span class="string">'rmse_MC(j,i) = sqrt(mean(('</span>,vj,<span class="string">'(fobs-1+istart:fobs-1+nobs)-y0(istart:end-1,j)).^2));'</span>])
|
||||
0155 <span class="keyword">end</span>
|
||||
0156 <span class="keyword">if</span> exist(<span class="string">'xparam1_mean'</span>,<span class="string">'var'</span>)
|
||||
0157 <span class="comment">%eval(['rmse_pmean(i) = sqrt(mean((',vj,'(fobs-1+istart:fobs-1+nobs)-y0M(istart:end-1)).^2));'])</span>
|
||||
0158 [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = <a href="DsgeSmoother.html" class="code" title="function [alphahat,etahat,epsilonhat,ahat,SteadyState,trend_coeff,aK] = DsgeSmoother(xparam1,gend,Y)">DsgeSmoother</a>(xparam1_mean,stock_gend,stock_data);
|
||||
0159 y0 = ahat(jxj,:)' + <span class="keyword">...</span>
|
||||
0160 kron(ys_mean(js,:),ones(size(ahat,2),1));
|
||||
0161 eval([<span class="string">'rmse_pmean(i) = sqrt(mean(('</span>,vj,<span class="string">'(fobs-1+istart:fobs-1+nobs)-y0(istart:end-1)).^2));'</span>])
|
||||
0162 <span class="keyword">end</span>
|
||||
0163 <span class="keyword">end</span>
|
||||
0164 clear stock_filter;
|
||||
0165 <span class="keyword">for</span> j=1:nruns,
|
||||
0166 lnprior(j,1) = <a href="priordens.html" class="code" title="function lnprior = priordens(para, pshape, p1, p2, p3, p4)">priordens</a>(x(j,:),bayestopt_.pshape,bayestopt_.p1,bayestopt_.p2,bayestopt_.p3,bayestopt_.p4);
|
||||
0167 <span class="keyword">end</span>
|
||||
0168 likelihood=logpo2(:)+lnprior(:);
|
||||
0169 disp(<span class="string">'... done!'</span>)
|
||||
0170
|
||||
0171 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0172 save([OutDir,<span class="string">'\'</span>,fnamtmp], <span class="string">'x'</span>, <span class="string">'logpo2'</span>, <span class="string">'likelihood'</span>, <span class="string">'rmse_MC'</span>, <span class="string">'rmse_mode'</span>,<span class="string">'rmse_pmean'</span>)
|
||||
0173 <span class="keyword">else</span>
|
||||
0174 save([OutDir,<span class="string">'\'</span>,fnamtmp], <span class="string">'likelihood'</span>, <span class="string">'rmse_MC'</span>, <span class="string">'rmse_mode'</span>,<span class="string">'rmse_pmean'</span>,<span class="string">'-append'</span>)
|
||||
0175 <span class="keyword">end</span>
|
||||
0176 <span class="keyword">else</span>
|
||||
0177 load([OutDir,<span class="string">'\'</span>,fnamtmp],<span class="string">'x'</span>,<span class="string">'logpo2'</span>,<span class="string">'likelihood'</span>,<span class="string">'rmse_MC'</span>,<span class="string">'rmse_mode'</span>,<span class="string">'rmse_pmean'</span>);
|
||||
0178 lnprior=likelihood(:)-logpo2(:);
|
||||
0179 nruns=size(x,1);
|
||||
0180 nfilt=floor(pfilt*nruns);
|
||||
0181 <span class="keyword">end</span>
|
||||
0182 <span class="comment">% smirnov tests</span>
|
||||
0183 nfilt0=nfilt*ones(size(vvarvecm,1),1);
|
||||
0184 logpo2=logpo2(:);
|
||||
0185 <span class="keyword">if</span> ~options_.opt_gsa.ppost
|
||||
0186 [dum, ipost]=sort(logpo2);
|
||||
0187 <span class="keyword">end</span>
|
||||
0188 <span class="keyword">for</span> i=1:size(vvarvecm,1),
|
||||
0189 [dum, ixx(:,i)]=sort(rmse_MC(:,i));
|
||||
0190 <span class="keyword">if</span> options_.opt_gsa.ppost,
|
||||
0191 <span class="comment">%nfilt0(i)=length(find(rmse_MC(:,i)<rmse_pmean(i)));</span>
|
||||
0192 rmse_txt=rmse_pmean;
|
||||
0193 <span class="keyword">else</span>
|
||||
0194 <span class="keyword">if</span> options_.opt_gsa.pprior,
|
||||
0195 rmse_txt=rmse_mode;
|
||||
0196 <span class="keyword">else</span>
|
||||
0197 <span class="comment">%nfilt0(i)=length(find(rmse_MC(:,i)<rmse_pmean(i)));</span>
|
||||
0198 rmse_txt=rmse_pmean;
|
||||
0199 <span class="keyword">end</span>
|
||||
0200 <span class="keyword">end</span>
|
||||
0201 <span class="keyword">for</span> j=1:npar+nshock,
|
||||
0202 [H,P,KSSTAT] = <a href="smirnov.html" class="code" title="function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )">smirnov</a>(x(ixx(nfilt0(i)+1:<span class="keyword">end</span>,i),j),x(ixx(1:nfilt0(i),i),j), alpha);
|
||||
0203 [H1,P1,KSSTAT1] = <a href="smirnov.html" class="code" title="function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )">smirnov</a>(x(ixx(nfilt0(i)+1:<span class="keyword">end</span>,i),j),x(ixx(1:nfilt0(i),i),j),alpha,1);
|
||||
0204 [H2,P2,KSSTAT2] = <a href="smirnov.html" class="code" title="function [H,prob,d] = smirnov(x1 , x2 , alpha, iflag )">smirnov</a>(x(ixx(nfilt0(i)+1:<span class="keyword">end</span>,i),j),x(ixx(1:nfilt0(i),i),j),alpha,-1);
|
||||
0205 <span class="keyword">if</span> H1 & H2==0,
|
||||
0206 SS(j,i)=1;
|
||||
0207 <span class="keyword">elseif</span> H1==0,
|
||||
0208 SS(j,i)=-1;
|
||||
0209 <span class="keyword">else</span>
|
||||
0210 SS(j,i)=0;
|
||||
0211 <span class="keyword">end</span>
|
||||
0212 PP(j,i)=P;
|
||||
0213 <span class="keyword">end</span>
|
||||
0214 <span class="keyword">end</span>
|
||||
0215 figure(<span class="string">'name'</span>,<span class="string">'prior'</span>)
|
||||
0216 <span class="keyword">for</span> i=1:size(vvarvecm,1),
|
||||
0217 subplot(3,3,i)
|
||||
0218 h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(lnprior(ixx(1:nfilt0(i),i)));
|
||||
0219 set(h,<span class="string">'color'</span>,<span class="string">'red'</span>)
|
||||
0220 hold on, <a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(lnprior)
|
||||
0221 h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(lnprior(ixx(nfilt0(i)+1:<span class="keyword">end</span>,i)));
|
||||
0222 set(h,<span class="string">'color'</span>,<span class="string">'green'</span>)
|
||||
0223 title(vvarvecm(i,:))
|
||||
0224 <span class="keyword">end</span>
|
||||
0225 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0226 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_post_lnprior'</span>])
|
||||
0227 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_lnprior'</span>]);
|
||||
0228 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_lnprior'</span>]);
|
||||
0229 <span class="keyword">else</span>
|
||||
0230 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0231 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_prior_lnprior'</span>])
|
||||
0232 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_lnprior'</span>]);
|
||||
0233 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_lnprior'</span>]);
|
||||
0234 <span class="keyword">else</span>
|
||||
0235 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_mc_lnprior'</span>])
|
||||
0236 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_lnprior'</span>]);
|
||||
0237 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_lnprior'</span>]);
|
||||
0238 <span class="keyword">end</span>
|
||||
0239 <span class="keyword">end</span>
|
||||
0240 close(gcf)
|
||||
0241 figure(<span class="string">'name'</span>,<span class="string">'likelihood'</span>)
|
||||
0242 <span class="keyword">for</span> i=1:size(vvarvecm,1),
|
||||
0243 subplot(3,3,i)
|
||||
0244 h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(likelihood(ixx(1:nfilt0(i),i)));
|
||||
0245 set(h,<span class="string">'color'</span>,<span class="string">'red'</span>)
|
||||
0246 hold on, h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(likelihood);
|
||||
0247 h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(likelihood(ixx(nfilt0(i)+1:<span class="keyword">end</span>,i)));
|
||||
0248 set(h,<span class="string">'color'</span>,<span class="string">'green'</span>)
|
||||
0249 title(vvarvecm(i,:))
|
||||
0250 <span class="keyword">end</span>
|
||||
0251 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0252 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_post_lnlik'</span>])
|
||||
0253 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_lnlik'</span>]);
|
||||
0254 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_lnlik'</span>]);
|
||||
0255 <span class="keyword">else</span>
|
||||
0256 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0257 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_prior_lnlik'</span>])
|
||||
0258 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_lnlik'</span>]);
|
||||
0259 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_lnlik'</span>]);
|
||||
0260 <span class="keyword">else</span>
|
||||
0261 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_mc_lnlik'</span>])
|
||||
0262 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_lnlik'</span>]);
|
||||
0263 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_lnlik'</span>]);
|
||||
0264 <span class="keyword">end</span>
|
||||
0265 <span class="keyword">end</span>
|
||||
0266 close(gcf)
|
||||
0267 figure(<span class="string">'name'</span>,<span class="string">'posterior'</span>)
|
||||
0268 <span class="keyword">for</span> i=1:size(vvarvecm,1),
|
||||
0269 subplot(3,3,i)
|
||||
0270 h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(logpo2(ixx(1:nfilt0(i),i)));
|
||||
0271 set(h,<span class="string">'color'</span>,<span class="string">'red'</span>)
|
||||
0272 hold on, h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(logpo2);
|
||||
0273 h=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(logpo2(ixx(nfilt0(i)+1:<span class="keyword">end</span>,i)));
|
||||
0274 set(h,<span class="string">'color'</span>,<span class="string">'green'</span>)
|
||||
0275 title(vvarvecm(i,:))
|
||||
0276 <span class="keyword">end</span>
|
||||
0277 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0278 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_post_lnpost'</span>])
|
||||
0279 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_lnpost'</span>]);
|
||||
0280 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_lnpost'</span>]);
|
||||
0281 <span class="keyword">else</span>
|
||||
0282 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0283 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_prior_lnpost'</span>])
|
||||
0284 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_lnpost'</span>]);
|
||||
0285 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_lnpost'</span>]);
|
||||
0286 <span class="keyword">else</span>
|
||||
0287 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_mc_lnpost'</span>])
|
||||
0288 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_lnpost'</span>]);
|
||||
0289 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_lnpost'</span>]);
|
||||
0290 <span class="keyword">end</span>
|
||||
0291 <span class="keyword">end</span>
|
||||
0292 close(gcf)
|
||||
0293
|
||||
0294 param_names=<span class="string">''</span>;
|
||||
0295 <span class="keyword">for</span> j=1:npar+nshock,
|
||||
0296 param_names=str2mat(param_names, bayestopt_.name{j});
|
||||
0297 <span class="keyword">end</span>
|
||||
0298 param_names=param_names(2:<span class="keyword">end</span>,:);
|
||||
0299
|
||||
0300 disp(<span class="string">' '</span>)
|
||||
0301 disp(<span class="string">'RMSE over the MC sample:'</span>)
|
||||
0302 disp(<span class="string">' min yr RMSE max yr RMSE'</span>)
|
||||
0303 <span class="keyword">for</span> j=1:size(vvarvecm,1),
|
||||
0304 disp([vvarvecm(j,:), sprintf(<span class="string">'%15.5g'</span>,[(min(rmse_MC(:,j))) [(max(rmse_MC(:,j)))]])])
|
||||
0305 <span class="keyword">end</span>
|
||||
0306 invar = find( std(rmse_MC)./mean(rmse_MC)<=0.0001 );
|
||||
0307 <span class="keyword">if</span> ~isempty(invar)
|
||||
0308 disp(<span class="string">' '</span>)
|
||||
0309 disp(<span class="string">' '</span>)
|
||||
0310 disp(<span class="string">'RMSE is not varying significantly over the MC sample for the following variables:'</span>)
|
||||
0311 disp(vvarvecm(invar,:))
|
||||
0312 disp(<span class="string">'These variables are excluded from SA'</span>)
|
||||
0313 disp(<span class="string">'[Unless you treat these series as exogenous, there is something wrong in your estimation !]'</span>)
|
||||
0314 <span class="keyword">end</span>
|
||||
0315 ivar = find( std(rmse_MC)./mean(rmse_MC)>0.0001 );
|
||||
0316 vvarvecm=vvarvecm(ivar,:);
|
||||
0317 rmse_MC=rmse_MC(:,ivar);
|
||||
0318
|
||||
0319 disp(<span class="string">' '</span>)
|
||||
0320 <span class="keyword">if</span> options_.opt_gsa.ppost==0 & options_.opt_gsa.pprior,
|
||||
0321 disp([<span class="string">'Sample filtered the '</span>,num2str(pfilt*100),<span class="string">'% best RMSE''s for each observed series ...'</span> ])
|
||||
0322 <span class="keyword">else</span>
|
||||
0323 disp([<span class="string">'Sample filtered the best RMSE''s smaller than RMSE at the posterior mean ...'</span> ])
|
||||
0324 <span class="keyword">end</span>
|
||||
0325 <span class="comment">% figure, boxplot(rmse_MC)</span>
|
||||
0326 <span class="comment">% set(gca,'xticklabel',vvarvecm)</span>
|
||||
0327 <span class="comment">% saveas(gcf,[fname_,'_SA_RMSE'])</span>
|
||||
0328
|
||||
0329 disp(<span class="string">' '</span>)
|
||||
0330 disp(<span class="string">' '</span>)
|
||||
0331 disp(<span class="string">'RMSE ranges after filtering:'</span>)
|
||||
0332 <span class="keyword">if</span> options_.opt_gsa.ppost==0 & options_.opt_gsa.pprior,
|
||||
0333 disp([<span class="string">' best '</span>,num2str(pfilt*100),<span class="string">'% filtered remaining 90%'</span>])
|
||||
0334 disp([<span class="string">' min max min max posterior mode'</span>])
|
||||
0335 <span class="keyword">else</span>
|
||||
0336 disp([<span class="string">' best filtered remaining '</span>])
|
||||
0337 disp([<span class="string">' min max min max posterior mean'</span>])
|
||||
0338 <span class="keyword">end</span>
|
||||
0339 <span class="keyword">for</span> j=1:size(vvarvecm,1),
|
||||
0340 disp([vvarvecm(j,:), sprintf(<span class="string">'%15.5g'</span>,[min(rmse_MC(ixx(1:nfilt0(j),j),j)) <span class="keyword">...</span>
|
||||
0341 max(rmse_MC(ixx(1:nfilt0(j),j),j)) <span class="keyword">...</span>
|
||||
0342 min(rmse_MC(ixx(nfilt0(j)+1:<span class="keyword">end</span>,j),j)) <span class="keyword">...</span>
|
||||
0343 max(rmse_MC(ixx(nfilt0(j)+1:<span class="keyword">end</span>,j),j)) <span class="keyword">...</span>
|
||||
0344 rmse_txt(j)])])
|
||||
0345 <span class="comment">% disp([vvarvecm(j,:), sprintf('%15.5g',[min(logpo2(ixx(1:nfilt,j))) ...</span>
|
||||
0346 <span class="comment">% max(logpo2(ixx(1:nfilt,j))) ...</span>
|
||||
0347 <span class="comment">% min(logpo2(ixx(nfilt+1:end,j))) ...</span>
|
||||
0348 <span class="comment">% max(logpo2(ixx(nfilt+1:end,j)))])])</span>
|
||||
0349 <span class="keyword">end</span>
|
||||
0350
|
||||
0351 <span class="comment">%stab_map_1(x, ipost(1:nfilt), ipost(nfilt+1:end), 'SA_post', 1);</span>
|
||||
0352 <span class="comment">%stab_map_2(x(ipost(1:nfilt),:),alpha2,'SA_post', 1);</span>
|
||||
0353 <span class="comment">% for i=1:size(vvarvecm,1),</span>
|
||||
0354 <span class="comment">% aname=['SA_fit_ALL_',deblank(vvarvecm(i,:))];</span>
|
||||
0355 <span class="comment">% stab_map_1(x, ixx(1:nfilt,i), ixx(nfilt+1:end,i), aname, 1);</span>
|
||||
0356 <span class="comment">% close all</span>
|
||||
0357 <span class="comment">% end</span>
|
||||
0358
|
||||
0359 SP=zeros(npar+nshock,size(vvarvecm,1));
|
||||
0360 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0365
|
||||
0366 <span class="keyword">for</span> j=1:npar+nshock, <span class="comment">%estim_params_.np,</span>
|
||||
0367 nsp(j)=length(find(SP(j,:)));
|
||||
0368 <span class="keyword">end</span>
|
||||
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 <span class="comment">% snam0=bayestopt_.name(find(nsp==0));</span>
|
||||
0374 <span class="comment">% snam1=bayestopt_.name(find(nsp==1));</span>
|
||||
0375 <span class="comment">% snam2=bayestopt_.name(find(nsp>1));</span>
|
||||
0376 <span class="comment">% snam=bayestopt_.name(find(nsp>0));</span>
|
||||
0377 nsnam=(find(nsp>1));
|
||||
0378
|
||||
0379 disp(<span class="string">' '</span>)
|
||||
0380 disp(<span class="string">' '</span>)
|
||||
0381 disp(<span class="string">'These parameters do not affect significantly the fit of ANY observed series:'</span>)
|
||||
0382 disp(snam0)
|
||||
0383 disp(<span class="string">' '</span>)
|
||||
0384 disp(<span class="string">'These parameters affect ONE single observed series:'</span>)
|
||||
0385 disp(snam1)
|
||||
0386 disp(<span class="string">' '</span>)
|
||||
0387 disp(<span class="string">'These parameters affect MORE THAN ONE observed series: trade off exists!'</span>)
|
||||
0388 disp(snam2)
|
||||
0389
|
||||
0390
|
||||
0391 <span class="comment">%pnam=bayestopt_.name(end-estim_params_.np+1:end);</span>
|
||||
0392 pnam=bayestopt_.name;
|
||||
0393
|
||||
0394 <span class="comment">% plot trade-offs</span>
|
||||
0395 a00=jet(size(vvarvecm,1));
|
||||
0396 <span class="keyword">for</span> ix=1:ceil(length(nsnam)/6),
|
||||
0397 figure,
|
||||
0398 <span class="keyword">for</span> j=1+6*(ix-1):min(size(snam2,1),6*ix),
|
||||
0399 subplot(2,3,j-6*(ix-1))
|
||||
0400 <span class="comment">%h0=cumplot(x(:,nsnam(j)+nshock));</span>
|
||||
0401 h0=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(x(:,nsnam(j)));
|
||||
0402 <span class="comment">%set(h0,'color',[1 1 1])</span>
|
||||
0403 hold on,
|
||||
0404 np=find(SP(nsnam(j),:));
|
||||
0405 <span class="comment">%a0=jet(nsp(nsnam(j)));</span>
|
||||
0406 a0=a00(np,:);
|
||||
0407 <span class="keyword">for</span> i=1:nsp(nsnam(j)), <span class="comment">%size(vvarvecm,1),</span>
|
||||
0408 <span class="comment">%h0=cumplot(x(ixx(1:nfilt,np(i)),nsnam(j)+nshock));</span>
|
||||
0409 h0=<a href="cumplot.html" class="code" title="function h = cumplot(x);">cumplot</a>(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)));
|
||||
0410 set(h0,<span class="string">'color'</span>,a0(i,:))
|
||||
0411 <span class="keyword">end</span>
|
||||
0412 ydum=get(gca,<span class="string">'ylim'</span>);
|
||||
0413 <span class="comment">%xdum=xparam1(nshock+nsnam(j));</span>
|
||||
0414 xdum=xparam1(nsnam(j));
|
||||
0415 h1=plot([xdum xdum],ydum);
|
||||
0416 set(h1,<span class="string">'color'</span>,[0.85 0.85 0.85],<span class="string">'linewidth'</span>,2)
|
||||
0417 h0=legend(str2mat(<span class="string">'base'</span>,vvarvecm(np,:)),0);
|
||||
0418 set(h0,<span class="string">'fontsize'</span>,6)
|
||||
0419 <span class="comment">%h0=legend({'base',vnam{np}}',0);</span>
|
||||
0420 xlabel(<span class="string">''</span>)
|
||||
0421 set(findobj(get(h0,<span class="string">'children'</span>),<span class="string">'type'</span>,<span class="string">'text'</span>),<span class="string">'interpreter'</span>,<span class="string">'none'</span>)
|
||||
0422 title([pnam{nsnam(j)}],<span class="string">'interpreter'</span>,<span class="string">'none'</span>)
|
||||
0423 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0424 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_post_'</span>,num2str(ix)])
|
||||
0425 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_'</span> int2str(ix)]);
|
||||
0426 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_'</span> int2str(ix)]);
|
||||
0427 <span class="keyword">else</span>
|
||||
0428 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0429 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_prior_'</span>,num2str(ix)])
|
||||
0430 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_'</span> int2str(ix)]);
|
||||
0431 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_'</span> int2str(ix)]);
|
||||
0432 <span class="keyword">else</span>
|
||||
0433 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_mc_'</span>,num2str(ix)])
|
||||
0434 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_'</span> int2str(ix)]);
|
||||
0435 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_'</span> int2str(ix)]);
|
||||
0436 <span class="keyword">end</span>
|
||||
0437 <span class="keyword">end</span>
|
||||
0438 <span class="keyword">end</span>
|
||||
0439 <span class="keyword">end</span>
|
||||
0440 close all
|
||||
0441
|
||||
0442 <span class="keyword">for</span> j=1:size(SP,2),
|
||||
0443 nsx(j)=length(find(SP(:,j)));
|
||||
0444 <span class="keyword">end</span>
|
||||
0445
|
||||
0446 number_of_grid_points = 2^9; <span class="comment">% 2^9 = 512 !... Must be a power of two.</span>
|
||||
0447 bandwidth = 0; <span class="comment">% Rule of thumb optimal bandwidth parameter.</span>
|
||||
0448 kernel_function = <span class="string">'gaussian'</span>; <span class="comment">% Gaussian kernel for Fast Fourrier Transform approximaton.</span>
|
||||
0449 <span class="comment">%kernel_function = 'uniform'; % Gaussian kernel for Fast Fourrier Transform approximaton.</span>
|
||||
0450
|
||||
0451 <span class="keyword">for</span> ix=1:ceil(length(nsnam)/6),
|
||||
0452 figure,
|
||||
0453 <span class="keyword">for</span> j=1+6*(ix-1):min(size(snam2,1),6*ix),
|
||||
0454 subplot(2,3,j-6*(ix-1))
|
||||
0455 optimal_bandwidth = <a href="mh_optimal_bandwidth.html" class="code" title="function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)">mh_optimal_bandwidth</a>(x(:,nsnam(j)),size(x,1),bandwidth,kernel_function);
|
||||
0456 [x1,f1] = <a href="kernel_density_estimate.html" class="code" title="function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">kernel_density_estimate</a>(x(:,nsnam(j)),number_of_grid_points,<span class="keyword">...</span>
|
||||
0457 optimal_bandwidth,kernel_function);
|
||||
0458 h0 = plot(x1, f1);
|
||||
0459 hold on,
|
||||
0460 np=find(SP(nsnam(j),:));
|
||||
0461 <span class="comment">%a0=jet(nsp(nsnam(j)));</span>
|
||||
0462 a0=a00(np,:);
|
||||
0463 <span class="keyword">for</span> i=1:nsp(nsnam(j)), <span class="comment">%size(vvarvecm,1),</span>
|
||||
0464 optimal_bandwidth = <a href="mh_optimal_bandwidth.html" class="code" title="function optimal_bandwidth = mh_optimal_bandwidth(data,n,bandwidth,kernel_function)">mh_optimal_bandwidth</a>(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)),nfilt,bandwidth,kernel_function);
|
||||
0465 [x1,f1] = <a href="kernel_density_estimate.html" class="code" title="function [abscissa,f] = kernel_density_estimate(data,number_of_grid_points,bandwidth,kernel_function)">kernel_density_estimate</a>(x(ixx(1:nfilt0(np(i)),np(i)),nsnam(j)),number_of_grid_points,<span class="keyword">...</span>
|
||||
0466 optimal_bandwidth,kernel_function);
|
||||
0467 h0 = plot(x1, f1);
|
||||
0468 set(h0,<span class="string">'color'</span>,a0(i,:))
|
||||
0469 <span class="keyword">end</span>
|
||||
0470 ydum=get(gca,<span class="string">'ylim'</span>);
|
||||
0471 set(gca,<span class="string">'ylim'</span>,[0 ydum(2)]);
|
||||
0472 <span class="comment">%xdum=xparam1(nshock+nsnam(j));</span>
|
||||
0473 xdum=xparam1(nsnam(j));
|
||||
0474 h1=plot([xdum xdum],[0 ydum(2)]);
|
||||
0475 set(h1,<span class="string">'color'</span>,[0.85 0.85 0.85],<span class="string">'linewidth'</span>,2)
|
||||
0476 h0=legend(str2mat(<span class="string">'base'</span>,vvarvecm(np,:)),0);
|
||||
0477 set(h0,<span class="string">'fontsize'</span>,6)
|
||||
0478 <span class="comment">%h0=legend({'base',vnam{np}}',0);</span>
|
||||
0479 xlabel(<span class="string">''</span>)
|
||||
0480 set(findobj(get(h0,<span class="string">'children'</span>),<span class="string">'type'</span>,<span class="string">'text'</span>),<span class="string">'interpreter'</span>,<span class="string">'none'</span>)
|
||||
0481 title([pnam{nsnam(j)}],<span class="string">'interpreter'</span>,<span class="string">'none'</span>)
|
||||
0482 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0483 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_post_dens_'</span>,num2str(ix)])
|
||||
0484 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_dens_'</span> int2str(ix)]);
|
||||
0485 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_post_dens_'</span> int2str(ix)]);
|
||||
0486 <span class="keyword">else</span>
|
||||
0487 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0488 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_prior_dens_'</span>,num2str(ix)])
|
||||
0489 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_dens_'</span> int2str(ix)]);
|
||||
0490 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_prior_dens_'</span> int2str(ix)]);
|
||||
0491 <span class="keyword">else</span>
|
||||
0492 saveas(gcf,[OutDir,<span class="string">'\'</span>,fname_,<span class="string">'_SA_fit_mc_dens_'</span>,num2str(ix)])
|
||||
0493 eval([<span class="string">'print -depsc2 '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_dens_'</span> int2str(ix)]);
|
||||
0494 eval([<span class="string">'print -dpdf '</span> OutDir <span class="string">'\'</span> fname_ <span class="string">'_SA_fit_mc_dens_'</span> int2str(ix)]);
|
||||
0495 <span class="keyword">end</span>
|
||||
0496 <span class="keyword">end</span>
|
||||
0497 <span class="keyword">end</span>
|
||||
0498 <span class="keyword">end</span>
|
||||
0499 close all
|
||||
0500
|
||||
0501 <span class="comment">% for j=1:size(SP,2),</span>
|
||||
0502 <span class="comment">% nfig=0;</span>
|
||||
0503 <span class="comment">% np=find(SP(:,j));</span>
|
||||
0504 <span class="comment">% for i=1:nsx(j), %size(vvarvecm,1),</span>
|
||||
0505 <span class="comment">% if mod(i,12)==1,</span>
|
||||
0506 <span class="comment">% nfig=nfig+1;</span>
|
||||
0507 <span class="comment">% %figure('name',['Sensitivity of fit of ',vnam{j}]),</span>
|
||||
0508 <span class="comment">% figure('name',['Sensitivity of fit of ',deblank(vvarvecm(j,:)),' ',num2str(nfig)]),</span>
|
||||
0509 <span class="comment">% end</span>
|
||||
0510 <span class="comment">%</span>
|
||||
0511 <span class="comment">% subplot(3,4,i-12*(nfig-1))</span>
|
||||
0512 <span class="comment">% optimal_bandwidth = mh_optimal_bandwidth(x(ixx(1:nfilt,j),np(i)),nfilt,bandwidth,kernel_function);</span>
|
||||
0513 <span class="comment">% [x1,f1] = kernel_density_estimate(x(ixx(1:nfilt,j),np(i)),number_of_grid_points,...</span>
|
||||
0514 <span class="comment">% optimal_bandwidth,kernel_function);</span>
|
||||
0515 <span class="comment">% plot(x1, f1,':k','linewidth',2)</span>
|
||||
0516 <span class="comment">% optimal_bandwidth = mh_optimal_bandwidth(x(ixx(nfilt+1:end,j),np(i)),nruns-nfilt,bandwidth,kernel_function);</span>
|
||||
0517 <span class="comment">% [x1,f1] = kernel_density_estimate(x(ixx(nfilt+1:end,j),np(i)),number_of_grid_points,...</span>
|
||||
0518 <span class="comment">% optimal_bandwidth,kernel_function);</span>
|
||||
0519 <span class="comment">% hold on, plot(x1, f1,'k','linewidth',2)</span>
|
||||
0520 <span class="comment">% ydum=get(gca,'ylim');</span>
|
||||
0521 <span class="comment">% %xdum=xparam1(nshock+np(i));</span>
|
||||
0522 <span class="comment">% xdum=xparam1(np(i));</span>
|
||||
0523 <span class="comment">% h1=plot([xdum xdum],ydum);</span>
|
||||
0524 <span class="comment">% set(h1,'color',[0.85 0.85 0.85],'linewidth',2)</span>
|
||||
0525 <span class="comment">% %xdum1=mean(x(ixx(1:nfilt,j),np(i)+nshock));</span>
|
||||
0526 <span class="comment">% xdum1=mean(x(ixx(1:nfilt,j),np(i)));</span>
|
||||
0527 <span class="comment">% h2=plot([xdum1 xdum1],ydum);</span>
|
||||
0528 <span class="comment">% set(h2,'color',[0 1 0],'linewidth',2)</span>
|
||||
0529 <span class="comment">% % h0=cumplot(x(nfilt+1:end,np(i)+nshock));</span>
|
||||
0530 <span class="comment">% % set(h0,'color',[1 1 1])</span>
|
||||
0531 <span class="comment">% % hold on,</span>
|
||||
0532 <span class="comment">% % h0=cumplot(x(ixx(1:nfilt,j),np(i)+nshock));</span>
|
||||
0533 <span class="comment">% % set(h0,'linestyle',':','color',[1 1 1])</span>
|
||||
0534 <span class="comment">% %title([pnam{np(i)}])</span>
|
||||
0535 <span class="comment">% title([pnam{np(i)},'. K-S prob ', num2str(PP(np(i),j))],'interpreter','none')</span>
|
||||
0536 <span class="comment">% xlabel('')</span>
|
||||
0537 <span class="comment">% if mod(i,12)==0 | i==nsx(j),</span>
|
||||
0538 <span class="comment">% saveas(gcf,[fname_,'_SA_fit_',deblank(vvarvecm(j,:)),'_',int2str(nfig)])</span>
|
||||
0539 <span class="comment">% close(gcf)</span>
|
||||
0540 <span class="comment">% end</span>
|
||||
0541 <span class="comment">% end</span>
|
||||
0542 <span class="comment">% end</span>
|
||||
0543
|
||||
0544
|
||||
0545 disp(<span class="string">' '</span>)
|
||||
0546 disp(<span class="string">' '</span>)
|
||||
0547 disp(<span class="string">'Sensitivity table (significance and direction):'</span>)
|
||||
0548 vav=char(zeros(1, size(param_names,2)+3 ));
|
||||
0549 ibl = 12-size(vvarvecm,2);
|
||||
0550 <span class="keyword">for</span> j=1:size(vvarvecm,1),
|
||||
0551 vav = [vav, char(zeros(1,ibl)),vvarvecm(j,:)];
|
||||
0552 <span class="keyword">end</span>
|
||||
0553 disp(vav)
|
||||
0554 <span class="keyword">for</span> j=1:npar+nshock, <span class="comment">%estim_params_.np,</span>
|
||||
0555 <span class="comment">%disp([param_names(j,:), sprintf('%8.5g',SP(j,:))])</span>
|
||||
0556 disp([param_names(j,:),<span class="string">' '</span>, sprintf(<span class="string">'%12.3g'</span>,PP(j,:))])
|
||||
0557 disp([char(zeros(1, size(param_names,2)+3 )),sprintf(<span class="string">' (%6g)'</span>,SS(j,:))])
|
||||
0558 <span class="keyword">end</span>
|
||||
0559
|
||||
0560
|
||||
0561 disp(<span class="string">' '</span>)
|
||||
0562 disp(<span class="string">' '</span>)
|
||||
0563 disp(<span class="string">'Starting bivariate analysis:'</span>)
|
||||
0564
|
||||
0565 <span class="keyword">for</span> i=1:size(vvarvecm,1)
|
||||
0566 <span class="keyword">if</span> options_.opt_gsa.ppost
|
||||
0567 fnam = [<span class="string">'SA_fit_post_'</span>,deblank(vvarvecm(i,:))];
|
||||
0568 <span class="keyword">else</span>
|
||||
0569 <span class="keyword">if</span> options_.opt_gsa.pprior
|
||||
0570 fnam = [<span class="string">'SA_fit_prior_'</span>,deblank(vvarvecm(i,:))];
|
||||
0571 <span class="keyword">else</span>
|
||||
0572 fnam = [<span class="string">'SA_fit_mc_'</span>,deblank(vvarvecm(i,:))];
|
||||
0573 <span class="keyword">end</span>
|
||||
0574 <span class="keyword">end</span>
|
||||
0575 <a href="stab_map_2.html" class="code" title="function stab_map_2(x,alpha2,fnam, dirname)">stab_map_2</a>(x(ixx(1:nfilt0(i),i),:),alpha2,fnam, OutDir);
|
||||
0576
|
||||
0577 <span class="comment">% [pc,latent,explained] = pcacov(c0);</span>
|
||||
0578 <span class="comment">% %figure, bar([explained cumsum(explained)])</span>
|
||||
0579 <span class="comment">% ifig=0;</span>
|
||||
0580 <span class="comment">% j2=0;</span>
|
||||
0581 <span class="comment">% for j=1:npar+nshock,</span>
|
||||
0582 <span class="comment">% i2=find(abs(pc(:,j))>alphaPC);</span>
|
||||
0583 <span class="comment">% if ~isempty(i2),</span>
|
||||
0584 <span class="comment">% j2=j2+1;</span>
|
||||
0585 <span class="comment">% if mod(j2,12)==1,</span>
|
||||
0586 <span class="comment">% ifig=ifig+1;</span>
|
||||
0587 <span class="comment">% figure('name',['PCA of the filtered sample ',deblank(vvarvecm(i,:)),' ',num2str(ifig)]),</span>
|
||||
0588 <span class="comment">% end</span>
|
||||
0589 <span class="comment">% subplot(3,4,j2-(ifig-1)*12)</span>
|
||||
0590 <span class="comment">% bar(pc(i2,j)),</span>
|
||||
0591 <span class="comment">% set(gca,'xticklabel',bayestopt_.name(i2)),</span>
|
||||
0592 <span class="comment">% set(gca,'xtick',[1:length(i2)])</span>
|
||||
0593 <span class="comment">% title(['PC ',num2str(j),'. Explained ',num2str(explained(j)),'%'])</span>
|
||||
0594 <span class="comment">% end</span>
|
||||
0595 <span class="comment">% if (mod(j2,12)==0 | j==(npar+nshock)) & j2,</span>
|
||||
0596 <span class="comment">% saveas(gcf,[fname_,'_SA_PCA_',deblank(vvarvecm(i,:)),'_',int2str(ifig)])</span>
|
||||
0597 <span class="comment">% end</span>
|
||||
0598 <span class="comment">% end</span>
|
||||
0599 <span class="comment">% close all</span>
|
||||
0600 <span class="keyword">end</span>
|
||||
0601</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of fnorm</title>
|
||||
<meta name="keywords" content="fnorm">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > fnorm.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>fnorm
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function e = fnorm(p2,p,p1,perc) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="pnorm.html" class="code" title="function p = pnorm(x,m,s)">pnorm</a> PNORM The normal distribution function</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function e = fnorm(p2,p,p1,perc)</a>
|
||||
0002 e = p - <a href="pnorm.html" class="code" title="function p = pnorm(x,m,s)">pnorm</a>(perc,p1,p2);</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,119 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of forcst</title>
|
||||
<meta name="keywords" content="forcst">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > forcst.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>forcst
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [yf,var_yf]=forcst(dr,y0,k,m) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="make_ex_.html" class="code" title="function make_ex_">make_ex_</a> Copyright (C) 2001 Michel Juillard</li><li><a href="simult_.html" class="code" title="function y_=simult_(y0,dr,ex_,iorder)">simult_</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [yf,var_yf]=forcst(dr,y0,k,m)</a>
|
||||
0002 <span class="keyword">global</span> M_ oo_ options_
|
||||
0003
|
||||
0004 options_.periods = k;
|
||||
0005 <a href="make_ex_.html" class="code" title="function make_ex_">make_ex_</a>;
|
||||
0006 yf = <a href="simult_.html" class="code" title="function y_=simult_(y0,dr,ex_,iorder)">simult_</a>(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 <span class="keyword">if</span> ~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 <span class="keyword">end</span>
|
||||
0021 gx = [];
|
||||
0022 k2 = [];
|
||||
0023 <span class="keyword">if</span> nstatic > 0
|
||||
0024 gx = dr.ghx(1:nstatic,:);
|
||||
0025 k2 = [1:nstatic]';
|
||||
0026 <span class="keyword">end</span>
|
||||
0027 <span class="keyword">if</span> size(dr.ghx,1) > nstatic+npred
|
||||
0028 gx = [gx; dr.ghx(nstatic+npred+1:<span class="keyword">end</span>,:)];
|
||||
0029 k2 = [k2; [nstatic+npred+1:size(dr.ghx,1)]'];
|
||||
0030 <span class="keyword">end</span>
|
||||
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 <span class="keyword">if</span> isempty(k2)
|
||||
0041 <span class="keyword">for</span> i=1:k
|
||||
0042 sigma_y1 = sigma_y1+sigma_u;
|
||||
0043 var_yf(i,k1) = diag(sigma_y1(1:npred,1:npred))';
|
||||
0044 <span class="keyword">if</span> i == k
|
||||
0045 <span class="keyword">break</span>
|
||||
0046 <span class="keyword">end</span>
|
||||
0047 sigma_u = hx*sigma_u*hx';
|
||||
0048 <span class="keyword">end</span>
|
||||
0049 <span class="keyword">else</span>
|
||||
0050 <span class="keyword">for</span> 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 <span class="keyword">if</span> i == k
|
||||
0056 <span class="keyword">break</span>
|
||||
0057 <span class="keyword">end</span>
|
||||
0058 sigma_u = hx*sigma_u*hx';
|
||||
0059 <span class="keyword">end</span>
|
||||
0060 <span class="keyword">end</span>
|
||||
0061
|
||||
0062
|
||||
0063
|
||||
0064
|
||||
0065
|
||||
0066
|
||||
0067
|
||||
0068
|
||||
0069
|
||||
0070
|
||||
0071
|
||||
0072
|
||||
0073</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 265 B |
|
@ -1,115 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of ftest</title>
|
||||
<meta name="keywords" content="ftest">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > ftest.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>ftest
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function ftest (s1,s2) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dcompare.html" class="code" title="function dcompare(s1)">dcompare</a> Copyright (C) 2001 Michel Juillard</li><li><a href="gcompare.html" class="code" title="function gcompare(s1,s2)">gcompare</a> Copyright (C) 2001 Michel Juillard</li><li><a href="mcompare.html" class="code" title="function mcompare(s1,s2)">mcompare</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function ftest (s1,s2)</a>
|
||||
0004
|
||||
0005 <span class="keyword">global</span> nvx nvy x y lag1
|
||||
0006
|
||||
0007 <span class="keyword">if</span> size(s1,1) ~= 2
|
||||
0008 error (<span class="string">'Spcifiez deux fichiers pour la comparaison.'</span>) ;
|
||||
0009 <span class="keyword">end</span>
|
||||
0010
|
||||
0011 <span class="keyword">for</span> i = 1:2
|
||||
0012 <span class="keyword">if</span> ~ isempty(find(abs(s1(i,:)) == 46))
|
||||
0013 error (<span class="string">'Entrez les noms de fichiers sans extensions.'</span>) ;
|
||||
0014 <span class="keyword">end</span>
|
||||
0015 <span class="keyword">end</span>
|
||||
0016
|
||||
0017 s1 = [s1 [<span class="string">' '</span>;<span class="string">' '</span>]] ;
|
||||
0018 file1 = [s1(1,1:min(find(abs(s1(1,:)) == 32))-1) <span class="string">'.BIN'</span>] ;
|
||||
0019 file2 = [s1(2,1:min(find(abs(s1(2,:)) == 32))-1) <span class="string">'.BIN'</span>] ;
|
||||
0020
|
||||
0021 fid=fopen(file1,<span class="string">'r'</span>) ;
|
||||
0022 n1 = fread(fid,1,<span class="string">'int'</span>) ;
|
||||
0023 n2 = fread(fid,1,<span class="string">'int'</span>) ;
|
||||
0024 n3 = fread(fid,1,<span class="string">'int'</span>) ;
|
||||
0025 lag1 = fread(fid,4,<span class="string">'int'</span>) ;
|
||||
0026 nvx = fread(fid,[n1,n3],<span class="string">'int'</span>) ;
|
||||
0027 x = fread(fid,[n1,n2],<span class="string">'float64'</span>) ;
|
||||
0028 fclose(fid) ;
|
||||
0029 nvx = setstr(nvx) ;
|
||||
0030
|
||||
0031 fid=fopen(file2,<span class="string">'r'</span>) ;
|
||||
0032 n1 = fread(fid,1,<span class="string">'int'</span>) ;
|
||||
0033 n2 = fread(fid,1,<span class="string">'int'</span>) ;
|
||||
0034 n3 = fread(fid,1,<span class="string">'int'</span>) ;
|
||||
0035 lag2 = fread(fid,4,<span class="string">'int'</span>) ;
|
||||
0036 nvy = fread(fid,[n1,n3],<span class="string">'int'</span>) ;
|
||||
0037 y = fread(fid,[n1,n2],<span class="string">'float64'</span>) ;
|
||||
0038 fclose(fid) ;
|
||||
0039 nvy = setstr(nvy) ;
|
||||
0040
|
||||
0041 <span class="keyword">if</span> size(x,1) ~= size(y,1)
|
||||
0042 error (<span class="string">'FTEST: The two files don''t have the same number of variables.'</span>);
|
||||
0043 <span class="keyword">end</span>
|
||||
0044
|
||||
0045 <span class="keyword">for</span> i = 1:size(x,1)
|
||||
0046 <span class="keyword">if</span> ~ strcmp(nvx(i,:),nvy(i,:))
|
||||
0047 error (<span class="string">'FTEST: The two files don''t have the same variables.'</span>) ;
|
||||
0048 <span class="keyword">end</span>
|
||||
0049 <span class="keyword">end</span>
|
||||
0050
|
||||
0051 <span class="keyword">if</span> nnz(lag1 - lag2) > 0
|
||||
0052 error (<span class="string">'FTEST: Leads and lags aren''t the same in both files.'</span>) ;
|
||||
0053 <span class="keyword">end</span>
|
||||
0054
|
||||
0055 j = zeros(size(s2,1),1);
|
||||
0056 <span class="keyword">for</span> i=1:size(s2,1)
|
||||
0057 k = strmatch(s2(i,:),nvx,<span class="string">'exact'</span>) ;
|
||||
0058 <span class="keyword">if</span> isempty(k)
|
||||
0059 t = [<span class="string">'FTEST: Variable '</span> s2(i) <span class="string">'doesn''t exist'</span>] ;
|
||||
0060 error (t) ;
|
||||
0061 <span class="keyword">else</span>
|
||||
0062 j(i) =k;
|
||||
0063 <span class="keyword">end</span>
|
||||
0064 <span class="keyword">end</span>
|
||||
0065
|
||||
0066 y = y(j,:) ;
|
||||
0067 x = x(j,:) ;
|
||||
0068
|
||||
0069 <span class="comment">%06/18/01 MJ replaced beastr by strmatch</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,135 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of gamm_rnd</title>
|
||||
<meta name="keywords" content="gamm_rnd">
|
||||
<meta name="description" content="PURPOSE: a matrix of random draws from the gamma distribution">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > gamm_rnd.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>gamm_rnd
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>PURPOSE: a matrix of random draws from the gamma distribution</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function gb = gamm_rnd(nrow,m,k) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> PURPOSE: a matrix of random draws from the gamma distribution
|
||||
---------------------------------------------------
|
||||
USAGE: r = gamm_rnd(n,m,k)
|
||||
where: n = the size of the vector drawn
|
||||
m = a parameter such that the mean of the gamma = m/k
|
||||
k = a parameter such that the variance of the gamma = m/(k^2)
|
||||
note: m=r/2, k=2 equals chisq r random deviate
|
||||
---------------------------------------------------
|
||||
RETURNS:
|
||||
r = an n x 1 vector of random numbers from the gamma distribution
|
||||
--------------------------------------------------
|
||||
SEE ALSO: gamm_inv, gamm_pdf, gamm_cdf
|
||||
---------------------------------------------------
|
||||
NOTE: written by: Michael Gordy, 15 Sept 1993
|
||||
mbgordy@athena.mit.edu
|
||||
---------------------------------------------------
|
||||
REFERENCES: Luc Devroye, Non-Uniform Random Variate Generation,
|
||||
New York: Springer Verlag, 1986, ch 9.3-6.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="beta_rnd.html" class="code" title="function rnd = beta_rnd (n, a, b)">beta_rnd</a> PURPOSE: random draws from the beta(a,b) distribution</li><li><a href="rndprior.html" class="code" title="function y = rndprior(bayestopt_)">rndprior</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function gb = gamm_rnd(nrow,m,k)</a>
|
||||
0002 <span class="comment">% PURPOSE: a matrix of random draws from the gamma distribution</span>
|
||||
0003 <span class="comment">%---------------------------------------------------</span>
|
||||
0004 <span class="comment">% USAGE: r = gamm_rnd(n,m,k)</span>
|
||||
0005 <span class="comment">% where: n = the size of the vector drawn</span>
|
||||
0006 <span class="comment">% m = a parameter such that the mean of the gamma = m/k</span>
|
||||
0007 <span class="comment">% k = a parameter such that the variance of the gamma = m/(k^2)</span>
|
||||
0008 <span class="comment">% note: m=r/2, k=2 equals chisq r random deviate</span>
|
||||
0009 <span class="comment">%---------------------------------------------------</span>
|
||||
0010 <span class="comment">% RETURNS:</span>
|
||||
0011 <span class="comment">% r = an n x 1 vector of random numbers from the gamma distribution</span>
|
||||
0012 <span class="comment">% --------------------------------------------------</span>
|
||||
0013 <span class="comment">% SEE ALSO: gamm_inv, gamm_pdf, gamm_cdf</span>
|
||||
0014 <span class="comment">%---------------------------------------------------</span>
|
||||
0015 <span class="comment">% NOTE: written by: Michael Gordy, 15 Sept 1993</span>
|
||||
0016 <span class="comment">% mbgordy@athena.mit.edu</span>
|
||||
0017 <span class="comment">%---------------------------------------------------</span>
|
||||
0018 <span class="comment">% REFERENCES: Luc Devroye, Non-Uniform Random Variate Generation,</span>
|
||||
0019 <span class="comment">% New York: Springer Verlag, 1986, ch 9.3-6.</span>
|
||||
0020
|
||||
0021 <span class="keyword">if</span> nargin ~= 3
|
||||
0022 error(<span class="string">'Wrong # of arguments to gamm_rnd'</span>);
|
||||
0023 <span class="keyword">end</span>;
|
||||
0024
|
||||
0025 ncol = 1;
|
||||
0026 gb=zeros(nrow,ncol);
|
||||
0027 <span class="keyword">if</span> m<=1
|
||||
0028 <span class="comment">% Use RGS algorithm by Best, p. 426</span>
|
||||
0029 c=1/m;
|
||||
0030 t=0.07+0.75*sqrt(1-m);
|
||||
0031 b=1+exp(-t)*m/t;
|
||||
0032 <span class="keyword">for</span> i1=1:nrow
|
||||
0033 <span class="keyword">for</span> i2=1:ncol
|
||||
0034 accept=0;
|
||||
0035 <span class="keyword">while</span> accept==0
|
||||
0036 u=rand; w=rand; v=b*u;
|
||||
0037 <span class="keyword">if</span> v<=1
|
||||
0038 x=t*(v^c);
|
||||
0039 accept=((w<=((2-x)/(2+x))) | (w<=exp(-x)));
|
||||
0040 <span class="keyword">else</span>
|
||||
0041 x=-log(c*t*(b-v));
|
||||
0042 y=x/t;
|
||||
0043 accept=(((w*(m+y-m*y))<=1) | (w<=(y^(m-1))));
|
||||
0044 <span class="keyword">end</span>
|
||||
0045 <span class="keyword">end</span>
|
||||
0046 gb(i1,i2)=x;
|
||||
0047 <span class="keyword">end</span>
|
||||
0048 <span class="keyword">end</span>
|
||||
0049 <span class="keyword">else</span>
|
||||
0050 <span class="comment">% Use Best's rejection algorithm XG, p. 410</span>
|
||||
0051 b=m-1;
|
||||
0052 c=3*m-0.75;
|
||||
0053 <span class="keyword">for</span> i1=1:nrow
|
||||
0054 <span class="keyword">for</span> i2=1:ncol
|
||||
0055 accept=0;
|
||||
0056 <span class="keyword">while</span> accept==0
|
||||
0057 u=rand; v=rand;
|
||||
0058 w=u*(1-u); y=sqrt(c/w)*(u-0.5);
|
||||
0059 x=b+y;
|
||||
0060 <span class="keyword">if</span> x >= 0
|
||||
0061 z=64*(w^3)*v*v;
|
||||
0062 accept=(z<=(1-2*y*y/x)) <span class="keyword">...</span>
|
||||
0063 | (log(z)<=(2*(b*log(x/b)-y)));
|
||||
0064 <span class="keyword">end</span>
|
||||
0065 <span class="keyword">end</span>
|
||||
0066 gb(i1,i2)=x;
|
||||
0067 <span class="keyword">end</span>
|
||||
0068 <span class="keyword">end</span>
|
||||
0069 <span class="keyword">end</span>
|
||||
0070 gb=gb/k;
|
||||
0071
|
||||
0072</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,94 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of gcompare</title>
|
||||
<meta name="keywords" content="gcompare">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > gcompare.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>gcompare
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function gcompare(s1,s2) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
|
||||
GCOMPARE : GCOMPARE ( [ 'file1' ; 'file2' ] , [ 'var1' ; 'var2' ...] )
|
||||
This optional command plots the trajectories of a list of
|
||||
variables in two different simulations. One plot is drawn
|
||||
for each variable. The trajectories must have been previously
|
||||
saved by the instruction DYNASAVE. The simulation in file1
|
||||
is refered to as the base simulation.</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="ftest.html" class="code" title="function ftest (s1,s2)">ftest</a> Copyright (C) 2001 Michel Juillard</li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <a name="_sub0" href="#_subfunctions" class="code">function gcompare(s1,s2)</a>
|
||||
0004 <span class="comment">% GCOMPARE : GCOMPARE ( [ 'file1' ; 'file2' ] , [ 'var1' ; 'var2' ...] )</span>
|
||||
0005 <span class="comment">% This optional command plots the trajectories of a list of</span>
|
||||
0006 <span class="comment">% variables in two different simulations. One plot is drawn</span>
|
||||
0007 <span class="comment">% for each variable. The trajectories must have been previously</span>
|
||||
0008 <span class="comment">% saved by the instruction DYNASAVE. The simulation in file1</span>
|
||||
0009 <span class="comment">% is refered to as the base simulation.</span>
|
||||
0010
|
||||
0011
|
||||
0012 <span class="keyword">global</span> options_ M_
|
||||
0013 <span class="keyword">global</span> nvx nvy x y lag1
|
||||
0014
|
||||
0015 <a href="ftest.html" class="code" title="function ftest (s1,s2)">ftest</a>(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 <span class="keyword">if</span> options_.smpl == 0
|
||||
0021 i = [M_.maximum_lag:size(y,2)]' ;
|
||||
0022 <span class="keyword">else</span>
|
||||
0023 i = [options_.smpl(1):options_.smpl(2)]' ;
|
||||
0024 <span class="keyword">end</span>
|
||||
0025
|
||||
0026 <span class="keyword">for</span> k = 1:size(x,1)
|
||||
0027 figure ;
|
||||
0028 plot (ix(i),x(k,i),ix(i),y(k,i)) ;
|
||||
0029 xlabel ([<span class="string">'Periods'</span>]) ;
|
||||
0030 title ([<span class="string">'Variable '</span> 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 <span class="keyword">end</span>
|
||||
0036
|
||||
0037 <span class="comment">% 06/18/01 MJ corrected treatment of options_.smpl</span>
|
||||
0038 <span class="comment">% 06/24/01 MJ removed color specification</span>
|
||||
0039
|
||||
0040
|
||||
0041</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,79 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of gendata</title>
|
||||
<meta name="keywords" content="gendata">
|
||||
<meta name="description" content="[y,epsilon,alpha,eta] = gendata(T, ssf, a0)">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > gendata.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>gendata
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>[y,epsilon,alpha,eta] = gendata(T, ssf, a0)</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [y,epsilon,alpha,eta] = gendata(T, ssf, a0) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> [y,epsilon,alpha,eta] = gendata(T, ssf, a0)
|
||||
|
||||
generates random data of the length T for the given state space form
|
||||
and initial state</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% [y,epsilon,alpha,eta] = gendata(T, ssf, a0)</span>
|
||||
0002 <span class="comment">%</span>
|
||||
0003 <span class="comment">% generates random data of the length T for the given state space form</span>
|
||||
0004 <span class="comment">% and initial state</span>
|
||||
0005
|
||||
0006 <span class="comment">% $Id: gendata.m 532 2005-11-30 13:51:33Z kamenik $</span>
|
||||
0007 <span class="comment">% Copyright 2005, Ondra Kamenik</span>
|
||||
0008
|
||||
0009 <a name="_sub0" href="#_subfunctions" class="code">function [y,epsilon,alpha,eta] = gendata(T, ssf, a0)</a>
|
||||
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 <span class="keyword">for</span> t = 1:T
|
||||
0026 y(:,t) = ssf.Z*alpha(:,t) + epsilon(:,t);
|
||||
0027 <span class="keyword">if</span> t ~= T
|
||||
0028 alpha(:,t+1) = ssf.T*alpha(:,t) + ssf.R*eta(:,t);
|
||||
0029 <span class="keyword">end</span>
|
||||
0030 <span class="keyword">end</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,101 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of generalized_cholesky</title>
|
||||
<meta name="keywords" content="generalized_cholesky">
|
||||
<meta name="description" content="proc gmchol(A);">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > generalized_cholesky.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>generalized_cholesky
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>proc gmchol(A);</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function AA = generalized_cholesky(A); </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> proc gmchol(A);
|
||||
/* calculates the Gill-Murray generalized choleski decomposition */
|
||||
/* input matrix A must be non-singular and symmetric */
|
||||
/* Author: Jeff Gill. Part of the Hessian Project. */
|
||||
local i,j,k,n,sum,R,theta_j,norm_A,phi_j,delta,xi_j,gamm,E,beta_j;</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="rows.html" class="code" title="function nr=rows(x)">rows</a> </li></ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% proc gmchol(A);</span>
|
||||
0002 <span class="comment">% /* calculates the Gill-Murray generalized choleski decomposition */</span>
|
||||
0003 <span class="comment">% /* input matrix A must be non-singular and symmetric */</span>
|
||||
0004 <span class="comment">% /* Author: Jeff Gill. Part of the Hessian Project. */</span>
|
||||
0005 <span class="comment">% local i,j,k,n,sum,R,theta_j,norm_A,phi_j,delta,xi_j,gamm,E,beta_j;</span>
|
||||
0006
|
||||
0007 <a name="_sub0" href="#_subfunctions" class="code">function AA = generalized_cholesky(A);</a>
|
||||
0008
|
||||
0009 n = <a href="rows.html" class="code" title="function nr=rows(x)">rows</a>(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 <span class="keyword">for</span> j = 1:n;
|
||||
0017 theta_j = 0;
|
||||
0018 <span class="keyword">for</span> i=1:n;
|
||||
0019 somme = 0;
|
||||
0020 <span class="keyword">for</span> k=1:i-1;
|
||||
0021 somme = somme + R(k,i)*R(k,j);
|
||||
0022 <span class="keyword">end</span>;
|
||||
0023 R(i,j) = (A(i,j) - somme)/R(i,i);
|
||||
0024 <span class="keyword">if</span> (A(i,j) -somme) > theta_j;
|
||||
0025 theta_j = A(i,j) - somme;
|
||||
0026 <span class="keyword">end</span>;
|
||||
0027 <span class="keyword">if</span> i > j;
|
||||
0028 R(i,j) = 0;
|
||||
0029 <span class="keyword">end</span>;
|
||||
0030 <span class="keyword">end</span>;
|
||||
0031 somme = 0;
|
||||
0032 <span class="keyword">for</span> k=1:j-1;
|
||||
0033 somme = somme + R(k,j)^2;
|
||||
0034 <span class="keyword">end</span>;
|
||||
0035 phi_j = A(j,j) - somme;
|
||||
0036 <span class="keyword">if</span> j+1 <= n;
|
||||
0037 xi_j = max(abs(A((j+1):n,j)));
|
||||
0038 <span class="keyword">else</span>;
|
||||
0039 xi_j = abs(A(n,j));
|
||||
0040 <span class="keyword">end</span>;
|
||||
0041 beta_j = sqrt(max([gamm ; (xi_j/n) ; eps]));
|
||||
0042 <span class="keyword">if</span> all(delta >= [abs(phi_j);((theta_j^2)/(beta_j^2))]);
|
||||
0043 E(j,j) = delta - phi_j;
|
||||
0044 <span class="keyword">elseif</span> all(abs(phi_j) >= [((delta^2)/(beta_j^2));delta]);
|
||||
0045 E(j,j) = abs(phi_j) - phi_j;
|
||||
0046 <span class="keyword">elseif</span> all(((theta_j^2)/(beta_j^2)) >= [delta;abs(phi_j)]);
|
||||
0047 E(j,j) = ((theta_j^2)/(beta_j^2)) - phi_j;
|
||||
0048 <span class="keyword">end</span>;
|
||||
0049 R(j,j) = sqrt(A(j,j) - somme + E(j,j));
|
||||
0050 <span class="keyword">end</span>;
|
||||
0051 AA = transpose(R)*R;</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,189 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of generalized_cholesky2</title>
|
||||
<meta name="keywords" content="generalized_cholesky2">
|
||||
<meta name="description" content="/*">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > generalized_cholesky2.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>generalized_cholesky2
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>/*</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function AA = generalized_cholesky2(A) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> /*
|
||||
** By Jeff Gill, April 2002.
|
||||
**
|
||||
** This procedure produces:
|
||||
**
|
||||
** y = chol(A+E), where E is a diagonal matrix with each element as small
|
||||
** as possible, and A and E are the same size. E diagonal values are
|
||||
** constrained by iteravely updated Gerschgorin bounds.
|
||||
**
|
||||
** REFERENCES:
|
||||
**
|
||||
** Jeff Gill and Gary King. 1998. "`Hessian not Invertable.' Help!"
|
||||
** manuscript in progress, Harvard University.
|
||||
**
|
||||
** Robert B. Schnabel and Elizabeth Eskow. 1990. "A New Modified Cholesky
|
||||
** Factorization," SIAM Journal of Scientific Statistical Computating,
|
||||
** 11, 6: 1136-58.
|
||||
**
|
||||
**
|
||||
**
|
||||
** Stphane Adjemian (2003): translation from Gauss to Matlab.
|
||||
*/</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% /*</span>
|
||||
0002 <span class="comment">% ** By Jeff Gill, April 2002.</span>
|
||||
0003 <span class="comment">% **</span>
|
||||
0004 <span class="comment">% ** This procedure produces:</span>
|
||||
0005 <span class="comment">% **</span>
|
||||
0006 <span class="comment">% ** y = chol(A+E), where E is a diagonal matrix with each element as small</span>
|
||||
0007 <span class="comment">% ** as possible, and A and E are the same size. E diagonal values are</span>
|
||||
0008 <span class="comment">% ** constrained by iteravely updated Gerschgorin bounds.</span>
|
||||
0009 <span class="comment">% **</span>
|
||||
0010 <span class="comment">% ** REFERENCES:</span>
|
||||
0011 <span class="comment">% **</span>
|
||||
0012 <span class="comment">% ** Jeff Gill and Gary King. 1998. "`Hessian not Invertable.' Help!"</span>
|
||||
0013 <span class="comment">% ** manuscript in progress, Harvard University.</span>
|
||||
0014 <span class="comment">% **</span>
|
||||
0015 <span class="comment">% ** Robert B. Schnabel and Elizabeth Eskow. 1990. "A New Modified Cholesky</span>
|
||||
0016 <span class="comment">% ** Factorization," SIAM Journal of Scientific Statistical Computating,</span>
|
||||
0017 <span class="comment">% ** 11, 6: 1136-58.</span>
|
||||
0018 <span class="comment">% **</span>
|
||||
0019 <span class="comment">% **</span>
|
||||
0020 <span class="comment">% **</span>
|
||||
0021 <span class="comment">% ** Stphane Adjemian (2003): translation from Gauss to Matlab.</span>
|
||||
0022 <span class="comment">% */</span>
|
||||
0023 <a name="_sub0" href="#_subfunctions" class="code">function AA = generalized_cholesky2(A)</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 <span class="keyword">if</span> min(eig(A)) > 0;
|
||||
0032 tau = -1000000;
|
||||
0033 <span class="keyword">end</span>;
|
||||
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 <span class="keyword">if</span> n > 2;
|
||||
0041 <span class="keyword">for</span> k = 1,n-2;
|
||||
0042 <span class="keyword">if</span> min((diag(A(k+1:n,k+1:n))' - A(k,k+1:n).^2/A(k,k))') < tau*gamm <span class="keyword">...</span>
|
||||
0043 & min(eig(A((k+1):n,(k+1):n))) < 0;
|
||||
0044 [tmp,dmax] = max(diag(A(k:n,k:n)));
|
||||
0045 <span class="keyword">if</span> 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 <span class="keyword">end</span>;
|
||||
0054 g = zeros(n-(k-1),1);
|
||||
0055 <span class="keyword">for</span> i=k:n;
|
||||
0056 <span class="keyword">if</span> i == 1;
|
||||
0057 sum1 = 0;
|
||||
0058 <span class="keyword">else</span>;
|
||||
0059 sum1 = sum(abs(A(i,k:(i-1)))');
|
||||
0060 <span class="keyword">end</span>;
|
||||
0061 <span class="keyword">if</span> i == n;
|
||||
0062 sum2 = 0;
|
||||
0063 <span class="keyword">else</span>;
|
||||
0064 sum2 = sum(abs(A((i+1):n,i)));
|
||||
0065 <span class="keyword">end</span>;
|
||||
0066 g(i-k+1) = A(i,i) - sum1 - sum2;
|
||||
0067 <span class="keyword">end</span>;
|
||||
0068 [tmp,gmax] = max(g);
|
||||
0069 <span class="keyword">if</span> 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 <span class="keyword">end</span>;
|
||||
0078 normj = sum(abs(A(k+1:n,k)));
|
||||
0079 delta = max([0;deltaprev;-A(k,k)+normj;-A(k,k)+tau*gamm]);
|
||||
0080 <span class="keyword">if</span> delta > 0;
|
||||
0081 A(k,k) = A(k,k) + delta;
|
||||
0082 deltaprev = delta;
|
||||
0083 <span class="keyword">end</span>;
|
||||
0084 <span class="keyword">end</span>;
|
||||
0085 A(k,k) = sqrt(A(k,k));
|
||||
0086 L(k,k) = A(k,k);
|
||||
0087 <span class="keyword">for</span> i=k+1:n;
|
||||
0088 <span class="keyword">if</span> L(k,k) > eps;
|
||||
0089 A(i,k) = A(i,k)/L(k,k);
|
||||
0090 <span class="keyword">end</span>;
|
||||
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 <span class="keyword">if</span> A(i,i) < 0;
|
||||
0094 A(i,i) = 0;
|
||||
0095 <span class="keyword">end</span>;
|
||||
0096 <span class="keyword">end</span>;
|
||||
0097 <span class="keyword">end</span>;
|
||||
0098 <span class="keyword">end</span>;
|
||||
0099 A(n-1,n) = A(n,n-1);
|
||||
0100 eigvals = eig(A(n-1:n,n-1:n));
|
||||
0101 dlist = [ 0 ; deltaprev ;<span class="keyword">...</span>
|
||||
0102 -min(eigvals)+tau*max((inv(1-tau)*max(eigvals)-min(eigvals))|gamm) ];
|
||||
0103 <span class="keyword">if</span> dlist(1) > dlist(2);
|
||||
0104 delta = dlist(1);
|
||||
0105 <span class="keyword">else</span>;
|
||||
0106 delta = dlist(2);
|
||||
0107 <span class="keyword">end</span>;
|
||||
0108 <span class="keyword">if</span> delta < dlist(3);
|
||||
0109 delta = dlist(3);
|
||||
0110 <span class="keyword">end</span>;
|
||||
0111 <span class="keyword">if</span> 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 <span class="keyword">end</span>;
|
||||
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';</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,105 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of get_the_name</title>
|
||||
<meta name="keywords" content="get_the_name">
|
||||
<meta name="description" content="stephane.adjemian@cepremap.cnrs.fr [07-13-2004]">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > get_the_name.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>get_the_name
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>stephane.adjemian@cepremap.cnrs.fr [07-13-2004]</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function [nam,texnam] = get_the_name(k,TeX) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> stephane.adjemian@cepremap.cnrs.fr [07-13-2004]</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="McMCDiagnostics.html" class="code" title="function McmcDiagnostic">McMCDiagnostics</a> stephane.adjemian@ens.fr [06-04-2005]</li><li><a href="PlotPosteriorDistributions.html" class="code" title="function PlotPosteriorDistributions()">PlotPosteriorDistributions</a> stephane.adjemian@ens.fr [09-09-2005]</li><li><a href="mode_check.html" class="code" title="function mode_check(x,fval,hessian,gend,data,lb,ub)">mode_check</a> </li><li><a href="plot_priors.html" class="code" title="function plot_priors">plot_priors</a> stephane.adjemian@cepremap.cnrs.fr [07-31-2004]</li><li><a href="posterior_distribution.html" class="code" title="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);">posterior_distribution</a> stephane.adjemian@cepremap.cnrs.fr [07-15-2004]</li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [nam,texnam] = get_the_name(k,TeX)</a>
|
||||
0002 <span class="comment">% stephane.adjemian@cepremap.cnrs.fr [07-13-2004]</span>
|
||||
0003 <span class="keyword">global</span> 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 <span class="keyword">if</span> k <= nvx
|
||||
0014 vname = deblank(M_.exo_names(estim_params_.var_exo(k,1),:));
|
||||
0015 nam = [<span class="string">'SE_'</span>,vname];
|
||||
0016 <span class="keyword">if</span> TeX
|
||||
0017 tname = deblank(M_.exo_names_tex(estim_params_.var_exo(k,1),:));
|
||||
0018 texnam = [<span class="string">'$ SE_{'</span> tname <span class="string">'} $'</span>];
|
||||
0019 <span class="keyword">end</span>
|
||||
0020 <span class="keyword">elseif</span> k <= (nvx+nvn)
|
||||
0021 vname = deblank(options_.varobs(estim_params_.var_endo(k-estim_params_.nvx,1),:));
|
||||
0022 nam=[<span class="string">'SE_EOBS_'</span>,vname];
|
||||
0023 <span class="keyword">if</span> TeX
|
||||
0024 tname = deblank(options_.TeX_varobs(estim_params_.var_endo(k-estim_params_.nvx,1),:));
|
||||
0025 texnam = [<span class="string">'$ SE_{'</span> tname <span class="string">'} $'</span>];
|
||||
0026 <span class="keyword">end</span>
|
||||
0027 <span class="keyword">elseif</span> 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,:)) <span class="string">'_'</span> deblank(M_.exo_names(k2,:))];
|
||||
0032 nam=[<span class="string">'CC_'</span>,vname];
|
||||
0033 <span class="keyword">if</span> TeX
|
||||
0034 tname = [deblank(M_.exo_names_tex(k1,:)) <span class="string">','</span> deblank(M_.exo_names_tex(k2,:))];
|
||||
0035 texnam = [<span class="string">'$ CC_{'</span> tname <span class="string">'} $'</span>];
|
||||
0036 <span class="keyword">end</span>
|
||||
0037 <span class="keyword">elseif</span> 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,:)) <span class="string">'_'</span> deblank(M_.endo_names(k2,:))];
|
||||
0042 nam=[<span class="string">'CC_EOBS_'</span> vname];
|
||||
0043 <span class="keyword">if</span> TeX
|
||||
0044 tname = [deblank(M_.endo_names_tex(k1,:)) <span class="string">','</span> deblank(M_.endo_names_tex(k2,:))];
|
||||
0045 texnam =[<span class="string">'$ CC_{'</span> tname <span class="string">'} $'</span>];
|
||||
0046 <span class="keyword">end</span>
|
||||
0047 <span class="keyword">else</span>
|
||||
0048 jj = k - (nvx+nvn+ncx+ncn);
|
||||
0049 jj1 = estim_params_.param_vals(jj,1);
|
||||
0050 nam = deblank(M_.param_names(jj1,:));
|
||||
0051 <span class="keyword">if</span> TeX
|
||||
0052 texnam = [<span class="string">'$ '</span> deblank(M_.param_names_tex(jj1,:)) <span class="string">' $'</span>];
|
||||
0053 <span class="keyword">end</span>
|
||||
0054 <span class="keyword">end</span>
|
||||
0055
|
||||
0056
|
||||
0057 <span class="comment">% SA 07-15-2004 Added TeX names.</span>
|
||||
0058 <span class="comment">% SA 12-02-2004 Changed non-TeX names format.</span>
|
||||
0059 <span class="comment">% SA 01-11-2005 v3TOv4</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,67 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of global_initialization</title>
|
||||
<meta name="keywords" content="global_initialization">
|
||||
<meta name="description" content="">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > global_initialization.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>global_initialization
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong></strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function global_initialization() </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"></pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function global_initialization()</a>
|
||||
0002 <span class="keyword">global</span> 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 = [];</pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,491 +0,0 @@
|
|||
/* 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"];
|
||||
}
|
|
@ -1,213 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Dependency Graph for .</title>
|
||||
<meta name="keywords" content="dependency, graph, dependence, .">
|
||||
<meta name="description" content="Dependency graph for .">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>
|
||||
<h1>Dependency Graph for .</h1>
|
||||
|
||||
<center>
|
||||
<img src="graph.png" usemap="#mainmap" alt="Dependency Graph for ." border="2" style="color:#000;">
|
||||
<map name="mainmap">
|
||||
<area shape="rect" href="CutSample.html" title="CutSample" alt="" coords="2892,198,3009,246">
|
||||
<area shape="rect" href="CheckPath.html" title="CheckPath" alt="" coords="2229,486,2344,534">
|
||||
<area shape="rect" href="DiffuseKalmanSmoother1.html" title="DiffuseKalmanSmoother1" alt="" coords="7239,294,7471,342">
|
||||
<area shape="rect" href="steady.html" title="steady" alt="" coords="7051,390,7133,438">
|
||||
<area shape="rect" href="set_default_option.html" title="set_default_option" alt="" coords="6375,870,6548,918">
|
||||
<area shape="rect" href="steady_.html" title="steady_" alt="" coords="6803,486,6893,534">
|
||||
<area shape="rect" href="DiffuseKalmanSmoother3.html" title="DiffuseKalmanSmoother3" alt="" coords="7495,294,7727,342">
|
||||
<area shape="rect" href="DiffuseKalmanSmootherH1.html" title="DiffuseKalmanSmootherH1" alt="" coords="6700,294,6945,342">
|
||||
<area shape="rect" href="DiffuseKalmanSmootherH3.html" title="DiffuseKalmanSmootherH3" alt="" coords="6969,294,7215,342">
|
||||
<area shape="rect" href="DiffuseKalmanSmootherH3corr.html" title="DiffuseKalmanSmootherH3corr" alt="" coords="7751,294,8025,342">
|
||||
<area shape="rect" href="DsgeLikelihood.html" title="DsgeLikelihood" alt="" coords="3771,294,3928,342">
|
||||
<area shape="rect" href="DiffuseLikelihood3.html" title="DiffuseLikelihood3" alt="" coords="3813,390,3997,438">
|
||||
<area shape="rect" href="DiffuseLikelihoodH1.html" title="DiffuseLikelihoodH1" alt="" coords="4021,390,4219,438">
|
||||
<area shape="rect" href="DiffuseLikelihoodH3.html" title="DiffuseLikelihoodH3" alt="" coords="4243,390,4440,438">
|
||||
<area shape="rect" href="DiffuseLikelihoodH3corr.html" title="DiffuseLikelihoodH3corr" alt="" coords="3403,390,3629,438">
|
||||
<area shape="rect" href="dynare_resolve.html" title="dynare_resolve" alt="" coords="3829,486,3979,534">
|
||||
<area shape="rect" href="kalman_filter.html" title="kalman_filter" alt="" coords="3653,390,3789,438">
|
||||
<area shape="rect" href="lyapunov_symm.html" title="lyapunov_symm" alt="" coords="5235,582,5395,630">
|
||||
<area shape="rect" href="priordens.html" title="priordens" alt="" coords="5016,390,5123,438">
|
||||
<area shape="rect" href="resol.html" title="resol" alt="" coords="4715,678,4787,726">
|
||||
<area shape="rect" href="kalman_transition_matrix.html" title="kalman_transition_matrix" alt="" coords="4621,582,4848,630">
|
||||
<area shape="rect" href="my_ordeig.html" title="my_ordeig" alt="" coords="5257,678,5372,726">
|
||||
<area shape="rect" href="lpdfgam.html" title="lpdfgam" alt="" coords="1312,486,1408,534">
|
||||
<area shape="rect" href="lpdfgbeta.html" title="lpdfgbeta" alt="" coords="4973,486,5077,534">
|
||||
<area shape="rect" href="lpdfig1.html" title="lpdfig1" alt="" coords="5101,486,5189,534">
|
||||
<area shape="rect" href="lpdfig2.html" title="lpdfig2" alt="" coords="5213,486,5301,534">
|
||||
<area shape="rect" href="lpdfnorm.html" title="lpdfnorm" alt="" coords="5325,486,5429,534">
|
||||
<area shape="rect" href="DsgeSmoother.html" title="DsgeSmoother" alt="" coords="5301,198,5448,246">
|
||||
<area shape="rect" href="set_all_parameters.html" title="set_all_parameters" alt="" coords="5123,294,5296,342">
|
||||
<area shape="rect" href="GetAllPosteriorDraws.html" title="GetAllPosteriorDraws" alt="" coords="2024,390,2224,438">
|
||||
<area shape="rect" href="GetOneDraw.html" title="GetOneDraw" alt="" coords="3479,294,3612,342">
|
||||
<area shape="rect" href="metropolis_draw.html" title="metropolis_draw" alt="" coords="3168,390,3328,438">
|
||||
<area shape="rect" href="GetPosteriorParametersStatistics.html" title="GetPosteriorParametersStatistics" alt="" coords="2319,198,2596,246">
|
||||
<area shape="rect" href="posterior_moments.html" title="posterior_moments" alt="" coords="2803,294,2981,342">
|
||||
<area shape="rect" href="kernel_density_estimate.html" title="kernel_density_estimate" alt="" coords="2637,390,2853,438">
|
||||
<area shape="rect" href="mh_optimal_bandwidth.html" title="mh_optimal_bandwidth" alt="" coords="2400,390,2613,438">
|
||||
<area shape="rect" href="McMCDiagnostics.html" title="McMCDiagnostics" alt="" coords="1743,198,1921,246">
|
||||
<area shape="rect" href="get_the_name.html" title="get_the_name" alt="" coords="1869,294,2008,342">
|
||||
<area shape="rect" href="PlotPosteriorDistributions.html" title="PlotPosteriorDistributions" alt="" coords="1297,198,1527,246">
|
||||
<area shape="rect" href="draw_prior_density.html" title="draw_prior_density" alt="" coords="1152,294,1333,342">
|
||||
<area shape="rect" href="mj_qgamma.html" title="mj_qgamma" alt="" coords="1053,390,1181,438">
|
||||
<area shape="rect" href="qbeta.html" title="qbeta" alt="" coords="1205,390,1280,438">
|
||||
<area shape="rect" href="qgamma.html" title="qgamma" alt="" coords="931,390,1029,438">
|
||||
<area shape="rect" href="qnorm.html" title="qnorm" alt="" coords="824,390,907,438">
|
||||
<area shape="rect" href="PosteriorIRF.html" title="PosteriorIRF" alt="" coords="3223,198,3353,246">
|
||||
<area shape="rect" href="ReshapeMatFiles.html" title="ReshapeMatFiles" alt="" coords="2877,390,3043,438">
|
||||
<area shape="rect" href="irf.html" title="irf" alt="" coords="6715,390,6787,438">
|
||||
<area shape="rect" href="set_parameters.html" title="set_parameters" alt="" coords="3117,294,3264,342">
|
||||
<area shape="rect" href="simult_.html" title="simult_" alt="" coords="6499,486,6589,534">
|
||||
<area shape="rect" href="dr1.html" title="dr1" alt="" coords="4591,774,4663,822">
|
||||
<area shape="rect" href="resid.html" title="resid" alt="" coords="4711,870,4783,918">
|
||||
<area shape="rect" href="dynare_solve.html" title="dynare_solve" alt="" coords="5987,774,6120,822">
|
||||
<area shape="rect" href="PosteriorSmoother.html" title="PosteriorSmoother" alt="" coords="4676,102,4849,150">
|
||||
<area shape="rect" href="UnivariateSpectralDensity.html" title="UnivariateSpectralDensity" alt="" coords="4621,486,4853,534">
|
||||
<area shape="rect" href="beta_rnd.html" title="beta_rnd" alt="" coords="8567,102,8668,150">
|
||||
<area shape="rect" href="gamm_rnd.html" title="gamm_rnd" alt="" coords="8605,198,8720,246">
|
||||
<area shape="rect" href="bksup.html" title="bksup" alt="" coords="6393,294,6473,342">
|
||||
<area shape="rect" href="selif.html" title="selif" alt="" coords="8211,390,8283,438">
|
||||
<area shape="rect" href="bksup1.html" title="bksup1" alt="" coords="6279,294,6369,342">
|
||||
<area shape="rect" href="bksupk.html" title="bksupk" alt="" coords="8201,294,8292,342">
|
||||
<area shape="rect" href="calib.html" title="calib" alt="" coords="4616,390,4688,438">
|
||||
<area shape="rect" href="calib_obj.html" title="calib_obj" alt="" coords="4104,486,4208,534">
|
||||
<area shape="rect" href="calib_obj2.html" title="calib_obj2" alt="" coords="4283,486,4395,534">
|
||||
<area shape="rect" href="indnv.html" title="indnv" alt="" coords="4469,486,4547,534">
|
||||
<area shape="rect" href="union.html" title="union" alt="" coords="5629,966,5707,1014">
|
||||
<area shape="rect" href="bicgstab.html" title="bicgstab" alt="" coords="4209,582,4308,630">
|
||||
<area shape="rect" href="f_var.html" title="f_var" alt="" coords="4111,582,4185,630">
|
||||
<area shape="rect" href="check.html" title="check" alt="" coords="6229,582,6307,630">
|
||||
<area shape="rect" href="print_info.html" title="print_info" alt="" coords="6213,678,6323,726">
|
||||
<area shape="rect" href="check_mh.html" title="check_mh" alt="" coords="8777,6,8889,54">
|
||||
<area shape="rect" href="my_subplot.html" title="my_subplot" alt="" coords="8772,102,8895,150">
|
||||
<area shape="rect" href="compDist.html" title="compDist" alt="" coords="1357,294,1464,342">
|
||||
<area shape="rect" href="posterior_density_estimate.html" title="posterior_density_estimate" alt="" coords="1405,390,1643,438">
|
||||
<area shape="rect" href="pgamma.html" title="pgamma" alt="" coords="753,486,855,534">
|
||||
<area shape="rect" href="dbeta.html" title="dbeta" alt="" coords="1205,486,1280,534">
|
||||
<area shape="rect" href="dgamma.html" title="dgamma" alt="" coords="931,486,1029,534">
|
||||
<area shape="rect" href="csminwel.html" title="csminwel" alt="" coords="193,198,300,246">
|
||||
<area shape="rect" href="bfgsi.html" title="bfgsi" alt="" coords="56,294,128,342">
|
||||
<area shape="rect" href="csminit.html" title="csminit" alt="" coords="325,390,416,438">
|
||||
<area shape="rect" href="numgrad.html" title="numgrad" alt="" coords="152,294,253,342">
|
||||
<area shape="rect" href="dcompare.html" title="dcompare" alt="" coords="8913,6,9023,54">
|
||||
<area shape="rect" href="bseastr.html" title="bseastr" alt="" coords="8924,102,9012,150">
|
||||
<area shape="rect" href="ftest.html" title="ftest" alt="" coords="9065,102,9137,150">
|
||||
<area shape="rect" href="disp_moments.html" title="disp_moments" alt="" coords="6189,390,6333,438">
|
||||
<area shape="rect" href="table.html" title="table" alt="" coords="6011,486,6083,534">
|
||||
<area shape="rect" href="disp_th_moments.html" title="disp_th_moments" alt="" coords="5832,390,6000,438">
|
||||
<area shape="rect" href="th_autocovariances.html" title="th_autocovariances" alt="" coords="5453,486,5632,534">
|
||||
<area shape="rect" href="dlognorm.html" title="dlognorm" alt="" coords="9316,6,9423,54">
|
||||
<area shape="rect" href="dnorm.html" title="dnorm" alt="" coords="9328,102,9411,150">
|
||||
<area shape="rect" href="hessian.html" title="hessian" alt="" coords="408,870,499,918">
|
||||
<area shape="rect" href="qzdiv.html" title="qzdiv" alt="" coords="4807,870,4884,918">
|
||||
<area shape="rect" href="set_state_space.html" title="set_state_space" alt="" coords="5593,870,5743,918">
|
||||
<area shape="rect" href="sylvester3.html" title="sylvester3" alt="" coords="4433,870,4543,918">
|
||||
<area shape="rect" href="sylvester3a.html" title="sylvester3a" alt="" coords="4567,870,4687,918">
|
||||
<area shape="rect" href="transition_matrix.html" title="transition_matrix" alt="" coords="4247,870,4409,918">
|
||||
<area shape="rect" href="qzswitch.html" title="qzswitch" alt="" coords="4795,966,4896,1014">
|
||||
<area shape="rect" href="dr11.html" title="dr11" alt="" coords="5693,774,5765,822">
|
||||
<area shape="rect" href="dr2.html" title="dr2" alt="" coords="4568,678,4640,726">
|
||||
<area shape="rect" href="dynare_MC.html" title="dynare_MC" alt="" coords="5087,102,5209,150">
|
||||
<area shape="rect" href="prior_bounds.html" title="prior_bounds" alt="" coords="992,294,1128,342">
|
||||
<area shape="rect" href="read_variables.html" title="read_variables" alt="" coords="5523,198,5667,246">
|
||||
<area shape="rect" href="set_prior.html" title="set_prior" alt="" coords="4827,198,4928,246">
|
||||
<area shape="rect" href="inverse_gamma_specification.html" title="inverse_gamma_specification" alt="" coords="4789,294,5048,342">
|
||||
<area shape="rect" href="uniform_specification.html" title="uniform_specification" alt="" coords="4565,294,4765,342">
|
||||
<area shape="rect" href="dynare_estimation.html" title="dynare_estimation" alt="" coords="2615,102,2788,150">
|
||||
<area shape="rect" href="asamin.html" title="asamin" alt="" coords="948,198,1036,246">
|
||||
<area shape="rect" href="generalized_cholesky.html" title="generalized_cholesky" alt="" coords="2671,198,2868,246">
|
||||
<area shape="rect" href="initial_estimation_checks.html" title="initial_estimation_checks" alt="" coords="3479,198,3705,246">
|
||||
<area shape="rect" href="marginal_density.html" title="marginal_density" alt="" coords="1060,198,1223,246">
|
||||
<area shape="rect" href="metropolis.html" title="metropolis" alt="" coords="3033,198,3148,246">
|
||||
<area shape="rect" href="mode_check.html" title="mode_check" alt="" coords="1945,198,2073,246">
|
||||
<area shape="rect" href="newrat.html" title="newrat" alt="" coords="524,198,609,246">
|
||||
<area shape="rect" href="plot_priors.html" title="plot_priors" alt="" coords="1601,198,1719,246">
|
||||
<area shape="rect" href="pltorg.html" title="pltorg" alt="" coords="1869,390,1949,438">
|
||||
<area shape="rect" href="rows.html" title="rows" alt="" coords="2299,294,2371,342">
|
||||
<area shape="rect" href="qchisq.html" title="qchisq" alt="" coords="885,294,968,342">
|
||||
<area shape="rect" href="mr_gstep.html" title="mr_gstep" alt="" coords="328,294,432,342">
|
||||
<area shape="rect" href="mr_hessian.html" title="mr_hessian" alt="" coords="507,294,627,342">
|
||||
<area shape="rect" href="dynare_sensitivity.html" title="dynare_sensitivity" alt="" coords="4787,6,4957,54">
|
||||
<area shape="rect" href="filt_mc_.html" title="filt_mc_" alt="" coords="4068,102,4167,150">
|
||||
<area shape="rect" href="stab_map_.html" title="stab_map_" alt="" coords="4537,102,4652,150">
|
||||
<area shape="rect" href="cumplot.html" title="cumplot" alt="" coords="4224,294,4320,342">
|
||||
<area shape="rect" href="smirnov.html" title="smirnov" alt="" coords="4104,294,4200,342">
|
||||
<area shape="rect" href="stab_map_2.html" title="stab_map_2" alt="" coords="4155,198,4280,246">
|
||||
<area shape="rect" href="lptauSEQ.html" title="lptauSEQ" alt="" coords="4555,198,4661,246">
|
||||
<area shape="rect" href="stab_map_1.html" title="stab_map_1" alt="" coords="4405,198,4531,246">
|
||||
<area shape="rect" href="stoch_simul.html" title="stoch_simul" alt="" coords="5584,294,5709,342">
|
||||
<area shape="rect" href="solve1.html" title="solve1" alt="" coords="6116,870,6199,918">
|
||||
<area shape="rect" href="lnsrch1.html" title="lnsrch1" alt="" coords="6549,966,6640,1014">
|
||||
<area shape="rect" href="fgamma.html" title="fgamma" alt="" coords="704,390,800,438">
|
||||
<area shape="rect" href="figamm.html" title="figamm" alt="" coords="587,390,680,438">
|
||||
<area shape="rect" href="fnorm.html" title="fnorm" alt="" coords="9447,6,9527,54">
|
||||
<area shape="rect" href="pnorm.html" title="pnorm" alt="" coords="9444,102,9529,150">
|
||||
<area shape="rect" href="forcst.html" title="forcst" alt="" coords="6548,294,6625,342">
|
||||
<area shape="rect" href="make_ex_.html" title="make_ex_" alt="" coords="6811,390,6923,438">
|
||||
<area shape="rect" href="gcompare.html" title="gcompare" alt="" coords="9047,6,9156,54">
|
||||
<area shape="rect" href="initvalf_.html" title="initvalf_" alt="" coords="9551,6,9649,54">
|
||||
<area shape="rect" href="dy_date.html" title="dy_date" alt="" coords="9553,102,9647,150">
|
||||
<area shape="rect" href="lnsrch.html" title="lnsrch" alt="" coords="6293,486,6373,534">
|
||||
<area shape="rect" href="LPTAU.html" title="LPTAU" alt="" coords="4344,294,4440,342">
|
||||
<area shape="rect" href="make_y_.html" title="make_y_" alt="" coords="7547,774,7651,822">
|
||||
<area shape="rect" href="mcompare.html" title="mcompare" alt="" coords="9180,6,9292,54">
|
||||
<area shape="rect" href="mgnldnsty.html" title="mgnldnsty" alt="" coords="9785,6,9897,54">
|
||||
<area shape="rect" href="matrictint.html" title="matrictint" alt="" coords="9671,102,9777,150">
|
||||
<area shape="rect" href="rfvar3.html" title="rfvar3" alt="" coords="9801,102,9881,150">
|
||||
<area shape="rect" href="varprior.html" title="varprior" alt="" coords="9905,102,9999,150">
|
||||
<area shape="rect" href="olr.html" title="olr" alt="" coords="6081,294,6153,342">
|
||||
<area shape="rect" href="disp_dr.html" title="disp_dr" alt="" coords="6075,390,6165,438">
|
||||
<area shape="rect" href="dyn2vec.html" title="dyn2vec" alt="" coords="5709,390,5808,438">
|
||||
<area shape="rect" href="olr1.html" title="olr1" alt="" coords="6127,486,6199,534">
|
||||
<area shape="rect" href="simult.html" title="simult" alt="" coords="6408,390,6488,438">
|
||||
<area shape="rect" href="olr2.html" title="olr2" alt="" coords="5840,774,5912,822">
|
||||
<area shape="rect" href="osr.html" title="osr" alt="" coords="5935,294,6007,342">
|
||||
<area shape="rect" href="osr1.html" title="osr1" alt="" coords="4877,486,4949,534">
|
||||
<area shape="rect" href="osr_obj.html" title="osr_obj" alt="" coords="4872,582,4963,630">
|
||||
<area shape="rect" href="p2toperc.html" title="p2toperc" alt="" coords="701,294,803,342">
|
||||
<area shape="rect" href="fbeta.html" title="fbeta" alt="" coords="491,390,563,438">
|
||||
<area shape="rect" href="posterior_distribution.html" title="posterior_distribution" alt="" coords="2097,198,2295,246">
|
||||
<area shape="rect" href="resol1.html" title="resol1" alt="" coords="5651,678,5733,726">
|
||||
<area shape="rect" href="rndprior.html" title="rndprior" alt="" coords="8628,6,8724,54">
|
||||
<area shape="rect" href="sim1.html" title="sim1" alt="" coords="6344,198,6416,246">
|
||||
<area shape="rect" href="simk.html" title="simk" alt="" coords="8263,198,8335,246">
|
||||
<area shape="rect" href="ffill.html" title="ffill" alt="" coords="8316,294,8388,342">
|
||||
<area shape="rect" href="simul.html" title="simul" alt="" coords="6472,102,6549,150">
|
||||
<area shape="rect" href="check_model.html" title="check_model" alt="" coords="5400,390,5533,438">
|
||||
<area shape="rect" href="stab_map_marginal.html" title="stab_map_marginal" alt="" coords="2547,294,2728,342">
|
||||
<area shape="rect" href="CreateBenchmark.html" title="CreateBenchmark" alt="" coords="9921,6,10089,54">
|
||||
<area shape="rect" href="DiffuseLikelihood1.html" title="DiffuseLikelihood1" alt="" coords="10113,6,10297,54">
|
||||
<area shape="rect" href="InitSeed.html" title="InitSeed" alt="" coords="10321,6,10417,54">
|
||||
<area shape="rect" href="MakeAllFigures.html" title="MakeAllFigures" alt="" coords="10441,6,10599,54">
|
||||
<area shape="rect" href="datatomfile.html" title="datatomfile" alt="" coords="10623,6,10743,54">
|
||||
<area shape="rect" href="dsample.html" title="dsample" alt="" coords="10767,6,10863,54">
|
||||
<area shape="rect" href="dynare.html" title="dynare" alt="" coords="10887,6,10972,54">
|
||||
<area shape="rect" href="dynasave.html" title="dynasave" alt="" coords="10996,6,11100,54">
|
||||
<area shape="rect" href="dynatype.html" title="dynatype" alt="" coords="11124,6,11228,54">
|
||||
<area shape="rect" href="ff1_.html" title="ff1_" alt="" coords="11252,6,11324,54">
|
||||
<area shape="rect" href="gendata.html" title="gendata" alt="" coords="11348,6,11441,54">
|
||||
<area shape="rect" href="generalized_cholesky2.html" title="generalized_cholesky2" alt="" coords="11465,6,11671,54">
|
||||
<area shape="rect" href="global_initialization.html" title="global_initialization" alt="" coords="11695,6,11879,54">
|
||||
<area shape="rect" href="hessian_sparse.html" title="hessian_sparse" alt="" coords="11903,6,12049,54">
|
||||
<area shape="rect" href="kalman_smoother.html" title="kalman_smoother" alt="" coords="12073,6,12241,54">
|
||||
<area shape="rect" href="lpdfbeta.html" title="lpdfbeta" alt="" coords="12265,6,12361,54">
|
||||
<area shape="rect" href="recursive_moments.html" title="recursive_moments" alt="" coords="12385,6,12567,54">
|
||||
<area shape="rect" href="rplot.html" title="rplot" alt="" coords="12591,6,12663,54">
|
||||
<area shape="rect" href="sec2hms.html" title="sec2hms" alt="" coords="12687,6,12785,54">
|
||||
<area shape="rect" href="set_shocks.html" title="set_shocks" alt="" coords="12809,6,12924,54">
|
||||
</map>
|
||||
</center>
|
||||
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:02 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,186 +0,0 @@
|
|||
<area shape="rect" href="CutSample.html" title="CutSample" alt="" coords="2892,198,3009,246">
|
||||
<area shape="rect" href="CheckPath.html" title="CheckPath" alt="" coords="2229,486,2344,534">
|
||||
<area shape="rect" href="DiffuseKalmanSmoother1.html" title="DiffuseKalmanSmoother1" alt="" coords="7239,294,7471,342">
|
||||
<area shape="rect" href="steady.html" title="steady" alt="" coords="7051,390,7133,438">
|
||||
<area shape="rect" href="set_default_option.html" title="set_default_option" alt="" coords="6375,870,6548,918">
|
||||
<area shape="rect" href="steady_.html" title="steady_" alt="" coords="6803,486,6893,534">
|
||||
<area shape="rect" href="DiffuseKalmanSmoother3.html" title="DiffuseKalmanSmoother3" alt="" coords="7495,294,7727,342">
|
||||
<area shape="rect" href="DiffuseKalmanSmootherH1.html" title="DiffuseKalmanSmootherH1" alt="" coords="6700,294,6945,342">
|
||||
<area shape="rect" href="DiffuseKalmanSmootherH3.html" title="DiffuseKalmanSmootherH3" alt="" coords="6969,294,7215,342">
|
||||
<area shape="rect" href="DiffuseKalmanSmootherH3corr.html" title="DiffuseKalmanSmootherH3corr" alt="" coords="7751,294,8025,342">
|
||||
<area shape="rect" href="DsgeLikelihood.html" title="DsgeLikelihood" alt="" coords="3771,294,3928,342">
|
||||
<area shape="rect" href="DiffuseLikelihood3.html" title="DiffuseLikelihood3" alt="" coords="3813,390,3997,438">
|
||||
<area shape="rect" href="DiffuseLikelihoodH1.html" title="DiffuseLikelihoodH1" alt="" coords="4021,390,4219,438">
|
||||
<area shape="rect" href="DiffuseLikelihoodH3.html" title="DiffuseLikelihoodH3" alt="" coords="4243,390,4440,438">
|
||||
<area shape="rect" href="DiffuseLikelihoodH3corr.html" title="DiffuseLikelihoodH3corr" alt="" coords="3403,390,3629,438">
|
||||
<area shape="rect" href="dynare_resolve.html" title="dynare_resolve" alt="" coords="3829,486,3979,534">
|
||||
<area shape="rect" href="kalman_filter.html" title="kalman_filter" alt="" coords="3653,390,3789,438">
|
||||
<area shape="rect" href="lyapunov_symm.html" title="lyapunov_symm" alt="" coords="5235,582,5395,630">
|
||||
<area shape="rect" href="priordens.html" title="priordens" alt="" coords="5016,390,5123,438">
|
||||
<area shape="rect" href="resol.html" title="resol" alt="" coords="4715,678,4787,726">
|
||||
<area shape="rect" href="kalman_transition_matrix.html" title="kalman_transition_matrix" alt="" coords="4621,582,4848,630">
|
||||
<area shape="rect" href="my_ordeig.html" title="my_ordeig" alt="" coords="5257,678,5372,726">
|
||||
<area shape="rect" href="lpdfgam.html" title="lpdfgam" alt="" coords="1312,486,1408,534">
|
||||
<area shape="rect" href="lpdfgbeta.html" title="lpdfgbeta" alt="" coords="4973,486,5077,534">
|
||||
<area shape="rect" href="lpdfig1.html" title="lpdfig1" alt="" coords="5101,486,5189,534">
|
||||
<area shape="rect" href="lpdfig2.html" title="lpdfig2" alt="" coords="5213,486,5301,534">
|
||||
<area shape="rect" href="lpdfnorm.html" title="lpdfnorm" alt="" coords="5325,486,5429,534">
|
||||
<area shape="rect" href="DsgeSmoother.html" title="DsgeSmoother" alt="" coords="5301,198,5448,246">
|
||||
<area shape="rect" href="set_all_parameters.html" title="set_all_parameters" alt="" coords="5123,294,5296,342">
|
||||
<area shape="rect" href="GetAllPosteriorDraws.html" title="GetAllPosteriorDraws" alt="" coords="2024,390,2224,438">
|
||||
<area shape="rect" href="GetOneDraw.html" title="GetOneDraw" alt="" coords="3479,294,3612,342">
|
||||
<area shape="rect" href="metropolis_draw.html" title="metropolis_draw" alt="" coords="3168,390,3328,438">
|
||||
<area shape="rect" href="GetPosteriorParametersStatistics.html" title="GetPosteriorParametersStatistics" alt="" coords="2319,198,2596,246">
|
||||
<area shape="rect" href="posterior_moments.html" title="posterior_moments" alt="" coords="2803,294,2981,342">
|
||||
<area shape="rect" href="kernel_density_estimate.html" title="kernel_density_estimate" alt="" coords="2637,390,2853,438">
|
||||
<area shape="rect" href="mh_optimal_bandwidth.html" title="mh_optimal_bandwidth" alt="" coords="2400,390,2613,438">
|
||||
<area shape="rect" href="McMCDiagnostics.html" title="McMCDiagnostics" alt="" coords="1743,198,1921,246">
|
||||
<area shape="rect" href="get_the_name.html" title="get_the_name" alt="" coords="1869,294,2008,342">
|
||||
<area shape="rect" href="PlotPosteriorDistributions.html" title="PlotPosteriorDistributions" alt="" coords="1297,198,1527,246">
|
||||
<area shape="rect" href="draw_prior_density.html" title="draw_prior_density" alt="" coords="1152,294,1333,342">
|
||||
<area shape="rect" href="mj_qgamma.html" title="mj_qgamma" alt="" coords="1053,390,1181,438">
|
||||
<area shape="rect" href="qbeta.html" title="qbeta" alt="" coords="1205,390,1280,438">
|
||||
<area shape="rect" href="qgamma.html" title="qgamma" alt="" coords="931,390,1029,438">
|
||||
<area shape="rect" href="qnorm.html" title="qnorm" alt="" coords="824,390,907,438">
|
||||
<area shape="rect" href="PosteriorIRF.html" title="PosteriorIRF" alt="" coords="3223,198,3353,246">
|
||||
<area shape="rect" href="ReshapeMatFiles.html" title="ReshapeMatFiles" alt="" coords="2877,390,3043,438">
|
||||
<area shape="rect" href="irf.html" title="irf" alt="" coords="6715,390,6787,438">
|
||||
<area shape="rect" href="set_parameters.html" title="set_parameters" alt="" coords="3117,294,3264,342">
|
||||
<area shape="rect" href="simult_.html" title="simult_" alt="" coords="6499,486,6589,534">
|
||||
<area shape="rect" href="dr1.html" title="dr1" alt="" coords="4591,774,4663,822">
|
||||
<area shape="rect" href="resid.html" title="resid" alt="" coords="4711,870,4783,918">
|
||||
<area shape="rect" href="dynare_solve.html" title="dynare_solve" alt="" coords="5987,774,6120,822">
|
||||
<area shape="rect" href="PosteriorSmoother.html" title="PosteriorSmoother" alt="" coords="4676,102,4849,150">
|
||||
<area shape="rect" href="UnivariateSpectralDensity.html" title="UnivariateSpectralDensity" alt="" coords="4621,486,4853,534">
|
||||
<area shape="rect" href="beta_rnd.html" title="beta_rnd" alt="" coords="8567,102,8668,150">
|
||||
<area shape="rect" href="gamm_rnd.html" title="gamm_rnd" alt="" coords="8605,198,8720,246">
|
||||
<area shape="rect" href="bksup.html" title="bksup" alt="" coords="6393,294,6473,342">
|
||||
<area shape="rect" href="selif.html" title="selif" alt="" coords="8211,390,8283,438">
|
||||
<area shape="rect" href="bksup1.html" title="bksup1" alt="" coords="6279,294,6369,342">
|
||||
<area shape="rect" href="bksupk.html" title="bksupk" alt="" coords="8201,294,8292,342">
|
||||
<area shape="rect" href="calib.html" title="calib" alt="" coords="4616,390,4688,438">
|
||||
<area shape="rect" href="calib_obj.html" title="calib_obj" alt="" coords="4104,486,4208,534">
|
||||
<area shape="rect" href="calib_obj2.html" title="calib_obj2" alt="" coords="4283,486,4395,534">
|
||||
<area shape="rect" href="indnv.html" title="indnv" alt="" coords="4469,486,4547,534">
|
||||
<area shape="rect" href="union.html" title="union" alt="" coords="5629,966,5707,1014">
|
||||
<area shape="rect" href="bicgstab.html" title="bicgstab" alt="" coords="4209,582,4308,630">
|
||||
<area shape="rect" href="f_var.html" title="f_var" alt="" coords="4111,582,4185,630">
|
||||
<area shape="rect" href="check.html" title="check" alt="" coords="6229,582,6307,630">
|
||||
<area shape="rect" href="print_info.html" title="print_info" alt="" coords="6213,678,6323,726">
|
||||
<area shape="rect" href="check_mh.html" title="check_mh" alt="" coords="8777,6,8889,54">
|
||||
<area shape="rect" href="my_subplot.html" title="my_subplot" alt="" coords="8772,102,8895,150">
|
||||
<area shape="rect" href="compDist.html" title="compDist" alt="" coords="1357,294,1464,342">
|
||||
<area shape="rect" href="posterior_density_estimate.html" title="posterior_density_estimate" alt="" coords="1405,390,1643,438">
|
||||
<area shape="rect" href="pgamma.html" title="pgamma" alt="" coords="753,486,855,534">
|
||||
<area shape="rect" href="dbeta.html" title="dbeta" alt="" coords="1205,486,1280,534">
|
||||
<area shape="rect" href="dgamma.html" title="dgamma" alt="" coords="931,486,1029,534">
|
||||
<area shape="rect" href="csminwel.html" title="csminwel" alt="" coords="193,198,300,246">
|
||||
<area shape="rect" href="bfgsi.html" title="bfgsi" alt="" coords="56,294,128,342">
|
||||
<area shape="rect" href="csminit.html" title="csminit" alt="" coords="325,390,416,438">
|
||||
<area shape="rect" href="numgrad.html" title="numgrad" alt="" coords="152,294,253,342">
|
||||
<area shape="rect" href="dcompare.html" title="dcompare" alt="" coords="8913,6,9023,54">
|
||||
<area shape="rect" href="bseastr.html" title="bseastr" alt="" coords="8924,102,9012,150">
|
||||
<area shape="rect" href="ftest.html" title="ftest" alt="" coords="9065,102,9137,150">
|
||||
<area shape="rect" href="disp_moments.html" title="disp_moments" alt="" coords="6189,390,6333,438">
|
||||
<area shape="rect" href="table.html" title="table" alt="" coords="6011,486,6083,534">
|
||||
<area shape="rect" href="disp_th_moments.html" title="disp_th_moments" alt="" coords="5832,390,6000,438">
|
||||
<area shape="rect" href="th_autocovariances.html" title="th_autocovariances" alt="" coords="5453,486,5632,534">
|
||||
<area shape="rect" href="dlognorm.html" title="dlognorm" alt="" coords="9316,6,9423,54">
|
||||
<area shape="rect" href="dnorm.html" title="dnorm" alt="" coords="9328,102,9411,150">
|
||||
<area shape="rect" href="hessian.html" title="hessian" alt="" coords="408,870,499,918">
|
||||
<area shape="rect" href="qzdiv.html" title="qzdiv" alt="" coords="4807,870,4884,918">
|
||||
<area shape="rect" href="set_state_space.html" title="set_state_space" alt="" coords="5593,870,5743,918">
|
||||
<area shape="rect" href="sylvester3.html" title="sylvester3" alt="" coords="4433,870,4543,918">
|
||||
<area shape="rect" href="sylvester3a.html" title="sylvester3a" alt="" coords="4567,870,4687,918">
|
||||
<area shape="rect" href="transition_matrix.html" title="transition_matrix" alt="" coords="4247,870,4409,918">
|
||||
<area shape="rect" href="qzswitch.html" title="qzswitch" alt="" coords="4795,966,4896,1014">
|
||||
<area shape="rect" href="dr11.html" title="dr11" alt="" coords="5693,774,5765,822">
|
||||
<area shape="rect" href="dr2.html" title="dr2" alt="" coords="4568,678,4640,726">
|
||||
<area shape="rect" href="dynare_MC.html" title="dynare_MC" alt="" coords="5087,102,5209,150">
|
||||
<area shape="rect" href="prior_bounds.html" title="prior_bounds" alt="" coords="992,294,1128,342">
|
||||
<area shape="rect" href="read_variables.html" title="read_variables" alt="" coords="5523,198,5667,246">
|
||||
<area shape="rect" href="set_prior.html" title="set_prior" alt="" coords="4827,198,4928,246">
|
||||
<area shape="rect" href="inverse_gamma_specification.html" title="inverse_gamma_specification" alt="" coords="4789,294,5048,342">
|
||||
<area shape="rect" href="uniform_specification.html" title="uniform_specification" alt="" coords="4565,294,4765,342">
|
||||
<area shape="rect" href="dynare_estimation.html" title="dynare_estimation" alt="" coords="2615,102,2788,150">
|
||||
<area shape="rect" href="asamin.html" title="asamin" alt="" coords="948,198,1036,246">
|
||||
<area shape="rect" href="generalized_cholesky.html" title="generalized_cholesky" alt="" coords="2671,198,2868,246">
|
||||
<area shape="rect" href="initial_estimation_checks.html" title="initial_estimation_checks" alt="" coords="3479,198,3705,246">
|
||||
<area shape="rect" href="marginal_density.html" title="marginal_density" alt="" coords="1060,198,1223,246">
|
||||
<area shape="rect" href="metropolis.html" title="metropolis" alt="" coords="3033,198,3148,246">
|
||||
<area shape="rect" href="mode_check.html" title="mode_check" alt="" coords="1945,198,2073,246">
|
||||
<area shape="rect" href="newrat.html" title="newrat" alt="" coords="524,198,609,246">
|
||||
<area shape="rect" href="plot_priors.html" title="plot_priors" alt="" coords="1601,198,1719,246">
|
||||
<area shape="rect" href="pltorg.html" title="pltorg" alt="" coords="1869,390,1949,438">
|
||||
<area shape="rect" href="rows.html" title="rows" alt="" coords="2299,294,2371,342">
|
||||
<area shape="rect" href="qchisq.html" title="qchisq" alt="" coords="885,294,968,342">
|
||||
<area shape="rect" href="mr_gstep.html" title="mr_gstep" alt="" coords="328,294,432,342">
|
||||
<area shape="rect" href="mr_hessian.html" title="mr_hessian" alt="" coords="507,294,627,342">
|
||||
<area shape="rect" href="dynare_sensitivity.html" title="dynare_sensitivity" alt="" coords="4787,6,4957,54">
|
||||
<area shape="rect" href="filt_mc_.html" title="filt_mc_" alt="" coords="4068,102,4167,150">
|
||||
<area shape="rect" href="stab_map_.html" title="stab_map_" alt="" coords="4537,102,4652,150">
|
||||
<area shape="rect" href="cumplot.html" title="cumplot" alt="" coords="4224,294,4320,342">
|
||||
<area shape="rect" href="smirnov.html" title="smirnov" alt="" coords="4104,294,4200,342">
|
||||
<area shape="rect" href="stab_map_2.html" title="stab_map_2" alt="" coords="4155,198,4280,246">
|
||||
<area shape="rect" href="lptauSEQ.html" title="lptauSEQ" alt="" coords="4555,198,4661,246">
|
||||
<area shape="rect" href="stab_map_1.html" title="stab_map_1" alt="" coords="4405,198,4531,246">
|
||||
<area shape="rect" href="stoch_simul.html" title="stoch_simul" alt="" coords="5584,294,5709,342">
|
||||
<area shape="rect" href="solve1.html" title="solve1" alt="" coords="6116,870,6199,918">
|
||||
<area shape="rect" href="lnsrch1.html" title="lnsrch1" alt="" coords="6549,966,6640,1014">
|
||||
<area shape="rect" href="fgamma.html" title="fgamma" alt="" coords="704,390,800,438">
|
||||
<area shape="rect" href="figamm.html" title="figamm" alt="" coords="587,390,680,438">
|
||||
<area shape="rect" href="fnorm.html" title="fnorm" alt="" coords="9447,6,9527,54">
|
||||
<area shape="rect" href="pnorm.html" title="pnorm" alt="" coords="9444,102,9529,150">
|
||||
<area shape="rect" href="forcst.html" title="forcst" alt="" coords="6548,294,6625,342">
|
||||
<area shape="rect" href="make_ex_.html" title="make_ex_" alt="" coords="6811,390,6923,438">
|
||||
<area shape="rect" href="gcompare.html" title="gcompare" alt="" coords="9047,6,9156,54">
|
||||
<area shape="rect" href="initvalf_.html" title="initvalf_" alt="" coords="9551,6,9649,54">
|
||||
<area shape="rect" href="dy_date.html" title="dy_date" alt="" coords="9553,102,9647,150">
|
||||
<area shape="rect" href="lnsrch.html" title="lnsrch" alt="" coords="6293,486,6373,534">
|
||||
<area shape="rect" href="LPTAU.html" title="LPTAU" alt="" coords="4344,294,4440,342">
|
||||
<area shape="rect" href="make_y_.html" title="make_y_" alt="" coords="7547,774,7651,822">
|
||||
<area shape="rect" href="mcompare.html" title="mcompare" alt="" coords="9180,6,9292,54">
|
||||
<area shape="rect" href="mgnldnsty.html" title="mgnldnsty" alt="" coords="9785,6,9897,54">
|
||||
<area shape="rect" href="matrictint.html" title="matrictint" alt="" coords="9671,102,9777,150">
|
||||
<area shape="rect" href="rfvar3.html" title="rfvar3" alt="" coords="9801,102,9881,150">
|
||||
<area shape="rect" href="varprior.html" title="varprior" alt="" coords="9905,102,9999,150">
|
||||
<area shape="rect" href="olr.html" title="olr" alt="" coords="6081,294,6153,342">
|
||||
<area shape="rect" href="disp_dr.html" title="disp_dr" alt="" coords="6075,390,6165,438">
|
||||
<area shape="rect" href="dyn2vec.html" title="dyn2vec" alt="" coords="5709,390,5808,438">
|
||||
<area shape="rect" href="olr1.html" title="olr1" alt="" coords="6127,486,6199,534">
|
||||
<area shape="rect" href="simult.html" title="simult" alt="" coords="6408,390,6488,438">
|
||||
<area shape="rect" href="olr2.html" title="olr2" alt="" coords="5840,774,5912,822">
|
||||
<area shape="rect" href="osr.html" title="osr" alt="" coords="5935,294,6007,342">
|
||||
<area shape="rect" href="osr1.html" title="osr1" alt="" coords="4877,486,4949,534">
|
||||
<area shape="rect" href="osr_obj.html" title="osr_obj" alt="" coords="4872,582,4963,630">
|
||||
<area shape="rect" href="p2toperc.html" title="p2toperc" alt="" coords="701,294,803,342">
|
||||
<area shape="rect" href="fbeta.html" title="fbeta" alt="" coords="491,390,563,438">
|
||||
<area shape="rect" href="posterior_distribution.html" title="posterior_distribution" alt="" coords="2097,198,2295,246">
|
||||
<area shape="rect" href="resol1.html" title="resol1" alt="" coords="5651,678,5733,726">
|
||||
<area shape="rect" href="rndprior.html" title="rndprior" alt="" coords="8628,6,8724,54">
|
||||
<area shape="rect" href="sim1.html" title="sim1" alt="" coords="6344,198,6416,246">
|
||||
<area shape="rect" href="simk.html" title="simk" alt="" coords="8263,198,8335,246">
|
||||
<area shape="rect" href="ffill.html" title="ffill" alt="" coords="8316,294,8388,342">
|
||||
<area shape="rect" href="simul.html" title="simul" alt="" coords="6472,102,6549,150">
|
||||
<area shape="rect" href="check_model.html" title="check_model" alt="" coords="5400,390,5533,438">
|
||||
<area shape="rect" href="stab_map_marginal.html" title="stab_map_marginal" alt="" coords="2547,294,2728,342">
|
||||
<area shape="rect" href="CreateBenchmark.html" title="CreateBenchmark" alt="" coords="9921,6,10089,54">
|
||||
<area shape="rect" href="DiffuseLikelihood1.html" title="DiffuseLikelihood1" alt="" coords="10113,6,10297,54">
|
||||
<area shape="rect" href="InitSeed.html" title="InitSeed" alt="" coords="10321,6,10417,54">
|
||||
<area shape="rect" href="MakeAllFigures.html" title="MakeAllFigures" alt="" coords="10441,6,10599,54">
|
||||
<area shape="rect" href="datatomfile.html" title="datatomfile" alt="" coords="10623,6,10743,54">
|
||||
<area shape="rect" href="dsample.html" title="dsample" alt="" coords="10767,6,10863,54">
|
||||
<area shape="rect" href="dynare.html" title="dynare" alt="" coords="10887,6,10972,54">
|
||||
<area shape="rect" href="dynasave.html" title="dynasave" alt="" coords="10996,6,11100,54">
|
||||
<area shape="rect" href="dynatype.html" title="dynatype" alt="" coords="11124,6,11228,54">
|
||||
<area shape="rect" href="ff1_.html" title="ff1_" alt="" coords="11252,6,11324,54">
|
||||
<area shape="rect" href="gendata.html" title="gendata" alt="" coords="11348,6,11441,54">
|
||||
<area shape="rect" href="generalized_cholesky2.html" title="generalized_cholesky2" alt="" coords="11465,6,11671,54">
|
||||
<area shape="rect" href="global_initialization.html" title="global_initialization" alt="" coords="11695,6,11879,54">
|
||||
<area shape="rect" href="hessian_sparse.html" title="hessian_sparse" alt="" coords="11903,6,12049,54">
|
||||
<area shape="rect" href="kalman_smoother.html" title="kalman_smoother" alt="" coords="12073,6,12241,54">
|
||||
<area shape="rect" href="lpdfbeta.html" title="lpdfbeta" alt="" coords="12265,6,12361,54">
|
||||
<area shape="rect" href="recursive_moments.html" title="recursive_moments" alt="" coords="12385,6,12567,54">
|
||||
<area shape="rect" href="rplot.html" title="rplot" alt="" coords="12591,6,12663,54">
|
||||
<area shape="rect" href="sec2hms.html" title="sec2hms" alt="" coords="12687,6,12785,54">
|
||||
<area shape="rect" href="set_shocks.html" title="set_shocks" alt="" coords="12809,6,12924,54">
|
Before Width: | Height: | Size: 189 KiB |
|
@ -1,99 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of hessian</title>
|
||||
<meta name="keywords" content="hessian">
|
||||
<meta name="description" content="Copyright (C) 2001 Michel Juillard">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > hessian.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>hessian
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>Copyright (C) 2001 Michel Juillard</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>function hessian_mat = hessian(func,x,varargin) </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> Copyright (C) 2001 Michel Juillard
|
||||
% computes second order partial derivatives
|
||||
uses Abramowitz and Stegun (1965) formulas 25.3.24 and 25.3.27 p. 884</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
<li><a href="dr1.html" class="code" title="function [dr,info]=dr1(dr,task)">dr1</a> Copyright (C) 2001 Michel Juillard</li><li><a href="dynare_estimation.html" class="code" title="function dynare_estimation(var_list_)">dynare_estimation</a> </li><li><a href="mode_check.html" class="code" title="function mode_check(x,fval,hessian,gend,data,lb,ub)">mode_check</a> </li></ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% Copyright (C) 2001 Michel Juillard</span>
|
||||
0002 <span class="comment">%% computes second order partial derivatives</span>
|
||||
0003 <span class="comment">% uses Abramowitz and Stegun (1965) formulas 25.3.24 and 25.3.27 p. 884</span>
|
||||
0004
|
||||
0005 <a name="_sub0" href="#_subfunctions" class="code">function hessian_mat = hessian(func,x,varargin)</a>
|
||||
0006 <span class="keyword">global</span> options_
|
||||
0007 func = str2func(func);
|
||||
0008 n=size(x,1);
|
||||
0009 <span class="comment">%h1=max(abs(x),options_.gstep*ones(n,1))*eps^(1/3);</span>
|
||||
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 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0028 xh_1=xh1;
|
||||
0029 hessian_mat = zeros(size(f0,1),n*n);
|
||||
0030 <span class="keyword">for</span> i=1:n
|
||||
0031 <span class="keyword">if</span> 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 <span class="keyword">end</span>
|
||||
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 <span class="keyword">for</span> 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 <span class="keyword">end</span>
|
||||
0049 i=i+1;
|
||||
0050 <span class="keyword">end</span>
|
||||
0051 <span class="comment">% 11/25/03 SA Created from Hessian_sparse (removed sparse)</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
|
@ -1,47 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
||||
"http://www.w3.org/TR/REC-html40/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>Description of hessian_sparse</title>
|
||||
<meta name="keywords" content="hessian_sparse">
|
||||
<meta name="description" content="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">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||||
<meta name="generator" content="m2html © 2003 Guillaume Flandin">
|
||||
<meta name="robots" content="index, follow">
|
||||
<link type="text/css" rel="stylesheet" href="../m2html.css">
|
||||
</head>
|
||||
<body>
|
||||
<a name="_top"></a>
|
||||
<div><a href="../index.html">Home</a> > <a href="index.html">.</a> > hessian_sparse.m</div>
|
||||
|
||||
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png"> Master index</a></td>
|
||||
<td align="right"><a href="index.html">Index for . <img alt=">" border="0" src="../right.png"></a></td></tr></table>-->
|
||||
|
||||
<h1>hessian_sparse
|
||||
</h1>
|
||||
|
||||
<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>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</strong></div>
|
||||
|
||||
<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="box"><strong>This is a script file. </strong></div>
|
||||
|
||||
<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre class="comment"> 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</pre></div>
|
||||
|
||||
<!-- crossreference -->
|
||||
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
This function calls:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
This function is called by:
|
||||
<ul style="list-style-image:url(../matlabicon.gif)">
|
||||
</ul>
|
||||
<!-- crossreference -->
|
||||
|
||||
|
||||
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
|
||||
<div class="fragment"><pre>0001 <span class="comment">% 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</span></pre></div>
|
||||
<hr><address>Generated on Fri 16-Jun-2006 09:09:06 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> © 2003</address>
|
||||
</body>
|
||||
</html>
|
Before Width: | Height: | Size: 255 B |