Page 1 of 1

Correlations Calculation

Posted: Tue Oct 01, 2013 11:36 am
by FrankC
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.

Re: Correlations Calculation

Posted: Tue Oct 01, 2013 11:40 am
by EViews Gareth
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

Posted: Tue Oct 01, 2013 12:00 pm
by FrankC
Thanks Gareth. This generates 10 matrix objects -- is it possible to generate just one object with all the 10 matrices?

Re: Correlations Calculation

Posted: Tue Oct 01, 2013 12:53 pm
by EViews Gareth
You'd have to create them and then merge them into one object (matrix, spool or table).

Re: Correlations Calculation

Posted: Tue Oct 01, 2013 1:22 pm
by FrankC
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

Re: Correlations Calculation

Posted: Tue Oct 01, 2013 1:25 pm
by EViews Gareth
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

Posted: Tue Oct 01, 2013 1:41 pm
by FrankC
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

Re: Correlations Calculation

Posted: Tue Oct 01, 2013 1:46 pm
by EViews Gareth

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

Posted: Tue Oct 01, 2013 1:53 pm
by FrankC
Thanks a lot. Problem solved!