Hi, I'm very confused about this point. I have the 100 realizations of the economy of 120 quarters each. Now, should i compute the statistics for each realization of the economy? should i do the same with the correlation coefficients? what about the lags? how many lags should we considered? should i have to do this for each realization? because in that case it will be a very large number of statistics. I will appreciate any help with these, thanks Lian
Assume you are only interested in three time series: (y,c,i)
1. Obtain a sample for {y,c,i} from t=0 to t=119 2. Log your sample {log y, log c, log i} 3. HP1600 your sample and keep the deviations: {dy, dc, di} 4. Compute the standard deviations of the three time series: \sigma(dy), \sigma(dc), \sigma(di) 5. Compute the correlation coefficients: \rho(dy,dy), \rho(dy,dc), \rho(dy,di) 6. Compute the correlations of three leads and three lags of each series and output: \rho(dy,dx-3), \rho(dy,dx-2), \rho(dy,dx-1), \rho(dy,dx+1), \rho(dy,dx+2), \rho(dy,dx+3), 7. Store the 12 statistics that you have just computed. 8. Obtain another independent sample. 9. Repeat. 10. When you have 100 samples, compute and report the averages and the standard deviations of the 12 statistics.
the part upto getting the standard deviations and thus the volatilities is pretty straight forward. However, the part of computing the correlation of y with the lags of the other variables repeated a over a 100 samples is pretty complicated. In fact, I am slightly lost about how I should be proceeding on that front.
First, the calculation of correlations (with lags) are not any different from the calculation of other statistics. So, having said that, let's see if this helps. The problem is the following: in each iteration i=1,2,...,100, you get a number of time series. Among them dy and dx. To calculate their contemporaneous correlation, you simple write corr(dy,dx) in your code. To calculate the correlation of dy with dx lagged n periods, you write corr(dy(1+n:N),dx(1:N-n)), where N=length(dy)=length(dx)=120. Similarly for lags of dy. So, for each i, you calculate those correlations for n=0,1,2,3. As you do with the standard deviations, you store each one of these correlations. In the end, after the 100th iteration, you should have 100 of each one of those correlations as well as standard deviations for each variable. With that at hand, you simply take their averages and standard deviations. That's all. MT
This is my explanation. I was typing it while Manuel was writing his. That shows how much we both value your welfare. Essentially we say the same things, so take your pick:
Say your sample has 10 observations of two variables y, x and that you want to compute the correlations with y of three leads and three lags of x. For the first lag do the following:
Hi, I talked to Javier yesterday and he told me that the results of HW3.2c should be the same as the Hansen's table. Now, My results are pretty similar, except for the investment standard deviation tat i get 0.61 and hansen has 0.51, is this correct? or did i have something wrong? also the other numbers are pretty similar but some are not exactly the same. (Consider that for the Average and Standard deviation of the Standard deviation you have to multiply what you get by 100 to get hansen's numbers). Thanks Lian
Recall that those figures are sample averages so they might be different. Actually, if you run your code (i.e., do the simulations) more than once, you're going to get different numbers. For the same reason, your results and Hansen's are going to be somewhat different. However, they should be reasonably close. In other words, you should not be able to reject the hypothesis that those two sample averages (yours and Hansen's) are the same. MT
If you do exactly as Hansen did (100 independent samples of 115 observations), you should get exactly the same results. Up to perhaps rounding errors. If you are getting exact solutions for y and h, you must get an exact solution for y/h. Did you divide before you log and detrend?
Hi, I'm very confused about this point. I have the 100 realizations of the economy of 120 quarters each. Now, should i compute the statistics for each realization of the economy? should i do the same with the correlation coefficients? what about the lags? how many lags should we considered? should i have to do this for each realization? because in that case it will be a very large number of statistics.
ReplyDeleteI will appreciate any help with these, thanks
Lian
Hi Lian!
ReplyDeleteThis is a rough sketch of the algorithm:
Assume you are only interested in three time series: (y,c,i)
1. Obtain a sample for {y,c,i} from t=0 to t=119
2. Log your sample {log y, log c, log i}
3. HP1600 your sample and keep the deviations: {dy, dc, di}
4. Compute the standard deviations of the three time series:
\sigma(dy), \sigma(dc), \sigma(di)
5. Compute the correlation coefficients:
\rho(dy,dy), \rho(dy,dc), \rho(dy,di)
6. Compute the correlations of three leads and three lags of each series
and output:
\rho(dy,dx-3), \rho(dy,dx-2), \rho(dy,dx-1), \rho(dy,dx+1), \rho(dy,dx+2),
\rho(dy,dx+3),
7. Store the 12 statistics that you have just computed.
8. Obtain another independent sample.
9. Repeat.
10. When you have 100 samples, compute and report the averages and
the standard deviations of the 12 statistics.
Good luck! :-)
the part upto getting the standard deviations and thus the volatilities is pretty straight forward. However, the part of computing the correlation of y with the lags of the other variables repeated a over a 100 samples is pretty complicated. In fact, I am slightly lost about how I should be proceeding on that front.
ReplyDeleteFirst, the calculation of correlations (with lags) are not any different from the calculation of other statistics. So, having said that, let's see if this helps. The problem is the following: in each iteration i=1,2,...,100, you get a number of time series. Among them dy and dx. To calculate their contemporaneous correlation, you simple write corr(dy,dx) in your code. To calculate the correlation of dy with dx lagged n periods, you write corr(dy(1+n:N),dx(1:N-n)), where N=length(dy)=length(dx)=120. Similarly for lags of dy. So, for each i, you calculate those correlations for n=0,1,2,3. As you do with the standard deviations, you store each one of these correlations. In the end, after the 100th iteration, you should have 100 of each one of those correlations as well as standard deviations for each variable. With that at hand, you simply take their averages and standard deviations. That's all.
ReplyDeleteMT
This is my explanation. I was typing it while Manuel was writing his. That shows how much we both value your welfare. Essentially we say the same things, so take your pick:
ReplyDeleteSay your sample has 10 observations of two variables y, x
and that you want to compute the correlations with y of three leads
and three lags of x. For the first lag do the following:
Define y^ = y4, y5, y6, y7
Define x1 = x3, x4, x5, x6
Compute corr(y^, x1)
Repeat for the remaining lags and leads of x
And you are done!
Note that y^ never changes and that x changes every time.
Oops! x1 is the first LEAD of x. Not the first LAG. I am sorry about that.
ReplyDeleteHi,
ReplyDeleteI talked to Javier yesterday and he told me that the results of HW3.2c should be the same as the Hansen's table. Now, My results are pretty similar, except for the investment standard deviation tat i get 0.61 and hansen has 0.51, is this correct? or did i have something wrong? also the other numbers are pretty similar but some are not exactly the same. (Consider that for the Average and Standard deviation of the Standard deviation you have to multiply what you get by 100 to get hansen's numbers).
Thanks
Lian
Recall that those figures are sample averages so they might be different. Actually, if you run your code (i.e., do the simulations) more than once, you're going to get different numbers. For the same reason, your results and Hansen's are going to be somewhat different.
ReplyDeleteHowever, they should be reasonably close. In other words, you should not be able to reject the hypothesis that those two sample averages (yours and Hansen's) are the same.
MT
If you do exactly as Hansen did (100 independent samples of 115 observations), you should get exactly the same results. Up to perhaps rounding errors. If you are getting exact solutions for y and h, you must get an exact solution for y/h. Did you divide before you log and detrend?
ReplyDeleteGreat and I have a swell offer you: Does Renovation Increase House Value split level home remodel
ReplyDelete