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