*! version 3.2 2026

Title

kapetanios -- Kapetanios (2005) unit-root test with up to 5 structural breaks

Version 3.2.0

Syntax

kapetanios varname [if] [in]
[, options]

Options
breaks(#) maximum number of structural breaks (1–5); default is 3

kmax(#) maximum number of lags; default is floor(4*(T/100)^0.25)

epsilon(#) trimming parameter; default is 0.1

model(#) model specification: 1, 2, or 3; default is 3

lagsel(method) lag selection method: ttest (default), bg, aic, or bic

bglags(#) max lags in BG test; default depends on data frequency

Description

kapetanios implements the unit-root test proposed by Kapetanios (2005),
which tests the null hypothesis of a unit root against the alternative of a
trend-stationary process with up to 5 structural breaks in the intercept
and/or trend. The test extends the single-break tests of Zivot and Andrews (1992)
and the two-break test of Lumsdaine and Papell (1997) to an arbitrary number of
breaks, while remaining computationally efficient through the sequential break
estimation strategy of Bai and Perron (1998).

Unlike tests that fix the number of breaks in advance, kapetanios searches
for the actual number of breaks (up to 5, or the user-specified maximum),
making it less dependent on a priori assumptions about the break structure.

The data must be declared as time series using tsset before calling
kapetanios.

Note on gaps in time series: For time series with gaps (e.g. daily
financial data with weekends and holidays excluded), kapetanios treats
observations as consecutive integers, ignoring calendar gaps. Users should
be aware of this when interpreting break dates and should ensure the data
is appropriately structured before running the test.

This program is largely a translation of the Gretl package
Kapetanios v2.1 (2022-04-11) by Andrea E. Sánchez Urbina,
Ricardo Ramírez and Daniel Ventosa-Santaulària to Stata,
with the following extensions:

Differences between the Gretl Kapetanios package and kapetanios:

1. kapetanios offers Breusch-Godfrey (BG) based lag selection via
a general-to-specific (GTS) procedure (lagsel(bg)), which directly
targets the elimination of serial correlation in test residuals.

2. kapetanios offers AIC-based lag selection (lagsel(aic)).

3. kapetanios offers BIC-based lag selection (lagsel(bic)).

4. For lagsel(aic) and lagsel(bic), a post-selection BG test is
automatically performed using the estimated break dates, and a warning is
issued if residual autocorrelation remains.

Test procedure

Test regression

The test is based on the following augmented Dickey-Fuller type regression:

y_t = mu_0 + mu_1*t + alpha*y_ + sum_^ c_i*Delta y_
+ sum_^ phi_i*DU_ + sum_^ psi_i*DT_ + e_t

where the break dummies are defined as:

DU_ = 1(t > T_) (intercept break)

DT_ = 1(t > T_) * (t - T_) (trend break)

with T_ denoting the date of the i-th structural break, and 1(.) being
the indicator function. The null hypothesis is H0: alpha = 1 (unit root).
The test statistic s_min is the minimum t-ratio on alpha over all estimated
break configurations. Rejection of H0 implies trend stationarity with structural
breaks.

Break search algorithm

The procedure follows the sequential strategy of Bai and Perron (1998), which
requires only O(T) least squares operations for any given number of breaks:

Step 1. Search for a single break over all feasible observation windows
(determined by the trimming parameter epsilon). For each candidate break date,
estimate the test regression and store the t-statistic and SSR.

Step 2. Select the break date that minimizes the SSR. This is the
first estimated break.

Step 3. Conditioning on the first break, search for a second break
over the remaining feasible windows (excluding a neighbourhood of the first
break of width epsilon*T). Choose the second break by minimizing the SSR.

Step 4. Repeat until m break dates have been estimated, or until
no more feasible windows remain.

Step 5. The test statistic is the minimum t-statistic across all
estimated break configurations: s_min = min.

Critical values

Critical values are reproduced from Table I of Kapetanios (2005), obtained
by simulation with T = 250 observations and 1000 replications under the unit
root null. Three model specifications are covered:

Model A (model(1)): intercept breaks only

Model B (model(2)): trend breaks only

Model C (model(3)): both intercept and trend breaks (default)

Critical values are provided for up to m = 5 breaks at the 10%, 5%, and 1%
significance levels.

Options

breaks(#) specifies the maximum number of structural breaks to search
for. Must be an integer between 1 and 5. Default is 3. The actual number
of breaks found may be less than m if the procedure exhausts all feasible
observation windows. As shown in Kapetanios (2005), the power of the test
generally decreases as m increases, so m should be guided by
economic considerations.

kmax(#) specifies the maximum number of lagged first differences to
include in the test regression. Lag length is selected automatically according
to the method in lagsel(). If not specified, the default is
floor(4*(T/100)^0.25) for the ttest method, and the Schwert (1989) rule
floor(12*(T/100)^0.5) for bg, aic, and bic.

epsilon(#) specifies the trimming parameter. At each break search step,
the first and last epsilon*T observations are excluded as candidate break dates.
Must be strictly between 0 and 0.5. Default is 0.1. If the chosen value
does not allow for any breaks given T, it is automatically adjusted to the
maximum feasible value.

model(#) specifies the deterministic components included in the break
dummies:

1 — Only intercept break dummies (DU). Model A in Kapetanios (2005).
Suitable when breaks affect only the level of the series.

2 — Only trend break dummies (DT). Model B in Kapetanios (2005).
Suitable when breaks affect only the slope of the trend.

3 — Both intercept and trend break dummies (DU and DT). Model C
in Kapetanios (2005). The most general specification and the default.

Lag selection

kapetanios offers four methods for selecting the lag length k. As discussed
in Kapetanios (2005), k may be treated as known or selected by a data-dependent
procedure. Ng and Perron (1995) show that both information criteria and sequential
testing procedures yield the same asymptotic distribution for the test statistic,
provided k is allowed to grow at appropriate rates.

lagsel(ttest) (default) — Sequential t-test of Ng and Perron (1995),
as used in Zivot and Andrews (1992) and Kapetanios (2005). Starting from
kmax downward, the t-statistic on the last included lag is evaluated.
The procedure stops at the first K for which |t| > 1.6 and selects that K.
If no lag satisfies this criterion, K = 0 is selected.

lagsel(bg) — General-to-specific (GTS) selection based on the
Breusch-Godfrey LM test for serial correlation (estat bgodfrey).
Starting from kmax downward, the BG test is applied to residuals at
lags 1 through bglags. If autocorrelation is detected at any lag
(p < 0.05), the procedure retains the previous lag length. This method
directly targets the elimination of serial correlation, which is the primary
purpose of including lagged differences in the test regression.

lagsel(aic) — Selects the lag that minimizes the Akaike Information
Criterion: AIC = log(SSR/n) + 2k/n. After selection, residuals are automatically
tested for autocorrelation using the BG test. A warning is issued if
autocorrelation remains.

lagsel(bic) — Selects the lag that minimizes the Bayesian Information
Criterion: BIC = log(SSR/n) + k*log(n)/n. BIC penalises additional parameters
more heavily than AIC and typically selects more parsimonious models. A BG
autocorrelation check is performed after selection, as with lagsel(aic).

bglags(#) — Maximum lag order in the BG test (for lagsel(bg)) and
in the post-selection autocorrelation check (for lagsel(aic/bic)). Default
is automatically set to span two years: 8 for quarterly, 24 for monthly,
52 for weekly, 100 for daily, and 2 for annual data.

Remarks

Lag selection and serial correlation

The purpose of including lagged first differences in the test regression is to
eliminate serial correlation in the residuals, which would otherwise distort the
asymptotic distribution of the test statistic. Kapetanios (2005) follows the
sequential t-test of Ng and Perron (1995), which selects the lag length based
on the significance of the last included lag (|t| > 1.6) rather than directly
testing for residual autocorrelation. Ng and Perron (1995) show that this
procedure is asymptotically valid — that is, it eliminates serial correlation
at the rate required for the test statistic to converge to its limiting
distribution.

In finite samples, however, the sequential t-test does not guarantee the absence
of residual autocorrelation at the selected lag length. The lagsel(bg) option
addresses this by directly testing residuals for serial correlation using the
Breusch-Godfrey LM test in a general-to-specific (GTS) framework. This approach
is more conservative in the sense that it explicitly verifies the elimination of
autocorrelation rather than relying on an indirect criterion. When lagsel(bg)
is specified, the BG test is applied at each lag order from 1 to bglags
separately. Testing at lag p corresponds to checking for AR(p)-type
autocorrelation in the residuals. By testing at all lags from 1 to bglags,
the procedure guards against autocorrelation of any order up to bglags —
not just at the highest lag. This is more comprehensive than testing only at a
single lag order. For the lagsel(aic) and lagsel(bic) options, a
post-selection Breusch-Godfrey test is automatically performed and a warning is
issued if autocorrelation remains, alerting the user to consider lagsel(bg)
instead.

Choosing the model specification

Model C (both DU and DT, the default) is the most general and is recommended
when there is uncertainty about the nature of the breaks. If economic theory
suggests that breaks affect only the level of the series (e.g. a one-time
policy intervention), Model A may be more appropriate. Model B is suitable
when breaks are expected to alter the growth rate. Note that using a more
general model than necessary reduces the power of the test.

Choosing the number of breaks

The maximum number of breaks (up to 5) should reflect prior economic knowledge
about the series. Kapetanios (2005) shows that power generally decreases with
m because successive breaks bring the alternative hypothesis closer to
the null. Setting m unnecessarily large weakens the ability to reject
the unit root null. For most macroeconomic series, m = 3 to 5 is
a reasonable range.

Choosing the lag selection method

The default ttest method replicates the original implementation of
Kapetanios (2005). The bg method is recommended when serial correlation
in residuals is a concern, as it directly targets its elimination using a
formal statistical test. The aic and bic methods are theoretically
justified by Ng and Perron (1995) and Kapetanios (2005), but since they
minimise an information criterion rather than testing for autocorrelation,
they may select a lag length that leaves residual serial correlation. The
automatic BG post-check alerts users to this possibility.

Trimming parameter

The default trimming epsilon = 0.1 excludes break dates in the first and last
10% of the sample. A smaller epsilon allows breaks closer to the sample
boundaries but may worsen finite sample properties. The procedure automatically
adjusts epsilon if the chosen value does not allow for any breaks.

Sample size considerations

Table IV of Kapetanios (2005) shows that when k is determined by sequential
testing, there is considerable size distortion in small samples (T = 50),
but the test performs well for T >= 100. Users should exercise caution when
applying the test to small samples.

Computational note

kapetanios uses Stata's Mata matrix language for all inner computations,
providing substantially faster execution than a pure ado-file implementation.
All matrix operations — including OLS estimation, lag selection, and break
search — are performed in Mata.

Stored results

kapetanios stores the following in r():

Scalars

r(stat) Kapetanios test statistic (minimum t-statistic)

r(cv10) critical value at 10% significance level

r(cv05) critical value at 5% significance level

r(cv01) critical value at 1% significance level

r(breaks) number of breaks found

r(best_lag) lag length selected

Matrices

r(lambda) column vector of estimated break observation numbers

Examples

Open dataset, declare time series and run with default settings:

. webuse lutkepohl2

. tsset qtr

. kapetanios consump

Maximum 2 breaks, intercept breaks only (Model A):

. kapetanios consump, breaks(2) model(1)

Trend breaks only (Model B), with kmax = 4:

. kapetanios consump, breaks(2) kmax(4) model(2)

Replication of Kapetanios (2005) specification — kmax = 1:

. kapetanios consump, breaks(3) kmax(1) epsilon(0.1) model(3)

Both intercept and trend breaks (Model C), default specification:

. kapetanios consump, model(3)

Breusch-Godfrey based lag selection (recommended):

. kapetanios consump, lagsel(bg)

BG lag selection with manual horizon of 8 lags:

. kapetanios consump, lagsel(bg) bglags(8)

AIC-based lag selection:

. kapetanios consump, lagsel(aic)

BIC-based lag selection:

. kapetanios consump, lagsel(bic)

Replication of Gretl Kapetanios package v2.1 results:

. webuse lutkepohl2

. tsset qtr

. kapetanios consump, breaks(3) kmax(1) epsilon(0.1) model(3)

This produces identical results to Kapetanios(consump, 3, 1, 0.1, 3)
in Gretl's Kapetanios package (version 2.1, 2022-04-11).

Access stored results after the test:

. kapetanios consump, breaks(2)

. display r(stat)

. matrix list r(lambda)

Examples using Gretl sample datasets

The following examples use datasets from the Gretl sample file collection,
hosted at https://www.eruygurakademi.com/datasets/kapetanios/.
Results have been verified to be numerically identical to the Gretl implementation.

Annual data (T=43): Interest rates and inflation, Canada.
Note: the Gretl implementation returns a non-invertible matrix error and
terminates for this dataset; kapetanios completes the estimation successfully,
demonstrating improved numerical stability.

. use https://www.eruygurakademi.com/datasets/kapetanios/jgm-data.dta, clear

. kapetanios r_s, kmax(5) breaks(4)

Quarterly data (T=258): MIDAS data, quarterly GDP and monthly covariates.

. use https://www.eruygurakademi.com/datasets/kapetanios/gdp_midas.dta, clear

. kapetanios qgdp, kmax(3) breaks(5)

. kapetanios d.qgdp, kmax(3) breaks(5)

. kapetanios d2.qgdp, kmax(3) breaks(5)

Monthly data (T=144): Box and Jenkins Series G (airline passengers).

. use https://www.eruygurakademi.com/datasets/kapetanios/bjg.dta, clear

. kapetanios lg, kmax(3) breaks(5)

. kapetanios d.lg, kmax(3) breaks(5)

Weekly data (T=2117): Weekly NYSE closing price, 1966–2006.
Note: due to the large sample size, estimation may take approximately 2 minutes.

. use https://www.eruygurakademi.com/datasets/kapetanios/nysewk.dta, clear

. kapetanios close, kmax(1) breaks(5)

. kapetanios d.close, kmax(1) breaks(5)

Daily data (T=1974): Bollerslev and Ghysels exchange rate data.
Note: due to the large sample size, estimation may take approximately 2 minutes.

. use https://www.eruygurakademi.com/datasets/kapetanios/b-g.dta, clear

. kapetanios Y, kmax(1)

. kapetanios Y, kmax(3) breaks(5)

. kapetanios d.Y, kmax(3) breaks(5)

References

Bai, J. and Perron, P. (1998). Estimating and testing linear models with
multiple structural changes. Econometrica, 66(1), 47–78.

Sánchez Urbina, A. E., Ramírez, R. and Ventosa-Santaulària, D. (2022).
Kapetanios (Gretl package, version 2.1).
Available from the Gretl package repository: http://gretl.sourceforge.net

Kapetanios, G. (2005). Unit-root testing against the alternative hypothesis
of up to m structural breaks. Journal of Time Series Analysis, 26(1), 123–133.

Lumsdaine, R. L. and Papell, D. H. (1997). Multiple trend breaks and the
unit root hypothesis. Review of Economics and Statistics, 79(2), 212–217.

Ng, S. and Perron, P. (1995). Unit root tests in ARMA models with
data-dependent methods for the selection of the truncation lag.
Journal of the American Statistical Association, 90(429), 268–281.

Schwert, G. W. (1989). Tests for unit roots: A Monte Carlo investigation.
Journal of Business & Economic Statistics, 7(2), 147–159.

Zivot, E. and Andrews, D. W. K. (1992). Further evidence on the Great Crash,
the oil-price shock, and the unit-root hypothesis.
Journal of Business & Economic Statistics, 10(3), 251–270.

Author

H. Ozan Eruygur

AHBV University, Ankara, Turkiye.

Department of Economics

https://www.ozaneruygur.com

eruygur@gmail.com

Eruygur Academy and Consulting (Eruygur Akademi ve Danismanlik), Ankara, Turkiye.

https://www.eruygurakademi.com

eruygurakademi@gmail.com

kapetanios v3.2.0 — April 2026

Please cite as:

Eruygur, H. O. 2026. kapetanios: Kapetanios (2005) unit-root test with up to 5 structural breaks.
Stata package version 3.2.0. Available from: https://www.eruygurakademi.com