Panel data graphs

Questions related to panel (pooled cross-section time series) data.
dalleyne
Posts: 5
Joined: Tue Mar 30, 2010 9:57 am

Panel data graphs

Unread post by dalleyne »

Hello evryone,
I have a regular panel data set with 13 countries with observations per country from (1991-2000).I am looking at the impact of FDI on growth. I am trying to generate a single graph in which the growth rates for each country is shown as a function of time.How do I do this using the graph procedure.Is this very similar to graphing a single series.
Thanks for your help.
DA
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Panel data graphs

Unread post by TomDoan »

It will probably look a bit busy, but this shows how to split up a panel data series into separate time series and graph them with the time periods coordinated. Note that you have to use MOVE rather than SET because SET won't let you transfer data across individuals (a protection against lagging into another individual's data).

Code: Select all

cal(panel=10,a) 1991:1
all 13//2000:1
set x = %ran(1.0)
dec vect[series] p(13)
do i=1,13
   move x i//1991:1 i//2000:1 p(i) 1991:1 
end do i
list iser = p
graph 13
cards iser
dalleyne
Posts: 5
Joined: Tue Mar 30, 2010 9:57 am

Re: Panel data graphs

Unread post by dalleyne »

Hello Tom,
Thanks for your quick response.The program worked and I now have the graphs I want.I was also able to use the graph label command to rename the new series p1 p2 p3 etc.
Best regards.
tomcy
Posts: 2
Joined: Tue Mar 27, 2012 12:36 pm

Re: Panel data graphs

Unread post by tomcy »

Hi

I have a panel data set with GDP and other variables for 14 countries from 1999:1 to 2011:4. I would like to pool the GDP data together for the 14 countries and create a single series from 1999 to 2011 which is the sum of GDP across the 22 countries over time. What is the best way to create and graph the pooled GDP series?

Thanks
Last edited by tomcy on Fri May 25, 2012 5:06 am, edited 1 time in total.
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Panel data graphs

Unread post by moderator »

You can use a PANEL instruction with the TSUM option to create a series containing the sum across individuals. For example:

panel(tsum=1.0) test / testsum

The output series will contain the same set of values in each individual, so you could just limit your GRAPH instruction to only graph the range for the first individual. For example:

graph
# testsum 1//1999:1 1//2011:4

Alternatively, you could use the COMPRESS option on PANEL as well. This eliminates the duplicated data that appears by default in individuals 2, 3, and so on. If you do that, there's no need to limit the range on the GRAPH instruction, since the series only contains data in the entries for individual one. For example:

panel(tsum=1.0,compress) test / testsumcomp
graph
# testsumcomp

Regards,
Tom Maycock
Estima
bbatson

Re: Panel data graphs

Unread post by bbatson »

Hi,

I am working with an unbalanced panel (4 states and ~22 years) and want to make an unstacked graph for some of my series so I can see individual state's certain variables over time in one figure (i.e. 1 figure output with 4 separate graphs). Also, is it possible to put vertical lines in certain years for only some of the states to reflect exogenous individual shocks?

Thank you,
Brian
moderator
Site Admin
Posts: 269
Joined: Thu Oct 19, 2006 4:33 pm

Re: Panel data graphs

Unread post by moderator »

bbatson wrote:Hi,

I am working with an unbalanced panel (4 states and ~22 years) and want to make an unstacked graph for some of my series so I can see individual state's certain variables over time in one figure (i.e. 1 figure output with 4 separate graphs).
It sounds like you are looking for something like:

spgraph(vfield=2,hfield=2)
do indiv=1,4
graph
# x indiv//start indiv//end
end do
spgraph(done)

where "start" and "end" are the desired dates or entry numbers. For example:

spgraph(vfield=2,hfield=2)
do indiv=1,4
graph
# x indiv//1990:1 indiv//2012:1
end do
spgraph(done)
bbatson wrote:Also, is it possible to put vertical lines in certain years for only some of the states to reflect exogenous individual shocks?
Sure, you can create series with 1s in the periods where you want vertical bars, and supply these using the GRID option on your graph instructions. If you wanted to flag the same time periods for each individual, you could just use one series. For example:

set gridser = %period(t)==1999:1.or.%period(t)==2005:1

would create a series with 1s for the two time periods in each individual. You could then do:

spgraph(vfield=2,hfield=2)
do indiv=1,4
graph(grid=gridser)
# x indiv//1990:1 indiv//2012:1
end do
spgraph(done)

If you need to highlight different periods in different individuals, you could still use a common grid series, with additional commands to set the desired periods within each individual, or you could create separate grid series. For the latter, you could just use 4 different names and use 4 graph instructions (rather than the DO loop), or you could keep the loop, and use a VECTOR of SERIES for the different grid series, referencing the appropriate vector element in the loop.

Regards,
Tom
Post Reply