Main Content

# lmctest

Leybourne-McCabe stationarity test

## Syntax

``h = lmctest(y)``
``````[h,pValue,stat,cValue] = lmctest(y)``````
``StatTbl = lmctest(Tbl)``
``[___] = lmctest(___,Name=Value)``
``[___,reg1,reg2] = lmctest(___)``

## Description

example

````h = lmctest(y)` returns the rejection decision `h` from conducting the Leybourne-McCabe stationarity test for assessing whether the univariate time series `y` is stationary.```

example

``````[h,pValue,stat,cValue] = lmctest(y)``` also returns the p-value `pValue`, test statistic `stat`, and critical value `cValue` of the test.```

example

````StatTbl = lmctest(Tbl)` returns the table `StatTbl` containing variables for the test results, statistics, and settings from conducting the Leybourne-McCabe stationarity test on the last variable of the input table or timetable `Tbl`. To select a different variable in `Tbl` to test, use the `DataVariable` name-value argument.```

example

````[___] = lmctest(___,Name=Value)` specifies options using one or more name-value arguments in addition to any of the input argument combinations in previous syntaxes. `lmctest` returns the output argument combination for the corresponding input arguments.Some options control the number of tests to conduct. The following conditions apply when `lmctest` conducts multiple tests: `lmctest` treats each test as separate from all other tests.If you specify `y`, all outputs are vectors.If you specify `Tbl`, each row of `StatTbl` contains the results of the corresponding test. For example, ```lmctest(Tbl,DataVariable="GDP",Alpha=0.025,Lags=[0 1])``` conducts two tests, at a level of significance of 0.025, on the variable `GDP` of the table `Tbl`. The first test includes `0` lagged terms in the structural model, and the second test includes `1` lagged term in the structural model.```

example

````[___,reg1,reg2] = lmctest(___)` additionally returns structures of regression statistics, which are required to form the test statistic. `reg1` – Maximum likelihood estimation of the reduced-form model`reg2` – Deterministic local level model of filtered response data, with Gaussian noise and an optional linear trend ```

## Examples

collapse all

Test a time series for stationarity using the default options of `lmctest`. Input the time series data as a numeric vector.

Load Schwert's macroeconomic data set. Extract the monthly unemployment rate `UN`.

```load Data_SchwertMacro un = DataTableMth.UN;```

Represent the series as a growth rate by applying the first difference.

`unr = diff(un);`

The first difference operation causes `unr` to have one less observation than `un`. The timebase of `unr` starts at observation 2.

Plot the unemployment growth rate.

```dts = datetime(datesMth,ConvertFrom="datenum"); plot(dts(2:end),unr) title("Unemployment Growth Rate")```

Assess the null hypothesis of the Leybourne-McCabe stationarity test that the unemployment growth rate series is a trend-stationary AR(0) model. Use default options.

`h = lmctest(unr)`
```h = logical 0 ```

`h = 0` indicates that, at a 5% level of significance, the test fails to reject the null hypothesis that the unemployment growth rate series is a trend-stationary AR(0) model.

Load Schwert's macroeconomic data set `Data_SchwertMacro.mat`. Extract the monthly unemployment rate `UN`, and apply the first difference to the series.

```load Data_SchwertMacro unr = diff(DataTableMth.UN);```

Assess the null hypothesis that the series is a trend-stationary AR(0) process. Return the test decision, $\mathit{p}$-value, test statistic, and critical value.

`[h,pValue,stats,cValue] = lmctest(unr)`
```h = logical 0 ```
```pValue = 0.1000 ```
```stats = 0.0978 ```
```cValue = 0.1460 ```

`pValue = 0.1000` is the maximum tabulated value; its actual value can be larger than 0.1000.

Test whether a time series, which is one variable in a table, for stationarity using the default options.

Load Schwert's macroeconomic data set. Convert the table of monthly series to a timetable.

```load Data_SchwertMacro dates = datetime(datesMth,ConvertFrom="datenum"); TT = table2timetable(DataTableMth,RowTimes=dates);```

Apply the first difference to all monthly series.

```DTT = varfun(@diff,TT(:,2:end)); DTT.Properties.VariableNames{end}```
```ans = 'diff_SIG' ```

Assess the null hypothesis of the Leybourne-McCabe stationarity test that the rate of the volatility of returns to Standard & Poor's composite index series is a trend-stationary AR(0) model.

