How to select one entity's time series from a panel data set
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
How to select one entity's time series from a panel data set
Hi,
imagine you have a panel data set loaded into eviews that contains time series for 100 entities (i.e. 100 time series). The panel data set is in long (stacked) format. How can I SELECT or FILTER or EXTRACT only one of the firm's time seriesat a time to work with when subsequently running eviews commands? In other words, I need to be able to tell eviews "perform this estimation, but only for entity X, and then repeat for entity X+1 etc, store results etc."...
I have a background in Stata, VBA and real programming languages like C but no experience at all with eviews, so I'd appreciate any hint.
Thank you
Steve
imagine you have a panel data set loaded into eviews that contains time series for 100 entities (i.e. 100 time series). The panel data set is in long (stacked) format. How can I SELECT or FILTER or EXTRACT only one of the firm's time seriesat a time to work with when subsequently running eviews commands? In other words, I need to be able to tell eviews "perform this estimation, but only for entity X, and then repeat for entity X+1 etc, store results etc."...
I have a background in Stata, VBA and real programming languages like C but no experience at all with eviews, so I'd appreciate any hint.
Thank you
Steve
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to select one entity's time series from a panel data
In EViews you use samples to set which observations you want to deal with. In a panel you can just set the sample to be equal to which ever cross-section you want to work with. Thus if, say, your cross-sections are countries, you could do the follow:
to work with all observations in the USA.
Code: Select all
smpl if country="USA"
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: How to select one entity's time series from a panel data
Assuming there's a variable that identifies a firm, use smpl if. For example
Code: Select all
smpl if firm = 73Re: How to select one entity's time series from a panel data
thanks guys for the quick answer,
in the meantime, studying the user guide i figured out the equivalent steps in the Sample menu of my group, but your solution of providing commands is more versatile!
Can you point me to a good and quick tutorial about how to create a batch so that i can repeat my steps for every firm?
Steve
in the meantime, studying the user guide i figured out the equivalent steps in the Sample menu of my group, but your solution of providing commands is more versatile!
Can you point me to a good and quick tutorial about how to create a batch so that i can repeat my steps for every firm?
Steve
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to select one entity's time series from a panel data
Code: Select all
for !i=1 to !numcross
smpl if @crossid = !i
'do something here
next
Re: How to select one entity's time series from a panel data
thank you for providing a code snippet. i have to follow-up questions:
1. my cross-section identifier values are not sequental like 1,2,3,4,5... how can i loop over my (unique) cross-section id values?
2. more specifically, for each entity i would need to perform a cointegration test (johansen) and then have a VECM estimation under some constraints.
If you somebody posted a code example about how to call the appropriate functions, plus, more importantly, how to retrieve specific results and write them to text file, i would be more than happy.
1. my cross-section identifier values are not sequental like 1,2,3,4,5... how can i loop over my (unique) cross-section id values?
2. more specifically, for each entity i would need to perform a cointegration test (johansen) and then have a VECM estimation under some constraints.
If you somebody posted a code example about how to call the appropriate functions, plus, more importantly, how to retrieve specific results and write them to text file, i would be more than happy.
-
tchaithonov
- Posts: 168
- Joined: Mon Apr 13, 2009 7:39 am
- Location: New York City
Re: How to select one entity's time series from a panel data
For 1), make good use of the function @ crossid. It ignores your numbering of the cross section and use the generic one, so it becomes 1,2,3...
Re: How to select one entity's time series from a panel data
thanks for joining my thread, but can you elaborate more how i make @crossid work for me in iterating over all unique identifier values?
i understood @crossid such that it just stands for whatever the variable name of my dataset is.
i understood @crossid such that it just stands for whatever the variable name of my dataset is.
-
startz
- Non-normality and collinearity are NOT problems!
- Posts: 3797
- Joined: Wed Sep 17, 2008 2:25 pm
Re: How to select one entity's time series from a panel data
@crossid ia a built-in function that gives a sequential numbering of cross sections in a panel data set.
Re: How to select one entity's time series from a panel data
so i have to think of it as a pointer that magically moves on to the next unique id value after being used?
I looked it up in the docs but they aren't very precise: "@crossid observations in range, returns the cross-section identifier index."
but how would i know the number of unique id values in the first place, so as to have an upper boundary in constructing a loop?
I looked it up in the docs but they aren't very precise: "@crossid observations in range, returns the cross-section identifier index."
but how would i know the number of unique id values in the first place, so as to have an upper boundary in constructing a loop?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to select one entity's time series from a panel data
It isn't a pointer at all. Rather it is an index of the cross-sections. Type "show @crossid" to see it.
Assuming you don't already know the number of cross-sections, and since @crossid is an index of all cross-sections running from 1 to the number of cross-sections you have, a simple way to find the number of cross-sections is to take the maximum of @crossid.
Assuming you don't already know the number of cross-sections, and since @crossid is an index of all cross-sections running from 1 to the number of cross-sections you have, a simple way to find the number of cross-sections is to take the maximum of @crossid.
Re: How to select one entity's time series from a panel data
ok, and how would i get the maximum? i tried max(@crossid) but with no luck
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
How to select one entity's time series from a panel data set
!ncross=@max(@crossid)
Re: How to select one entity's time series from a panel data
this yields an error: "@crossid is an illegal or reserved name in !ncross=@max(@crossid)"
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13586
- Joined: Tue Sep 16, 2008 5:38 pm
Re: How to select one entity's time series from a panel data
That's what I get for answering without thinking...
Code: Select all
series temp = @crossid
!ncross = @max(temp)
d temp
Who is online
Users browsing this forum: No registered users and 0 guests
