Expected value of a power

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Expected value of a power

Postby Fab.valenti » Fri Oct 14, 2011 2:03 pm

Hello,

I'm new to Dynare and, hopefully, I have a very simple question. I was wondering which was the correct way of writing the following line into dynare:

E_t[x_{t+1}^y]

If I write it like "x(t+1)^y", I'm afraid that Dynare would understand "[E_t(x_{t+1})]^y", that is not what I want...

I thought of creating a new variable "z=x^y" and then simply write "z(+1)", would that be correct?

Thanks a lot!


Fabrizio
Fab.valenti
 
Posts: 7
Joined: Fri Oct 14, 2011 1:44 pm

Re: Expected value of a power

Postby SébastienVillemot » Thu Oct 27, 2011 4:05 pm

No, if you write "x(t+1)^y", then Dynare understands
E_t[x_{t+1}^y].

Dynare automatically prepends an E_t in front of all equations.

So you don't need an auxiliary variable.

Best,
Sébastien Villemot
Economist at OFCE – Sciences Po
SébastienVillemot
 
Posts: 706
Joined: Fri Dec 07, 2007 2:29 pm
Location: Paris, France

Re: Expected value of a power

Postby jpfeifer » Thu Oct 27, 2011 8:07 pm

Actually, I think that Sébastien's answer is not the whole story. There are cases (like the Epstein-Zin preferences you are trying to use, I guess) where you need an auxiliary variable, see http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=2997. From my experience, using this type of auxiliary variable works in Dynare.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Expected value of a power

Postby StephaneAdjemian » Mon Nov 07, 2011 5:23 pm

The auxiliary variable is not needed except if you want to have the expectation of x_{t+1}^y inside a non linear function. For instance if in your model
you have something like

u(E_t[x_{t+1}^y]) = 0;

where u is a non linear function, then you just need to defin the auxiliary variable z as you propose and to rewrite the equation as

u(z(1)) = 0;

Best,
Stéphane.
Stéphane Adjemian
Université du Maine, GAINS and DynareTeam
https://stepan.adjemian.eu
StephaneAdjemian
 
Posts: 429
Joined: Wed Jan 05, 2005 4:24 pm
Location: Paris, France.

Re: Expected value of a power

Postby Fab.valenti » Thu Nov 17, 2011 9:26 am

Thank you all for your answers.

I am actually working with Epstein-Zin preferences and so far using the auxiliary variable seems to work.

Best,

Fabrizio
Fab.valenti
 
Posts: 7
Joined: Fri Oct 14, 2011 1:44 pm

Re: Expected value of a power

Postby jpfeifer » Fri Feb 10, 2012 8:08 am

Just to clarify Stéphane's answer. If you want to enter u(E_t[x_{t+1}^y]) = 0 where u is nonlinear, you need two equations
Code: Select all
u(z) = 0;
z=x(+1)^y;

The z in the first equation does not get a timing t+1, because the expectations operator at time t makes z belong to the information set at time t.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Expected value of a power

Postby farukakbal » Sun Dec 04, 2016 5:33 pm

How can i write the code segment that differentiate:
[exp(-V(t+1)/Theta)] / Expectation_t[exp(-V(t+1)/Theta)]
I fear i will always get 1 due to expectation operator that dynare uses.
farukakbal
 
Posts: 8
Joined: Sun Dec 04, 2016 5:25 pm

Re: Expected value of a power

Postby jpfeifer » Sun Dec 04, 2016 5:38 pm

You can find an example of Epstein-Zin preferences at https://github.com/JohannesPfeifer/DSGE_mod/blob/master/Caldara_et_al_2012/Caldara_et_al_2012.mod
Note that you need to use
Code: Select all
order>1
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Expected value of a power

Postby farukakbal » Wed Dec 14, 2016 10:34 pm

Testing the code that you suggesti I simply defined another variable that give the ratio between [V(+1)^sigma] and E_t[V(+1)^sigma]. For this purpose i defined another variable f1 and after the code line:
Code: Select all
// Define an auxiliary variable s that captures E_t[V(+1)^sigma]
s =V(+1)^(1-gamma);


I have written:
Code: Select all
f1 =(V(+1)^(1-gamma))/s;


Trying to take impulse response of the new variable f1, I observed that nothing changes in f1, which means that this auxiliary variable concept seems to not working.

Am i doing this wrong?

Thanks.
Attachments
Caldara_test.mod
(6.07 KiB) Downloaded 85 times
farukakbal
 
Posts: 8
Joined: Sun Dec 04, 2016 5:25 pm

Re: Expected value of a power

Postby jpfeifer » Thu Dec 15, 2016 8:45 am

I am not sure what you were trying to test, but the f1 you defined is not supposed to change, because it is identical to 1.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Expected value of a power

Postby farukakbal » Mon Dec 19, 2016 11:46 am

My original problem was to seperate
Code: Select all
V(+1)^(1-gamma)
and
Code: Select all
E_t[V(+1)^(1-gamma)]
.
I want to see if there is anything different between the value of
Code: Select all
V(+1)^(1-gamma)
and
Code: Select all
s
which is defined as
Code: Select all
E_t[V(+1)^(1-gamma)]
.
The code that you suggest find the ratio
Code: Select all
V(+1)^(1-gamma)/E_t[V(+1)^(1-gamma)]
by defining s first than writing
Code: Select all
V(+1)^(1-gamma)/s
. Hence, i tried to observe this ratio with new variable f1.
farukakbal
 
Posts: 8
Joined: Sun Dec 04, 2016 5:25 pm

Re: Expected value of a power

Postby jpfeifer » Wed Dec 21, 2016 7:56 am

That's not going to work. There is an expected value conditional on time t around every equation in Dynare. Therefore
Code: Select all
V(+1)^(1-gamma)/s=E_t(V(+1)^(1-gamma)/s)=1/s*E_t(V(+1)^(1-gamma))=1/s*s=1

where you can pull s out of the expectations because it is contained in the information set. The trick is to have a nonlinear transformation of that ratio like
Code: Select all
(V(+1)^(1-gamma)/s)^(1-(1/theta))=E_t[(V(+1)^(1-gamma)/s)^(1-(1/theta))]=(1/s)^(1-(1/theta))*E_t((V(+1)^(1-gamma))^(1-(1/theta)))~=1

because due to Jensen's inequality this is not equal to 1. In the first term
Code: Select all
(1/s)^(1-(1/theta))

the expectation is inside of the "to the power of (1-(1/theta))", while in
Code: Select all
E_t((V(+1)^(1-gamma))^(1-(1/theta)))

it is around the term.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Expected value of a power

Postby farukakbal » Wed Dec 21, 2016 12:56 pm

Thank you for the clear answer. I now understand how dynare expectation opeariton works. Considering this, i rearranged my code in which i have a similar form
Code: Select all
exp(-V(+1)/chi)/E_t[exp(-V(+1)/chi)]
where chi is robustness parameter.
I have written above expression as
Code: Select all
EV = -(V(+1)/chi);
and the original term is
Code: Select all
exp((-V(+1)/chi)-EV)
where exp() is a nonlinear function as you suggest.
I was expecting to have different irf responses whenever i change the value of chi. Yet i always am taking the same irf with different chi values.
My first response was to check whether i have written the ratio in a correct way. Now i am sure about that part yet i am clearly doing something else wrong.
Does exp() function have another property rather than being nonlinear - like it takes expectation inside etc.- or am i missing something obvious.
Here is my code if you want to look at.
Thanks again.
Attachments
Robust_Simple.mod
Order edited to 2
(8.68 KiB) Downloaded 65 times
Last edited by farukakbal on Wed Dec 21, 2016 3:25 pm, edited 1 time in total.
farukakbal
 
Posts: 8
Joined: Sun Dec 04, 2016 5:25 pm

Re: Expected value of a power

Postby jpfeifer » Wed Dec 21, 2016 1:23 pm

As mentioned in my first reply, you need
[url]order>1[/url]
If you only do a linear approximation, all nonlinearities are gone.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Expected value of a power

Postby farukakbal » Wed Dec 21, 2016 2:49 pm

I am sorry for that confusion but even if i change the order to 2 i obtain the same IRFs.
I will rebuild the code and inform the forum about the progress.
farukakbal
 
Posts: 8
Joined: Sun Dec 04, 2016 5:25 pm

Next

Return to Dynare help

Who is online

Users browsing this forum: Google [Bot] and 9 guests