Panel Data manipulation

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

bjleend
Posts: 3
Joined: Thu Jun 04, 2015 3:01 pm

Panel Data manipulation

Postby bjleend » Thu Jun 04, 2015 3:17 pm

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.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Panel Data manipulation

Postby EViews Glenn » Thu Jun 04, 2015 3:40 pm

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")

bjleend
Posts: 3
Joined: Thu Jun 04, 2015 3:01 pm

Re: Panel Data manipulation

Postby bjleend » Fri Jun 05, 2015 12:58 pm

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.

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

Panel Data manipulation

Postby EViews Gareth » Fri Jun 05, 2015 2:40 pm

You'll have to write an EViews program with a for loop that sets the sample each time through the loop

bjleend
Posts: 3
Joined: Thu Jun 04, 2015 3:01 pm

Re: Panel Data manipulation

Postby bjleend » Mon Jun 08, 2015 8:14 am

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.

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

Re: Panel Data manipulation

Postby EViews Gareth » Mon Jun 08, 2015 8:30 am

Code: Select all

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

kwasiyeboah42
Posts: 3
Joined: Sat Aug 29, 2015 11:07 am

Re: Panel Data manipulation

Postby kwasiyeboah42 » Sat Aug 29, 2015 12:20 pm

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?

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

Re: Panel Data manipulation

Postby EViews Gareth » Sat Aug 29, 2015 1:02 pm

You could store the coefficients into a matrix, yes.

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


Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 2 guests