Page 1 of 3
PREGRESS
Posted: Mon Jul 14, 2014 11:26 am
by smukherjee01
Hi!
I have a data set called ABC1 of unbalanced panel. I have indexed the data as can be seen from the attachment ABC1.xlsx.
As RATS best understands RATS DATA FILE I have transformed that to ABC1.RAT.
Then using PFORM, it made the unbalanced panel into balanced panel. The code I used is as follows:
CALENDAR(D) 2011:10:3
OPEN DATA "C:\Users\29056491\Desktop\ABC1.RAT"
CALENDAR(D) 2011:10:3
DATA(FORMAT=RATS,ORG=COLUMNS,DATEFORM="y/m/d") 2011:10:03 2013:11:29 Index FR FE OFQTOTAL OFQ2M OFQ1M
PFORM(INDIV=INDEX) PFR
#FR
PFORM(INDIV=INDEX) PFE
#FE
PFORM(INDIV=INDEX) POFQTOTAL
#OFQTOTAL
PFORM(INDIV=INDEX) POFQ2M
#OFQ2M
PFORM(INDIV=INDEX) POFQ1M
#OFQ1M
CAL(D,PANELOBS=%NOBS) 2011:10:3
COPY(FORMAT=XLS,ORG=COLS) / Index PFR PFE POFQTOTAL POFQ2M POFQ1M
Then I get an excel file ABC2.xls (attached).
Now when I run the regression of the following form
CALENDER(PANELOBS=20,D) 2011:10:3
ALLOCATE 26//2013:11:29
OPEN DATA "C:\Users\29056491\Desktop\ABC2.XLS"
DATA(FORMAT=XLS,ORG=COLUMNS) 2011:10:03 2013:11:29 INDEX PFR PFE POFQTOTAL POFQ2M POFQ1M
SET TPFE = PFE*10
SET TPFR = PFR*10
INSTRUMENTS CONSTANT TPFR{1 TO 3}
PREG(METHOD=POOLED,INSTRUMENTS,LWINDOW=NEWEY,LAGS=16) TPFE
#CONSTANT TPFR
I get the output
Panel Regression - Estimation by Pooled Sample-IV
Dependent Variable TPFE
Panel(20) of Daily(5) Data From 1//2011:10:06 To 54//2011:10:07
Usable Observations 376
Degrees of Freedom 374
Skipped/Missing (from 1062) 686
Mean of Dependent Variable 0.1341040193
Std Error of Dependent Variable 0.4674296774
Standard Error of Estimate 0.8281285891
Sum of Squared Residuals 256.48806305
J-Specification(2) 2312.8030
Significance Level of J 0.0000000
Variable Coeff Std Error T-Stat Signif
************************************************************************************
1. Constant 0.029238650 0.067262046 0.43470 0.66378194
2. TPFR 15.775872147 5.776871289 2.73087 0.00631678
The problem is in the output. It is saying "Skipped/Missing (from 1062) 686". But the total number of observations is not 1062.
Re: PREGRESS
Posted: Mon Jul 14, 2014 12:17 pm
by TomDoan
CALENDER(PANELOBS=20,D) 2011:10:3
ALLOCATE 26//2013:11:29
20 daily observations but spanning over two years? Something's wrong there.
Re: PREGRESS
Posted: Mon Jul 14, 2014 2:53 pm
by smukherjee01
Thanks Tom.
Yes on an average there are 20 trading days each month spanning over 26 months. So 20 daily observations and al total there are 26 months to consider. Some months have less trading days like February. That is why it is an unbalanced panel. Months with 31 days have larger trading days. I have done the PFORM to make it a balanced panel.
Re: PREGRESS
Posted: Mon Jul 14, 2014 3:03 pm
by TomDoan
Don't call it daily data. Just
CALENDAR(PANELOBS=20)
ALLOCATE 26//20
Re: PREGRESS
Posted: Mon Jul 14, 2014 3:57 pm
by smukherjee01
I am trying to do that, as follows:
CALENDER(PANELOBS=20)
ALLOCATE 26//20
OPEN DATA "C:\Desktop\OFQUANTITYOPCG\ABC2.XLS"
DATA(FORMAT=XLS,ORG=COLUMNS) 2011:10:03 2013:11:29 INDEX PFR PFE POFQTOTAL POFQ2M POFQ1M
SET TPFE = PFE*10
SET TPFR = PFR*10
INSTRUMENTS CONSTANT TPFR{1 TO 3}
PREG(METHOD=POOLED,INSTRUMENTS,LWINDOW=NEWEY,LAGS=16) TPFE
#CONSTANT TPFR
It is returning this error
## SR10. Missing Values And/Or SMPL Options Leave No Usable Data Points
Re: PREGRESS
Posted: Mon Jul 14, 2014 7:19 pm
by TomDoan
The CALENDAR and ALLOCATE that I posted is for the PFORM'ed data, not the original data.
Given what you're trying to do, there is no point at which you want to set a daily calendar. All that does is to muck up the entry mappings. A daily calendar is for a full time series with five day a week data. What you have is 26 months ("individuals") of up to 20 observations.
Re: PREGRESS
Posted: Tue Jul 15, 2014 6:09 pm
by smukherjee01
Thanks. Seems to be working fine now. Thanks again.
Re: PREGRESS
Posted: Fri Jul 18, 2014 11:25 am
by smukherjee01
Hi!
I have been trying to do a PFORM, but I am not getting a balanced panel.
EXP1 (attached) is the original Excel File. Then I converted that to RATS DATA FILE (attached).
I wrote a RATS program to make the PFORM
CALENDAR(D) 2011:10:01
OPEN DATA "C:\Users\00000000\Desktop\New folder\EXP1.RAT"
DATA(FORMAT=RATS,ORG=COLUMNS,DATEFORM="Y/M/D") 2011:10:01 2013:12:30 FRN FEN OFQNT
PFORM PFRN
#FRN
PFORM PFEN
#FEN
PFORM POFQNT
#OFQNT
CAL(D,PANELOBS=%NOBS) 2011:10:01
COPY(FORMAT=XLS,ORG=COLS) / PFRN PFEN POFQNT
The final output after this is the PFORMEXP1.XLS. It has 586 observations (excluding the header). Now I have 27 months so if I get a balanced panel after PFORM, I should have equal number of observations each month as PFORM makes up for the missing days of each month. But if I divide 586 by 27 I get 21.7037. I don't understand this. I should get a whole number and not a fraction.
I have 27 months of daily observations. PFORM is not making my unbalanced panel to a balanced panel.
Please help.
Re: PREGRESS
Posted: Fri Jul 18, 2014 12:54 pm
by TomDoan
What happened to the INDIV option on your PFORM?
Re: PREGRESS
Posted: Fri Jul 18, 2014 1:19 pm
by smukherjee01
The previous INDIV series was created by me. There is actually no INDIVIDUAL series. Should I create a new series manually and name it as INDIVIDUAL? Like all the January is 1 (creating a series of 31 1s), all the February is 2 (creating a series of 28 2s) etc etc, and then perform the PFORM.
I wanted it to do the PFORM just based on the time.
Re: PREGRESS
Posted: Fri Jul 18, 2014 1:38 pm
by TomDoan
You can create it using date functions:
set ym = %year(t)*12+%month(t)
pform(indiv=ym) ...
It isn't necessary that the "INDIV" series start at 1, as long as it uniquely identifies each individual.
Re: PREGRESS
Posted: Fri Jul 18, 2014 2:59 pm
by smukherjee01
Thanks.
But still the same problem exists. The code now used is
CALENDAR(D) 2011:10:01
OPEN DATA "D:\EXPERIMENT18072014\EXP18072014.RAT"
DATA(FORMAT=RATS,ORG=COLUMNS,DATEFORM="Y/M/D") 2011:10:01 2013:12:30 FRN FEN OFQNT
SET YM = %year(t)*12+%month(t)
PFORM(indiv=YM) PFRN
#FRN
PFORM(indiv=YM) PFEN
#FEN
PFORM(indiv=YM) POFQNT
#OFQNT
CAL(D,PANELOBS=%NOBS) 2011:10:01
COPY(FORMAT=XLS,ORG=COLS) / YM PFRN PFEN POFQNT
I get the output file PFORMED (attached). The indexing stops at row number 537 and the data continues till row number 568. In either case PFORM is not formed as I have 27 months. So leaving out the header row it's 536 observations. 536 divided by 27 is 19.85. And 565 divided by 27 is 20.92. According to RATS Manual I should get a balanced panel after PFORM
This is the problem which I am having, no matter what I do RATS is failing to compute a balanced panel.
Re: PREGRESS
Posted: Fri Jul 18, 2014 3:57 pm
by TomDoan
After your PFORM's you want just:
CAL(PANELOBS=%NOBS)
allocate 27//%nobs
You need the ALLOCATE to reset the length to match the expanded data. You don't want the D on the CALENDAR since it's not daily data---it's panel data.
Note, by the way, that what you are getting isn't a "balanced" panel in the sense in which that is used in the literature (which means the same number of time periods per individual). Instead, you have a data set which is properly organized for the RATS panel scheme.
Re: PREGRESS
Posted: Fri Jul 18, 2014 4:57 pm
by smukherjee01
Thanks.
I tried that. That does not change anything from what I got previously. The same 536 indexed values. The new program is
CALENDAR(D) 2011:10:01
OPEN DATA "D:\EXPERIMENT18072014\EXP18072014.RAT"
DATA(FORMAT=RATS,ORG=COLUMNS,DATEFORM="Y/M/D") 2011:10:01 2013:12:30 FRN FEN OFQNT
SET YM = %year(t)*12+%month(t)
PFORM(indiv=YM) PFRN
#FRN
PFORM(indiv=YM) PFEN
#FEN
PFORM(indiv=YM) POFQNT
#OFQNT
CAL(PANELOBS=%NOBS)
ALLOCATE 27//%NOBS
COPY(FORMAT=XLS,ORG=COLS) / YM PFRN PFEN POFQNT
The final Excel file is same as attached PFORMED1. This does not change anything.
I understand that the data is not in the usual 'balanced' version after PFORM. But the problem is the next step. In this Excel file I have numbered the observations after each month. After PFORM the first month has 21 observations, the second month has 20 observations and so on.
If each month has different observations then I can't perform the panel regression of the form below, afterwards
CALENDER(PANELOBS=21)
ALLOCATE 27//21
OPEN DATA "D:\PFORMED1.XLS"
DATA(FORMAT=XLS,ORG=COLUMNS) / PFRN PFEN POFQNT
INSTRUMENTS CONSTANT TPFRN{1}
PREG(METHOD=POOLED,INSTRUMENTS,LWINDOW=NEWEY,LAGS=1) TPFEN
#CONSTANT TPFRN
As then how I am going to decide what to write in the highlighted part below?
CALENDER(PANELOBS=21)
ALLOCATE 27//21
Should I write 21, 20 what should I write?
If all the months are same then only I can write the correct value in the highlighted portion.
Re: PREGRESS
Posted: Fri Jul 18, 2014 5:26 pm
by TomDoan
I'm perplexed by what you're trying to do. METHOD=POOLED isn't a panel data technique; it's OLS and is completely unaffected by whether you have the same number of time periods per individual. What is it that you intend to do that treats each month as a separate "individual"? (Don't tell me about your struggles with PFORM, tell me what the endgame is). Basically, what you're doing in setting up the panel data set is saying that March 1 and September 1 are more similar than March 1 and February 28.