Do not update a dseries object, but instantiate a new object.
parent
4775bca073
commit
351da3b865
|
@ -244,24 +244,25 @@ fprintf(fid, '%s', expression);
|
|||
fclose(fid);
|
||||
|
||||
%
|
||||
% Third print a routine for evaluating VAR_EXPECTATION/PAC_EXPECTATION term (updates a dseries object).
|
||||
% Third print a routine for evaluating VAR_EXPECTATION/PAC_EXPECTATION term (returns a dseries object).
|
||||
%
|
||||
kind = strrep(expectationmodelkind, '-', '_');
|
||||
mkdir(sprintf('+%s/+%s', M_.fname, kind));
|
||||
filename = sprintf('+%s/+%s/evaluate_%s.m', M_.fname, kind, expectationmodelname);
|
||||
fid = fopen(filename, 'w');
|
||||
fprintf(fid, 'function dbase = evaluate_%s(dbase)\n\n', expectationmodelname);
|
||||
fprintf(fid, '%% Evaluates %s term (%s), updating a dseries object.\n', kind, expectationmodelname);
|
||||
fprintf(fid, 'function ds = evaluate_%s(dbase)\n\n', expectationmodelname);
|
||||
fprintf(fid, '%% Evaluates %s term (%s).\n', kind, expectationmodelname);
|
||||
fprintf(fid, '%%\n');
|
||||
fprintf(fid, '%% INPUTS\n');
|
||||
fprintf(fid, '%% - dbase [dseries] databse containing all the variables appearing in the auxiliary model for the expectation.\n');
|
||||
fprintf(fid, '%%\n');
|
||||
fprintf(fid, '%% OUTPUTS\n');
|
||||
fprintf(fid, '%% - dbase [dseries] same databse augmented with the expectation term .\n');
|
||||
fprintf(fid, '%% - ds [dseries] the expectation term .\n');
|
||||
fprintf(fid, '%%\n');
|
||||
fprintf(fid, '%% REMARKS\n');
|
||||
fprintf(fid, '%% The name of the appended variable in dbase is the declared name for the (PAC/VAR) expectation model.\n\n');
|
||||
fprintf(fid, '%% This file has been generated by dynare (%s).\n\n', datestr(now));
|
||||
fprintf(fid, 'ds = dseries();\n\n');
|
||||
|
||||
id = 0;
|
||||
|
||||
|
@ -351,5 +352,5 @@ for i=1:maxlag
|
|||
end
|
||||
end
|
||||
|
||||
fprintf(fid, 'dbase.%s = %s;', expectationmodelname, expression);
|
||||
fprintf(fid, 'ds.%s = %s;', expectationmodelname, expression);
|
||||
fclose(fid);
|
|
@ -56,14 +56,14 @@ verbatim;
|
|||
initialconditions(1,4) = .7; % x(-3)
|
||||
initialconditions = ...
|
||||
dseries(initialconditions, dates('2000Q1'), {'foo', 'y','z', 'x'});
|
||||
set_dynare_seed('default');
|
||||
set_dynare_seed('default');
|
||||
ts = simul_backward_model(initialconditions, 15);
|
||||
foo = ts.foo.data;
|
||||
% Evaluate the (VAR) expectation term
|
||||
ts = example.var_expectations.evaluate_varexp(ts);
|
||||
ts{'toto'} = example.var_expectations.evaluate_varexp(ts);
|
||||
% Check tthat the evaluation is correct.
|
||||
range = dates('2000Q4'):dates('2004Q2');
|
||||
if max(abs(ts(range).foo.data-ts(range).varexp.data))>1e-5
|
||||
if max(abs(ts(range).foo.data-ts(range).toto.data))>1e-5
|
||||
error('Expectation term evaluations do not match!')
|
||||
end
|
||||
end;
|
Loading…
Reference in New Issue