I am attempting to fit the Nifty oil and gas sector index (on price returns) using Stata software. In order to run the augmented Dicky Fuller test, I need to find the optimal lag of the series. While I am aware that lag length can be determined using ACF and PACF, I want to find a better method to do so. Using google search I found two commands: dfgls and varsoc.
But for some unknown reason, dfgls is showing error but varsoc is working well. However, from stata manual, varsoc command is for VARs and VECMs. Then, does that mean I cannot use it for determining the optimal lag length of univariate time series model? If not, what other commands should I use that will give Akaike information criteria (AIC) and lag lengths?