*! version 1.0.3 07oct2022

Title

xtarimau -- Finds the best [S]ARIMA[X] models in heterogeneous
panels with the help of arimaauto

Syntax

xtarimau
[varlist]
[if] [in]
[weight]
[, options]

Panel wrapper
preestimation(string) any command or program, defined with
program define, including a series of commands, which will run
prior to the model estimation for each time series

postestimation(string) any command or program, defined with
program define, including a series of commands, which will run
after the model estimation for each time series

export(string) .ster file path, estimates will be appended

Best model selection
ic(string) model selection criterion for [TS] arima:
"llf" (maximization of the LLF),
"aic" (minimization of the AIC) or "sic" (minimization
of the SIC) (by default: "aic")

stationary limit the model space to stationary models only,
ARIMA(p,0,q)(P,0,Q) which will disable the automatic
determination of #d with the help of [TS] dfgls
and kpss

noseasonal limit the model space to non-seasonal models only,
ARIMA(p,d,q) which will disable the automatic determination
of #D with the help of hegy

nostepwise switch to bulk estimation from the Hyndman-Khandakar
algorithm

Tests-related
level(#) confidence level, constrained by the critical values of
hegy: 90, 95 or 99
(by default: c(level))

mode(string) lag selection criterion for unit root tests:
"maic", "bic" or "seq" (by default: "maic")

hegy(...) options directly passed to hegy
except gls (enabled by default, to disable specify nogls),
mode(string) and maxlag(#) which will be ignored

dfgls(...) options directly passed
to [TS] dfgls except maxlag(#) which will
be ignored

kpss(...) options directly passed to kpss
except maxlag(#) which will be ignored

sdtest a test for heterogeneity, i.e., whether the standard
deviations of #p, #d, #q, #P, #D, #Q across the panel are 0

ARIMA-related
noconstant suppress constant term if both
arima(#p,#d,#q) and sarima(#P,#D,#Q,#s) are specified

arima(#p,#d,#q) specify ARIMA(p,d,q) model for dependent
variable which will disable the automatic determination of #d
with the help of [TS] dfgls and kpss

sarima(#P,#D,#Q,#s) specify period-#s multiplicative
seasonal ARIMA term which will disable the automatic determination
of #D with the help of hegy

arima(...) options directly passed to
[TS] arima except ar(numlist), ma(numlist),
mar(numlist, #s) and
mma(numlist, #s)} which will be
ignored

Limits and maximum values
max(numlist) limit of p and q
in ARIMA(p,d,q) (by default: 5 5)

mmax(numlist) limit of P and Q
in ARIMA(p,d,q)(P,D,Q) (by default: 2 2)

invroot(real) limit of inverse characteristic roots
in estat aroots (by default: 1/1.001)

maxlag(#) maximum lag order to be used in unit root tests
(by default: . aka unlimited)

maxmodels(#) maximum number of estimated models
(by default: . aka unlimited)

iterate(#) maximum number of iterations(influences convergence)
(by default: 100)

Reporting
trace(#) print hegy, [TS] dfgls and
kpss output if 1 and [TS] arima output
if 2 (by default: 0)

The user must tsset the data before using xtarimau;
see [TS] tsset.

depvar and indepvars may contain time-series operators;
see tsvarlist.

by, collect, fp, rolling, statsby, and xi
are not allowed; see prefix.

iweights are allowed; see weights.

See [TS] arima postestimation for features
available after estimation.

Description

xtarimau is a panel wrapper for arimaauto which is de facto an "augmented" Mata-written sister program to Christopher F. Baum's ARMA-limited
arimasel with mutually consistent output, allowing for ARIMA(p,d,q)
and multiplicative seasonal ARIMA(p,d,q)(P,D,Q) models, selecting the
best model based on the LLF, AIC or SIC, and returning its estimates at the same
time. However, unlike arimasel, the selection is by default peformed
with the help of the Hyndman-Khandakar algorithm, first implemented in the
auto.arima
function (part of of the "forecast" package) in the R language.

xtarimau can therefore be considered an estimation command, built on
top of arimaauto, storing estimates under the name ts_# or saving
them into a .ster file and returning the best estimated models in
r(models). The user can also access r(ictests), r(icarima), and
hidden r(limits).

Stata-adjusted Hyndman-Khandakar algorithm:

The model selection algorithm described in Hyndman and Khandakar (2008) is
based on a combination of a modified Canova-Hansen seasonal unit root test
(with an empirical formula for calculation of its critical values) and of the
KPSS unit root test, aimed at avoiding (alleged) overdifferencing caused
by tests which assume unit root in their null hypothesis such as hegy
and [TS] dfuller. Since the Canova-Hansen test was unavailable
in Stata 17 and its implementation would have been a feat of its own,
the algorithm was "inverted" to work with more powerful GLS-based
hegy and [TS] dfgls unit root tests with a correction
by the KPSS unit root test to prevent the mentioned overdifferencing aka large
#d in ARIMA(p,d,q) and ARIMA(p,d,q)(P,D,Q) models. The
user can disable GLS in hegy and pass additional options to all the
three tests; see options (syntax).

Unit root tests:

hegy performs the Hylleberg, Engle, Granger, and Yoo (HEGY) (1990) test
for both monthly and quarterly data, allowing for generalized least-squares
(GLS) and ordinary least-squares (OLS) and detrending (controlled by the
nogls option). It automatically determines the lag length (order of
augmentation) based on the modified AIC (MAIC) (del Barrio Castro, Osborn, and
Taylor, 2016), Bayesian information criterion (BIC), and sequential t test
for the last augmentation lag (Hall, 1994; Ng and Perron, 2001). User may
control the deterministic terms with help of the det() option; see
hegy for syntax and examples. The critical values are constructed
from the empirically estimated response surface (del Barrio Castro,
Bodnar, and Sansó, 2015).

NB xtarimau only uses the hegy's t test for Nyquist
frequencies (t_S/2).

[TS] dfgls performs a modified Dickey-Fuller t test for a unit
root in which the series has been transformed by a generalized least-squares
regression. By default, a trend is included; see [TS] dfgls
for syntax and examples.

kpss performs the Kwiatkowski, Phillips, Schmidt, Shin (KPSS, 1992)
test for stationarity of a time series. This test differs from
[TS] dfgls, by having a null hypothesis of stationarity. The
test may be conducted under the null of either trend stationarity
(the default) or level stationarity; see kpss for syntax and
examples.

PS The maximum lag length in the unit root tests is calculated with the
help of the Schwert (1989) formula(s) (the default) or xtarimau's
maxlag(#) option.

Heterogeneity tests:

A set of sdtesti commands, called via the sdtest option,
is used to test whether the standard deviations of #p, #d, #q, #P, #D, #Q in
r(models) are equal to 0.

Options

For hegy(...) see a list of
hegy options

For dfgls(...) see a list of
dfgls options

For kpss(...) see a list of
kpss options

For arima(...) see a list of
arima options

Examples

panel data:
. sysuse xtline1.dta, clear
. xtarimau calories, noseas
. xtarimau calories, noseas nostep maxm(15) export(test)
. xtarimau calories, noseas post(predict xb)

Author

Ilya Bolotov

Prague University of Economics and Business

Prague, Czech Republic

ilya.bolotov@vse.cz

Thanks for citing this software and my works on the topic:

Bolotov, I. (2022). XTARIMAU: Stata module to find the best [S]ARIMA[X]
models in heterogeneous panels with the help of arimaauto. Available from
https://ideas.repec.org/c/boc/bocode/s459048.html.

References

del Barrio Castro, T., A. Bodnar, and A. Sansó. 2015. Numerical
distribution functions for seasonal unit root tests with OLS and GLS
detrending. Working Paper 73, DEA.
http://dea.uib.es/digitalAssets/353/353054_w73.pdf.

del Barrio Castro, T., D. R. Osborn, and A. M. R. Taylor. 2016. The
performance of lag selection and detrending methods for HEGY seasonal unit
root tests. Econometric Reviews 35: 122-168.

Hall, A. 1994. Testing for a unit root in time series with pretest data-based
model selection. Journal of Business and Economic Statistics 12: 461-470.

Hylleberg, S., R. F. Engle, C. W. J. Granger, and B. S. Yoo. 1990. Seasonal
integration and cointegration. Journal of Econometrics 44: 215-238.

Hyndman, R. J. and Y. Khandakar. 2008. Automatic time series forecasting: the
forecast package for R. Journal of statistical software, 27(1), 1-22.

Kwiatkowski, D., P. C. Phillips, P. Schmidt, and Y. Shin (1992). Testing the
null hypothesis of stationarity against the alternative of a unit root: How
sure are we that economic time series have a unit root?.
Journal of econometrics, 54(1-3), 159-178.

Ng, S., and P. Perron. 2001. Lag length selection and the construction of unit
root tests with good size and power. Econometrica 69: 1519-1554.

Rodrigues, P. M. M., and A. M. R. Taylor. 2007. Efficient tests of the
seasonal unit root hypothesis. Journal of Econometrics 141: 548-573.

Schwert, G. W. 1989. Tests for unit roots: A Monte Carlo investigation.
Journal of Business and Economic Statistics 2: 147-159.