Improvements to smoother2histval (ref #594)

- fix handling of auxiliary variables related to lagged endogenous
- add preprocessor interface
- add histval_file
- add tests (for smoother2histval with outfile, and for histval_file)
time-shift
Sébastien Villemot 2014-04-03 15:05:20 +02:00
parent c24ae80ae2
commit 9eebfc87b0
13 changed files with 371 additions and 33 deletions

60
matlab/histvalf.m Normal file
View File

@ -0,0 +1,60 @@
function histvalf(fname)
% Copyright (C) 2014 Dynare Team
%
% This file is part of Dynare.
%
% Dynare is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
%
% Dynare is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
global M_ oo_
if ~exist(fname)
error(['Can''t find datafile: ' fname ]);
end
M_.endo_histval = repmat(oo_.steady_state, 1, M_.maximum_endo_lag);
S = load(fname);
outvars = fieldnames(S);
for i = 1:length(outvars)
ov_ = outvars{i};
if ov_(end) == '_'
ov = ov_(1:end-1);
j = strmatch(ov, M_.endo_names, 'exact');
if isempty(j)
error(['smoother2histval: output variable ' ov ' does not exist.'])
end
else
% Lagged endogenous, search through aux vars
z = strsplit(ov_, '_');
ov = z{1};
lead_lag = str2num(z{2});
j = [];
for i = 1:length(M_.aux_vars)
if M_.aux_vars(i).type ~= 1
continue
end
orig_var = deblank(M_.endo_names(M_.aux_vars(i).orig_index, :));
if strcmp(orig_var, ov) && M_.aux_vars(i).orig_lead_lag == lead_lag
j = M_.aux_vars(i).endo_index;
end
end
if isempty(j)
continue
end
end
M_.endo_histval(j, :) = getfield(S, ov_);
end

View File

@ -1,12 +1,12 @@
function smoother2histval(infile, invars, period, outfile, outvars)
function smoother2histval(opts)
% This function takes values from oo_.SmoothedVariables and copies them into
% M_.histval.
%
% INPUTS
% Optional fields in 'opts' structure:
% infile: An optional *_results MAT file created by Dynare.
% If present, oo_.SmoothedVariables is read from there.
% Otherwise, it is read from the global workspace.
% invars: An optional cell array listing variables to read in
% invars: An optional char or cell array listing variables to read in
% oo_.SmoothedVariables. If absent, all the endogenous
% variables present in oo_.SmoothedVariables are used.
% period: An optional period number to use as the starting point
@ -15,7 +15,7 @@ function smoother2histval(infile, invars, period, outfile, outvars)
% smoothed values. If absent, the last observation is used.
% outfile: An optional MAT file in which to save the histval structure.
% If absent, the output will be written in M_.endo_histval
% outvars: An optional cell array listing variables to be written in
% outvars: An optional char or cell array listing variables to be written in
% outfile or M_.endo_histval. This cell must be of same
% length than invars, and there is a mapping between the input
% variable at the i-th position in invars, and the output
@ -43,13 +43,13 @@ function smoother2histval(infile, invars, period, outfile, outvars)
global M_ options_ oo_
if nargin == 0 || isempty(infile)
if ~isfield(opts, 'infile')
if ~isfield(oo_, 'SmoothedVariables')
error('Could not find smoothed variables; did you set the "smoother" option?')
end
smoothedvals = oo_.SmoothedVariables;
else
S = load(infile);
S = load(opts.infile);
if ~isfield(S, 'oo_') || ~isfield(S.oo_, 'SmoothedVariables')
error('Could not find smoothed variables in file; is this a Dynare results file, and did you set the "smoother" option when producing it?')
end
@ -100,49 +100,92 @@ if n < M_.maximum_endo_lag
error('Not enough observations to create initial conditions')
end
if nargin < 2 || isempty(invars)
if isfield(opts, 'invars')
invars = opts.invars;
if ischar(invars)
invars = cellstr(invars);
end
else
invars = fieldnames(smoothedvals);
end
if nargin < 3 || isempty(period)
period = n;
else
if isfield(opts, 'period')
period = opts.period;
if period > n
error('The period that you indicated is beyond the data sample')
end
if period < M_.maximum_endo_lag
error('The period that you indicated is too small to construct initial conditions')
end
else
period = n;
end
if nargin < 5 || isempty(outvars)
outvars = invars;
else
if isfield(opts, 'outvars')
outvars = opts.outvars;
if ischar(outvars)
outvars = cellstr(outvars);
end
if length(invars) ~= length(outvars)
error('The number of input and output variables is not the same')
end
else
outvars = invars;
end
endo_histval = repmat(oo_.steady_state, 1, M_.maximum_endo_lag);
% Initialize outputs
if ~isfield(opts, 'outfile')
% Output to M_.endo_histval
M_.endo_histval = repmat(oo_.steady_state, 1, M_.maximum_endo_lag);
else
% Output to a file
o = struct();
end
% Handle all variables to be copied
for i = 1:length(invars)
s = getfield(smoothedvals, invars{i});
j = strmatch(outvars{i}, M_.endo_names, 'exact');
if isempty(j)
if strncmp('AUX_', outvars{i}, 4)
warning(['smoother2histval: output auxiliary variable ' outvars{i} ' does not exist, ignoring.'])
else
v = s((period-M_.maximum_endo_lag+1):period);
if ~isfield(opts, 'outfile')
j = strmatch(outvars{i}, M_.endo_names, 'exact');
if isempty(j)
error(['smoother2histval: output variable ' outvars{i} ' does not exist.'])
else
M_.endo_histval(j, :) = v;
end
else
endo_histval(j, :) = s((period-M_.maximum_endo_lag+1):period);
% When saving to a file, x(-1) is in the variable called "x_"
o = setfield(o, [ outvars{i} '_' ], v);
end
end
if nargin < 4 || isempty(outfile)
M_.endo_histval = endo_histval;
else
save(outfile, 'endo_histval')
% Handle auxiliary variables for lags
for i = 1:length(M_.aux_vars)
if M_.aux_vars(i).type ~= 1
continue
end
orig_var = deblank(M_.endo_names(M_.aux_vars(i).orig_index, :));
[m, k] = ismember(orig_var, outvars);
if m
s = getfield(smoothedvals, invars{k});
l = M_.aux_vars(i).orig_lead_lag;
if period-M_.maximum_endo_lag+1+l < 1
error('The period that you indicated is too small to construct initial conditions')
end
v = s((period-M_.maximum_endo_lag+1+l):(period+l));
if ~isfield(opts, 'outfile')
j = M_.aux_vars(i).endo_index;
M_.endo_histval(j, :) = v;
else
% When saving to a file, x(-2) is in the variable called "x_-2"
o = setfield(o, [ orig_var '_' num2str(l) ], v);
end
end
end
% Finalize output
if isfield(opts, 'outfile')
save(opts.outfile, '-struct', 'o')
end
end

View File

@ -2822,3 +2822,15 @@ CorrOptionsStatement::writeCOutput(ostream &output, const string &basename)
output << "msdsgeinfo->addMeasurementErrorCorrOption(new ModFileMeasurementErrorCorrOption(";
output << "index, index1, init));" << endl;
}
Smoother2histvalStatement::Smoother2histvalStatement(const OptionsList &options_list_arg) :
options_list(options_list_arg)
{
}
void
Smoother2histvalStatement::writeOutput(ostream &output, const string &basename) const
{
options_list.writeOutput(output, "options_smoother2histval");
output << "smoother2histval(options_smoother2histval);" << endl;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2012 Dynare Team
* Copyright (C) 2003-2014 Dynare Team
*
* This file is part of Dynare.
*
@ -846,4 +846,13 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class Smoother2histvalStatement : public Statement
{
private:
const OptionsList options_list;
public:
Smoother2histvalStatement(const OptionsList &options_list_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
#endif

View File

@ -97,8 +97,8 @@ class ParsingDriver;
%token DEFAULT FIXED_POINT
%token FORECAST K_ORDER_SOLVER INSTRUMENTS SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
%token GAMMA_PDF GRAPH GRAPH_FORMAT CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK STD
%token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT
%token HISTVAL HISTVAL_FILE HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID HYBRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT INFILE INVARS
%token <string_val> INT_NUMBER
%token INV_GAMMA_PDF INV_GAMMA1_PDF INV_GAMMA2_PDF IRF IRF_SHOCKS IRF_PLOT_THRESHOLD IRF_CALIBRATION
%token KALMAN_ALGO KALMAN_TOL SUBSAMPLES OPTIONS TOLF
@ -110,14 +110,14 @@ class ParsingDriver;
%token <string_val> NAME
%token NAN_CONSTANT NO_STATIC NOBS NOCONSTANT NODISPLAY NOCORR NODIAGNOSTIC NOFUNCTIONS
%token NOGRAPH NOMOMENTS NOPRINT NORMAL_PDF SAVE_DRAWS
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
%token OBSERVATION_TRENDS OPTIM OPTIM_WEIGHTS ORDER OSR OSR_PARAMS MAX_DIM_COVA_GROUP ADVANCED OUTFILE OUTVARS
%token PARALLEL_LOCAL_FILES PARAMETERS PARAMETER_SET PARTIAL_INFORMATION PERFECT_FORESIGHT PERIODS PERIOD PLANNER_OBJECTIVE PLOT_CONDITIONAL_FORECAST PLOT_PRIORS PREFILTER PRESAMPLE
%token PRINT PRIOR_MC PRIOR_TRUNC PRIOR_MODE PRIOR_MEAN POSTERIOR_MODE POSTERIOR_MEAN POSTERIOR_MEDIAN PRUNING
%token <string_val> QUOTED_STRING
%token QZ_CRITERIUM QZ_ZERO_THRESHOLD FULL DSGE_VAR DSGE_VARLAG DSGE_PRIOR_WEIGHT TRUNCATE
%token RELATIVE_IRF REPLIC SIMUL_REPLIC RPLOT SAVE_PARAMS_AND_STEADY_STATE PARAMETER_UNCERTAINTY
%token SHOCKS SHOCK_DECOMPOSITION SIGMA_E SIMUL SIMUL_ALGO SIMUL_SEED ENDOGENOUS_TERMINAL_PERIOD
%token SMOOTHER SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO SOLVER_PERIODS
%token SMOOTHER SMOOTHER2HISTVAL SQUARE_ROOT_SOLVER STACK_SOLVE_ALGO STEADY_STATE_MODEL SOLVE_ALGO SOLVER_PERIODS
%token STDERR STEADY STOCH_SIMUL SURPRISE SYLVESTER SYLVESTER_FIXED_POINT_TOL REGIMES REGIME
%token TEX RAMSEY_MODEL RAMSEY_POLICY PLANNER_DISCOUNT DISCRETIONARY_POLICY DISCRETIONARY_TOL
%token <string_val> TEX_NAME
@ -270,6 +270,8 @@ statement : parameters
| model_diagnostics
| moment_calibration
| irf_calibration
| smoother2histval
| histval_file
;
dsample : DSAMPLE INT_NUMBER ';'
@ -623,6 +625,10 @@ histval_list : histval_list histval_elem
histval_elem : symbol '(' signed_integer ')' EQUAL expression ';' { driver.hist_val($1, $3, $6); };
histval_file : HISTVAL_FILE '(' FILENAME EQUAL filename ')' ';'
{ driver.histval_file($5); }
;
model_options : BLOCK { driver.block(); }
| o_cutoff
| o_mfs
@ -2390,6 +2396,23 @@ irf_calibration_item : symbol COMMA symbol COMMA calibration_range ';'
{ driver.add_irf_calibration_item($1, $3, $6, $8); }
;
smoother2histval : SMOOTHER2HISTVAL ';'
{ driver.smoother2histval(); }
| SMOOTHER2HISTVAL '(' smoother2histval_options_list ')' ';'
{ driver.smoother2histval(); }
;
smoother2histval_options_list : smoother2histval_option COMMA smoother2histval_options_list
| smoother2histval_option
;
smoother2histval_option : o_infile
| o_invars
| o_period
| o_outfile
| o_outvars
;
o_dr_algo : DR_ALGO EQUAL INT_NUMBER {
if (*$3 == string("0"))
driver.warning("dr_algo option is now deprecated, and may be removed in a future version of Dynare");
@ -2841,6 +2864,12 @@ o_irf_plot_threshold : IRF_PLOT_THRESHOLD EQUAL non_negative_number { driver.opt
o_consider_all_endogenous : CONSIDER_ALL_ENDOGENOUS { driver.option_str("endo_vars_for_moment_computations_in_estimation", "all_endogenous_variables"); };
o_consider_only_observed : CONSIDER_ONLY_OBSERVED { driver.option_str("endo_vars_for_moment_computations_in_estimation", "only_observed_variables"); };
o_infile : INFILE EQUAL filename { driver.option_str("infile", $3); };
o_invars : INVARS EQUAL '(' symbol_list ')' { driver.option_symbol_list("invars"); };
o_period : PERIOD EQUAL INT_NUMBER { driver.option_num("period", $3); };
o_outfile : OUTFILE EQUAL filename { driver.option_str("outfile", $3); };
o_outvars : OUTVARS EQUAL '(' symbol_list ')' { driver.option_symbol_list("outvars"); };
range : symbol ':' symbol
{
$1->append(":");

View File

@ -146,6 +146,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<INITIAL>bvar_forecast {BEGIN DYNARE_STATEMENT; return token::BVAR_FORECAST; }
<INITIAL>dynare_sensitivity {BEGIN DYNARE_STATEMENT; return token::DYNARE_SENSITIVITY;}
<INITIAL>initval_file {BEGIN DYNARE_STATEMENT; return token::INITVAL_FILE;}
<INITIAL>histval_file {BEGIN DYNARE_STATEMENT; return token::HISTVAL_FILE;}
<INITIAL>forecast {BEGIN DYNARE_STATEMENT; return token::FORECAST;}
<INITIAL>shock_decomposition {BEGIN DYNARE_STATEMENT; return token::SHOCK_DECOMPOSITION;}
<INITIAL>sbvar {BEGIN DYNARE_STATEMENT; return token::SBVAR;}
@ -166,6 +167,7 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<INITIAL>calib_smoother { BEGIN DYNARE_STATEMENT; return token::CALIB_SMOOTHER; }
<INITIAL>model_diagnostics {BEGIN DYNARE_STATEMENT; return token::MODEL_DIAGNOSTICS;}
<INITIAL>extended_path {BEGIN DYNARE_STATEMENT; return token::EXTENDED_PATH;}
<INITIAL>smoother2histval {BEGIN DYNARE_STATEMENT; return token::SMOOTHER2HISTVAL;}
<DYNARE_STATEMENT>; {
if (!sigma_e)
@ -532,7 +534,11 @@ DATE -?[0-9]+([YyAa]|[Mm]([1-9]|1[0-2])|[Qq][1-4]|[Ww]([1-9]{1}|[1-4][0-9]|5[0-2
<DYNARE_STATEMENT>long_name {return token::LONG_NAME;}
<DYNARE_STATEMENT>consider_all_endogenous {return token::CONSIDER_ALL_ENDOGENOUS;}
<DYNARE_STATEMENT>consider_only_observed {return token::CONSIDER_ONLY_OBSERVED;}
<DYNARE_STATEMENT>infile {return token::INFILE;}
<DYNARE_STATEMENT>invars {return token::INVARS;}
<DYNARE_STATEMENT>period {return token::PERIOD;}
<DYNARE_STATEMENT>outfile {return token::OUTFILE;}
<DYNARE_STATEMENT>outvars {return token::OUTVARS;}
<DYNARE_STATEMENT>[\$][^$]*[\$] {
strtok(yytext+1, "$");

View File

@ -341,6 +341,17 @@ InitvalFileStatement::writeOutput(ostream &output, const string &basename) const
<< "initvalf('" << filename << "');" << endl;
}
HistvalFileStatement::HistvalFileStatement(const string &filename_arg) :
filename(filename_arg)
{
}
void
HistvalFileStatement::writeOutput(ostream &output, const string &basename) const
{
output << "histvalf('" << filename << "');" << endl;
}
HomotopyStatement::HomotopyStatement(const homotopy_values_t &homotopy_values_arg,
const SymbolTable &symbol_table_arg) :
homotopy_values(homotopy_values_arg),

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2003-2012 Dynare Team
* Copyright (C) 2003-2014 Dynare Team
*
* This file is part of Dynare.
*
@ -122,6 +122,15 @@ public:
virtual void writeOutput(ostream &output, const string &basename) const;
};
class HistvalFileStatement : public Statement
{
private:
const string filename;
public:
HistvalFileStatement(const string &filename_arg);
virtual void writeOutput(ostream &output, const string &basename) const;
};
class HomotopyStatement : public Statement
{
public:

View File

@ -2679,3 +2679,16 @@ void ParsingDriver::end_irf_calibration()
irf_calibration_constraints.clear();
}
void
ParsingDriver::smoother2histval()
{
mod_file->addStatement(new Smoother2histvalStatement(options_list));
options_list.clear();
}
void
ParsingDriver::histval_file(string *filename)
{
mod_file->addStatement(new HistvalFileStatement(*filename));
delete filename;
}

View File

@ -665,6 +665,9 @@ public:
void add_irf_calibration_item(string *endo, string *periods, string *exo, vector<string *> *range);
//! End a moment_calibration statement
void end_irf_calibration();
void smoother2histval();
void histval_file(string *filename);
};
#endif // ! PARSING_DRIVER_HH

View File

@ -173,7 +173,9 @@ MODFILES = \
gradient/fs2000_numgrad_5.mod \
filter_step_ahead/fs2000_filter_step_ahead_bayesian.mod \
filter_step_ahead/fs2000_filter_step_ahead_ML.mod \
loglinear/example4_loglinear.mod
loglinear/example4_loglinear.mod \
smoother2histval/fs2000_simul.mod \
smoother2histval/fs2000_smooth.mod
XFAIL_MODFILES = ramst_xfail.mod \
estim_param_in_shock_value.mod
@ -244,6 +246,9 @@ dsge-var/dsgevar_forward_estimated_lambda.m.trs: dsge-var/simul_hybrid.m.trs
dsge-var/dsgevar_forward_calibrated_lambda.o.trs: dsge-var/simul_hybrid.o.trs
dsge-var/dsgevar_forward_estimated_lambda.o.trs: dsge-var/simul_hybrid.o.trs
smoother2histval/fs2000_simul.m.trs: smoother2histval/fs2000_smooth.m.trs
smoother2histval/fs2000_simul.o.trs: smoother2histval/fs2000_smooth.o.trs
# Matlab TRS Files
M_TRS_FILES = $(patsubst %.mod, %.m.trs, $(MODFILES))
M_TRS_FILES += run_block_byte_tests_matlab.m.trs run_reporting_test_matlab.m.trs run_all_unitary_tests.m.trs

View File

@ -0,0 +1,60 @@
// Test that histval_file works
// Note that an observation equation has been modified in order to have an aux var for lagged endo
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-2);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
initval;
k = 6;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady;
histval_file(filename = 'fs2000_histval.mat');
simul(periods = 30);

View File

@ -0,0 +1,78 @@
// Test that smoother2histval works (with an outfile)
// Note that an observation equation has been modified in order to have an aux var for lagged endo
var m P c e W R k d n l gy_obs gp_obs y dA;
varexo e_a e_m;
parameters alp bet gam mst rho psi del;
alp = 0.33;
bet = 0.99;
gam = 0.003;
mst = 1.011;
rho = 0.7;
psi = 0.787;
del = 0.02;
model;
dA = exp(gam+e_a);
log(m) = (1-rho)*log(mst) + rho*log(m(-1))+e_m;
-P/(c(+1)*P(+1)*m)+bet*P(+1)*(alp*exp(-alp*(gam+log(e(+1))))*k^(alp-1)*n(+1)^(1-alp)+(1-del)*exp(-(gam+log(e(+1)))))/(c(+2)*P(+2)*m(+1))=0;
W = l/n;
-(psi/(1-psi))*(c*P/(1-n))+l/n = 0;
R = P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(-alp)/W;
1/(c*P)-bet*P*(1-alp)*exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)/(m*l*c(+1)*P(+1)) = 0;
c+k = exp(-alp*(gam+e_a))*k(-1)^alp*n^(1-alp)+(1-del)*exp(-(gam+e_a))*k(-1);
P*c = m;
m-1+d = l;
e = exp(e_a);
y = k(-1)^alp*n^(1-alp)*exp(-alp*(gam+e_a));
gy_obs = dA*y/y(-2);
gp_obs = (P/P(-1))*m(-1)/dA;
end;
initval;
k = 6;
m = mst;
P = 2.25;
c = 0.45;
e = 1;
W = 4;
R = 1.02;
d = 0.85;
n = 0.19;
l = 0.86;
y = 0.6;
gy_obs = exp(gam);
gp_obs = exp(-gam);
dA = exp(gam);
end;
shocks;
var e_a; stderr 0.014;
var e_m; stderr 0.005;
end;
steady;
check;
estimated_params;
alp, beta_pdf, 0.356, 0.02;
bet, beta_pdf, 0.993, 0.002;
gam, normal_pdf, 0.0085, 0.003;
mst, normal_pdf, 1.0002, 0.007;
rho, beta_pdf, 0.129, 0.223;
psi, beta_pdf, 0.65, 0.05;
del, beta_pdf, 0.01, 0.005;
stderr e_a, inv_gamma_pdf, 0.035449, inf;
stderr e_m, inv_gamma_pdf, 0.008862, inf;
end;
varobs gp_obs gy_obs;
options_.solve_tolf = 1e-12;
estimation(order=1,datafile=fsdat_simul,nobs=192,loglinear,mh_replic=1500,mh_nblocks=1,mh_jscale=0.8,smoother);
smoother2histval(period = 5, outfile = 'fs2000_histval.mat');