Page 1 of 1

Is there an @elem() commmand for panel data?

Posted: Wed Jul 28, 2010 10:09 am
by ech447
Is there an @elem() commmand for panel data? Something like @elem(PX, * - 2006) that would return the 2006 value of PX for the UK when the computations were for the UK (one of the panel cross-sections) but use the 2006 value of PX for Spain (another) when the computations are for Spain? I use EViews 7.1, latest update. Thanks.

Re: Is there an @elem() commmand for panel data?

Posted: Wed Jul 28, 2010 10:23 am
by EViews Gareth
No, although you can always set the sample equal to the observation you want, and then take the maximum of the series (the max of a single number is just that number):

Code: Select all

smpl 2006 2006 if country = "UK" !value = @max(px)

Re: Is there an @elem() commmand for panel data?

Posted: Thu Jul 29, 2010 7:21 am
by ech447
Thanks.
In terms of future EViews development, it would be useful to have such a command. Not infrequently we want to use indexes formed by, say, taking PX/@elem(PX,2002) for a standard time series. For panel data, I switch to a spreadsheet program for my computations. It would be nice to be able to just stay in EViews.

Re: Is there an @elem() commmand for panel data?

Posted: Thu Jul 29, 2010 9:34 am
by EViews Glenn
Thanks for the suggestion. A couple of things.

First, your proposed syntax is interesting. One issue is that one could conceivably want the alternate definition of your @elem in which we return the cross-section value for the given year, as in

PX/@elem(PX,"UK")

That's all fine, but now the issue comes as to how to disambiguate the two approaches. One idea is to use @elem in the fashion that you suggested, and to add an @elemc or some other such function which returns the others. We'll give this some more thought.

One of the reasons we haven't added the particular function is that most things that we can think of can be done with little effort using current EViews tools. Note that you can (relatively) easily generate your indices in EViews. Expanding on Gareth's suggestion, first, you need to generate a series which has the 1996 values for each cross-section matched to each observation in a cross section. Once you have that, you can compute your index in the natural way:

Code: Select all

series pxscale = @maxsby(PX, @crossid, "1996 1996") series PX1 = PX / pxscale
You can combine this into a single statement if you'd like

Code: Select all

series PX1 = PX / @maxsby(PX, @crossid, "1996 1996")
You can wrap this in a subroutine if you wish, and even design an add-in to handle the front end input so that all you'd have to enter is the series name and the year/date.

Hope this helps. Thanks again for the suggestion.

Re: Is there an @elem() commmand for panel data?

Posted: Fri Aug 30, 2013 12:12 pm
by andre
Following up on your suggestion. I would like to create an index relative to the date variables of an element in the panel. For example, a series GDP relative to the GDP of the United States for each year. Something like

"series y = 100*gdp/@(gdp, countrycode="USA", 1950 2000)."

This command would generate a series for US with "100" for all dates. For the other countries, it would generate GDP relative to the US for each year in the panel. How to do this?

Re: Is there an @elem() commmand for panel data?

Posted: Fri Aug 30, 2013 12:57 pm
by EViews Glenn
I think this will work (but you should double-check). The denominator computes the sums-by-year for GDP, but only for the specified country so that you'll get just the GDP for the US in each year

Code: Select all

series y = 100*gdp/@sumsby(gdp, year, "@all if countrycode=""USA""")

Re: Is there an @elem() commmand for panel data?

Posted: Mon Sep 02, 2013 3:56 am
by andre
Yes! thank you.
I think this will work (but you should double-check). The denominator computes the sums-by-year for GDP, but only for the specified country so that you'll get just the GDP for the US in each year

Code: Select all

series y = 100*gdp/@sumsby(gdp, year, "@all if countrycode=""USA""")