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.

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.

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?