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.
Panel Data manipulation
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Glenn
- EViews Developer
- Posts: 2682
- Joined: Wed Oct 15, 2008 9:17 am
Re: Panel Data manipulation
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
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.
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
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
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.
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
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
if you were to run this, would there be a way to store the coefficients in a single place, and calculate their average?Code: Select all
for !i=1 to 40 smpl if id=!i equation eq!i.ls y c x next
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Panel Data manipulation
You could store the coefficients into a matrix, yes.
There are lots of examples:
http://forums.eviews.com/viewtopic.php?f=5&t=1638
There are lots of examples:
http://forums.eviews.com/viewtopic.php?f=5&t=1638
Who is online
Users browsing this forum: No registered users and 1 guest
