ycroissant / plm

Panel Data Econometrics with R
GNU General Public License v2.0
49 stars 13 forks source link

Result of cipstest / lags = 0L #39

Closed akoncak closed 1 year ago

akoncak commented 1 year ago

Hello, My question about Pesaran, M.H. (2007)'s CIPS test. In R, we can test via cipstest command. I was trying to regenerate the critical values of this test. I took test statistic via cipstest commad. However, my critical values are always smaller than the original ones.

I just wanted to be sure from my data-generating process and wrote code in GAUSS. I got the same results as the original paper. After that, using the same data set, model, and lag length R's cipstest gives different results from Eviews, Stata (pescadf), and GAUSS (tspdlib library). All of these programs provide the same result. I wonder why this difference.

Thank you,

tappek commented 1 year ago

Hi there, It will be hard to follow up on this one without any reproducible code. Tests often have many options which can make it somewhat involved to replicate test results across various implementations.

akoncak commented 1 year ago

Hello,

Thank you for your answer.

I generated data and test it with R. Test statistic is -1.35 (for "dmg" and "mg") and -1.27 (for "cmg"). After with same generated data I tested in Stata, Eviews and GAUSS. It's -1.465 for all of them (You can find data set in txt file: data_pseudo.txt).

Thanks,

#Pseudo Panel Data
set.seed(5)
N=30             #number of cross sections N= 30, 50, 100
T=30              #number of time period    T= 10, 20, 30, 50, 100

y = matrix(0, T+50, N)
y[1, ] = 0 

e = matrix(0, T+50, N)

for (j in 1:N) {
  for (i in 2:(T+50)) {

    #Cross-section depen.
    ft = matrix(rnorm(T+50, 0, 1), T+50, N)  
    # gamma = matrix(runif(N, 0, 1), 1, N)*4-1   #High: U[-1, 3]; Low: U[0, 0.02]
    # crosssec = ft%*%t(gamma)

    y[i, j] = y[i - 1, j] + ft[i, j ] + e[i, j]  
  }}

# y = trimr(y,50,0)                              #delete first 50 obs
# dgp=as.matrix(as.vector(y))

#CIPS Test
pdat = pdata.frame(dgp, N)

type="drift"      #"none", "drift", "trend"
lags=0            #integer, lag order for Dickey-Fuller augmentation
model="cmg"       #one of "cmg" (default), "mg", "dmg",
cipstest(pdat[ ,1], lags= lags, type = type, model=model)
GiovanniMillo commented 1 year ago

Hello. Thank you for the bug report (and thx tappek for bringing this to my attention). I have checked the cipstest() results against Stata's pescadf on your data: all is fine for positive lag orders, but for lag=0 cipstest outputs the test statistic of lag=1 (and a warning that something has gone wrong in the code!) We will fix this. All that said, please notice that (afaik) nobody ever uses lag=0 in applications, since the time when "DF" became "ADF". This is why nobody spotted this before. Thx once more for doing so.

akoncak commented 1 year ago

Hello @GiovanniMillo thank you for your explanation. I understand now