Page 1 of 1

Rearranging Input Data

Posted: Mon Jun 21, 2010 2:46 pm
by TomDoan
The following shows probably the simplest way to rearrange panel data that are in separate files for each variable in the "wrong" orientation. The data files are blocked as 40 rows (time dimension) by 19 columns (countries). If you read that by free-format using DATA, the data will be blocked the wrong way, with consecutive entries being different individuals for a single time period. While you can read that in the wrong orientation and use PFORM with the TRANPOSE option to rearrange it, it's probably simpler (and clearer) to read into a T x N array and copy information out of a "VEC'ed" version of that matrix.

Raw data files:
Y.DAT
(5.28 KiB) Downloaded 1131 times
X.DAT
(5.28 KiB) Downloaded 1169 times
Z.DAT
(5.28 KiB) Downloaded 1245 times

Code: Select all

*
* Analysis of money demand function from Nelson C. Mark & Donggyu Sul,
* 2003,  "Cointegration Vector Estimation by Panel DOLS and Long-run
* Money Demand," Oxford Bulletin of Economics and Statistics, vol. 65,
* no. 5, 655-680.
*
* Program to rearrange data from three separate data files
*
cal(panelobs=40)
all 19//40
*
* Rearrange the data, which are in a T x N block with a separate file
* for each.
*
dec rect ydata(40,19) xdata(40,19) zdata(40,19)
open data y.dat
read(unit=data) ydata
open data x.dat
read(unit=data) xdata
open data z.dat
read(unit=data) zdata
*
set realm = %vec(ydata)(t)
set realy = %vec(xdata)(t)
set rate  = %vec(zdata)(t)
*
open copy panelmoneyx.xls
copy(format=xls,org=columns,nodates)

Re: Rearranging Input Data

Posted: Sat Jul 07, 2012 6:30 am
by guo
Hi,Tom

Thank you very much for your previous help.

Concerning on the rearrangement, right now I have 110 rows of time and 98 columns of individuals.

The program is as follows:

open data "D:\Electro New\ex_ca yoy panel.xls"
DATA(FORMAT=xls,ORG=obs)

pform(transpose, blocks=110) p_new
# p
pform(transpose, blocks=110) n_new
# n

calendar(panelobs=110,m) 2003:1
allocate 96//2012:3

dec vector[series] dummies(96)
do i = 1,96
set dummies(i) = %indiv(t) == i
end do i

I thought individual(i) should contain vertical vector of time,p_new, nr_new and dummies(i). But in series window I could only get row vector of individual(i) from 2003:2 to 2012:3.

If I am wrong, where should I correct ?

Thank you very much.

Best Regards

Guo

Re: Rearranging Input Data

Posted: Sat Jul 07, 2012 7:52 pm
by moderator
I'm confused about how your original data file is organized. Could you attach it?

Re: Rearranging Input Data

Posted: Sun Jul 08, 2012 2:14 am
by guo
Dear Moderator,

Thank you very much for your kind reply.

The attachment is the data.
I'd like to rearrange them and then apply them to random panel analysis.

I am very looking forward to your answer.

Best Regards

guo

Re: Rearranging Input Data

Posted: Sun Jul 08, 2012 4:04 am
by TomDoan
You have two types of data on the file - the individual-invariant data P and N and the panel data. You have to read this in the original time-series calendar scheme, then PFORM it to the expanded panel-dated setup:

Code: Select all

OPEN DATA "C:\TEMP\panel rearragment 2012-7-8.xlsx"
CALENDAR(M) 2003:2
DATA(FORMAT=XLSX,ORG=COLUMNS,right=100) 2003:02 2012:04
pform x
# individual_1 to individual_96
calendar(m,panel=2012:4) 2003:2
all 96//2012:4
pform(repeat) p_new
# p
pform(repeat) n_new
# n

Re: Rearranging Input Data

Posted: Sun Jul 08, 2012 6:22 am
by guo
Dear Tom,

Thank you very much for your kind reply. I ran the program, and it seems no problem.

In series window of Rats, "X" contains 96 rows and 110 columns. P and N contain 1 row and 11o columns separately.

If I want to do the random panel analysis, usually in individual(i), the framework of the whole dataset, say "X", should contain individual(1) itself, P and N; individual(2) itself, P and N;...; individual(96) itself, P and N. But in my series window, "X" ,P and N are separated.

Can I do random panel analysis directly based on the separate "X", P and N? If not, what should I do further?

Thank you very much for your precious time and attention.

Best Regards

guo

Re: Rearranging Input Data

Posted: Sun Jul 08, 2012 10:24 am
by TomDoan
Use P_NEW and N_NEW rather than P and N. Those have the values replicated across individuals.