# hegy-test: Hylleberg, Engle, Granger and Yoo Test for Seasonal Unit... In uroot: Unit Root Tests for Seasonal Time Series

## Description

Hylleberg, Engle, Granger and Yoo (HEGY) test statistics for the null hypothesis seasonal unit roots.

## Usage

 ```1 2 3 4 5 6 7``` ```hegy.test(x, deterministic = c(1,0,0), lag.method = c("fixed", "AIC", "BIC", "AICc"), maxlag = 0, pvalue = c("RS", "bootstrap", "raw"), rs.nobsreg = 15, boot.args = list(seed = 123, lag.method = lag.method[1], maxlag = maxlag, byseason = FALSE, nb = 1000, BTdim = c(100, 10), debug.tid = -1)) hegy.regressors(x) ```

## Arguments

 `x` a univariate seasonal time series.
 `deterministic` a vector of length three containing zeros or ones to indicate, respectively, whether a constant, a trend or seasonal dummies are included in the regression equation of the test.
 `lag.method` a character specifying the lag order selection method.
 `maxlag` the maximum lag order to be considered by `lag.method`.
 `pvalue` a character specifying the method employed to compute p-values: `"RS"`, the default, interpolation based on response surface regressions; `"bootstrap"`, bootstrap; `"raw"` interpolation in the tables provided in the reference papers.
 `rs.nobsreg` an integer indicating the number of points employed in the response surface regression (only for `pvalue = "RS"`).
 `boot.args` a list containing the parameters employed in the bootstrap. See details below.

## Details

The regression equation employed to obtain the tests statistics may include the following deterministic terms: a constant, a linear trend, seasonal dummies. These terms are selected by setting to 1 the corresponding element in the vector `deterministic`: `deterministic = c(0,0,0)` no deterministic components, `deterministic = c(1,0,0)` includes a constant, `deterministic = c(1,0,1)` a constant and seasonal dummies, `deterministic = c(1,1,0)` a constant and a trend and `deterministic = c(1,1,1)` includes the three components.

The regression equation may include lags of the dependent variable. When `lag.method = "fixed"`, the lag order is fixed to `maxlag`; otherwise, `maxlag` is the maximum number of lags considered in a lag selection procedure that minimises the `lag.method` criterion, which can be `AIC` or `BIC` or corrected AIC, `AICc`, obtained as AIC + (2k(k+1))/(n-k-1), where k is the number of parameters and n is the number of available observations in the model.

Response surface based p-values, `pvalue="RS"`, is not available with option `lag.method = "AICc"`.

P-values based on response surface regressions follow the method described in MacKinnon (1994), Harvey+vanDijk (2006) and Díaz-Emparanza (2014). Gretl code provided by Díaz-Emparanza (2014) has been ported to function `hegy.rs.pvalue`. Note: the case `deterministic = c(0,0,0)` is not considered; `NA`s are returned if p-values based on response surfaces are selected for that case.

Bootstrapped p-values follow the approach described in Burridge and Robert Taylor (2004). The following arguments can be defined in `boot.args`:

• `seed`: a numeric, the seed of the random generator employed for resampling the residuals.

• `lag.method`: a character, the lag order selection method. This is the same as `lag.method` employed in the original regression, except that here, the AIC, BIC and AICc are obtained upon the residual sums of squares rather than the likelihood value.

• `maxlag`: a numeric, maximum number of lags. Same behaviour as `maxlag` explained above for the original regression.

• `byseason`: logical, should the residuals be resampled by season? If `TRUE`, the residuals belonging to the same season are resampled (at each time t, the residuals belonging to the corresponding season at time t are resampled); otherwise, the entire series of residuals is resampled regardless of the season they belong to.

• `nb`: a numeric, the number of bootstrap replicates.

• `BTdim`: a vector of length two containing the number of blocks and the number of threads per block to be run on parallel on the GPU. The product of these two elements must be equal or greater than `nb`.

• `debug.tid`: an integer employed for debugging. Currently ignored.

By default `boot.args\$lag.method` and `boot.args\$maxlag` are set equal to the same options employed for the original data in arguments `lag.method` and `maxlag`; if the default options are desired, these values need not be explicitly defined in the list `boot.args`.

The standard definition of the AIC, BIC and AICc criteria is used for the original series. For the bootstrapped series, these criteria are defined upon the residual sum squares of the model:

AIC = n log RSS/n + 2 k

BIC = n log RSS/n + k log(n)

AICc = AIC + (2 k (k+1)) / (n - k - 1)

where RSS is the residual sum of squares, k is the number of parameters in the model and n is the number of available observations.

