# E(XY) vs E(X)*E(Y) in dynare?

Dear members,

I encountered a strange (at least to me) problem while calculating bond price using dynare. I hope someone can tell me what I am doing wrong.

``rbn0_1 = 1/ (beta*mu(+1)/mu * (1/pi(+1))) ``

The code above is how I calculate the short-term nominal interest rate using the stochastic discounted factor and tomorrow’s inflation. (nominal SDF = real SDF / tomorrow’s inflation).

I also tried to define SDF explicitly in the dynare and tried the same thing,

``` sdf = beta*mu/mu(-1); sdf_test = 1/ (sdf(+1) * (1/pi(+1)); ```

I expected `rbn0_1` and `sdf_test` gives the same result, but they didn’t. (They have different theoretical mean provided by the dynare.)

I really hope someone let me know what I have done wrong.

** I attached the full code.

Best,
Leo
DPSW_WP_1.mod (13.2 KB)

What you describe in your post is perfectly equivalent and will return the same results. However, what you do in your mod-file is not what you describe.
You have

```test_sdf = 1/(sdf(+1)/pi(+1)); ```
which in Dynare means

```test_sdf =E_t 1/(sdf(+1)/pi(+1))]; ```
because there is a conditional expectation around every equation. You also have

```vbn0_1= (bet*mu(+1)/mu)*(1/pi(+1)); rbn0_1= vbn0_1^(-1); ```
which is

```vbn0_1= E_t(bet*mu(+1)/mu)*(1/pi(+1))]; rbn0_1= vbn0_1^(-1); ```
Note that there is no expected value in the last line because everything is dated time t and therefore in the information set. For that reason

```rbn0_1= (E_t(bet*mu(+1)/mu)*(1/pi(+1))])^(-1); ```
As you can clearly see, the conditional expectations is now in the denominator only, while for test_sdf it is around everything.

Leo.

[quote=“jpfeifer”]What you describe in your post is perfectly equivalent and will return the same results. However, what you do in your mod-file is not what you describe.
You have

```test_sdf = 1/(sdf(+1)/pi(+1)); ```
which in Dynare means

```test_sdf =E_t 1/(sdf(+1)/pi(+1))]; ```
because there is a conditional expectation around every equation. You also have

```vbn0_1= (bet*mu(+1)/mu)*(1/pi(+1)); rbn0_1= vbn0_1^(-1); ```
which is

```vbn0_1= E_t(bet*mu(+1)/mu)*(1/pi(+1))]; rbn0_1= vbn0_1^(-1); ```
Note that there is no expected value in the last line because everything is dated time t and therefore in the information set. For that reason

```rbn0_1= (E_t(bet*mu(+1)/mu)*(1/pi(+1))])^(-1); ```
As you can clearly see, the conditional expectations is now in the denominator only, while for test_sdf it is around everything.[/quote]