Transforming series from panel data to time series data

Questions related to panel (pooled cross-section time series) data.
RomainR
Posts: 18
Joined: Fri Jul 19, 2013 7:19 am

Transforming series from panel data to time series data

Unread post by RomainR »

Hi,
I have a very simple question. I run panel regressions and get the residuals (series called RESIDS). RESIDS has a panel format and I would like to transform it in a time series format, i.e. one series of residuals for each individual. To be clear, an example with N = 2 individuals and T = 3 periods, the RESIDS series is for instance in the following format: (-1 -3 4 0 2 -2)’.
I would like to create 2 series (called RESIDS1 and RESIDS2) in this format: RESIDS1 = (-1 -3 4)’ and RESIDS2 = (0 2 -2)’. I tried to get RESIDS1 and RESIDS2 with this code:
dec vector[series] resids1(%panelsize())
do i=1,%panelsize()
set resids(i) i//1970:1 i//2007:1 = (%indiv(t)==i)*RESIDS;
end do i
But instead I get RESIDS1 = (-1 -3 4 NA NA NA)’ and RESIDS2 = (NA NA NA 0 2 -2)’, i.e. RESIDS1 and RESIDS2 have a panel format. So how can I do to fix this problem and obtain RESIDS1 and RESIDS2 in a time series format (i.e. without the NA and with a dimension 3*1)? Thanks.
Best
Romain
TomDoan
Posts: 7814
Joined: Wed Nov 01, 2006 4:36 pm

Re: Transforming series from panel data to time series data

Unread post by TomDoan »

If you add the NOPANEL option to the SET it should work. (By default, SET produces an NA when the RHS formula is for a different individual than the entry being set, which prevents it from lagging or leading out of one individual into another).

An alternative to SET(NOPANEL) is the MOVE instruction which is designed to shift data around. Instead of your SET:

move i//1970:1 i//2007:1 resids(i) 1970:1
RomainR
Posts: 18
Joined: Fri Jul 19, 2013 7:19 am

Re: Transforming series from panel data to time series data

Unread post by RomainR »

Many thanks, Tom. It helped me a lot and now I get what I wanted to.
Best
Romain
Post Reply