`StatTbl = lmctest(DTT)`
```StatTbl=1×8 table h pValue stat cValue Lags Alpha Trend Test _____ ______ _________ ______ ____ _____ _____ ________ Test 1 false 0.1 0.0027953 0.146 0 0.05 true {'var2'} ```

`lmctest` returns test results and settings in the table `StatTbl`, where variables correspond to test results (`h`, `pValue`, `stat`, and `cValue`) and settings (`Lags`, `Alpha`, `Trend`, and `Test`), and rows correspond to individual tests (in this case, `lmctest` conducts one test).

By default, `lmctest` tests the last variable in the table. To select a variable from an input table to test, set the `DataVariable` option.

Test the growth of the US unemployment rate using the data in [5].

Load Schwert's macroeconomic data set. Convert the table of monthly series to a timetable. Apply the first difference to all variables in the timetable.

```load Data_SchwertMacro dates = datetime(datesMth,ConvertFrom="datenum"); TT = table2timetable(DataTableMth,RowTimes=dates); TT.Dates = []; DTT = varfun(@diff,TT);```

Define the time range of the sample considered in [4]. Extract a subtable with the corresponding dates.

```trLM = timerange("1948-01-01","1985-12-01","closed"); DTT4 = DTT(trLM,:);```

Assess the null hypothesis that the unemployment rate growth is a trend-stationary, AR(1) process. Conduct the same test twice. For the first test, specify the test statistic that uses the estimated variance from OLS regression (`Test = "var1"`). For the second test, specify the test statistic that uses estimated variance from the maximum likelihood of the reduced-form regression model (`Test = "var2"`).

```StatTbl = lmctest(DTT4,DataVariable="diff_UN", ... Lags=1,Test=["var1" "var2"])```
```StatTbl=2×8 table h pValue stat cValue Lags Alpha Trend Test _____ ________ ________ ______ ____ _____ _____ ________ Test 1 false 0.1 0.099166 0.146 1 0.05 true {'var1'} Test 2 true 0.020721 0.18741 0.146 1 0.05 true {'var2'} ```

Row `Test 1` of `StatTbl` contains the results of the first test `StatTbl.h(1)` = 0 indicates that, at a 5% level of significance, there is not enough evidence to reject that the unemployment growth rate is a trend-stationary, AR(1) process. Row `Test 2` of `StatTbl` contains the results of the second test `StatTbl.h(2)` = 1 indicates that, at a 5% level of significance, there is enough evidence to reject that the unemployment growth rate is a trend-stationary, AR(1) process, which implies that the unemployment rate growth is nonstationary.

Leybourne and McCabe report that the original LMC statistic fails to reject stationarity, while the modified LMC statistic does reject it [4].

Load Schwert's macroeconomic data set. Convert the table of monthly series to a timetable. Apply the first difference to all variables in the timetable.

```load Data_SchwertMacro dates = datetime(datesMth,ConvertFrom="datenum"); TT = table2timetable(DataTableMth,RowTimes=dates); TT.Dates = []; DTT = varfun(@diff,TT);```

Assess the null hypothesis that the unemployment rate growth is a trend-stationary, AR(1) process. Return the regression statistics from the maximum likelihood estimation of reduced-form model and from the OLS estimation of deterministic local level model of filtered response data.

`[StatTbl,reg1,reg2] = lmctest(DTT,DataVariable="diff_UN",Lags=1);`

Display the coefficients of both regressions.

```rownames = ["c_0"; "delta"; "b_1"]; varnames = ["Coefficient"; "SE"; "PValue"]; coeff = reg1.coeff; se = reg1.se; pval = reg1.tStats.pVal; table(coeff,se,pval,RowNames=rownames,VariableNames=varnames)```
```ans=3×3 table Coefficient SE PValue ___________ _________ __________ c_0 -0.00051942 0.0041996 0.90162 delta -0.25044 0.051797 1.8304e-06 b_1 0.63665 0.046451 5.6215e-36 ```
```rownames = ["Intercept"; "Trend"]; coeff = reg2.coeff; se = reg2.se; pval = reg2.tStats.pVal; table(coeff,se,pval,RowNames=rownames,VariableNames=varnames)```
```ans=2×3 table Coefficient SE PValue ___________ __________ _______ Intercept 0.013904 0.024521 0.57099 Trend -2.2372e-05 9.3396e-05 0.81079 ```

## Input Arguments

