Correlations Calculation

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason

FrankC
Posts: 8
Joined: Tue Sep 03, 2013 1:21 pm

Correlations Calculation

Postby FrankC » Tue Oct 01, 2013 11:36 am

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

Postby EViews Gareth » Tue Oct 01, 2013 11:40 am

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

FrankC
Posts: 8
Joined: Tue Sep 03, 2013 1:21 pm

Re: Correlations Calculation

Postby FrankC » Tue Oct 01, 2013 12:00 pm

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

Postby EViews Gareth » Tue Oct 01, 2013 12:53 pm

You'd have to create them and then merge them into one object (matrix, spool or table).

FrankC
Posts: 8
Joined: Tue Sep 03, 2013 1:21 pm

Re: Correlations Calculation

Postby FrankC » Tue Oct 01, 2013 1:22 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Correlations Calculation

Postby EViews Gareth » Tue Oct 01, 2013 1:25 pm

No, you'll have to use g.cor separately (with the out= option) to make the matrices, then put them inside the bigger one.

FrankC
Posts: 8
Joined: Tue Sep 03, 2013 1:21 pm

Re: Correlations Calculation

Postby FrankC » Tue Oct 01, 2013 1:41 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Correlations Calculation

Postby EViews Gareth » Tue Oct 01, 2013 1:46 pm

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

FrankC
Posts: 8
Joined: Tue Sep 03, 2013 1:21 pm

Re: Correlations Calculation

Postby FrankC » Tue Oct 01, 2013 1:53 pm

Thanks a lot. Problem solved!


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests