adding "exclusion constants" to svar identification
parent
c6a33a96f1
commit
dcf5273b26
|
@ -1149,10 +1149,12 @@ PlotConditionalForecastStatement::writeOutput(ostream &output, const string &bas
|
|||
SvarIdentificationStatement::SvarIdentificationStatement(const svar_identification_exclusion_t &exclusion_arg,
|
||||
const bool &upper_cholesky_present_arg,
|
||||
const bool &lower_cholesky_present_arg,
|
||||
const bool &constants_exclusion_present_arg,
|
||||
const SymbolTable &symbol_table_arg) :
|
||||
exclusion(exclusion_arg),
|
||||
upper_cholesky_present(upper_cholesky_present_arg),
|
||||
lower_cholesky_present(lower_cholesky_present_arg),
|
||||
constants_exclusion_present(constants_exclusion_present_arg),
|
||||
symbol_table(symbol_table_arg)
|
||||
{
|
||||
}
|
||||
|
@ -1199,10 +1201,12 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
|||
if (lower_cholesky_present)
|
||||
output << "options_.ms.lower_cholesky=1;" << endl;
|
||||
|
||||
if (constants_exclusion_present)
|
||||
output << "options_.ms.constants_exclusion=1;" << endl;
|
||||
|
||||
if (!upper_cholesky_present && !lower_cholesky_present)
|
||||
{
|
||||
int n = symbol_table.endo_nbr();
|
||||
// int m = symbol_table.exo_nbr();
|
||||
int m = 1; // this is the constant, not the shocks
|
||||
int r = getMaxLag();
|
||||
int k = r*n+m;
|
||||
|
@ -1226,7 +1230,7 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
|||
output << "options_.ms.Ri = zeros(" << k << ", " << k << ", " << n << ");" << endl;
|
||||
|
||||
vector<int> rows(n);
|
||||
for(vector<int>::iterator it=rows.begin(); it != rows.end(); it++) *it = 1;
|
||||
fill(rows.begin(),rows.end(),1);
|
||||
|
||||
for (svar_identification_exclusion_t::const_iterator it = exclusion.begin(); it != exclusion.end(); it++)
|
||||
{
|
||||
|
@ -1265,6 +1269,14 @@ SvarIdentificationStatement::writeOutput(ostream &output, const string &basename
|
|||
}
|
||||
}
|
||||
}
|
||||
if (constants_exclusion_present)
|
||||
{
|
||||
for (unsigned int h = 0; h < n; h++)
|
||||
{
|
||||
output << "options_.ms.Ri(" << rows[h] << ", " << m << ", " << h+1 << ") = 1;" << endl;
|
||||
rows[h]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -517,12 +517,14 @@ private:
|
|||
const svar_identification_exclusion_t exclusion;
|
||||
const bool upper_cholesky_present;
|
||||
const bool lower_cholesky_present;
|
||||
const bool constants_exclusion_present;
|
||||
const SymbolTable &symbol_table;
|
||||
int getMaxLag() const;
|
||||
public:
|
||||
SvarIdentificationStatement(const svar_identification_exclusion_t &exclusion_arg,
|
||||
const bool &upper_cholesky_present_arg,
|
||||
const bool &lower_cholesky_present_arg,
|
||||
const bool &constants_exclusion_present_arg,
|
||||
const SymbolTable &symbol_table_arg);
|
||||
virtual void checkPass(ModFileStructure &mod_file_struct);
|
||||
virtual void writeOutput(ostream &output, const string &basename) const;
|
||||
|
|
|
@ -144,8 +144,8 @@ class ParsingDriver;
|
|||
/* end of GSA analysis*/
|
||||
%token FREQ INITIAL_YEAR INITIAL_SUBPERIOD FINAL_YEAR FINAL_SUBPERIOD DATA VLIST VARLIST LOG_VAR PERCENT_VAR
|
||||
%token VLISTLOG VLISTPER
|
||||
%token RESTRICTION_FNAME NLAGS CROSS_RESTRICTIONS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST BAYESIAN_PRIOR
|
||||
%token DUMMY_OBS NSTATES INDXSCALESSTATES
|
||||
%token RESTRICTIONS RESTRICTION_FNAME CROSS_RESTRICTIONS NLAGS CONTEMP_REDUCED_FORM REAL_PSEUDO_FORECAST
|
||||
%token DUMMY_OBS NSTATES INDXSCALESSTATES BAYESIAN_PRIOR
|
||||
%token <string_val> ALPHA BETA ABAND NINV CMS NCMS CNUM
|
||||
%token GSIG2_LMD GSIG2_LMDM Q_DIAG FLAT_PRIOR NCSK NSTD
|
||||
%token INDXPARR INDXOVR INDXAP APBAND INDXIMF IMFBAND INDXFORE FOREBAND INDXGFOREHAT INDXGIMFHAT
|
||||
|
@ -154,7 +154,7 @@ class ParsingDriver;
|
|||
%token OUTPUT_FILE_TAG DRAWS_NBR_BURN_IN_1 DRAWS_NBR_BURN_IN_2 HORIZON
|
||||
%token SBVAR TREND_VAR DEFLATOR GROWTH_FACTOR MS_IRF MS_VARIANCE_DECOMPOSITION
|
||||
%token MS_ESTIMATION MS_SIMULATION MS_COMPUTE_MDD MS_COMPUTE_PROBABILITIES MS_FORECAST
|
||||
%token SVAR_IDENTIFICATION EQUATION EXCLUSION LAG UPPER_CHOLESKY LOWER_CHOLESKY
|
||||
%token SVAR_IDENTIFICATION EQUATION EXCLUSION LAG UPPER_CHOLESKY LOWER_CHOLESKY
|
||||
%token MARKOV_SWITCHING CHAIN STATE DURATION NUMBER_OF_STATES
|
||||
%token SVAR COEFFICIENTS VARIANCES CONSTANTS EQUATIONS
|
||||
%token EXTERNAL_FUNCTION EXT_FUNC_NAME EXT_FUNC_NARGS FIRST_DERIV_PROVIDED SECOND_DERIV_PROVIDED
|
||||
|
@ -672,21 +672,20 @@ svar_identification : SVAR_IDENTIFICATION ';' svar_identification_list END ';'
|
|||
{ driver.end_svar_identification(); }
|
||||
;
|
||||
|
||||
svar_identification_list : svar_exclusion_list
|
||||
svar_identification_list : svar_identification_list svar_identification_elem
|
||||
| svar_identification_elem
|
||||
;
|
||||
|
||||
svar_identification_elem : EXCLUSION LAG INT_NUMBER ';' svar_equation_list
|
||||
{ driver.combine_lag_and_restriction($3); }
|
||||
| EXCLUSION CONSTANTS ';'
|
||||
{ driver.add_constants_exclusion(); }
|
||||
| UPPER_CHOLESKY ';'
|
||||
{ driver.add_upper_cholesky(); }
|
||||
| LOWER_CHOLESKY ';'
|
||||
{ driver.add_lower_cholesky(); }
|
||||
;
|
||||
|
||||
svar_exclusion_list : svar_exclusion_list svar_exclusion_elem
|
||||
| svar_exclusion_elem
|
||||
;
|
||||
|
||||
svar_exclusion_elem : EXCLUSION LAG INT_NUMBER ';' svar_equation_list
|
||||
{ driver.combine_lag_and_restriction($3); }
|
||||
;
|
||||
|
||||
svar_equation_list : svar_equation_list EQUATION INT_NUMBER COMMA svar_var_list ';'
|
||||
{ driver.add_restriction_in_equation($3); }
|
||||
| EQUATION INT_NUMBER COMMA svar_var_list ';'
|
||||
|
|
|
@ -419,6 +419,7 @@ string eofbuff;
|
|||
<DYNARE_BLOCK># {return Dynare::parser::token_type (yytext[0]);}
|
||||
|
||||
<DYNARE_BLOCK>autocorr {return token::AUTOCORR;}
|
||||
<DYNARE_BLOCK>restrictions {return token::RESTRICTIONS;}
|
||||
|
||||
/* Inside Dynare statement */
|
||||
<DYNARE_STATEMENT>solve_algo {return token::SOLVE_ALGO;}
|
||||
|
@ -454,7 +455,6 @@ string eofbuff;
|
|||
<DYNARE_STATEMENT>duration {return token::DURATION;}
|
||||
<DYNARE_STATEMENT>coefficients {return token::COEFFICIENTS;}
|
||||
<DYNARE_STATEMENT>variances {return token::VARIANCES;}
|
||||
<DYNARE_STATEMENT>constants {return token::CONSTANTS;}
|
||||
<DYNARE_STATEMENT>equations {return token::EQUATIONS;}
|
||||
|
||||
<DYNARE_STATEMENT>[\.] {return Dynare::parser::token_type (yytext[0]);}
|
||||
|
@ -517,6 +517,7 @@ string eofbuff;
|
|||
<DYNARE_STATEMENT,DYNARE_BLOCK>full {return token::FULL;}
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>nan {return token::NAN_CONSTANT;}
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>inf {return token::INF_CONSTANT;}
|
||||
<DYNARE_STATEMENT,DYNARE_BLOCK>constants {return token::CONSTANTS;}
|
||||
|
||||
/* options for GSA module by Marco Ratto */
|
||||
<DYNARE_STATEMENT>identification {return token::IDENTIFICATION;}
|
||||
|
|
|
@ -747,9 +747,11 @@ ParsingDriver::end_svar_identification()
|
|||
mod_file->addStatement(new SvarIdentificationStatement(svar_ident_exclusion_values,
|
||||
svar_upper_cholesky,
|
||||
svar_lower_cholesky,
|
||||
svar_constants_exclusion,
|
||||
mod_file->symbol_table));
|
||||
svar_upper_cholesky = false;
|
||||
svar_lower_cholesky = false;
|
||||
svar_constants_exclusion = false;
|
||||
svar_restriction_symbols.clear();
|
||||
svar_equation_restrictions.clear();
|
||||
svar_ident_exclusion_values.clear();
|
||||
|
@ -775,6 +777,12 @@ ParsingDriver::combine_lag_and_restriction(string *lag)
|
|||
delete lag;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_constants_exclusion(void)
|
||||
{
|
||||
svar_constants_exclusion = true;
|
||||
}
|
||||
|
||||
void
|
||||
ParsingDriver::add_restriction_in_equation(string *equation)
|
||||
{
|
||||
|
|
|
@ -142,13 +142,15 @@ private:
|
|||
HomotopyStatement::homotopy_values_t homotopy_values;
|
||||
//! Temporary storage for svar_identification blocks
|
||||
SvarIdentificationStatement::svar_identification_exclusion_t svar_ident_exclusion_values;
|
||||
//! Temporary storage for mapping the equation number to the restrictions within an svar_identification bock
|
||||
//! Temporary storage for mapping the equation number to the restrictions within an svar_identification block
|
||||
map<int, vector<int> > svar_equation_restrictions;
|
||||
//! Temporary storage for restrictions in an equation within an svar_identification bock
|
||||
//! Temporary storage for restrictions in an equation within an svar_identification block
|
||||
vector<int> svar_restriction_symbols;
|
||||
//! Temporary storage for upper cholesky within an svar_identification bock
|
||||
//! Temporary storage for constants exculsion within an svar_identification
|
||||
bool svar_constants_exclusion;
|
||||
//! Temporary storage for upper cholesky within an svar_identification block
|
||||
bool svar_upper_cholesky;
|
||||
//! Temporary storage for lower cholesky within an svar_identification bock
|
||||
//! Temporary storage for lower cholesky within an svar_identification block
|
||||
bool svar_lower_cholesky;
|
||||
|
||||
//! Temporary storage for argument list of external function
|
||||
|
@ -353,6 +355,8 @@ public:
|
|||
void add_restriction_in_equation(string *equation);
|
||||
//! Svar_Identification Statement: add list of restriction symbol ids
|
||||
void add_in_svar_restriction_symbols(string *name);
|
||||
//! Svar_Identification Statement: add exclusions of constants
|
||||
void add_constants_exclusion();
|
||||
//! Svar_Identification Statement: restriction of form upper cholesky
|
||||
void add_upper_cholesky();
|
||||
//! Svar_Identification Statement: restriction of form lower cholesky
|
||||
|
|
Loading…
Reference in New Issue