collapse all

Univariate time series data, specified as a numeric vector. Each element of `y` represents an observation.

Data Types: `double`

Time series data, specified as a table or timetable. Each row of `Tbl` is an observation.

Specify a single series (variable) to test by using the `DataVariable` argument. The selected variable must be numeric.

Note

`lmctest` removes missing observations, represented by `NaN` values, from the input series.

### Name-Value Arguments

Specify optional pairs of arguments as `Name1=Value1,...,NameN=ValueN`, where `Name` is the argument name and `Value` is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose `Name` in quotes.

Example: `lmctest(Tbl,DataVariable="GDP",Alpha=0.025,Lags=[0 1])` conducts two tests, at a level of significance of 0.025, on the variable `GDP` of the table `Tbl`. The first test includes `0` lagged terms in the structural model, and the second test includes `1` lagged term in the structural model.

Number p of lagged values of yt to include in the structural model, specified as a nonnegative integer or vector of nonnegative integers. p is equal to the number of lagged differences of yt in the reduced-form model.

`lmctest` conducts a separate test for each element in `Lags`.

`Lags` > 0 decreases the sample size (see Algorithms).

Tip

To draw valid inferences from a Leybourne-McCabe stationarity test, you must determine a suitable value for the `Lags` argument. The test is robust when p is greater than its true value in the data-generating process, and simulation evidence shows that, under the null hypothesis, the marginal distribution of the MLE of bp is asymptotically normal [3]. Therefore, you can use a standard t-test to determine whether bp is significant. However, estimated coefficient standard errors are unreliable when the MA(1) coefficient a is near 1. For a model-order test, valid under both the null and alternative hypotheses, that relies only on the MLEs of bp and a, and not on their standard errors, see [4].

Example: `Lags=[0 1]` includes no lags in the structural model for the first test, and then includes yt - 1 in the structural model for the second test.

Data Types: `double`

Flag for including deterministic trend δt in the structural model, specified as a logical scalar or vector. `Trend=true` is equivalent to including the drift term δ in the reduced-form model.

`lmctest` conducts a separate test for each element in `Trend`.

Tip

With a specific testing strategy in mind, determine the value of the `Trend` argument by the growth characteristics of the input time series.

• If the input series grows, include a trend term by setting `Trend` to `true` (default). This setting provides a reasonable comparison of a trend stationary null and a unit root process with drift.

• If a series does not exhibit long-term growth characteristics, exclude a trend term by setting `Trend` to `false`.

Example: `Trend=false` excludes δt from the structural model for all tests.

Data Types: `logical`

Variance estimate ${\stackrel{^}{\sigma }}_{1}^{2}$ to use for the test statistic, specified as an estimate name, or a string vector or cell vector of estimate names, in this table.

Test NameDescription
`"var1"`

`${\stackrel{^}{\sigma }}_{1}^{2}=\frac{{e}_{2}\prime {e}_{2}}{T},$`

where `e`2 is the residual vector from the regression of the deterministic local level model of the filtered responses.

`"var2"`

${\stackrel{^}{\sigma }}_{1}^{2}=a{\sigma }^{2}$, where `a` and σ2 are MLEs from the reduced-form model regression.

For more details, see Test Statistics.

`lmctest` conducts a separate test for each estimate name in `Test`.

Example: `Test=["var1" "var2"]` conducts two tests. The first test uses the variance estimate described by `"var1"` to compute the test statistic, and the second test uses the variance estimate `"var2"`.

Data Types: `char` | `cell` | `string`

Nominal significance level for the hypothesis test, specified a numeric scalar between `0.01` and `0.10` or a numeric vector of such values.

`lmctest` conducts a separate test for each value in `Alpha`.

Example: `Alpha=[0.01 0.05]` uses a level of significance of `0.01` for the first test, and then uses a level of significance of `0.05` for the second test.

Data Types: `double`

Variable in `Tbl` to test, specified as a string scalar or character vector containing a variable name in `Tbl.Properties.VariableNames`, or an integer or logical vector representing the index of a name. The selected variable must be numeric.

Example: `DataVariable="GDP"`

Example: `DataVariable=[false true false false]` or `DataVariable=2` tests the second table variable.

Data Types: `double` | `logical` | `char` | `string`

## Output Arguments

collapse all

Test rejection decisions, returned as a logical scalar or vector with length equal to the number of tests. `lmctest` returns `h` when you supply the input `y`.

