dynare/matlab/doc/calib_obj.html

114 lines
6.1 KiB
HTML

<!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 &copy; 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> &gt; <a href="index.html">.</a> &gt; calib_obj.m</div>
<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for .&nbsp;<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 &gt; 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 &lt; 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> &copy; 2003</address>
</body>
</html>