Page 1 of 1

A Problem of Writting Equations in Dynare

PostPosted: Thu Mar 16, 2017 7:08 am
by Peter Xiong
Dear All,

I got a problem when writting equations in dynare. I will show as folows,

#Omega=beta*(C-zeta0*L^(1+zeta)/(1+zeta) )/(C(+1)-zeta0*(L(+1))^(1+zeta)/(1+zeta))*(1-sigma+sigma*psi(+1));
mu=Omega*((rk(+1)+(1-delta)*Q(+1))/Q-(1+tauK)*R(+1));

Here i have two choies, one is writting the ''Omega'' as auxiliary variable and add the sign of ''#'', this is the same with Substituting omega into the next equation. The other choice is writting ''Omega'' as an endogeneous variable.

I found that the simulation result is very different with these two choies.

Please help me with this problem.

Thnak you very much!

Peter

Re: A Problem of Writting Equations in Dynare

PostPosted: Thu Mar 16, 2017 7:52 am
by jpfeifer
I am not really following here. Model-local variable (the ones with #) only exist within the context of the model, because whenever the model-local variable is encountered, the expression for it is substituted. This is exactly what you describe. So there must be something else going on.

Re: A Problem of Writting Equations in Dynare

PostPosted: Fri Mar 17, 2017 1:39 am
by Peter Xiong
jpfeifer wrote:I am not really following here. Model-local variable (the ones with #) only exist within the context of the model, because whenever the model-local variable is encountered, the expression for it is substituted. This is exactly what you describe. So there must be something else going on.

I mean there is two situations, one is, I write Omega with #, and the other situation is I write Omega without # and regard it as an endogeneous variable and declare it in ''var'' part.

The problem is, I found the result is very different between these two situations.

Can you help me with this problem. Thank you very much !

Re: A Problem of Writting Equations in Dynare

PostPosted: Fri Mar 17, 2017 8:02 am
by jpfeifer
As I said, this should not happen. Please provide the files to replicate the issue.

Re: A Problem of Writting Equations in Dynare

PostPosted: Fri Mar 17, 2017 8:51 am
by Peter Xiong
jpfeifer wrote:As I said, this should not happen. Please provide the files to replicate the issue.


This is the fle.

Thnak you very much.

Re: A Problem of Writting Equations in Dynare

PostPosted: Fri Mar 17, 2017 9:23 am
by jpfeifer
I cannot spot any differences. What do you I have to do to see the problem?

Re: A Problem of Writting Equations in Dynare

PostPosted: Fri Mar 17, 2017 9:35 am
by Peter Xiong
jpfeifer wrote:I cannot spot any differences. What do you I have to do to see the problem?


Change the parameter ''omega_taustar'' (in line 73)form 0 to 0.01, by two different situations, and see the last result,i.e. oo_.mean(26).

With ''#'', ''omega_taustar'' form 0 to 0.01, the oo_.mean(26) decrease. And without ''#'', when ''omega_taustar'' form 0 to 0.01, the oo_.mean(26) increase.

Re: A Problem of Writting Equations in Dynare

PostPosted: Mon Mar 20, 2017 10:37 am
by jpfeifer
There is a good reason for this and it involves i)Jensen's Inequality, ii) auxilary variables, and iii) the convention that there is a conditional expectation around every single equation you enter into Dynare.

What you have in your problem is basically an Euler equation with Omega being the stochastic discount factor. Say the SDF between t and t+1 is given by the standard
Code: Select all
Omega=beta*(C(+1)/C)^(-sigma)

What you want to evaluate is
Code: Select all
mu=E_t(SDF_{t,t+1} R_{t+1});

Note that the SDF depends on things not yet known at time t and that the pricing kernel involves a conditional expectation as of time t around the product of SDF and future return. This implies that at higher order, the covariance between the SDF and the return plays a role for pricing the asset. With your model-local variable, you get exactly the above expression, because whenever the SDF is encountered, it is substituted in. When you have
Code: Select all
#Omega=beta*(C(+1)/C)^(-sigma)
mu=Omega*R(+1)

this is equal to
Code: Select all
mu=E_t(beta*(C(+1)/C)^(-sigma)*R(+1))

where the E_t comes from the Dynare convention that there is a conditional expectation around every line.

Now consider your definition of Omega as a separate auxiliary variable
Code: Select all
Omega=beta*(C(+1)/C)^(-sigma)
mu=Omega*R(+1)

The first line tells Dynare that
Code: Select all
Omega=E_t(beta*(C(+1)/C)^(-sigma))

This means Omega is not an expression anymore, but the conditional expectation of the SDF as of time t, which is not random anymore. Substituting this into the pricing equation gives
Code: Select all
mu=E_t(E_t(beta*(C(+1)/C)^(-sigma))*R(+1))=E_t(beta*(C(+1)/C)^(-sigma))*E_t(R(+1))

which is very different from before, because now Jensen's Inequality does not apply anymore and the covariance drops out.

Re: A Problem of Writting Equations in Dynare

PostPosted: Mon Mar 20, 2017 11:27 am
by Peter Xiong
jpfeifer wrote:There is a good reason for this and it involves i)Jensen's Inequality, ii) auxilary variables, and iii) the convention that there is a conditional expectation around every single equation you enter into Dynare.

What you have in your problem is basically an Euler equation with Omega being the stochastic discount factor. Say the SDF between t and t+1 is given by the standard
Code: Select all
Omega=beta*(C(+1)/C)^(-sigma)

What you want to evaluate is
Code: Select all
mu=E_t(SDF_{t,t+1} R_{t+1});

Note that the SDF depends on things not yet known at time t and that the pricing kernel involves a conditional expectation as of time t around the product of SDF and future return. This implies that at higher order, the covariance between the SDF and the return plays a role for pricing the asset. With your model-local variable, you get exactly the above expression, because whenever the SDF is encountered, it is substituted in. When you have
Code: Select all
#Omega=beta*(C(+1)/C)^(-sigma)
mu=Omega*R(+1)

this is equal to
Code: Select all
mu=E_t(beta*(C(+1)/C)^(-sigma)*R(+1))

where the E_t comes from the Dynare convention that there is a conditional expectation around every line.

Now consider your definition of Omega as a separate auxiliary variable
Code: Select all
Omega=beta*(C(+1)/C)^(-sigma)
mu=Omega*R(+1)

The first line tells Dynare that
Code: Select all
Omega=E_t(beta*(C(+1)/C)^(-sigma))

This means Omega is not an expression anymore, but the conditional expectation of the SDF as of time t, which is not random anymore. Substituting this into the pricing equation gives
Code: Select all
mu=E_t(E_t(beta*(C(+1)/C)^(-sigma))*R(+1))=E_t(beta*(C(+1)/C)^(-sigma))*E_t(R(+1))

which is very different from before, because now Jensen's Inequality does not apply anymore and the covariance drops out.


I get it. Thank you very much, professor jpfeifer!