• Values of `1` indicate rejection of the AR(p) null hypothesis in favor of the ARIMA(p,1,1) alternative.

• Values of `0` indicate failure to reject the AR(p) null hypothesis.

Test statistic p-values, returned as a numeric scalar or vector with length equal to the number of tests. `lmctest` returns `pValue` when you supply the input `y`.

The p-values are right-tail probabilities.

When test statistics are outside tabulated critical values, `lmctest` returns maximum (`0.10`) or minimum (`0.01`) p-values.

Test statistics, returned as a numeric scalar or vector with length equal to the number of tests. `lmctest` returns `stat` when you supply the input `y`.

For details, see Test Statistics.

Critical values, returned as a numeric scalar or vector with length equal to the number of tests. `lmctest` returns `cValue` when you supply the input `y`.

Critical values are for right-tail probabilities.

Test summary, returned as a table with variables for the outputs `h`, `pValue`, `stat`, and `cValue`, and with a row for each test. `lmctest` returns `StatTbl` when you supply the input `Tbl`.

`StatTbl` contains variables for the test settings specified by `Lags`, `Alpha`, `Trend`, and `Test`.

Regression statistics from the maximum likelihood estimation of the reduced-form model, returned as a structure array with the number of records equal to the number of tests.

Each element of `reg1` has the fields in this table. You can access a field using dot notation, for example, `reg(1).coeff` contains the coefficient estimates of the first test.

 `num` Length of input series with `NaN`s removed, T – 1 `size` Effective sample size, adjusted for lags and difference, T – (p + 1) `names` Regression coefficient names `coeff` Estimated coefficient values `se` Estimated coefficient standard errors `Cov` Estimated coefficient covariance matrix `tStats` t statistics of coefficients and p-values `FStat` F statistic and p-value `yMu` Mean of the lag-adjusted input series `ySigma` Standard deviation of the lag-adjusted input series `yHat` Fitted values of the lag-adjusted input series `res` Regression residuals `DWStat` Durbin-Watson statistic `SSR` Regression sum of squares `SSE` Error sum of squares `SST` Total sum of squares `MSE` Mean square error `RMSE` Standard error of the regression `RSq` R2 statistic `aRSq` Adjusted R2 statistic `LL` Loglikelihood of data under Gaussian innovations `AIC` Akaike information criterion `BIC` Bayesian (Schwarz) information criterion `HQC` Hannan-Quinn information criterion

Regression statistics from the estimation of the deterministic local level model of the filtered response data, returned as a structure array with the number of records equal to the number of tests.

`reg2` has the same fields as `reg1`, but with the differences described in the following table.

 `num` Length of input series with `NaN`s removed, T – p `size` Effective sample size, adjusted for lags and difference, T – p

## More About

collapse all

### Leybourne-McCabe Stationarity Test

The Leybourne-McCabe stationarity test assesses the null hypothesis that a response series yt is a trend-stationary, degree p autoregressive model (AR(p)) against the alternative hypothesis that yt is nonstationary.

Structural Model for Hypotheses

The structural model for the response series is

`$\begin{array}{c}{y}_{t}={c}_{t}+\delta t+{b}_{1}{y}_{t-1}+\cdots +{b}_{p}{y}_{t-1}+{u}_{1,t}\\ {c}_{t}={c}_{t-1}+{u}_{2,t},\end{array}$`

where

• $\begin{array}{c}{u}_{1,t}~\text{iid}\left(0,{\sigma }_{1}^{2}\right)\\ {u}_{2,t}~\text{iid}\left(0,{\sigma }_{2}^{2}\right),\end{array}$

• u1,t and u2,t are independent.

• The number of lags p is the value of the `Lags` option.

• The trend term δt is present when `Trend`=`true`.

• T is the sample size without missing observations.

The model is second-order equivalent in moments to the reduced-form ARIMA(p,1,1) model

`$\Delta {y}_{t}=\delta +{b}_{1}\Delta {y}_{t-1}+...+{b}_{p}\Delta {y}_{t-p}+\left(1-aL\right){v}_{t},$`

where L is the lag operator Lyt = yt–1 and vt ~ iid(0,σ2).

The null hypothesis is that σ22 = 0 in the structural model, which is equivalent to a = 1 in the reduced-form model. The alternative is that σ22 > 0 or a < 1. Under the null hypothesis, the structural model is AR(p) with intercept c0 and trend δt; the reduced-form model is an over-differenced ARIMA(p,1,1) representation of the same process.

