Title

ocsb -- Osborn-Chui-Smith-Birchenhall (OCSB) test for seasonal unit roots

Syntax

OCSB test for seasonal unit root:

ocsb varname [if] [in] [, options]

Estimate the number of seasonal differences needed to make the time series stationary:

ocsb_ndiff varname [if] [in] [, options]

ocsb
lag(#) lag order for AR model (0-3 recommended); default is lag(0)

seasonal(#) seasonal period; if not specified, determined from tsset

regress display regression output

ocsb_ndiff
maxdiffs(#) maximum number of seasonal differences to consider; default is maxdiff(2)

lag(#) lag order for OCSB test; default is lag(0)

seasonal(#) seasonal period; if not specified, determined from tsset

force continue testing even with insufficient observations

quiet suppress iteration output, show only final result

You must tsset your data before using ocsb and ocsb_ndiff; see [TS] tsset.

varname may contain time-series operators; see tsvarlist.

Description

ocsb implements the Osborn-Chui-Smith-Birchenhall (OCSB) test for seasonal unit roots.
The OCSB test is designed to determine whether seasonal differencing is needed for a time series.
The null hypothesis is that the series has a seasonal unit root (needs seasonal differencing),
while the alternative is that the series is stationary (does not need seasonal differencing).

ocsb_ndiff is a wrapper program that repeatedly applies the OCSB test to determine
the optimal number of seasonal differences required to make a time series stationary.
It follows an iterative procedure similar to nsdiffs
in R's forecast package.

Options

lag(#) specifies the lag order for the autoregressive (AR) model used in the test.
For ocsb, this is the lag used in the single test. For ocsb_ndiff, this is the
lag used at each iteration. Typical values are 0-3. Higher lags may be used for longer series.

seasonal(#) specifies the seasonal period (e.g., 4 for quarterly, 12 for monthly, etc.).
If not specified, the program attempts to determine the period from the tsset settings.
If the seasonal period cannot be determined from tsset (for example, if the time variable
is sequential numbers 1, 2, 3, ...), you must specify the seasonal period using seasonal(#).
It is important that when using the seasonal() option, the specified seasonal
period correctly reflects the true seasonality of the data. Using an incorrect seasonal period
will produce meaningless test results.

regress (for ocsb only) displays the regression output from the final OCSB regression.

maxdiffs(#) (for ocsb_ndiff only) specifies the maximum number of seasonal differences
to consider. Default is 2, as most time series require at most one or two seasonal differences.

force (for ocsb_ndiff only) forces the program to continue testing even when there are
insufficient observations. By default, the program stops if there are not enough observations
for reliable testing.

quiet (for ocsb_ndiff only) suppresses the iteration table and shows only the final result.

Examples

Setup

. webuse air2

. gen date = m(1949m1) + _n - 1

. format date %tm

. tsset date

Test whether air follows a unit-root process for annual seasonal data

. ocsb air

. ocsb air, lag(2) regress

Determine seasonal differencing order up to a max of twice differencing

. ocsb_ndiff air

. ocsb_ndiff air, maxd(2) lag(2)

Remarks

1. The OCSB test is designed for seasonal time series with period m > 1.
For non-seasonal data, use dfuller, pperron, or kpss instead.

2. The test requires at least m + lag + 3 observations for reliable results.

3. For automatic lag selection, consider using lag(0) for short series,
lag(1) or lag(2) for medium series, and lag(3) for long series.

4. The ocsb_ndiff program follows the same logic as R's nsdiffs
function with test="ocsb".

Stored results for ocsb

ocsb stores the following in r():

Scalars

r(tstat) t-statistic

r(crit) 5% critical value

r(coef) coefficient estimate

r(lag) lag order used

r(m) seasonal period

r(N) number of observations in final regression

ocsb_ndiff stores the following in r():

Scalars

r(D) optimal number of seasonal differences

r(m) seasonal period

r(maxD) maximum D considered

References

Osborn, D. R., Chui, A. P. L., Smith, J., & Birchenhall, C. R. (1988).
Seasonality and the order of integration for consumption.
Oxford Bulletin of Economics and Statistics, 50(4), 361-377.

Hyndman, R. J., & Khandakar, Y. (2008).
Automatic time series forecasting: The forecast package for R.
Journal of Statistical Software, 27(3), 1-22.

Forecast package for R. https://pkg.robjhyndman.com/forecast/

Authors

Ariel Linden

President, Linden Consulting Group, LLC

alinden@lindenconsulting.org

Citation of ocsb

ocsb is not an official Stata command. It is a free contribution
to the research community, like a paper. Please cite it as such:

Linden A. (2026). OCSB: Stata module to compute the Osborn-Chui-Smith-Birchenhall (OCSB) test for seasonal unit roots

Also see

Help: dfuller, pperron, kpss (if installed), hegy (if installed)