147 lines
8.2 KiB
HTML
147 lines
8.2 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 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> |