I am testing several variables for unit roots via the
urca package) and
CADFtest package) functions. Both packages have functions allow to select the optimal number of lags via information criteria. While the resulting number of lags is visible in the test output, I would like to store them as a factor (to later summarize the results for all variables in an output matrix). However, when I try using the slot function, the following errors come up:
urca (with a maximum of 14 lags and automatic lag order selection through the AIC):
x <- ur.df(myvar$var1, lags = 14, selectlags = "AIC")
x@lags = 14 (i.e. the maximum number of lags, although only 12 lags are used). If I don't include
lags = 14, the automatic selection no longer works and
x@lags = 1.
CADF (with a maximum of 14 lags and automatic lag order selection through the AIC):
x <- CADFtest(myvar$var1, max.lag.y = 14, criterion = "AIC")
x@lags yields the error message
"Error: trying to get slot "lags" from an object (class "CADFtest") that is not an S4 object"
Is there a way to either fix the
@lags slot for
urca or implement a similar function for