parser corrections + adapting 2nd order approx code

git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@458 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
michel 2005-09-22 14:28:25 +00:00
parent 6a200bfca0
commit 46b1cb222b
4 changed files with 28 additions and 18 deletions

View File

@ -42,7 +42,11 @@ else
z = repmat(dr.ys,1,klen);
end
z = z(iyr0) ;
[junk,jacobia_] = feval([M_.fname '_dynamic'],z,tempex);
if options_.order == 1
[junk,jacobia_] = feval([M_.fname '_dynamic'],z,tempex);
elseif options_.order == 2
[junk,jacobia_,hessian] = feval([M_.fname '_dynamic'],z,tempex);
end
oo_.exo_simul = tempex ;
tempex = [];
@ -104,7 +108,7 @@ if options_.olr
jacobia_ = jacobia1;
clear jacobia1
% computes steady state
resid = feval([fname_ '_fff'],zeros(olr_state_.old_M_.endo_nbr,1));
resid = feval([M_.fname '_steady'],zeros(olr_state_.old_M_.endo_nbr,1));
if resid'*resid < 1e-12
dr.ys =[dr.ys; zeros(nj,1)];
else
@ -316,7 +320,7 @@ if options_.order == 1
end
% Second order
tempex = oo_.exo_simul ;
%tempex = oo_.exo_simul ;
%hessian = real(hessext('ff1_',[z; oo_.exo_steady_state]))' ;
kk = flipud(cumsum(flipud(M_.lead_lag_incidence(M_.maximum_lag+1:end,order_var)),1));
@ -335,11 +339,11 @@ kk1(k1(k2)) = k2;
kk1 = [kk1 length(k1)+1:length(k1)+M_.exo_nbr];
kk = reshape([1:nk^2],nk,nk);
kk1 = kk(kk1,kk1);
hessian = zeros(M_.endo_nbr,nk^2);
hessian(:,kk1(:)) = real(hessian_sparse('ff1_',[z; oo_.exo_steady_state])) ;
%[junk,junk,hessian] = feval([M_.fname '_dynamic'],z, oo_.exo_steady_state);
hessian(:,kk1(:)) = hessian;
oo_.exo_simul = tempex ;
clear tempex
%oo_.exo_simul = tempex ;
%clear tempex
n1 = 0;
n2 = np;
@ -536,7 +540,7 @@ for i=1:M_.maximum_lead
H = E1 + hx*H;
end
RHS = RHS*Sigma_e_(:);
RHS = RHS*M_.Sigma_e(:);
dr.fuu = RHS;
RHS = -RHS-dr.fbias;
dr.ghs2 = LHS\RHS;

Binary file not shown.

View File

@ -19,6 +19,12 @@ if M_.exo_nbr == 0
oo_.exo_steady_state = [] ;
end
if M_.maximum_exo_lag > 0 || M_.maximum_exo_lead > 0
error (['RESOL: stochastic exogenous variables must appear only at the' ...
' current period. Use additional endogenous variables']) ;
end
% check if ys is steady state
tempex = oo_.exo_simul;
oo_.exo_simul = repmat(oo_.exo_steady_state',M_.maximum_lag+M_.maximum_lead+1,1);

View File

@ -61,10 +61,10 @@ global it_
int2str(length(find(dr_.kstate(:,2) == M_.maximum_lag+2)))])
disp([' Number of static variables: ' int2str(dr_.nstatic)])
my_title='MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS';
labels = deblank(lgx_);
labels = deblank(M_.exo_names);
headers = strvcat('Variables',labels);
lh = size(labels,2)+2;
table(my_title,headers,labels,Sigma_e_,lh,10,6);
table(my_title,headers,labels,M_.Sigma_e,lh,10,6);
disp(' ')
disp_dr(dr_,options_.order,var_list);
end
@ -94,9 +94,9 @@ global it_
if n == 0
n = M_.endo_nbr;
ivar = [1:n]';
var_list = lgoo_.endo_simul;
var_list = M_.endo_names;
if TeX
var_listTeX = lgoo_.endo_simulToo_.exo_simul;
var_listTeX = M_.endo_names_tex;
end
else
ivar=zeros(n,1);
@ -104,13 +104,13 @@ global it_
var_listTeX = [];
end
for i=1:n
i_tmp = strmatch(var_list(i,:),lgoo_.endo_simul,'exact');
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;
if TeX
var_listTeX = strvcat(var_listTeX,deblank(lgoo_.endo_simulToo_.exo_simul(i_tmp,:)));
var_listTeX = strvcat(var_listTeX,deblank(M_.endo_names_tex(i_tmp,:)));
end
end
end
@ -122,15 +122,15 @@ global it_
fprintf(fidTeX,' \n');
end
olditer = iter_;% Est-ce vraiment utile ? Il y a la même ligne dans irf...
SS(lgx_orig_ord_,lgx_orig_ord_)=Sigma_e_+1e-14*eye(M_.exo_nbr);
SS(M_.exo_names_orig_order,M_.exo_names_orig_order)=M_.Sigma_e+1e-14*eye(M_.exo_nbr);
cs = transpose(chol(SS));
tit(lgx_orig_ord_,:) = lgx_;
tit(M_.exo_names_orig_order,:) = M_.exo_names;
if TeX
titTeX(lgx_orig_ord_,:) = lgx_Too_.exo_simul;
titTeX(M_.exo_names_orig_order,:) = M_.exo_names_tex;
end
for i=1:M_.exo_nbr
if SS(i,i) > 1e-13
y=irf(dr_,cs(lgx_orig_ord_,i), options_.irf, options_.drop, ...
y=irf(dr_,cs(M_.exo_names_orig_order,i), options_.irf, options_.drop, ...
options_.replic, options_.order);
if options_.relative_irf
y = 100*y/cs(i,i);