Hi everyone.
This is my first post in this forum and I am already asking questions.
I have two series X, Y, and Z and each one of them has 50 yearly observations. I would like to create a 5-year rolling window for the correlation coefficient for all the possible combinations, but I am struggling with it (I know, I am a newbie...).
I have read this thread, but it seems that that will give me a backward correlation (at each point the statistic give us only the previous 10 years) and I want to use five years of data both before and after. Hope this is clear.
Thanks in advance!
Rolling window correlation
Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Rolling window correlation
Follow us on Twitter @IHSEViews
-
- Posts: 8
- Joined: Thu Jun 03, 2010 5:28 am
Re: Rolling window correlation
Thanks for your answer.
Isn't that leading both series? I guess I don't get how leading both series will give me at each point the correlation for both five years after and before.
Thanks once again.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Rolling window correlation
Sorry, misunderstood. Put a lead of 5 years on both.
Follow us on Twitter @IHSEViews
-
- Posts: 8
- Joined: Thu Jun 03, 2010 5:28 am
Re: Rolling window correlation
Thanks, but still is not working. Even when I use this:
It does not give me the correct values (I'm checking with another software). For once, by leading the variable, I am getting rid of the first observations so that does not work.
Maybe this example will clarify what I want: Suppose (annual data) X={x1,x2,x3,x4,x5,x6} and Y={y1,y2,y3,y4,y5,y6} and suppose that I want a two year rolling window (two years before and two years after each observation). Therefore, the series should be Correlation={NA, NA, corr({x1,x2,x3,x4,x5},{y1,y2,y3,y4,y5}), corr({x2,x3,x4,x5,x6},{y2,y3,y4,y5,y6}),NA,NA})}
Please, let me know if you need a numeric example.
Thanks.
Code: Select all
@movcor(x(5),y(5),10)
It does not give me the correct values (I'm checking with another software). For once, by leading the variable, I am getting rid of the first observations so that does not work.
Maybe this example will clarify what I want: Suppose (annual data) X={x1,x2,x3,x4,x5,x6} and Y={y1,y2,y3,y4,y5,y6} and suppose that I want a two year rolling window (two years before and two years after each observation). Therefore, the series should be Correlation={NA, NA, corr({x1,x2,x3,x4,x5},{y1,y2,y3,y4,y5}), corr({x2,x3,x4,x5,x6},{y2,y3,y4,y5,y6}),NA,NA})}
Please, let me know if you need a numeric example.
Thanks.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Rolling window correlation
Did you check the EViews numbers manually? They seem to work for me:
Code: Select all
create u 6
rndseed 1
series y=rnd
series x=rnd
group g x y
series corr = @movcor(y(2),x(2),5)
'check by making two matrices from the middle two parts, and calculating the correlations
smpl 1 5
matrix s1 = @convert(g)
freeze(cor1) s1.cor
smpl 2 6
matrix s2 = @convert(g)
freeze(cor2) s2.cor
Follow us on Twitter @IHSEViews
-
- Posts: 8
- Joined: Thu Jun 03, 2010 5:28 am
Re: Rolling window correlation
Isn't working for me...
Can I post the series that I'm trying to work with as well as the result I'm getting and I `correct' one?
Thanks.
Can I post the series that I'm trying to work with as well as the result I'm getting and I `correct' one?
Thanks.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13318
- Joined: Tue Sep 16, 2008 5:38 pm
-
- Posts: 8
- Joined: Thu Jun 03, 2010 5:28 am
Re: Rolling window correlation
You were right. I used @movcor(y(alpha),x(alpha),2*alpha+1) where alpha is the size of the window and it worked.
Thanks!
Thanks!
Re: Rolling window correlation
Does anybody know how to calculate rolling window correlation for even number of years?
thanks.
thanks.
Who is online
Users browsing this forum: No registered users and 16 guests