# Expectation of function,vs,function of expectations

Hi,

I am using dynare++ 4.2.4, however I am confused as to how dynare++ handle the expectations of functions.
This is not a deterministic model and I wish to use order 3.

Suppose that I have the following:
Et[Mt+1*Rt+1]=1
let mt+1=log(Mt+1), rt+1=log(rt+1)
Then we have: Et[exp([mt+1]+[rt+1])=1

Question A , how do I write the above equation in dynare++?
If I write in model statement that 1=exp(m(+1)+r(+1)), how do I know if dynare++ will interpret it as
Et[exp{[mt+1]+[rt+1]}=1, versus, exp{Et[mt+1]+Et[rt+1]=1

Question B, a related question is, in general, how do I unambiguously tell dynare++ , that for a function of variable xt+1, I want f(Et(xt+1))=1 and not Et(f(xt+1))=1

Thank you.

As far as I know, Dynare always has an implicit conditional expectations operator at the beginning of each equation, i.e. E_t(f(x_{t+1}))=E_t(1). If you want a function of an expectations operator, i.e. f(E_t(x_{t+1}))=1 , you need to add an auxiliary variable:
[Expected value of a power)

As Stéphane pointed out, no need for aux variable unless u is non linear, and in this case u(E_t[x_{t+1}^y]) = 0 is to be written as u(z(1)) = 0, with an aux variable z.

I now have a feeling of what is going on, but I still yearn for a very explict rule, can you please resolve directly how to write following?
1.Et[f(x(t+1))]
2.f(Et(x(t+1))])
where f is non-linear
and
3.If I understand correctly, the starting point is the steady state in non-stochastic-case, but the final result is in steady state of stochastic-case. Will either 1 or 2 or both 1and2 make the approximation ‘bad’ around steady state in stochastic case? I use order=3 in models with exogenous shocks in dynare++ 4.2.4.

Thanks

The point of Stephane is that the expectations operator is a linear operator. Hence, if the function u is a linear function,
u(E_t[x_{t+1}^y]) = 0 is equal to E_t(u(x_{t+1}^y))=0.
But as he said, only if u is linear. E.g. say u(z)= alpha+bettaz. Then u(x_{t+1}^y)=alpha+bettax_{t+1}^y. Thus,
E_t (alpha+bettax_{t+1}^y)= alpha+bettaE_t(x_{t+1}^y).
But if u is non-linear, you cannot pull the expectations inside and need an auxiliary variable.

1. would be written as f(x(1)).
2. would be written as f(z) with an auxiliary variable z=x(1)^y

By the way, note that Stéphane’s answer has the wrong timing for z. Due to the conditional expectations at time t, z belongs to the information set at time t.

Regarding 3: if f is non-linear, only the second version will deliver a correct approximation at order 2 or higher. The reason is that with 1 you ignore Jensen’s Inequality and get a linear approximation.

Thank you jpfeifer, for the brilliant reply. However Ian’s quote points out that dynare is not good at handling equation 2. that is, to write out the theoretical model f(Et(x(t+1))]) as f(z) with z=x(1)^y.
Does Ian’s quote points out that dynare++ (stochastic, order >2) cannot handle the scenario of f(Et(x(t+1))]) very well?

I don’t agree with Ian’s statement. Using Dynare (and by extension Dynare++), I am able to essentially replicate the findings in
ideas.repec.org/p/nbr/nberwo/15026.html, suggesting that it works perfectly well.