bpfaff / urca

Unit Root and Cointegration Tests for Time Series Data
4 stars 4 forks source link

Error in ur.pp #2

Closed catapulta closed 3 years ago

catapulta commented 4 years ago

Hello, thanks for developing this package. I'm getting an error when running the following:

> urca::ur.pp(c(rep(0, 10), 2))
Error in coef(test.reg)[2, 1] : subscript out of bounds

Env: R 3.6.1 urca_1.3-0

jmablans commented 4 years ago

Dear Mr Pfaff,

I'm also running into this issue. Seems that the Error ... vs NaN behaviour is inconsistent. Would be nice if NaN is always returned when no value can be calculated.

Thank you in advance and kind regards, Jan Blans

ts <- as.ts(c(0,0))
urca::ur.pp(ts)
# Error in coef(test.reg)[2, 1] : subscript out of bounds

ts <- as.ts(c(1,1))
urca::ur.pp(ts)
# Error in coef(test.reg)[2, 1] : subscript out of bounds

ts <- as.ts(c(0,1))
urca::ur.pp(ts)
# Error in coef(test.reg)[2, 1] : subscript out of bounds

ts <- as.ts(c(1,1,0))
urca::ur.pp(ts)
# Error in coef(test.reg)[2, 1] : subscript out of bounds

ts <- as.ts(c(1,1,1,0))
urca::ur.pp(ts)
# Error in coef(test.reg)[2, 1] : subscript out of bounds

ts <- as.ts(c(1,0,1))
urca::ur.pp(ts)
# no error, result:
# ################################################## 
# # Phillips-Perron Unit Root / Cointegration Test # 
# ################################################## 
# 
# The value of the test statistic is: -4 

ts <- as.ts(c(0, 1, 1))
urca::ur.pp(ts)
# no error, result:
# ################################################## 
# # Phillips-Perron Unit Root / Cointegration Test # 
# ################################################## 
# 
# The value of the test statistic is: NaN 

ts <- as.ts(c(1,1,0,0))
urca::ur.pp(ts)
# no error, result :
# ################################################## 
# # Phillips-Perron Unit Root / Cointegration Test # 
# ################################################## 
# 
# The value of the test statistic is: -0.9375 

ts <- as.ts(c(0,0,0,0,0))
urca::ur.pp(ts)
# Error in coef(test.reg)[2, 1] : subscript out of bounds
Apolsus commented 3 years ago

Will this problem be solve ? For so many years?

bpfaff commented 3 years ago

Honestly, fixing senseless user input is not a top priority; patches are welcome.

catapulta commented 3 years ago

@bpfaff I'd be glad to put in time to fix the issue -- any guidance would be much appreciated (eg how to contribute, what's the preferred output).

Return of sensible and consistent output should be a priority.