Correlations Calculation
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
Correlations Calculation
Hi, Sorry for this simple question as I am new to Eviews. I have a panel workfile with cross section id as country and time series id as year. I have 10 countries.There are three variables X, Y, Z. How can I get a correlation matrix of X Y and Z for each country (that is, 10 triangular 3X3 matrices of correlations). Thanks.
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Correlations Calculation
You'll have to knock up a program:
Code: Select all
group g x y z
for !i=1 to 10
smpl if @crossid=!i
g.cor(out=cross!i)
next
Re: Correlations Calculation
Thanks Gareth. This generates 10 matrix objects -- is it possible to generate just one object with all the 10 matrices?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Correlations Calculation
You'd have to create them and then merge them into one object (matrix, spool or table).
Re: Correlations Calculation
Thanks! I created a bigger matrix "corrall" and hope to hold all the individual matrices. But the following does not seem to work "Syntax error in matplace(corrall, g.cor, 1,1). I guess I cannot put g.cor in the matplace function?
group g x y z
matrix(9,3) corrall
!row=1
for !i=1 to 3
smpl if @crossid=!i
matplace(corrall, g.cor, !row,1)
!row=!row+3
next
group g x y z
matrix(9,3) corrall
!row=1
for !i=1 to 3
smpl if @crossid=!i
matplace(corrall, g.cor, !row,1)
!row=!row+3
next
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Correlations Calculation
No, you'll have to use g.cor separately (with the out= option) to make the matrices, then put them inside the bigger one.
Re: Correlations Calculation
Another attempt failed... message "Submatrix extracted from non matrix/vector in matplace(corrall,cross!iCORR,!row,1)". Any hint what's wrong again?
group g x y z
matrix(9,3) corrall
!row=1
for !i=1 to 3
smpl if @crossid=!i
g.cor(out=cross!i)
matplace(corrall,cross!iCORR,!row,1)
!row=!row+3
next
group g x y z
matrix(9,3) corrall
!row=1
for !i=1 to 3
smpl if @crossid=!i
g.cor(out=cross!i)
matplace(corrall,cross!iCORR,!row,1)
!row=!row+3
next
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Correlations Calculation
Code: Select all
group g x y z
matrix(9,3) corrall
!row=1
for !i=1 to 3
smpl if @crossid=!i
g.cor(out=cross!i)
matrix temp = cross!icorr
matplace(corrall,temp,!row,1)
!row=!row+3
next
Re: Correlations Calculation
Thanks a lot. Problem solved!
Who is online
Users browsing this forum: No registered users and 2 guests
