488 lines
32 KiB
HTML
488 lines
32 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 stab_map_</title>
|
||
|
<meta name="keywords" content="stab_map_">
|
||
|
<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> > stab_map_.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>stab_map_
|
||
|
</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 x0 = stab_map_(Nsam, fload, ksstat, alpha2, prepSA, pprior, ilptau, OutputDirectoryName) </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 x0 = stab_map_(Nsam, fload, alpha2, prepSA, pprior)
|
||
|
|
||
|
Mapping of stability regions in the prior ranges applying
|
||
|
Monte Carlo filtering techniques.
|
||
|
|
||
|
M. Ratto, Global Sensitivity Analysis for Macroeconomic models
|
||
|
I. Mapping stability, MIMEO, 2005.
|
||
|
|
||
|
INPUTS
|
||
|
Nsam = MC sample size
|
||
|
fload = 0 to run new MC; 1 to load prevoiusly generated analysis
|
||
|
alpha2 = significance level for bivariate sensitivity analysis
|
||
|
[abs(corrcoef) > alpha2]
|
||
|
prepSA = 1: save transition matrices for mapping reduced form
|
||
|
= 0: no transition matrix saved (default)
|
||
|
pprior = 1: sample from prior ranges (default): sample saved in
|
||
|
_prior.mat file
|
||
|
= 0: sample from posterior ranges: sample saved in
|
||
|
_mc.mat file
|
||
|
OUTPUT:
|
||
|
x0: one parameter vector for which the model is stable.
|
||
|
|
||
|
GRAPHS
|
||
|
1) Pdf's of marginal distributions under the stability (dotted
|
||
|
lines) and unstability (solid lines) regions
|
||
|
2) Cumulative distributions of:
|
||
|
- stable subset (dotted lines)
|
||
|
- unacceptable subset (solid lines)
|
||
|
3) Bivariate plots of significant correlation patterns
|
||
|
( abs(corrcoef) > alpha2) under the stable and unacceptable subsets
|
||
|
|
||
|
USES lptauSEQ,
|
||
|
stab_map_1, stab_map_2
|
||
|
|
||
|
Copyright (C) 2005 Marco Ratto
|
||
|
THIS PROGRAM WAS WRITTEN FOR MATLAB BY
|
||
|
Marco Ratto,
|
||
|
Unit of Econometrics and Statistics AF
|
||
|
(http://www.jrc.cec.eu.int/uasa/),
|
||
|
IPSC, Joint Research Centre
|
||
|
The European Commission,
|
||
|
TP 361, 21020 ISPRA(VA), ITALY
|
||
|
marco.ratto@jrc.it
|
||
|
|
||
|
ALL COPIES MUST BE PROVIDED FREE OF CHARGE AND MUST INCLUDE THIS COPYRIGHT
|
||
|
NOTICE.</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="lptauSEQ.html" class="code" title="function [lpmat] = lptauSEQ(Nsam,Nvar)">lptauSEQ</a> [lpmat] = lptauSEQ(Nsam,Nvar)</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><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="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</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 x0 = stab_map_(Nsam, fload, ksstat, alpha2, prepSA, pprior, ilptau, OutputDirectoryName)</a>
|
||
|
0002 <span class="comment">%</span>
|
||
|
0003 <span class="comment">% function x0 = stab_map_(Nsam, fload, alpha2, prepSA, pprior)</span>
|
||
|
0004 <span class="comment">%</span>
|
||
|
0005 <span class="comment">% Mapping of stability regions in the prior ranges applying</span>
|
||
|
0006 <span class="comment">% Monte Carlo filtering techniques.</span>
|
||
|
0007 <span class="comment">%</span>
|
||
|
0008 <span class="comment">% M. Ratto, Global Sensitivity Analysis for Macroeconomic models</span>
|
||
|
0009 <span class="comment">% I. Mapping stability, MIMEO, 2005.</span>
|
||
|
0010 <span class="comment">%</span>
|
||
|
0011 <span class="comment">% INPUTS</span>
|
||
|
0012 <span class="comment">% Nsam = MC sample size</span>
|
||
|
0013 <span class="comment">% fload = 0 to run new MC; 1 to load prevoiusly generated analysis</span>
|
||
|
0014 <span class="comment">% alpha2 = significance level for bivariate sensitivity analysis</span>
|
||
|
0015 <span class="comment">% [abs(corrcoef) > alpha2]</span>
|
||
|
0016 <span class="comment">% prepSA = 1: save transition matrices for mapping reduced form</span>
|
||
|
0017 <span class="comment">% = 0: no transition matrix saved (default)</span>
|
||
|
0018 <span class="comment">% pprior = 1: sample from prior ranges (default): sample saved in</span>
|
||
|
0019 <span class="comment">% _prior.mat file</span>
|
||
|
0020 <span class="comment">% = 0: sample from posterior ranges: sample saved in</span>
|
||
|
0021 <span class="comment">% _mc.mat file</span>
|
||
|
0022 <span class="comment">% OUTPUT:</span>
|
||
|
0023 <span class="comment">% x0: one parameter vector for which the model is stable.</span>
|
||
|
0024 <span class="comment">%</span>
|
||
|
0025 <span class="comment">% GRAPHS</span>
|
||
|
0026 <span class="comment">% 1) Pdf's of marginal distributions under the stability (dotted</span>
|
||
|
0027 <span class="comment">% lines) and unstability (solid lines) regions</span>
|
||
|
0028 <span class="comment">% 2) Cumulative distributions of:</span>
|
||
|
0029 <span class="comment">% - stable subset (dotted lines)</span>
|
||
|
0030 <span class="comment">% - unacceptable subset (solid lines)</span>
|
||
|
0031 <span class="comment">% 3) Bivariate plots of significant correlation patterns</span>
|
||
|
0032 <span class="comment">% ( abs(corrcoef) > alpha2) under the stable and unacceptable subsets</span>
|
||
|
0033 <span class="comment">%</span>
|
||
|
0034 <span class="comment">% USES lptauSEQ,</span>
|
||
|
0035 <span class="comment">% stab_map_1, stab_map_2</span>
|
||
|
0036 <span class="comment">%</span>
|
||
|
0037 <span class="comment">% Copyright (C) 2005 Marco Ratto</span>
|
||
|
0038 <span class="comment">% THIS PROGRAM WAS WRITTEN FOR MATLAB BY</span>
|
||
|
0039 <span class="comment">% Marco Ratto,</span>
|
||
|
0040 <span class="comment">% Unit of Econometrics and Statistics AF</span>
|
||
|
0041 <span class="comment">% (http://www.jrc.cec.eu.int/uasa/),</span>
|
||
|
0042 <span class="comment">% IPSC, Joint Research Centre</span>
|
||
|
0043 <span class="comment">% The European Commission,</span>
|
||
|
0044 <span class="comment">% TP 361, 21020 ISPRA(VA), ITALY</span>
|
||
|
0045 <span class="comment">% marco.ratto@jrc.it</span>
|
||
|
0046 <span class="comment">%</span>
|
||
|
0047 <span class="comment">% ALL COPIES MUST BE PROVIDED FREE OF CHARGE AND MUST INCLUDE THIS COPYRIGHT</span>
|
||
|
0048 <span class="comment">% NOTICE.</span>
|
||
|
0049 <span class="comment">%</span>
|
||
|
0050
|
||
|
0051 <span class="comment">%global bayestopt_ estim_params_ dr_ options_ ys_ fname_</span>
|
||
|
0052 <span class="keyword">global</span> bayestopt_ estim_params_ options_ oo_ M_
|
||
|
0053
|
||
|
0054 dr_ = oo_.dr;
|
||
|
0055 <span class="keyword">if</span> isfield(dr_,<span class="string">'ghx'</span>),
|
||
|
0056 ys_ = oo_.dr.ys;
|
||
|
0057 nspred = size(dr_.ghx,2);
|
||
|
0058 nboth = dr_.nboth;
|
||
|
0059 nfwrd = dr_.nfwrd;
|
||
|
0060 <span class="keyword">end</span>
|
||
|
0061 fname_ = M_.fname;
|
||
|
0062
|
||
|
0063 nshock = estim_params_.nvx;
|
||
|
0064 nshock = nshock + estim_params_.nvn;
|
||
|
0065 nshock = nshock + estim_params_.ncx;
|
||
|
0066 nshock = nshock + estim_params_.ncn;
|
||
|
0067
|
||
|
0068
|
||
|
0069 <span class="keyword">if</span> nargin==0,
|
||
|
0070 Nsam=2000; <span class="comment">%2^13; %256;</span>
|
||
|
0071 <span class="keyword">end</span>
|
||
|
0072 <span class="keyword">if</span> nargin<2,
|
||
|
0073 fload=0;
|
||
|
0074 <span class="keyword">end</span>
|
||
|
0075 <span class="keyword">if</span> nargin<3,
|
||
|
0076 ksstat=0.1;
|
||
|
0077 <span class="keyword">end</span>
|
||
|
0078 <span class="keyword">if</span> nargin<4,
|
||
|
0079 alpha2=0.3;
|
||
|
0080 <span class="keyword">end</span>
|
||
|
0081 <span class="keyword">if</span> nargin<5,
|
||
|
0082 prepSA=0;
|
||
|
0083 <span class="keyword">end</span>
|
||
|
0084 <span class="keyword">if</span> nargin<6,
|
||
|
0085 pprior=1;
|
||
|
0086 <span class="keyword">end</span>
|
||
|
0087 <span class="keyword">if</span> nargin<7,
|
||
|
0088 ilptau=1;
|
||
|
0089 <span class="keyword">end</span>
|
||
|
0090 <span class="keyword">if</span> nargin<8,
|
||
|
0091 OutputDirectoryName=<span class="string">''</span>;
|
||
|
0092 <span class="keyword">end</span>
|
||
|
0093
|
||
|
0094 options_.periods=0;
|
||
|
0095 options_.nomoments=1;
|
||
|
0096 options_.irf=0;
|
||
|
0097 options_.noprint=1;
|
||
|
0098
|
||
|
0099 <span class="keyword">if</span> fload==0 | nargin<2 | isempty(fload),
|
||
|
0100 <span class="keyword">if</span> prepSA
|
||
|
0101 T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),Nsam/2);
|
||
|
0102 <span class="keyword">end</span>
|
||
|
0103
|
||
|
0104
|
||
|
0105 <span class="keyword">if</span> estim_params_.np<52 & ilptau,
|
||
|
0106 [lpmat] = <a href="lptauSEQ.html" class="code" title="function [lpmat] = lptauSEQ(Nsam,Nvar)">lptauSEQ</a>(Nsam,estim_params_.np);
|
||
|
0107 <span class="keyword">if</span> estim_params_.np>30
|
||
|
0108 <span class="keyword">for</span> j=1:estim_params_.np,
|
||
|
0109 lpmat(:,j)=lpmat(randperm(Nsam),j);
|
||
|
0110 <span class="keyword">end</span>
|
||
|
0111 <span class="keyword">end</span>
|
||
|
0112 <span class="keyword">else</span>
|
||
|
0113 <span class="comment">%[lpmat] = rand(Nsam,estim_params_.np);</span>
|
||
|
0114 <span class="keyword">for</span> j=1:estim_params_.np,
|
||
|
0115 lpmat(:,j) = randperm(Nsam)'./(Nsam+1); <span class="comment">%latin hypercube</span>
|
||
|
0116 <span class="keyword">end</span>
|
||
|
0117 <span class="keyword">end</span>
|
||
|
0118
|
||
|
0119 <span class="keyword">if</span> pprior,
|
||
|
0120 <span class="keyword">for</span> j=1:nshock,
|
||
|
0121 lpmat0(:,j) = randperm(Nsam)'./(Nsam+1); <span class="comment">%latin hypercube</span>
|
||
|
0122 lpmat0(:,j)=lpmat0(:,j).*(bayestopt_.ub(j)-bayestopt_.lb(j))+bayestopt_.lb(j);
|
||
|
0123 <span class="keyword">end</span>
|
||
|
0124 <span class="keyword">for</span> j=1:estim_params_.np,
|
||
|
0125 lpmat(:,j)=lpmat(:,j).*(bayestopt_.ub(j+nshock)-bayestopt_.lb(j+nshock))+bayestopt_.lb(j+nshock);
|
||
|
0126 <span class="keyword">end</span>
|
||
|
0127 <span class="keyword">else</span>
|
||
|
0128 <span class="comment">% for j=1:nshock,</span>
|
||
|
0129 <span class="comment">% xparam1(j) = oo_.posterior_mode.shocks_std.(bayestopt_.name{j});</span>
|
||
|
0130 <span class="comment">% sd(j) = oo_.posterior_std.shocks_std.(bayestopt_.name{j});</span>
|
||
|
0131 <span class="comment">% lpmat0(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube</span>
|
||
|
0132 <span class="comment">% lb = max(bayestopt_.lb(j), xparam1(j)-2*sd(j));</span>
|
||
|
0133 <span class="comment">% ub1=xparam1(j)+(xparam1(j) - lb); % define symmetric range around the mode!</span>
|
||
|
0134 <span class="comment">% ub = min(bayestopt_.ub(j),ub1);</span>
|
||
|
0135 <span class="comment">% if ub<ub1,</span>
|
||
|
0136 <span class="comment">% lb=xparam1(j)-(ub-xparam1(j)); % define symmetric range around the mode!</span>
|
||
|
0137 <span class="comment">% end</span>
|
||
|
0138 <span class="comment">% lpmat0(:,j) = lpmat0(:,j).*(ub-lb)+lb;</span>
|
||
|
0139 <span class="comment">% end</span>
|
||
|
0140 <span class="comment">% %</span>
|
||
|
0141 <span class="comment">% for j=1:estim_params_.np,</span>
|
||
|
0142 <span class="comment">% xparam1(j+nshock) = oo_.posterior_mode.parameters.(bayestopt_.name{j+nshock});</span>
|
||
|
0143 <span class="comment">% sd(j+nshock) = oo_.posterior_std.parameters.(bayestopt_.name{j+nshock});</span>
|
||
|
0144 <span class="comment">% lb = max(bayestopt_.lb(j+nshock),xparam1(j+nshock)-2*sd(j+nshock));</span>
|
||
|
0145 <span class="comment">% ub1=xparam1(j+nshock)+(xparam1(j+nshock) - lb); % define symmetric range around the mode!</span>
|
||
|
0146 <span class="comment">% ub = min(bayestopt_.ub(j+nshock),ub1);</span>
|
||
|
0147 <span class="comment">% if ub<ub1,</span>
|
||
|
0148 <span class="comment">% lb=xparam1(j+nshock)-(ub-xparam1(j+nshock)); % define symmetric range around the mode!</span>
|
||
|
0149 <span class="comment">% end</span>
|
||
|
0150 <span class="comment">% %ub = min(bayestopt_.ub(j+nshock),xparam1(j+nshock)+2*sd(j+nshock));</span>
|
||
|
0151 <span class="comment">% if estim_params_.np>30 & estim_params_.np<52</span>
|
||
|
0152 <span class="comment">% lpmat(:,j) = lpmat(randperm(Nsam),j).*(ub-lb)+lb;</span>
|
||
|
0153 <span class="comment">% else</span>
|
||
|
0154 <span class="comment">% lpmat(:,j) = lpmat(:,j).*(ub-lb)+lb;</span>
|
||
|
0155 <span class="comment">% end</span>
|
||
|
0156 <span class="comment">% end</span>
|
||
|
0157 <span class="comment">%load([fname_,'_mode'])</span>
|
||
|
0158 eval([<span class="string">'load '</span> options_.mode_file <span class="string">';'</span>]');
|
||
|
0159 d = chol(inv(hh));
|
||
|
0160 lp=randn(Nsam*2,nshock+estim_params_.np)*d+kron(ones(Nsam*2,1),xparam1');
|
||
|
0161 <span class="keyword">for</span> j=1:Nsam*2,
|
||
|
0162 lnprior(j) = any(lp(j,:)'<=bayestopt_.lb | lp(j,:)'>=bayestopt_.ub);
|
||
|
0163 <span class="keyword">end</span>
|
||
|
0164 ireal=[1:2*Nsam];
|
||
|
0165 ireal=ireal(find(lnprior==0));
|
||
|
0166 lp=lp(ireal,:);
|
||
|
0167 Nsam=min(Nsam, length(ireal));
|
||
|
0168 lpmat0=lp(1:Nsam,1:nshock);
|
||
|
0169 lpmat=lp(1:Nsam,nshock+1:end);
|
||
|
0170 clear lp lnprior ireal;
|
||
|
0171 <span class="keyword">end</span>
|
||
|
0172 <span class="comment">%</span>
|
||
|
0173 h = waitbar(0,<span class="string">'Please wait...'</span>);
|
||
|
0174 istable=[1:Nsam];
|
||
|
0175 jstab=0;
|
||
|
0176 iunstable=[1:Nsam];
|
||
|
0177 iindeterm=zeros(1,Nsam);
|
||
|
0178 iwrong=zeros(1,Nsam);
|
||
|
0179 <span class="keyword">for</span> j=1:Nsam,
|
||
|
0180 M_.params(estim_params_.param_vals(:,1)) = lpmat(j,:)';
|
||
|
0181 <a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a>([]);
|
||
|
0182 dr_ = oo_.dr;
|
||
|
0183 <span class="keyword">if</span> isfield(dr_,<span class="string">'ghx'</span>),
|
||
|
0184 egg(:,j) = sort(dr_.eigval);
|
||
|
0185 iunstable(j)=0;
|
||
|
0186 <span class="keyword">if</span> prepSA
|
||
|
0187 jstab=jstab+1;
|
||
|
0188 T(:,:,jstab) = [dr_.ghx dr_.ghu];
|
||
|
0189 <span class="keyword">end</span>
|
||
|
0190 <span class="keyword">if</span> ~exist(<span class="string">'nspred'</span>),
|
||
|
0191 nspred = size(dr_.ghx,2);
|
||
|
0192 nboth = dr_.nboth;
|
||
|
0193 nfwrd = dr_.nfwrd;
|
||
|
0194 <span class="keyword">end</span>
|
||
|
0195 <span class="keyword">else</span>
|
||
|
0196 istable(j)=0;
|
||
|
0197 <span class="keyword">if</span> isfield(dr_,<span class="string">'eigval'</span>)
|
||
|
0198 egg(:,j) = sort(dr_.eigval);
|
||
|
0199 <span class="keyword">if</span> any(isnan(egg(1:nspred,j)))
|
||
|
0200 iwrong(j)=j;
|
||
|
0201 <span class="keyword">else</span>
|
||
|
0202 <span class="keyword">if</span> (nboth | nfwrd) & abs(egg(nspred+1,j))<=options_.qz_criterium,
|
||
|
0203 iindeterm(j)=j;
|
||
|
0204 <span class="keyword">end</span>
|
||
|
0205 <span class="keyword">end</span>
|
||
|
0206 <span class="keyword">else</span>
|
||
|
0207 egg(:,j)=ones(size(egg,1),1).*1.1;
|
||
|
0208 iwrong(j)=j;
|
||
|
0209 <span class="keyword">end</span>
|
||
|
0210 <span class="keyword">end</span>
|
||
|
0211 ys_=real(dr_.ys);
|
||
|
0212 yys(:,j) = ys_;
|
||
|
0213 ys_=yys(:,1);
|
||
|
0214 waitbar(j/Nsam,h,[<span class="string">'MC iteration '</span>,int2str(j),<span class="string">'/'</span>,int2str(Nsam)])
|
||
|
0215 <span class="keyword">end</span>
|
||
|
0216 close(h)
|
||
|
0217 <span class="keyword">if</span> prepSA,
|
||
|
0218 T=T(:,:,1:jstab);
|
||
|
0219 <span class="keyword">end</span>
|
||
|
0220 istable=istable(find(istable)); <span class="comment">% stable params</span>
|
||
|
0221 iunstable=iunstable(find(iunstable)); <span class="comment">% unstable params</span>
|
||
|
0222 iindeterm=iindeterm(find(iindeterm)); <span class="comment">% indeterminacy</span>
|
||
|
0223 iwrong=iwrong(find(iwrong)); <span class="comment">% dynare could not find solution</span>
|
||
|
0224
|
||
|
0225 <span class="comment">% % map stable samples</span>
|
||
|
0226 <span class="comment">% istable=[1:Nsam];</span>
|
||
|
0227 <span class="comment">% for j=1:Nsam,</span>
|
||
|
0228 <span class="comment">% if any(isnan(egg(1:nspred,j)))</span>
|
||
|
0229 <span class="comment">% istable(j)=0;</span>
|
||
|
0230 <span class="comment">% else</span>
|
||
|
0231 <span class="comment">% if abs(egg(nspred,j))>=options_.qz_criterium; %(1-(options_.qz_criterium-1)); %1-1.e-5;</span>
|
||
|
0232 <span class="comment">% istable(j)=0;</span>
|
||
|
0233 <span class="comment">% %elseif (dr_.nboth | dr_.nfwrd) & abs(egg(nspred+1,j))<=options_.qz_criterium; %1+1.e-5;</span>
|
||
|
0234 <span class="comment">% elseif (nboth | nfwrd) & abs(egg(nspred+1,j))<=options_.qz_criterium; %1+1.e-5;</span>
|
||
|
0235 <span class="comment">% istable(j)=0;</span>
|
||
|
0236 <span class="comment">% end</span>
|
||
|
0237 <span class="comment">% end</span>
|
||
|
0238 <span class="comment">% end</span>
|
||
|
0239 <span class="comment">% istable=istable(find(istable)); % stable params</span>
|
||
|
0240 <span class="comment">%</span>
|
||
|
0241 <span class="comment">% % map unstable samples</span>
|
||
|
0242 <span class="comment">% iunstable=[1:Nsam];</span>
|
||
|
0243 <span class="comment">% for j=1:Nsam,</span>
|
||
|
0244 <span class="comment">% %if abs(egg(dr_.npred+1,j))>1+1.e-5 & abs(egg(dr_.npred,j))<1-1.e-5;</span>
|
||
|
0245 <span class="comment">% %if (dr_.nboth | dr_.nfwrd),</span>
|
||
|
0246 <span class="comment">% if ~any(isnan(egg(1:5,j)))</span>
|
||
|
0247 <span class="comment">% if (nboth | nfwrd),</span>
|
||
|
0248 <span class="comment">% if abs(egg(nspred+1,j))>options_.qz_criterium & abs(egg(nspred,j))<options_.qz_criterium; %(1-(options_.qz_criterium-1));</span>
|
||
|
0249 <span class="comment">% iunstable(j)=0;</span>
|
||
|
0250 <span class="comment">% end</span>
|
||
|
0251 <span class="comment">% else</span>
|
||
|
0252 <span class="comment">% if abs(egg(nspred,j))<options_.qz_criterium; %(1-(options_.qz_criterium-1));</span>
|
||
|
0253 <span class="comment">% iunstable(j)=0;</span>
|
||
|
0254 <span class="comment">% end</span>
|
||
|
0255 <span class="comment">% end</span>
|
||
|
0256 <span class="comment">% end</span>
|
||
|
0257 <span class="comment">% end</span>
|
||
|
0258 <span class="comment">% iunstable=iunstable(find(iunstable)); % unstable params</span>
|
||
|
0259 <span class="keyword">if</span> pprior,
|
||
|
0260 <span class="keyword">if</span> ~prepSA
|
||
|
0261 save([OutputDirectoryName <span class="string">'\'</span> fname_ <span class="string">'_prior'</span>],<span class="string">'lpmat'</span>,<span class="string">'lpmat0'</span>,<span class="string">'iunstable'</span>,<span class="string">'istable'</span>,<span class="string">'iindeterm'</span>,<span class="string">'iwrong'</span>,<span class="string">'egg'</span>,<span class="string">'yys'</span>,<span class="string">'nspred'</span>,<span class="string">'nboth'</span>,<span class="string">'nfwrd'</span>)
|
||
|
0262 <span class="keyword">else</span>
|
||
|
0263 save([OutputDirectoryName <span class="string">'\'</span> fname_ <span class="string">'_prior'</span>],<span class="string">'lpmat'</span>,<span class="string">'lpmat0'</span>,<span class="string">'iunstable'</span>,<span class="string">'istable'</span>,<span class="string">'iindeterm'</span>,<span class="string">'iwrong'</span>,<span class="string">'egg'</span>,<span class="string">'yys'</span>,<span class="string">'T'</span>,<span class="string">'nspred'</span>,<span class="string">'nboth'</span>,<span class="string">'nfwrd'</span>)
|
||
|
0264 <span class="keyword">end</span>
|
||
|
0265
|
||
|
0266 <span class="keyword">else</span>
|
||
|
0267 <span class="keyword">if</span> ~prepSA
|
||
|
0268 save([OutputDirectoryName <span class="string">'\'</span> fname_ <span class="string">'_mc'</span>], <span class="keyword">...</span>
|
||
|
0269 <span class="string">'lpmat'</span>,<span class="string">'lpmat0'</span>,<span class="string">'iunstable'</span>,<span class="string">'istable'</span>,<span class="string">'iindeterm'</span>,<span class="string">'iwrong'</span>,<span class="string">'egg'</span>,<span class="string">'yys'</span>,<span class="string">'nspred'</span>,<span class="string">'nboth'</span>,<span class="string">'nfwrd'</span>)
|
||
|
0270 <span class="keyword">else</span>
|
||
|
0271 save([OutputDirectoryName <span class="string">'\'</span> fname_ <span class="string">'_mc'</span>], <span class="keyword">...</span>
|
||
|
0272 <span class="string">'lpmat'</span>,<span class="string">'lpmat0'</span>,<span class="string">'iunstable'</span>,<span class="string">'istable'</span>,<span class="string">'iindeterm'</span>,<span class="string">'iwrong'</span>,<span class="string">'egg'</span>,<span class="string">'yys'</span>,<span class="string">'T'</span>,<span class="string">'nspred'</span>,<span class="string">'nboth'</span>,<span class="string">'nfwrd'</span>)
|
||
|
0273 <span class="keyword">end</span>
|
||
|
0274 <span class="keyword">end</span>
|
||
|
0275 <span class="keyword">else</span>
|
||
|
0276 <span class="keyword">if</span> pprior,
|
||
|
0277 filetoload=[OutputDirectoryName <span class="string">'\'</span> fname_ <span class="string">'_prior'</span>];
|
||
|
0278 <span class="keyword">else</span>
|
||
|
0279 filetoload=[OutputDirectoryName <span class="string">'\'</span> fname_ <span class="string">'_mc'</span>];
|
||
|
0280 <span class="keyword">end</span>
|
||
|
0281 load(filetoload,<span class="string">'lpmat'</span>,<span class="string">'lpmat0'</span>,<span class="string">'iunstable'</span>,<span class="string">'istable'</span>,<span class="string">'iindeterm'</span>,<span class="string">'iwrong'</span>,<span class="string">'egg'</span>,<span class="string">'yys'</span>,<span class="string">'nspred'</span>,<span class="string">'nboth'</span>,<span class="string">'nfwrd'</span>)
|
||
|
0282 Nsam = size(lpmat,1);
|
||
|
0283
|
||
|
0284 <span class="keyword">if</span> prepSA & isempty(strmatch(<span class="string">'T'</span>,who(<span class="string">'-file'</span>, filetoload),<span class="string">'exact'</span>)),
|
||
|
0285 h = waitbar(0,<span class="string">'Please wait...'</span>);
|
||
|
0286 options_.periods=0;
|
||
|
0287 options_.nomoments=1;
|
||
|
0288 options_.irf=0;
|
||
|
0289 options_.noprint=1;
|
||
|
0290 <a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a>([]);
|
||
|
0291 T=zeros(size(dr_.ghx,1),size(dr_.ghx,2)+size(dr_.ghu,2),length(istable));
|
||
|
0292 ntrans=length(istable);
|
||
|
0293 <span class="keyword">for</span> j=1:ntrans,
|
||
|
0294 M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(j),:)';
|
||
|
0295 <a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a>([]);
|
||
|
0296 dr_ = oo_.dr;
|
||
|
0297 T(:,:,j) = [dr_.ghx dr_.ghu];
|
||
|
0298 <span class="keyword">if</span> ~exist(<span class="string">'nspred'</span>)
|
||
|
0299 nspred = size(dr_.ghx,2);
|
||
|
0300 nboth = dr_.nboth;
|
||
|
0301 nfwrd = dr_.nfwrd;
|
||
|
0302 <span class="keyword">end</span>
|
||
|
0303 ys_=real(dr_.ys);
|
||
|
0304 yys(:,j) = ys_;
|
||
|
0305 ys_=yys(:,1);
|
||
|
0306 waitbar(j/ntrans,h,[<span class="string">'MC iteration '</span>,int2str(j),<span class="string">'/'</span>,int2str(ntrans)])
|
||
|
0307 <span class="keyword">end</span>
|
||
|
0308 close(h)
|
||
|
0309 save(filetoload,<span class="string">'T'</span>,<span class="string">'-append'</span>)
|
||
|
0310 <span class="keyword">end</span>
|
||
|
0311 <span class="keyword">end</span>
|
||
|
0312
|
||
|
0313 <span class="keyword">if</span> pprior
|
||
|
0314 aname=<span class="string">'prior_stab'</span>;
|
||
|
0315 auname=<span class="string">'prior_unacceptable'</span>;
|
||
|
0316 aunstname=<span class="string">'prior_unstable'</span>;
|
||
|
0317 aindname=<span class="string">'prior_indeterm'</span>;
|
||
|
0318 asname=<span class="string">'prior_stable'</span>;
|
||
|
0319 <span class="keyword">else</span>
|
||
|
0320 aname=<span class="string">'mc_stab'</span>;
|
||
|
0321 auname=<span class="string">'mc_unacceptable'</span>;
|
||
|
0322 aunstname=<span class="string">'mc_unstable'</span>;
|
||
|
0323 aindname=<span class="string">'mc_indeterm'</span>;
|
||
|
0324 asname=<span class="string">'mc_stable'</span>;
|
||
|
0325 <span class="keyword">end</span>
|
||
|
0326 delete([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_'</span>,aname,<span class="string">'_*.*'</span>]);
|
||
|
0327 <span class="comment">%delete([OutputDirectoryName,'\',fname_,'_',aname,'_SA_*.*']);</span>
|
||
|
0328 delete([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_'</span>,asname,<span class="string">'_corr_*.*'</span>]);
|
||
|
0329 delete([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_'</span>,auname,<span class="string">'_corr_*.*'</span>]);
|
||
|
0330 delete([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_'</span>,aunstname,<span class="string">'_corr_*.*'</span>]);
|
||
|
0331 delete([OutputDirectoryName,<span class="string">'\'</span>,fname_,<span class="string">'_'</span>,aindname,<span class="string">'_corr_*.*'</span>]);
|
||
|
0332
|
||
|
0333 <span class="keyword">if</span> length(iunstable)>0 & length(iunstable)<Nsam,
|
||
|
0334 disp([num2str(length(istable)/Nsam*100),<span class="string">'\% of the prior support is stable.'</span>])
|
||
|
0335 disp([num2str( (length(iunstable)-length(iwrong)-length(iindeterm) )/Nsam*100),<span class="string">'\% of the prior support is unstable.'</span>])
|
||
|
0336 <span class="keyword">if</span> ~isempty(iindeterm),
|
||
|
0337 disp([num2str(length(iindeterm)/Nsam*100),<span class="string">'\% of the prior support gives indeterminacy.'</span>])
|
||
|
0338 <span class="keyword">end</span>
|
||
|
0339 <span class="keyword">if</span> ~isempty(iwrong),
|
||
|
0340 disp(<span class="string">' '</span>);
|
||
|
0341 disp([<span class="string">'For '</span>,num2str(length(iwrong)/Nsam*100),<span class="string">'\% of the prior support dynare could not find a solution.'</span>])
|
||
|
0342 <span class="keyword">end</span>
|
||
|
0343 <span class="comment">% Blanchard Kahn</span>
|
||
|
0344 [proba, dproba] = <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>(lpmat, istable, iunstable, aname,0);
|
||
|
0345 indstab=find(dproba>ksstat);
|
||
|
0346 disp(<span class="string">'The following parameters mostly drive acceptable behaviour'</span>)
|
||
|
0347 disp(M_.param_names(estim_params_.param_vals(indstab,1),:))
|
||
|
0348 <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>(lpmat, istable, iunstable, aname, 1, indstab, OutputDirectoryName);
|
||
|
0349 <span class="keyword">if</span> ~isempty(iindeterm),
|
||
|
0350 ixun=iunstable(find(~ismember(iunstable,[iindeterm,iwrong])));
|
||
|
0351 [proba, dproba] = <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>(lpmat, [1:Nsam], iindeterm, [aname, <span class="string">'_indet'</span>],0);
|
||
|
0352 indindet=find(dproba>ksstat);
|
||
|
0353 disp(<span class="string">'The following parameters mostly drive indeterminacy'</span>)
|
||
|
0354 disp(M_.param_names(estim_params_.param_vals(indindet,1),:))
|
||
|
0355 <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>(lpmat, [1:Nsam], iindeterm, [aname, <span class="string">'_indet'</span>], 1, indindet, OutputDirectoryName);
|
||
|
0356 <span class="keyword">if</span> ~isempty(ixun),
|
||
|
0357 [proba, dproba] = <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>(lpmat, [1:Nsam], ixun, [aname, <span class="string">'_unst'</span>],0);
|
||
|
0358 indunst=find(dproba>ksstat);
|
||
|
0359 disp(<span class="string">'The following parameters mostly drive instability'</span>)
|
||
|
0360 disp(M_.param_names(estim_params_.param_vals(indunst,1),:))
|
||
|
0361 <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>(lpmat, [1:Nsam], ixun, [aname, <span class="string">'_unst'</span>], 1, indunst, OutputDirectoryName);
|
||
|
0362 <span class="keyword">end</span>
|
||
|
0363 <span class="keyword">end</span>
|
||
|
0364
|
||
|
0365 disp(<span class="string">' '</span>)
|
||
|
0366 disp(<span class="string">'Starting bivariate analysis:'</span>)
|
||
|
0367
|
||
|
0368 c0=corrcoef(lpmat(istable,:));
|
||
|
0369 c00=tril(c0,-1);
|
||
|
0370
|
||
|
0371 <a href="stab_map_2.html" class="code" title="function stab_map_2(x,alpha2,fnam, dirname)">stab_map_2</a>(lpmat(istable,:),alpha2, asname, OutputDirectoryName);
|
||
|
0372 <a href="stab_map_2.html" class="code" title="function stab_map_2(x,alpha2,fnam, dirname)">stab_map_2</a>(lpmat(iunstable,:),alpha2, auname, OutputDirectoryName);
|
||
|
0373 <span class="keyword">if</span> ~isempty(iindeterm),
|
||
|
0374 <a href="stab_map_2.html" class="code" title="function stab_map_2(x,alpha2,fnam, dirname)">stab_map_2</a>(lpmat(iindeterm,:),alpha2, aindname, OutputDirectoryName);
|
||
|
0375 <span class="keyword">if</span> ~isempty(ixun),
|
||
|
0376 <a href="stab_map_2.html" class="code" title="function stab_map_2(x,alpha2,fnam, dirname)">stab_map_2</a>(lpmat(ixun,:),alpha2, aunstname, OutputDirectoryName);
|
||
|
0377 <span class="keyword">end</span>
|
||
|
0378 <span class="keyword">end</span>
|
||
|
0379
|
||
|
0380 x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
|
||
|
0381 x0 = [x0; lpmat(istable(1),:)'];
|
||
|
0382 <span class="keyword">if</span> istable(end)~=Nsam
|
||
|
0383 M_.params(estim_params_.param_vals(:,1)) = lpmat(istable(1),:)';
|
||
|
0384 <a href="stoch_simul.html" class="code" title="function info=stoch_simul(var_list)">stoch_simul</a>([]);
|
||
|
0385 <span class="keyword">end</span>
|
||
|
0386 <span class="keyword">else</span>
|
||
|
0387 <span class="keyword">if</span> length(iunstable)==0,
|
||
|
0388 disp(<span class="string">'All parameter values in the specified ranges are stable!'</span>)
|
||
|
0389 x0=0.5.*(bayestopt_.ub(1:nshock)-bayestopt_.lb(1:nshock))+bayestopt_.lb(1:nshock);
|
||
|
0390 x0 = [x0; lpmat(istable(1),:)'];
|
||
|
0391 <span class="keyword">else</span>
|
||
|
0392 disp(<span class="string">'All parameter values in the specified ranges are not acceptable!'</span>)
|
||
|
0393 x0=[];
|
||
|
0394 <span class="keyword">end</span>
|
||
|
0395
|
||
|
0396 <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>
|