diff --git a/matlab/datatomfile.m b/matlab/datatomfile.m new file mode 100644 index 0000000000000000000000000000000000000000..0ebb995921e93f0261ac5b856c3455816aa8b3d3 --- /dev/null +++ b/matlab/datatomfile.m @@ -0,0 +1,43 @@ +% 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) ; + diff --git a/matlab/dr1.m b/matlab/dr1.m index 2c07be4917ef56ada44d06631ed9b714f44a7d51..4b6f15f103eb4f409d72201d99c9fc3a0709c941 100644 --- a/matlab/dr1.m +++ b/matlab/dr1.m @@ -165,7 +165,7 @@ if M_.maximum_lead == 0; % backward model m = 0; for i=M_.maximum_lag:-1:1 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); end if M_.exo_nbr diff --git a/matlab/stoch_simul.m b/matlab/stoch_simul.m index 7f805050dd399456729bd86641be6ec3ecd3a928..266e67052e93360e61b68c662e848e5fb46f1d05 100644 --- a/matlab/stoch_simul.m +++ b/matlab/stoch_simul.m @@ -32,9 +32,9 @@ global it_ TeX = options_.TeX; - if options_.simul & ~isempty(iter_) & options_.periods == 0 - options_.periods = iter_; - end +% if options_.simul & ~isempty(iter_) & options_.periods == 0 +% options_.periods = iter_; +% end iter_ = max(options_.periods,1); if M_.exo_nbr > 0 oo_.exo_simul= ones(iter_ + M_.maximum_lag + M_.maximum_lead,1) * oo_.exo_steady_state'; diff --git a/matlab/transition_matrix.m b/matlab/transition_matrix.m new file mode 100644 index 0000000000000000000000000000000000000000..052bc25c63cb8e05d93921a479e150afb26cb752 --- /dev/null +++ b/matlab/transition_matrix.m @@ -0,0 +1,27 @@ +% 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