### predetermined_variables:

```* reworked a little bit the implementation
* documented the command in the reference manual

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3143 ac1d8469-bf42-47a9-8791-bf33cf982152```
parent d17b813c
 ... ... @@ -378,6 +378,7 @@ In the description of Dynare commands, the following conventions are observed: ... ... @@ -610,6 +611,81 @@ change_type(parameters) y, w; predetermined_variables predetermined_variables declare some endogenous variables as predetermined predetermined_variables VARIABLE_NAME VARIABLE_NAME ; Description In Dynare, the default convention is that the timing of a variable reflects when this variable is decided. The typical example is for capital stock: since the capital stock used at current period is actually decided at the previous period, then the capital stock entering the production function is k(-1), and the law of motion of capital must be written: k = i + (1-delta)*k(-1) Put another way, for stock variables, the default in Dynare is to use a “stock at the end of the period” concept, instead of a “stock at the beginning of the period” convention. The predetermined_variables is used to change that convention. The endogenous variables declared as predetermined variables are supposed to be decided one period ahead of all other endogenous variables. For stock variables, they are supposed to follow a “stock at the beginning of the period” convention. Example The following two program snippets are strictly equivalent. Using default Dynare timing convention: var y, k, i; ... model; y = k(-1)^alpha; k = i + (1-delta)*k(-1); ... end; Using the alternative timing convention: var y, k, i; predetermined_variables k; ... model; y = k^alpha; k(+1) = i + (1-delta)*k; ... end; Expressions ... ...
 ... ... @@ -1995,15 +1995,6 @@ DynamicModel::writeDynamicModel(ostream &DynamicOutput, bool use_dll) const void DynamicModel::writeOutput(ostream &output, const string &basename, bool block, bool byte_code, bool use_dll) const { // Write list of predetermined variables in M_.predetermined_variables if (predetermined_variables_vec.size() > 0) { output << "M_.predetermined_variables = '';" << endl; for(vector ::const_iterator it = predetermined_variables_vec.begin(); it != predetermined_variables_vec.end(); it++) output << "M_.predetermined_variables = strvcat(M_.predetermined_variables, '" << *it << "');" << endl; } /* Writing initialisation for M_.lead_lag_incidence matrix M_.lead_lag_incidence is a matrix with as many columns as there are endogenous variables and as many rows as there are periods in the ... ... @@ -3090,34 +3081,11 @@ DynamicModel::substituteExpectation(bool partial_information_model) void DynamicModel::transformPredeterminedVariables() { for(vector ::const_iterator it = predetermined_variables_vec.begin(); it != predetermined_variables_vec.end(); it++) for(int i = 0; i < (int) equations.size(); i++) { try { if(symbol_table.getType(*it)!=eEndogenous) { cerr << "Error: You must declare predetermined variable " << *it << " as an endogenous variable." << endl; exit(EXIT_FAILURE); } } catch(SymbolTable::UnknownSymbolNameException &e) { cerr << "Error: predetermind variable " << *it << " has not been declared." << endl; exit(EXIT_FAILURE); } catch(...) { cerr << "error in DynamicModel::transformPredeterminedVariables(), should not arrive here" << endl; exit(EXIT_FAILURE); } for(int i = 0; i < (int) equations.size(); i++) { BinaryOpNode *substeq = dynamic_cast(equations[i]->decreaseLeadsLagsPredeterminedVariables(*it)); assert(substeq != NULL); equations[i] = substeq; } BinaryOpNode *substeq = dynamic_cast(equations[i]->decreaseLeadsLagsPredeterminedVariables()); assert(substeq != NULL); equations[i] = substeq; } } ... ...
 ... ... @@ -165,8 +165,6 @@ public: int mfs; //! the file containing the model and the derivatives code ofstream code_file; //! Stores variables declared to be predetermined by "predetermined_variables" statement vector predetermined_variables_vec; //! Execute computations (variable sorting + derivation) /*! \param jacobianExo whether derivatives w.r. to exo and exo_det should be in the Jacobian (derivatives w.r. to endo are always computed) ... ...