Given a maximum lag, `maxlag`, the first `maxlag` observations are removed before fitting the models to be compared by the selected criterion. In this way, all the models contain the same number of observations. Once the lag order is selected, the statistics are obtained using the entire sample (except those observations that are missed due to the eventually chosen lags).

The HEGY regressors were originally proposed in Hylleberg etal. (1990) for quarterly data. They are generalized to monthly series in Beaulieu and Miron (1993) and to weekly data in Cáceres (1996). Franses and Hobijn (1997) show tabulated values for bimonthly and biannual data as well as quarterly and monthly data. `hegy.rergessors` follows the expressions given in Smith etal. (2009), which define the regressors for a general periodicity of the time series.

## Value

`hegy.test` returns a list of class `"HEGYtest"` with the following components:

 `statistics` the value of the test statistics.
 `pvalues` the p-values for each test statistics.
 `method` a character string describing the type of test.
 `data.name` a character string giving the name of the data.
 `fitted.model` the fitted regression model.
 `lag.method` a character, the lag order selection criterion.
 `lag.order` a numeric, the number of lags included in the regression.
 `strdet` a character, auxiliary element for `print` describing the deterministic elements that were selected.
 `type.pvalue` a character, the value of the input argument codepvalue.
 `bootstrap` a list, parameter options employed in the bootstrap (if `pvalue = "bootstrap"`).
 `boot.chosen.lags` a vector, the lag orders chosen for each bootstrap replicate (if `pvalue = "bootstrap"` and `boot.args\$lag.method != "fixed"`).
 `pvlabels` a vector of characters containing a label related to each p-values. Auxiliary element for `print` method.

The method `print` displays the test statistics and p-values; `summary` shows the same output and includes the fitted regression model; `residuals` returns the residuals from the regression model fitted to the original data.

`hegy.regressors` returns a matrix containing the HEGY regressors which are used to test null of unit root at different frequencies.

## References

Beaulieu, J. J. Miron, J. A. (1993) "Seasonal unit roots in aggregate U.S. data." Journal of Econometrics 55(1-2), pp. 305-328. DOI: http://dx.doi.org/10.1016/0304-4076(93)90018-Z.

Burridge, P. and Taylor, R. (2004) "Bootstrapping the HEGY seasonal unit root tests." Journal of Econometrics 123(1), pp. 67-87. DOI: http://dx.doi.org/10.1016/j.jeconom.2003.10.029.

Cáceres, J. J. (1996) "Contraste de raíces unitarias en datos semanales." Estadística Española 38(41), pp. 139-159.

Díaz-Emparanza, I. (2014) "Numerical distribution functions for seasonal unit root tests"- Computational Statistics and Data Analysis, 76, pp. 237-247. DOI: http://dx.doi.org/10.1016/j.csda.2013.03.006. Gretl code: http://www.ehu.eus/ignacio.diaz-emparanza/packages/GHegy.gfn.

Franses, F. H. (1991) "Seasonality, non-stationarity and the forecasting of monthly time series." International Journal of Forecasting 7(2), pp. 199-208. DOI: http://dx.doi.org/10.1016/0169-2070(91)90054-Y.

Franses, P. H. and Hobijn, H. (1997) "Critical values for unit root tests in seasonal time series." Journal of Applied Statistics 24(1), pp. 25-47.

Harvey D. I. and van Dijk D. (2006). "Sample size, lag order and critical values of seasonal unit root tests." Computational Statistics & Data Analysis, 50(10), 2734-2751. DOI: http://dx.doi.org/10.1016/j.csda.2005.04.011.

Hylleberg, S., Engle, R., Granger, C. and Yoo, B. (1990) "Seasonal integration and cointegration." Journal of Econometrics 44(1), pp. 215-238. DOI: http://dx.doi.org/10.1016/0304-4076(90)90080-D.

MacKinnon J. G. (1994). "Approximate asymptotic distribution functions for unit-root and cointegration tests." Journal of Business and Economic Statistics, 12(2), 167-176. DOI: http://dx.doi.org/10.1080/07350015.1994.10510005.

Smith, R. J., Taylor, A. M. R. and del Barrio Castro, T. (2009) "Regression-based seasonal unit roots."Econometric Theory 25(2), pp. 527-560. DOI: http://dx.doi.org/10.1017/S0266466608090166.

`hegy.rs.pvalue`, `uroot.raw.pvalue`.
 ```1 2 3 4 5 6 7 8``` ```x <- bgt.data[["LCONSEXPCO"]] hegy.test(x, deterministic = c(1,1,1), lag.method = "fixed", maxlag = 1) ## Not run: # this requires CUDA capable GPU hegy.test(x, deterministic = c(1,1,1), lag.method = "fixed", maxlag = 1, pvalue = "bootstrap") ## End(Not run) ```