robjhyndman / forecast

Forecasting Functions for Time Series and Linear Models
http://pkg.robjhyndman.com/forecast
1.1k stars 340 forks source link

Why the specific lags used in kpss unit root test in **ndiffs**? #959

Closed pgg1309 closed 1 month ago

pgg1309 commented 1 month ago

Hi, The function ndiffs uses a specific number of lags for the ur.kpss test

use.lag = trunc(3 * sqrt(length(x)) / 13)

Questions: (a) why is this lag used ? would it make sense regardless of the periodicity of the series ? (b) why not pick lags for the other two tests ? (ur.df and ur.pp)

Thanks!

robjhyndman commented 1 month ago

See https://stats.stackexchange.com/a/350363/159 Periodicity is irrelevant -- this is a unit root test, not a seasonality test.

We use the default lags for the other tests. This was purely about backwards compatibility.

pgg1309 commented 1 month ago

Thanks!