Test Statistics

`lmctest` computes test statistics using this two-stage method:

1. Perform OLS regression of the reduced-form model to obtain maximum likelihood estimates (MLEs) of the coefficients (results are stored in the output `reg1`). Specifically, regress Y = Δyt on p lagged differences of y. `lmctest` stores the regression results in `reg1`.

2. Regress filtered data zt onto xt where

• ${z}_{t}={y}_{t}-{b}_{1}{y}_{t-1}-...-{b}_{p}{y}_{t-p}.$

• t = p+1,…,T

• xt is one of the following:

• 1, for an intercept-only model when `Trend=false`

• [1 t], for a model with an intercept and deterministic tome trend when `Trend=true`

`lmctest` stores the regression results in `reg2`.

The test statistic s* (output `stat`) is

`${s}^{\ast }=\frac{{e}_{1}\prime V{e}_{1}}{{s}^{2}{T}^{2}},$`

wherea

• e1 is a vector of the residuals from the reduced-form model regression.

• V(i,j) = min(i,j)

• s2 is an estimate of ${\sigma }_{1}^{2}$ that depends on the value of the variance-estimation algorithm option `Test`:

• `"var1"` — The estimate is

`${\stackrel{^}{\sigma }}_{1}^{2}=\frac{{e}_{2}\prime {e}_{2}}{T},$`

where `e`2 is the residual vector from the regression zt onto xt (output `reg2`). This selection is the original Leybourne-McCabe test, as described in [3], and it has a rate of consistency O(`T`).

• `"var2"` (default) — The estimate is 2, where `a` and σ2 are MLEs from the reduced-form model regression (output `reg1`). This selection is the modified Leybourne-McCabe test, as described in [4], and it has a rate of consistency O(`T`2).

## Tips

• The alternative hypothesis that σ22 > 0 implies 0 < a < 1. As a result, an alternative model with a = 0 and a random walk, reduced-form model with iid errors is not possible. The class of I(1) alternatives represented by such a model is appropriate for economic series with significant MA(1) components [3]. To test for a random walk, use `vratiotest`.

## Algorithms

• The value of the `Lags` option lags the response in the structural model, and the reduced-form model operates on the first difference of the response. In general, when a time series is lagged or differenced, the sample size is reduced. Without a presample, if yt is defined for t = 1,…,T, the lagged series ytk is defined for t = k+1,…,T. When ytk is differenced, the time base reduces to k+2,…,T. p lagged differences reduce the common time base to p+2,…,T and the effective sample size is T – (p+1).

• Test statistics follow nonstandard distributions under the null, even asymptotically. Asymptotic critical values for a standard set of significance levels between 0.01 and 0.1, for models with and without a trend, have been tabulated in [2] using Monte Carlo simulations. Critical values `cValue` and p-values `pValue` reported by `lmctest` are interpolated from the tables. The tabulated tables are identical to those for `kpsstest`.

• Bootstrapped critical values, used by tests with a unit root null (such as `adftest` and `pptest`), are not possible for `lmctest` [1]. As a result, size distortions for small samples may be significant, especially for highly persistent processes.

## References

[1] Caner, M., and L. Kilian. "Size Distortions of Tests of the Null Hypothesis of Stationarity: Evidence and Implications for the PPP Debate." Journal of International Money and Finance. Vol. 20, 2001, pp. 639–657.

[2] Kwiatkowski, D., P. C. B. Phillips, P. Schmidt, and Y. Shin. “Testing the Null Hypothesis of Stationarity against the Alternative of a Unit Root.” Journal of Econometrics. Vol. 54, 1992, pp. 159–178.

[3] Leybourne, S. J., and B. P. M. McCabe. "A Consistent Test for a Unit Root." Journal of Business and Economic Statistics. Vol. 12, 1994, pp. 157–166.

[4] Leybourne, S. J., and B. P. M. McCabe. "Modified Stationarity Tests with Data-Dependent Model-Selection Rules." Journal of Business and Economic Statistics. Vol. 17, 1999, pp. 264–270.

[5] Schwert, G. W. "Effects of Model Specification on Tests for Unit Roots in Macroeconomic Data." Journal of Monetary Economics. Vol. 20, 1987, pp. 73–103.

## Version History

Introduced in R2010a