Page 1 of 1

Panel Data manipulation

Posted: Thu Jun 04, 2015 3:17 pm
by bjleend
Hi,

I want to know a simple data manipulation in panel data workfile.

I have successfully created panel data workfile as cross-section stacked for time period. So, my data series x is stacked as x(i=1) for t=1 to T, and x(i=2) for t=1 to T, etc.

I would like to create a new series y(i,t)=x(i,t)-x(i=35 for example,t) for each i. That is, the new series y(i,t) is x(i,t) minus x(i=35) for the same t. Of course y(i=35,t)=0 for all t.

Thanks.

Re: Panel Data manipulation

Posted: Thu Jun 04, 2015 3:40 pm
by EViews Glenn
If the series YR is your t identifier, and FN is your i identifier:

Code: Select all

series y = x - @meansby(x, yr, "if fn=35")

Re: Panel Data manipulation

Posted: Fri Jun 05, 2015 12:58 pm
by bjleend
Thank you!! It worked perfectly.

One more follow up question. Now, I have panel data stacked t=1 to T for each i=1 to n. Can I get a time-series regression for each i separately using a simple command? I know that I can manually do this by specifying in the Sample window "if id=1", "if id=2", etc. Is there any way that I can get this automatically for each i. I have about 40 cross-section units for each T=360.

Thanks.

Panel Data manipulation

Posted: Fri Jun 05, 2015 2:40 pm
by EViews Gareth
You'll have to write an EViews program with a for loop that sets the sample each time through the loop

Re: Panel Data manipulation

Posted: Mon Jun 08, 2015 8:14 am
by bjleend
Again, thanks for your help. My problem is to run time-series regression for each cross-section unit in a panel data. So, I wrote a small program as following:

for !i=1 to 40
smpl if id=i
ls y c x
next

id is my cross-section ID identifier.

As I run this program, it gives me the following error: Error in Sample. i is not defined in "smpl if id=i". I don't know what is wrong here. I thought FOR loop starts from 1 to 40 and executes "ls" command for each i.

If I execute this program one by one manually like

smpl if id=1
ls y c x

This program works when I change manually id=1, id=2, etc.

Thanks.

Re: Panel Data manipulation

Posted: Mon Jun 08, 2015 8:30 am
by EViews Gareth

Code: Select all

for !i=1 to 40 smpl if id=!i equation eq!i.ls y c x next

Re: Panel Data manipulation

Posted: Sat Aug 29, 2015 12:20 pm
by kwasiyeboah42

Code: Select all

for !i=1 to 40 smpl if id=!i equation eq!i.ls y c x next
if you were to run this, would there be a way to store the coefficients in a single place, and calculate their average?

Re: Panel Data manipulation

Posted: Sat Aug 29, 2015 1:02 pm
by EViews Gareth
You could store the coefficients into a matrix, yes.

There are lots of examples:
http://forums.eviews.com/viewtopic.php?f=5&t=1638