Hi, I was trying to do part 4 of the homework but i have a problem using the interpolation algorithm. the command in matlab is interp1(x,Y,xi) where Y is the function and xi is the extended array (as far as I understand for example if x is a 5 element vector from 1 to 5, Y is log(x) and xi is a 100 element vector from 1 to 5. So here we obtain a 100 vector with the interpolated values). Now i don't know what to do with the value function, how should i procede? Should i interpolate the value function beore maximizing? how many should i use for the interpolation? Thanks in advance Lian
I was doing PS1 and in the first question using kM=exp(z)^(1/(1-alpha)) with z=0 as you said in class means that kM=1 and thus all our capital points are between zero and 1. This means that the return fn, log(exp(z)*k^alpha+(1-delta)*k-kprime) is always log of a number less than 1 (as we have full depreciation) and thus the value fn, while it does converge just gives stupid numbers. Is this intentional?
Re lian: You interpolate before maximizing (it's easiest to do it row by row). And use 50 pts for the interpolation in q4.
Hi. I calculated the SSR for the different models and found that interpolating increases the SSR. This seems counterintuitive. Does anyone else have the same result? Thanks, Eleonora
Lian, you don't need to interpolate the instantaneous utility function log(c). You already know the function. You need to interpolate the the unknown value function for which you only know its value on the grid points. You interpolate V_i to make it "continuous" and hence to be able to choose optimal k' that doesn't necessarily belongs to the grid for capital.
Let's try this exercise. Minimize y=x^2+0.5*x^3 for x in [-1,1]. Clearly x*=0. Now, let's do it in the computer as follows:
1) Assume you don't know the 2nd term of the function (ie., .5*x^3, and let's call it g(x)) over the whole domain.
2) Suppose you only know g(x) on few points. Say N points, x_i, i=1,...,N, in [-1,1]. Do NOT include 0 (zero) on that grid. For instance, in Matlab, create the array x_i=-1:.03:1.
3) Create the vector g_i=0.5*x_i.^3 in the beginning of your code.
4) Create the following Matlab function:
function out = FFF(z) %z can be scalar or a vector in [-1,1] global x_i g_i out = z.^2 + interp1(x_i,g_i,z) return
5) Now use Matlab function fminbnd to find the minimum of the function FFF. You should get something very close to zero as minimizer.
What you need to do in PS1 is something quite similar to that!!!
Eleonora, you should not get that result. The whole idea of interpolating is to reduce the Euler errors. Are you sure that the convergence criteria are the same in both cases? How about the convergence criteria of each maximization?
Hi ! I also found that interpolating increases the SSR. Maybe I am doing wrong the interpolation because I can not use the codes that the professor send us with this example of function "Y" with the unknown part "G".
Do you have any outputs (eg. maybe the value fns given some tolerance level, for q2 and for q4 with M=20) that we can use to check that our codes are doing the right thing?
In q7, are the sum of squared errors implied by the associated policy fns that we are to calculate just the SSR of the difference between the interpolated and uninterpolated policy fns that we calculate here?
I do have some output related to the first few questions (ie., the deterministic growth model with log utility and full depreciation). Of course, my results depend on the convergence criterion and the exact grid I used. So, I considered that V_i has converge when max(abs(V_i - V_i+1))<10^(-6). My grid is: kgrid = linspace(.001,1,M) ; For M=20, I got SSR = 3.5193e-004 with no interpolation, and the first 3 values of V_i+1 are -19.6840, -17.9550, -17.6654.
As for the last question, you need to calculate the Euler errors. That is, use the Euler equation and the approximate policy function you've found to calculate LHS-RHS. Do that for each policy function you find.
Another output I can give you for you to check whether your code is fine is the average squared error of your policy function (instead of the value function as I ask you to do in the homework), that I denote SSRg. Recall that as you know the true value function you also know the true policy function. So in the case with linear interpolation, I get SSRg = 1.2072e-004.
I have a question about part 8: What does it mean to start from the invariant distribution? does it mean we choose the starting value randomly from the invariant distribution of all states?
Another problem in question 8 is that we get negative values for investment. It makes no sense but I think up to there everything is correct.... Then of course we cant log and detrend it. Did you try it? And did you get only positive investment? Or anyone else?? Thanks,
So another thing: to find the the sum of squared euler errors for the interpolated part of question 7. How do we find k''. k' will not be in the grid so we cannot use the value function. The same thing goes for simulating the economy i guess. I am really lost at that point.
Fabian, Interpolate the policy function if you need to. I suppose you don't need to find k'' by interpolating g if k' is always in K_D (the case of no interpolation), right? I hope this helps.
Hi, In question 7 i calculate the transition matriz and i found that pi13 and pi31 are zeros, that doesn`t make so much sense with what Manuel told s about getting an invariant matrix without zeros for any state.I use q=1 but i try also with bigger q's) Is mine correct? do you get the same? Thanks Lian
@Lian they should definitely not be zeros. Are you using the normcdf command with the mean & std error of the epsilon to calculate the numbers? Using that with the formulas from the lecture notes should give you the correct (nonzero) values for the transition matrix.
What do you want us to submit for this assignment? Do you just want the m-files or do you want us to also give you copies of the graphs &/or the numbers for the SSRs & Business cycle stddevs?
Also, when you say: Set the initial state (k0,z0) according to it's invariant distribution. Do you mean that rather than starting the economy in the steady state as we did with Javier we should calculate the invariant distribution of (k,z) and then using a rand number choose the starting point based on this (and if so then what about the interpolated case, do we just use the same invariant distn calculated for the discrete case).
If you cant beat themjoin them. But you do know your daughter will give that up if shethinks it can save you. erotic sex teaching stories free toon porn stories real femdom stories bondage gag stories mind control incest sex stories If you cant beat themjoin them. But you do know your daughter will give that up if shethinks it can save you.
Here, this usually helps with peoples first tatoo. I said two things, first, she couldnt tell hergirlfriend about the tape as it might get to her husband somehow. sex post stories sites male masturbation with moms lingerie stories milfs seducing young men sex stories free fantasy incest text stories stories about beastiality Here, this usually helps with peoples first tatoo. I said two things, first, she couldnt tell hergirlfriend about the tape as it might get to her husband somehow.
Hi, I was trying to do part 4 of the homework but i have a problem using the interpolation algorithm. the command in matlab is interp1(x,Y,xi) where Y is the function and xi is the extended array (as far as I understand for example if x is a 5 element vector from 1 to 5, Y is log(x) and xi is a 100 element vector from 1 to 5. So here we obtain a 100 vector with the interpolated values). Now i don't know what to do with the value function, how should i procede? Should i interpolate the value function beore maximizing? how many should i use for the interpolation?
ReplyDeleteThanks in advance
Lian
I was doing PS1 and in the first question using kM=exp(z)^(1/(1-alpha)) with z=0 as you said in class means that kM=1 and thus all our capital points are between zero and 1. This means that the return fn, log(exp(z)*k^alpha+(1-delta)*k-kprime) is always log of a number less than 1 (as we have full depreciation) and thus the value fn, while it does converge just gives stupid numbers. Is this intentional?
ReplyDeleteRe lian: You interpolate before maximizing (it's easiest to do it row by row). And use 50 pts for the interpolation in q4.
PART 5
ReplyDeleteHi.
I calculated the SSR for the different models and found that interpolating increases the SSR. This seems counterintuitive. Does anyone else have the same result?
Thanks,
Eleonora
Lian, you don't need to interpolate the instantaneous utility function log(c). You already know the function. You need to interpolate the the unknown value function for which you only know its value on the grid points. You interpolate V_i to make it "continuous" and hence to be able to choose optimal k' that doesn't necessarily belongs to the grid for capital.
ReplyDeleteLet's try this exercise. Minimize y=x^2+0.5*x^3 for x in [-1,1]. Clearly x*=0.
Now, let's do it in the computer as follows:
1) Assume you don't know the 2nd term of the function (ie., .5*x^3, and let's call it g(x)) over the whole domain.
2) Suppose you only know g(x) on few points. Say N points, x_i, i=1,...,N, in [-1,1]. Do NOT include 0 (zero) on that grid. For instance, in Matlab, create the array x_i=-1:.03:1.
3) Create the vector g_i=0.5*x_i.^3 in the beginning of your code.
4) Create the following Matlab function:
function out = FFF(z)
%z can be scalar or a vector in [-1,1]
global x_i g_i
out = z.^2 + interp1(x_i,g_i,z)
return
5) Now use Matlab function fminbnd to find the minimum of the function FFF. You should get something very close to zero as minimizer.
What you need to do in PS1 is something quite similar to that!!!
Eleonora, you should not get that result. The whole idea of interpolating is to reduce the Euler errors. Are you sure that the convergence criteria are the same in both cases? How about the convergence criteria of each maximization?
ReplyDeleteAs for the negative log(c), that should not be a problem. Try with z positive, and see what happens.
ReplyDeleteHi ! I also found that interpolating increases the SSR. Maybe I am doing wrong the interpolation because I can not use the codes that the professor send us with this example of function "Y" with the unknown part "G".
ReplyDeleteCintia
I've realize that you might have a problem if k1=0. Set k1=.0001. Sorry about that!
ReplyDeleteManuel,
ReplyDeleteDo you have any outputs (eg. maybe the value fns given some tolerance level, for q2 and for q4 with M=20) that we can use to check that our codes are doing the right thing?
In q7, are the sum of squared errors implied by the associated policy fns that we are to calculate just the SSR of the difference between the interpolated and uninterpolated policy fns that we calculate here?
ReplyDeleteI do have some output related to the first few questions (ie., the deterministic growth model with log utility and full depreciation). Of course, my results depend on the convergence criterion and the exact grid I used. So, I considered that V_i has converge when max(abs(V_i - V_i+1))<10^(-6). My grid is:
ReplyDeletekgrid = linspace(.001,1,M) ;
For M=20, I got
SSR = 3.5193e-004 with no interpolation, and the first 3 values of V_i+1 are
-19.6840, -17.9550, -17.6654.
As for the last question, you need to calculate the Euler errors. That is, use the Euler equation and the approximate policy function you've found to calculate LHS-RHS. Do that for each policy function you find.
Another output I can give you for you to check whether your code is fine is the average squared error of your policy function (instead of the value function as I ask you to do in the homework), that I denote SSRg. Recall that as you know the true value function you also know the true policy function. So in the case with linear interpolation, I get SSRg = 1.2072e-004.
ReplyDeleteI have a question about part 8: What does it mean to start from the invariant distribution? does it mean we choose the starting value randomly from the invariant distribution of all states?
ReplyDeleteThat's right!
ReplyDeleteAnother problem in question 8 is that we get negative values for investment. It makes no sense but I think up to there everything is correct....
ReplyDeleteThen of course we cant log and detrend it.
Did you try it? And did you get only positive investment? Or anyone else??
Thanks,
Fabian
So another thing:
ReplyDeleteto find the the sum of squared euler errors for the interpolated part of question 7. How do we find k''. k' will not be in the grid so we cannot use the value function. The same thing goes for simulating the economy i guess. I am really lost at that point.
Thanks again,
Fabian
of course i meant policy function, not value function :)
ReplyDeleteThats how lost i am!
Fabian, Interpolate the policy function if you need to. I suppose you don't need to find k'' by interpolating g if k' is always in K_D (the case of no interpolation), right?
ReplyDeleteI hope this helps.
Hi, In question 7 i calculate the transition matriz and i found that pi13 and pi31 are zeros, that doesn`t make so much sense with what Manuel told s about getting an invariant matrix without zeros for any state.I use q=1 but i try also with bigger q's) Is mine correct? do you get the same?
ReplyDeleteThanks
Lian
@Lian
ReplyDeletethey should definitely not be zeros. Are you using the normcdf command with the mean & std error of the epsilon to calculate the numbers?
Using that with the formulas from the lecture notes should give you the correct (nonzero) values for the transition matrix.
What do you want us to submit for this assignment? Do you just want the m-files or do you want us to also give you copies of the graphs &/or the numbers for the SSRs & Business cycle stddevs?
ReplyDeleteAlso, when you say:
ReplyDeleteSet the initial state (k0,z0) according to it's invariant distribution.
Do you mean that rather than starting the economy in the steady state as we did with Javier we should calculate the invariant distribution of (k,z) and then using a rand number choose the starting point based on this (and if so then what about the interpolated case, do we just use the same invariant distn calculated for the discrete case).
I want you to hand in the output I ask (graphs, tables, etc.). I also want you to email me your codes.
ReplyDeleteAs for the other question. Yes, you should find the invariant dist of the state vector (k,z) and draw your initial state from there.
Why I can not see the content except the title? Is this blog limited access?
ReplyDeleteıaaısıaısdsa
ReplyDeleted
If you cant beat themjoin them. But you do know your daughter will give that up if shethinks it can save you.
ReplyDeleteerotic sex teaching stories
free toon porn stories
real femdom stories
bondage gag stories
mind control incest sex stories
If you cant beat themjoin them. But you do know your daughter will give that up if shethinks it can save you.
Here, this usually helps with peoples first tatoo. I said two things, first, she couldnt tell hergirlfriend about the tape as it might get to her husband somehow.
ReplyDeletesex post stories sites
male masturbation with moms lingerie stories
milfs seducing young men sex stories
free fantasy incest text stories
stories about beastiality
Here, this usually helps with peoples first tatoo. I said two things, first, she couldnt tell hergirlfriend about the tape as it might get to her husband somehow.