Determining the Number of Factors

Questions related to panel (pooled cross-section time series) data.

Determining the Number of Factors

Postby Frauke » Tue May 17, 2011 5:09 am

Hello,

I want to analyse a money demand function for a panel of countries and would like to determine the number of factors to apply the PANIC methodology proposed by Bai and Ng (2004), A PANIC attack on unit roots and cointegration. Econometrica, 72, 1127–1177. Thus, I use the RATS procedure baing.scr (with fewer features since I work with RATS 6.3) to estimate the required number of factors of the set of countries for each variable (using the formulas in Bai and Ng, "Determining the Number of Factors in Approximate Factor Models", Econometrica, 2002, vol 70, pp 191-222).

First of all, I am not sure whether I have to define the original (differenced)* variables as matrix x or already estimated factors (using principal component analysis) or even both (I attach both as xls-file).
(Parameters: x = nper x nvar matrix of data. The factors are nper x 1 vectors)

Further, even though there are no error messages I get no output as I would expect from the code:

report(action=define)
report(atrow=1,atcol=1,align=center) "Factors" "PCP1" "PCP2" "ICP1" "ICP2"
report(atrow=2,atcol=1,fillby=cols) %seq(1,max)
report(atrow=2,atcol=2) stats
report(action=format,atcol=2,tocol=2,tag=min,special=onestar)
report(action=format,atcol=3,tocol=3,tag=min,special=onestar)
report(action=format,atcol=4,tocol=4,tag=min,special=onestar)
report(action=format,atcol=5,tocol=5,tag=min,special=onestar)
report(action=format,atrow=2,atcol=2,picture="*.#####",align=decimal)
report(action=show)

What might be the problem(s)?

Thanks in advance!
Frauke

*Following the PANIC methodology proposed by Bai and Ng (2004) I want to apply the method of principal components to the first differenced data.
Attachments
factors.xls
factors of a panel ot countries for M1, output, interest rate, wealth and exchange rate, respectively
(68.5 KiB) Downloaded 149 times
moneydemand.xls
M1, output, interest rate, wealth and exchange rate in levels and first differences for a panel of countries
(528.5 KiB) Downloaded 156 times
baing.src
(2.76 KiB) Downloaded 166 times
Frauke
 
Posts: 10
Joined: Mon May 16, 2011 8:43 am

Re: Determining the Number of Factors

Postby Frauke » Thu May 19, 2011 7:22 am

Hello again,

I just run the more recent version of baing.scr again with RATS 7.
Unfortunately I get a lot of error messages:

## SX9. REPORT is not a Basic Data Type
>>>>local report <<<<
## CP3. Instruction is Illegal Outside Compiled Section
>>>>local <<<<
## SX11. Identifier WX is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>dim wx(<<<<
## SX11. Identifier CENTER is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>if center.or.<<<<

and so forth.

These four messages appear when running the program lines:

local report freport
local string ltitle

dim wx(nper,nvar)
if center.or.standardize {

Have I to define more than a x matrix with the data which I want to reduce to factors?
Are there any bugs in the program code baing.scr?

Regards,
Frauke
Frauke
 
Posts: 10
Joined: Mon May 16, 2011 8:43 am

Re: Determining the Number of Factors

Postby TomDoan » Thu May 19, 2011 1:31 pm

Frauke wrote:Hello again,

I just run the more recent version of baing.scr again with RATS 7.
Unfortunately I get a lot of error messages:

## SX9. REPORT is not a Basic Data Type
>>>>local report <<<<
## CP3. Instruction is Illegal Outside Compiled Section
>>>>local <<<<
## SX11. Identifier WX is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>dim wx(<<<<
## SX11. Identifier CENTER is Not Recognizable. Incorrect Option Field or Parameter Order?
>>>>if center.or.<<<<

and so forth.

These four messages appear when running the program lines:

local report freport
local string ltitle

dim wx(nper,nvar)
if center.or.standardize {

Have I to define more than a x matrix with the data which I want to reduce to factors?
Are there any bugs in the program code baing.scr?

Regards,
Frauke


The ability to define a LOCAL REPORT was added with version 7.1. The number-crunching didn't change, just the output, so there's no reason to use an incompatible version of BaiNg.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Determining the Number of Factors

Postby TomDoan » Thu May 19, 2011 3:54 pm

Frauke wrote:Hello,

I want to analyse a money demand function for a panel of countries and would like to determine the number of factors to apply the PANIC methodology proposed by Bai and Ng (2004), A PANIC attack on unit roots and cointegration. Econometrica, 72, 1127–1177. Thus, I use the RATS procedure baing.scr (with fewer features since I work with RATS 6.3) to estimate the required number of factors of the set of countries for each variable (using the formulas in Bai and Ng, "Determining the Number of Factors in Approximate Factor Models", Econometrica, 2002, vol 70, pp 191-222).

First of all, I am not sure whether I have to define the original (differenced)* variables as matrix x or already estimated factors (using principal component analysis) or even both (I attach both as xls-file).
(Parameters: x = nper x nvar matrix of data. The factors are nper x 1 vectors)

Further, even though there are no error messages I get no output as I would expect from the code:

report(action=define)
report(atrow=1,atcol=1,align=center) "Factors" "PCP1" "PCP2" "ICP1" "ICP2"
report(atrow=2,atcol=1,fillby=cols) %seq(1,max)
report(atrow=2,atcol=2) stats
report(action=format,atcol=2,tocol=2,tag=min,special=onestar)
report(action=format,atcol=3,tocol=3,tag=min,special=onestar)
report(action=format,atcol=4,tocol=4,tag=min,special=onestar)
report(action=format,atcol=5,tocol=5,tag=min,special=onestar)
report(action=format,atrow=2,atcol=2,picture="*.#####",align=decimal)
report(action=show)

What might be the problem(s)?

Thanks in advance!
Frauke

*Following the PANIC methodology proposed by Bai and Ng (2004) I want to apply the method of principal components to the first differenced data.


You indeed want to apply BaiNg to the first differenced data. This seems to work. I tested it with an older version of RATS.

Code: Select all
open data moneydemand.xls
data(format=xls,org=columns,sheet="dm1") 1 98 m1_au m1_cn m1_dk m1_fr m1_bd $
  m1_it m1_jp m1_nl m1_sd m1_sw m1_us
make x
# m1_au to m1_us
@baing(max=4,standardize) x
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Determining the Number of Factors

Postby Frauke » Fri May 20, 2011 3:14 am

Thanks a lot!
Now it works without any problems.

However, can you please confirm that it is correct to include the original, i.e. not decomposed, data in x but not the already estimated factors?
Or to put it in another way: Implies baing.scr a principal component analysis?

Regards,
Frauke
Frauke
 
Posts: 10
Joined: Mon May 16, 2011 8:43 am

Re: Determining the Number of Factors

Postby TomDoan » Fri May 20, 2011 6:04 am

Frauke wrote:Thanks a lot!
Now it works without any problems.

However, can you please confirm that it is correct to include the original, i.e. not decomposed, data in x but not the already estimated factors?
Or to put it in another way: Implies baing.scr a principal component analysis?

Regards,
Frauke


That's correct. You input the original set of data (in this case in differences). Once you've decided upon the number of components, you use either PRINCOMP or PRINFACTORS (both standard RATS procedures) to extract the desired principal components for the next step.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm

Re: Determining the Number of Factors

Postby Frauke » Fri May 20, 2011 7:49 am

Thanks for the quick and informative reply!
Frauke
 
Posts: 10
Joined: Mon May 16, 2011 8:43 am


Return to Panel Data

Who is online

Users browsing this forum: No registered users and 0 guests