Page 1 of 1

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

PostPosted: Wed Oct 19, 2016 11:30 am
by leolee
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.

Code: Select all
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,

Code: Select all
 sdf = beta*mu/mu(-1);
sdf_test = 1/ (sdf(+1) * (1/pi(+1));


I expected
Code: Select all
rbn0_1
and
Code: Select all
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

Re: E(XY) vs E(X)*E(Y) in dynare?

PostPosted: Wed Oct 19, 2016 3:19 pm
by 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
Code: Select all
test_sdf   = 1/(sdf(+1)/pi(+1));

which in Dynare means
Code: Select all
test_sdf   =E_t [ 1/(sdf(+1)/pi(+1))];

because there is a conditional expectation around every equation. You also have
Code: Select all
vbn0_1= (bet*mu(+1)/mu)*(1/pi(+1));
rbn0_1= vbn0_1^(-1);

which is
Code: Select all
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
Code: Select all
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.

Re: E(XY) vs E(X)*E(Y) in dynare?

PostPosted: Wed Oct 19, 2016 3:32 pm
by leolee
Thank you for your answer. Now I see what was wrong!

Leo.

jpfeifer wrote: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
Code: Select all
test_sdf   = 1/(sdf(+1)/pi(+1));

which in Dynare means
Code: Select all
test_sdf   =E_t [ 1/(sdf(+1)/pi(+1))];

because there is a conditional expectation around every equation. You also have
Code: Select all
vbn0_1= (bet*mu(+1)/mu)*(1/pi(+1));
rbn0_1= vbn0_1^(-1);

which is
Code: Select all
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
Code: Select all
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.