Commit c6495dfc authored by MichelJuillard's avatar MichelJuillard
Browse files

first implementation of transform_logpow. It creates too many auxilary

variables and probably violates Jensen inequality in some cases.
parent 62967319
......@@ -4155,31 +4155,31 @@ void
DynamicModel::substituteLogPow(void)
{
ExprNode::subst_table_t subst_table;
vector<BinaryOpNode *> neweqs;
vector<BinaryOpNode *> neweqs1, neweqs2;
// Substitute in model local variables
for (map<int, expr_t>::iterator it = local_variables_table.begin();
it != local_variables_table.end(); it++)
it->second = it->second->substituteLogPow(subst_table, neweqs);
it->second = it->second->substituteLogPow(subst_table, neweqs1, neweqs2);
// Substitute in equations
for (int i = 0; i < (int) equations.size(); i++)
{
BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->substituteLogPow(subst_table, neweqs));
BinaryOpNode *substeq = dynamic_cast<BinaryOpNode *>(equations[i]->substituteLogPow(subst_table, neweqs1, neweqs2));
assert(substeq != NULL);
equations[i] = substeq;
}
// Add new equations
for (int i = 0; i < (int) neweqs.size(); i++)
addEquation(neweqs[i]);
for (int i = 0; i < (int) neweqs1.size(); i++)
addEquation(neweqs1[i]);
// Add the new set of equations at the *beginning* of aux_equations
copy(neweqs.rbegin(), neweqs.rend(), front_inserter(aux_equations));
copy(neweqs2.rbegin(), neweqs2.rend(), front_inserter(aux_equations));
if (subst_table.size() > 0)
{
cout << "Adding auxiliary variables for log and pow expressions: added " << neweqs.size() << " auxiliary variables and equations." << endl;
cout << "Adding auxiliary variables for log and pow expressions: added " << neweqs1.size() << " auxiliary variables and equations." << endl;
}
}
......
......@@ -302,7 +302,7 @@ public:
void substituteExpectation(bool partial_information_model);
//! Transform the model by add auxiliary variables for log and pow expressions
void substituteLogPow(void)
void substituteLogPow(void);
//! Transforms the model by decreasing the lead/lag of predetermined variables in model equations by one
void transformPredeterminedVariables();
......
......@@ -102,7 +102,7 @@ class ParsingDriver;
%token <string_val> FLOAT_NUMBER
%token DEFAULT FIXED_POINT
%token FORECAST K_ORDER_SOLVER INSTRUMENTS PRIOR SHIFT MEAN STDEV VARIANCE MODE INTERVAL SHAPE DOMAINN
%token GAMMA_PDF GRAPH CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK STD
%token GAMMA_PDF GRAPH CONDITIONAL_VARIANCE_DECOMPOSITION NOCHECK TRANSFORM_LOGPOW STD
%token HISTVAL HOMOTOPY_SETUP HOMOTOPY_MODE HOMOTOPY_STEPS HOMOTOPY_FORCE_CONTINUE HP_FILTER HP_NGRID
%token IDENTIFICATION INF_CONSTANT INITVAL INITVAL_FILE BOUNDS JSCALE INIT
%token <string_val> INT_NUMBER
......@@ -837,6 +837,7 @@ steady_options : o_solve_algo
| o_markowitz
| o_maxit
| o_nocheck
| TRANSFORM_LOGPOW { driver.transform_logpow(); };
;
check : CHECK ';'
......
......@@ -438,6 +438,7 @@ string eofbuff;
<DYNARE_STATEMENT>homotopy_steps {return token::HOMOTOPY_STEPS; }
<DYNARE_STATEMENT>homotopy_force_continue {return token::HOMOTOPY_FORCE_CONTINUE;}
<DYNARE_STATEMENT>nocheck {return token::NOCHECK; }
<DYNARE_STATEMENT>transform_logpow {return token::TRANSFORM_LOGPOW; }
<DYNARE_STATEMENT>controlled_varexo {return token::CONTROLLED_VAREXO; }
<DYNARE_STATEMENT>parameter_set {return token::PARAMETER_SET; }
......
......@@ -424,6 +424,12 @@ NumConstNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
return const_cast<NumConstNode *>(this);
}
expr_t
NumConstNode::substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const
{
return const_cast<NumConstNode *>(this);
}
bool
NumConstNode::isNumConstNodeEqualTo(double value) const
{
......@@ -1179,6 +1185,12 @@ VariableNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
return const_cast<VariableNode *>(this);
}
expr_t
VariableNode::substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const
{
return const_cast<VariableNode *>(this);
}
bool
VariableNode::isNumConstNodeEqualTo(double value) const
{
......@@ -2200,6 +2212,72 @@ UnaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNo
}
}
expr_t
UnaryOpNode::substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const
{
if (op_code==oLog)
{
subst_table_t::iterator it = subst_table.find(const_cast<UnaryOpNode *>(this));
if (it != subst_table.end())
return const_cast<VariableNode *>(it->second);
//Arriving here, we need to create an auxiliary variable for the argument of the log expression:
//AUX_LOG_(arg.idx)
int symb_id = datatree.symbol_table.addLogAuxiliaryVar(arg->idx);
expr_t newAuxE = datatree.AddVariable(symb_id, 0);
assert(dynamic_cast<VariableNode *>(newAuxE) != NULL);
subst_table[this] = dynamic_cast<VariableNode *>(newAuxE);
//take care of any nested log expressions by calling arg->substituteLogPow(.), then decreaseLeadsLags for this oExpectation operator
//arg(lag-period) (holds entire subtree of arg(lag-period)
expr_t substexpr = arg->substituteLogPow(subst_table, neweqs1, neweqs2);
assert(substexpr != NULL);
// auxiliary equation with the exponential of the auxiliary variable
expr_t lhs = datatree.AddExp(newAuxE);
neweqs1.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(lhs, substexpr)));
// definition of the auxiliary variable to be used in initval and steadystate files
expr_t definition = datatree.AddLog(substexpr);
neweqs2.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(newAuxE,definition)));
return newAuxE;
}
else if (op_code==oSqrt)
{
subst_table_t::iterator it = subst_table.find(const_cast<UnaryOpNode *>(this));
if (it != subst_table.end())
return const_cast<VariableNode *>(it->second);
//Arriving here, we need to create an auxiliary variable for the argument of the log expression:
//AUX_LOG_(arg.idx)
int symb_id = datatree.symbol_table.addPowAuxiliaryVar(arg->idx);
expr_t newAuxE = datatree.AddVariable(symb_id, 0);
assert(dynamic_cast<VariableNode *>(newAuxE) != NULL);
subst_table[this] = dynamic_cast<VariableNode *>(newAuxE);
//take care of any nested log expressions by calling arg->substituteLogPow(.), then decreaseLeadsLags for this oExpectation operator
//arg(lag-period) (holds entire subtree of arg(lag-period)
expr_t substexpr = arg->substituteLogPow(subst_table, neweqs1, neweqs2);
assert(substexpr != NULL);
// auxiliary equation with the exponential of the auxiliary variable
expr_t lhs = datatree.AddExp(newAuxE);
neweqs1.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(lhs, substexpr)));
// definition of the auxiliary variable to be used in initval and steadystate files
expr_t definition = datatree.AddLog(substexpr);
neweqs2.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(newAuxE,definition)));
// expression to be used instead of sqrt
expr_t constant = datatree.AddNonNegativeConstant("0.5");
newAuxE = datatree.AddTimes(constant,newAuxE);
newAuxE = datatree.AddExp(newAuxE);
return newAuxE;
}
else
{
expr_t argsubst = arg->substituteLogPow(subst_table, neweqs1, neweqs2);
return buildSimilarUnaryOpNode(argsubst, datatree);
}
}
bool
UnaryOpNode::isNumConstNodeEqualTo(double value) const
{
......@@ -3413,6 +3491,61 @@ BinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOpN
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
expr_t
BinaryOpNode::substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const
{
if (op_code==oPower)
{
NumConstNode *arg2_node = dynamic_cast<NumConstNode *>(arg2);
if (arg2_node != NULL)
{
// the power exponent is a numerical constant
double arg2_val = arg2_node->eval(eval_context_t());
if (arg2_val == round(arg2_val))
// the power exponent is an integer, no transformation
{
expr_t arg1subst = arg1->substituteLogPow(subst_table, neweqs1, neweqs2);
expr_t arg2subst = arg2->substituteLogPow(subst_table, neweqs1, neweqs2);
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
}
subst_table_t::iterator it = subst_table.find(const_cast<BinaryOpNode *>(this));
if (it != subst_table.end())
return const_cast<VariableNode *>(it->second);
//Arriving here, we need to create an auxiliary variable for the argument of the log expression:
//AUX_LOG_(arg.idx)
int symb_id = datatree.symbol_table.addPowAuxiliaryVar(arg1->idx);
expr_t newAuxE = datatree.AddVariable(symb_id, 0);
assert(dynamic_cast<VariableNode *>(newAuxE) != NULL);
subst_table[this] = dynamic_cast<VariableNode *>(newAuxE);
//take care of any nested pow expressions by calling arg->substituteLogPow(.), then decreaseLeadsLags for this oExpectation operator
//arg(lag-period) (holds entire subtree of arg(lag-period)
expr_t arg1substexpr = arg1->substituteLogPow(subst_table, neweqs1, neweqs2);
assert(arg1substexpr != NULL);
expr_t arg2substexpr = arg2->substituteLogPow(subst_table, neweqs1, neweqs2);
assert(arg2substexpr != NULL);
// auxiliary equation with the exponential of the auxiliary variable
expr_t lhs = datatree.AddExp(newAuxE);
neweqs1.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(lhs, arg1substexpr)));
// definition of the auxiliary variable to be used in initval and steadystate files
expr_t definition = datatree.AddLog(arg1substexpr);
neweqs2.push_back(dynamic_cast<BinaryOpNode *>(datatree.AddEqual(newAuxE,definition)));
// expression to be used instead of sqrt
newAuxE = datatree.AddTimes(arg2substexpr,newAuxE);
newAuxE = datatree.AddExp(newAuxE);
return newAuxE;
}
else
{
expr_t arg1subst = arg1->substituteLogPow(subst_table, neweqs1, neweqs2);
expr_t arg2subst = arg2->substituteLogPow(subst_table, neweqs1, neweqs2);
return buildSimilarBinaryOpNode(arg1subst, arg2subst, datatree);
}
}
expr_t
BinaryOpNode::addMultipliersToConstraints(int i)
{
......@@ -4003,6 +4136,15 @@ TrinaryOpNode::substituteExpectation(subst_table_t &subst_table, vector<BinaryOp
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
expr_t
TrinaryOpNode::substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const
{
expr_t arg1subst = arg1->substituteLogPow(subst_table, neweqs1, neweqs2);
expr_t arg2subst = arg2->substituteLogPow(subst_table, neweqs1, neweqs2);
expr_t arg3subst = arg3->substituteLogPow(subst_table, neweqs1, neweqs2);
return buildSimilarTrinaryOpNode(arg1subst, arg2subst, arg3subst, datatree);
}
bool
TrinaryOpNode::isNumConstNodeEqualTo(double value) const
{
......@@ -4537,6 +4679,15 @@ ExternalFunctionNode::substituteExpectation(subst_table_t &subst_table, vector<B
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
expr_t
ExternalFunctionNode::substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const
{
vector<expr_t> arguments_subst;
for (vector<expr_t>::const_iterator it = arguments.begin(); it != arguments.end(); it++)
arguments_subst.push_back((*it)->substituteLogPow(subst_table, neweqs1, neweqs2));
return buildSimilarExternalFunctionNode(arguments_subst, datatree);
}
expr_t
ExternalFunctionNode::buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const
{
......
......@@ -357,7 +357,7 @@ public:
\param[in,out] subst_table Map used to store expressions that have already be substituted and their corresponding variable, in order to avoid creating two auxiliary variables for the same sub-expr.
\param[out] neweqs Equations to be added to the model to match the creation of auxiliary variables.
*/
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const = 0;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const = 0;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const = 0;
......@@ -437,7 +437,7 @@ public:
virtual expr_t substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
......@@ -496,7 +496,7 @@ public:
virtual expr_t substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
......@@ -570,7 +570,7 @@ public:
virtual expr_t substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
......@@ -657,7 +657,7 @@ public:
virtual expr_t substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
......@@ -724,7 +724,7 @@ public:
virtual expr_t substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual bool isNumConstNodeEqualTo(double value) const;
virtual bool isVariableNodeEqualTo(SymbolType type_arg, int variable_id, int lag_arg) const;
......@@ -794,7 +794,7 @@ public:
virtual expr_t substituteExoLead(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool deterministic_model) const;
virtual expr_t substituteExoLag(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteExpectation(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs, bool partial_information_model) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs) const;
virtual expr_t substituteLogPow(subst_table_t &subst_table, vector<BinaryOpNode *> &neweqs1, vector<BinaryOpNode *> &neweqs2) const;
virtual expr_t buildSimilarExternalFunctionNode(vector<expr_t> &alt_args, DataTree &alt_datatree) const;
virtual expr_t decreaseLeadsLagsPredeterminedVariables() const;
virtual bool isNumConstNodeEqualTo(double value) const;
......
......@@ -36,9 +36,8 @@ ModFile::ModFile() : expressions_tree(symbol_table, num_constants, external_func
ramsey_FOC_equations_dynamic_model(symbol_table, num_constants, external_functions_table),
static_model(symbol_table, num_constants, external_functions_table),
steady_state_model(symbol_table, num_constants, external_functions_table, static_model),
linear(false), block(false), byte_code(false),
use_dll(false), no_static(false), nonstationary_variables(false),
ramsey_policy_orig_eqn_nbr(0)
linear(false), block(false), byte_code(false), use_dll(false), no_static(false),
nonstationary_variables(false), transform_logpow(false), ramsey_policy_orig_eqn_nbr(0)
{
}
......@@ -246,7 +245,8 @@ ModFile::transformPass()
// Create auxiliary vars for Expectation operator
dynamic_model.substituteExpectation(mod_file_struct.partial_information);
dynamic_model.substituteLogPow();
if (transform_logpow)
dynamic_model.substituteLogPow();
if (nonstationary_variables)
{
......
......@@ -78,6 +78,9 @@ public:
//! Are nonstationary variables present ?
bool nonstationary_variables;
//! Is the log and power functions should be transformed ?
bool transform_logpow;
//! Global evaluation context
/*! Filled using initval blocks and parameters initializations */
eval_context_t global_eval_context;
......
......@@ -520,6 +520,12 @@ ParsingDriver::mfs(string *value)
delete value;
}
void
ParsingDriver::transform_logpow()
{
mod_file->transform_logpow = true;
}
void
ParsingDriver::end_initval()
{
......
......@@ -239,6 +239,8 @@ public:
void cutoff(string *value);
//! mfs option of model block
void mfs(string *value);
//! transform_logpow for model
void transform_logpow(void);
//! Sets the FILENAME for the initial value in initval
void initval_file(string *filename);
//! Declares an endogenous variable
......
......@@ -386,6 +386,48 @@ SymbolTable::addMultiplierAuxiliaryVar(int index) throw (FrozenException)
return symb_id;
}
int
SymbolTable::addLogAuxiliaryVar(int index) throw (FrozenException)
{
ostringstream varname;
int symb_id;
varname << "AUX_LOG_" << index+1;
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
}
catch (AlreadyDeclaredException &e)
{
cerr << "ERROR: you should rename your variable called " << varname.str() << ", this name is internally used by Dynare" << endl;
exit(EXIT_FAILURE);
}
aux_vars.push_back(AuxVarInfo(symb_id, avMultiplier, 0, 0, index));
return symb_id;
}
int
SymbolTable::addPowAuxiliaryVar(int index) throw (FrozenException)
{
ostringstream varname;
int symb_id;
varname << "AUX_POW_" << index+1;
try
{
symb_id = addSymbol(varname.str(), eEndogenous);
}
catch (AlreadyDeclaredException &e)
{
cerr << "ERROR: you should rename your variable called " << varname.str() << ", this name is internally used by Dynare" << endl;
exit(EXIT_FAILURE);
}
aux_vars.push_back(AuxVarInfo(symb_id, avMultiplier, 0, 0, index));
return symb_id;
}
int
SymbolTable::searchAuxiliaryVars(int orig_symb_id, int orig_lead_lag) const throw (SearchFailedException)
{
......
......@@ -39,7 +39,9 @@ enum aux_var_t
avExoLag = 3, //!< Substitute for exo lags >= 2
avExpectation = 4, //!< Substitute for Expectation Operator
// Type 5 now unused
avMultiplier = 6 //!< Multipliers for FOC of Ramsey Problem
avMultiplier = 6, //!< Multipliers for FOC of Ramsey Problem
avLog = 7, //!< Substitute argument of log expression
avPow = 8 //!< Substitute argument for power expression
};
//! Information on some auxiliary variables
......@@ -221,6 +223,18 @@ public:
\return the symbol ID of the new symbol
*/
int addMultiplierAuxiliaryVar(int index) throw (FrozenException);
//! Adds an auxiliary variable for log expression
/*!
\param[in] index Used to construct the variable name
\return the symbol ID of the new symbol
*/
int addLogAuxiliaryVar(int index) throw (FrozenException);
//! Adds an auxiliary variable for power expression
/*!
\param[in] index Used to construct the variable name
\return the symbol ID of the new symbol
*/
int addPowAuxiliaryVar(int index) throw (FrozenException);
//! Searches auxiliary variables which are substitutes for a given symbol_id and lead/lag
/*!
The search is only performed among auxiliary variables of endo/exo lag.
......
var c k aa;
varexo x;
parameters alph gam delt bet rho;
alph=0.5;
gam=0.5;
delt=0.02;
bet=0.05;
rho=0.9;
model;
c + k - aa*k(-1)^alph - (1-delt)*k(-1);
c^(-gam) - (1+bet)^(-1)*(aa(+1)*alph*k^(alph-1) + 1 - delt)*c(+1)^(-gam);
log(aa) = rho*log(aa(-1))+x;
end;
initval;
x = 0;
aa = 1;
k = ((delt+bet)/(1.0*aa*alph))^(1/(alph-1));
c = aa*k^alph-delt*k;
end;
steady(transform_logpow);
check;
shocks;
var x;
periods 1;
values 0.2;
end;
simul(periods=200);
rplot c;
rplot k;
write_latex_dynamic_model;
write_latex_static_model;
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment