Transforming series from panel data to time series data
Posted: Fri Jul 26, 2019 5:50 am
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
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