Skip to content
Snippets Groups Projects
Commit 89f1118b authored by michel's avatar michel
Browse files

v4: corrected stoch_simul for iter_\ncorrected backward models in dr1.m\nadded...

v4: corrected stoch_simul for iter_\ncorrected backward models in dr1.m\nadded datatomfile.m and transition_matrix.m

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@581 ac1d8469-bf42-47a9-8791-bf33cf982152
parent de1ad981
No related branches found
No related tags found
No related merge requests found
% Copyright (C) 2001 Michel Juillard
%
function datatomfile (s,var_list)
% 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.
global M_ oo_
%fid=fopen([s,'.m'],'w') ;
sm=[s,'.m'];
fid=fopen(sm,'w') ;
n = size(var_list,1);
if n == 0
n = M_.endo_nbr;
ivar = [1:n]';
var_list = M_.endo_names;
else
ivar=zeros(n,1);
for i=1:n
i_tmp = strmatch(var_list(i,:),M_.endo_names,'exact');
if isempty(i_tmp)
error (['One of the specified variables does not exist']) ;
else
ivar(i) = i_tmp;
end
end
end
for i = 1:n
fprintf(fid,[M_.endo_names(ivar(i),:), '=['],'\n') ;
fprintf(fid,'\n') ;
fprintf(fid,'%15.8g\n',oo_.endo_simul(ivar(i),:)') ;
fprintf(fid,'\n') ;
fprintf(fid,'];\n') ;
fprintf(fid,'\n') ;
end
fclose(fid) ;
...@@ -165,7 +165,7 @@ if M_.maximum_lead == 0; % backward model ...@@ -165,7 +165,7 @@ if M_.maximum_lead == 0; % backward model
m = 0; m = 0;
for i=M_.maximum_lag:-1:1 for i=M_.maximum_lag:-1:1
k = nonzeros(M_.lead_lag_incidence(i,order_var)); k = nonzeros(M_.lead_lag_incidence(i,order_var));
dr.ghx(:,m+[1:length(k)]) = -a(:,k); dr.ghx(:,m+[1:length(k)]) = -b\a(:,k);
m = m+length(k); m = m+length(k);
end end
if M_.exo_nbr if M_.exo_nbr
......
...@@ -32,9 +32,9 @@ global it_ ...@@ -32,9 +32,9 @@ global it_
TeX = options_.TeX; TeX = options_.TeX;
if options_.simul & ~isempty(iter_) & options_.periods == 0 % if options_.simul & ~isempty(iter_) & options_.periods == 0
options_.periods = iter_; % options_.periods = iter_;
end % end
iter_ = max(options_.periods,1); iter_ = max(options_.periods,1);
if M_.exo_nbr > 0 if M_.exo_nbr > 0
oo_.exo_simul= ones(iter_ + M_.maximum_lag + M_.maximum_lead,1) * oo_.exo_steady_state'; oo_.exo_simul= ones(iter_ + M_.maximum_lag + M_.maximum_lead,1) * oo_.exo_steady_state';
......
% makes transition matrices out of ghx and ghu
function [A,B] = transition_matrix(dr)
global M_
exo_nbr = M_.exo_nbr;
ykmin_ = M_.maximum_endo_lag;
nx = size(dr.ghx,2);
kstate = dr.kstate;
ikx = [dr.nstatic+1:dr.nstatic+dr.npred];
A = zeros(nx,nx);
k0 = kstate(find(kstate(:,2) <= ykmin_+1),:);
i0 = find(k0(:,2) == ykmin_+1);
A(i0,:) = dr.ghx(ikx,:);
B = zeros(nx,exo_nbr);
B(i0,:) = dr.ghu(ikx,:);
for i=ykmin_:-1:2
i1 = find(k0(:,2) == i);
n1 = size(i1,1);
j = zeros(n1,1);
for j1 = 1:n1
j(j1) = find(k0(i0,1)==k0(i1(j1),1));
end
A(i1,i0(j))=eye(n1);
i0 = i1;
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment