# Problem with expectation in dynare

Dear Professor Pfeifer,

I have encountered a problem with expectation in dynare code. It is much like the question in Expectations vs realized, which I still do not understand how to realize this in the code. Would you please give any advice ? Thank you very much.

When I was reading Suh(2011) titled Evaluating Macroprudential Policy with Financial
Friction DSGE Model, I saw the equation like (30) in the paper. I’m not sure how to deal with \bar{\omega }_{t}^{a} and \bar{\omega }_{t}^{b} in the dynare code.

Is it correct to write as bellow in dynare?

\bar{\omega }_{t}^{a}=\frac{R_{t}^{LB}L_{t}^{B}}{R_{t+1}^{K}{{q}_{t}}{{K}_{t}}}

\bar{\omega }_{t}^{b}=\frac{R_{t-1}^{LB}L_{t-1}^{B}}{R_{t}^{K}{{q}_{t-1}}{{K}_{t-1}}}

The timing in these papers is always tricky. The strange part is the timing on \bar \omega_t^b as it is stated to be in t+1. In that case, its timing in Dynare would indeed by t+1 and you would enter it for period t, i.e. shift everything by one period as you did above. What need to take care of is
E_tR_{t+1}^K, which is a variable dated time t and defined in equation (28). Your equation does not correctly handle this as you cannot pull the expectation into the denominator.

Dear Professor Pfeifer,

I’m sorry that I do not quite understand why

cannot pull the expectation into the denominator

Would you please tell me how should I deal with this E_tR_{t+1}^K in the code?

Thank you very much.

As I wrote Equation (28) defines the whole object.

Dear Professor Pfeifer,

Isn’t equation (28) the first-order condition of standard debt contract written as bellow?
\left[ 1-\Gamma \left( \bar{\omega }_{t}^{a} \right) \right]\frac{{{E}_{t}}\left( R_{t+1}^{K} \right)}{R_{t}^{f}}=\frac{{\Gamma }'\left( \bar{\omega }_{t}^{a} \right)}{{\Gamma }'\left( \bar{\omega }_{t}^{a} \right)-\mu {G}'\left( \bar{\omega }_{t}^{a} \right)}\left\{ 1-\left[ \Gamma \left( \bar{\omega }_{t}^{a} \right)-\mu G\left( \bar{\omega }_{t}^{a} \right) \right]\frac{{{E}_{t}}\left( R_{t+1}^{K} \right)}{R_{t}^{f}} \right\}

And I see in Bernanke et al.(1999) and Christiano et al.(2010)'s code that E_tR_{t+1}^K is equal to R_{t+1}^{K} in dynare. I thought that I should include all three eqations bellow in dynare. It seems that \bar{\omega }_{t}^{a}=\bar{\omega }_{t+1}^{b}, which is so wierd. Would you please point out the mistake?

\bar{\omega }_{t}^{a}{R_{t+1}^{K}{{q}_{t}}{{K}_{t}}}={R_{t}^{LB}L_{t}^{B}}
\bar{\omega }_{t}^{b}{R_{t}^{K}{{q}_{t-1}}{{K}_{t-1}}}={R_{t-1}^{LB}L_{t-1}^{B}}
\left[ 1-\Gamma \left( \bar{\omega }_{t}^{a} \right) \right]\frac{R_{t+1}^{k}}{R_{t}^{f}}=\frac{{\Gamma }'\left( \bar{\omega }_{t}^{a} \right)}{{\Gamma }'\left( \bar{\omega }_{t}^{a} \right)-\mu {G}'\left( \bar{\omega }_{t}^{a} \right)}\left\{ 1-\left[ \Gamma \left( \bar{\omega }_{t}^{a} \right)-\mu G\left( \bar{\omega }_{t}^{a} \right) \right]\frac{R_{t+1}^{k}}{R_{t}^{f}} \right\}