xtthreshold

Estimation of Thresholds in Stata

View the Project on GitHub JanDitzen/xtthreshold

xtthreshold – Threshold Estimation for Interactive Fixed Effects Models

version release

Title

xtthreshold – Threshold estimation for interactive fixed effects models.


Syntax

xtthreshold depvar indepvars1 | [indepvars2] [if] [in], threshold(thresvar) [csa(varlist1) grid(integer)]

Variable Notes:


Contents


Description

We consider a panel dataset over cross-sectional units i and time t, with three sets of independent variables:

The model is defined as:

y(i,t) = b₁ x(i,t) + g₁ I(z(i,t) < v) w(i,t) + g₂ I(z(i,t) > v) w(i,t) + u(i,t)

The error term has an interactive fixed effect structure:

u(i,t) = g(i) f(t) + ε(i,t)

Where:

The estimator uses cross-sectional averages to span the factor space (see Ditzen & Karavias, 2025).

Implementation

xtthreshold follows Ditzen et al. (2025) to:

  1. Estimate the threshold v using a grid over z(i,t)
  2. Estimate coefficients b₁, g₁, and g₂
  3. Choose v minimizing the sum of squared residuals (SSR)

Likelihood Ratio Test

LR(v₀) = NT × [SSR(v₀) - SSR(v)] / SSR(v)

Options


Postestimation

You can use estat to explore and visualize results:

estat split         // Splits variables in indepvars1 at threshold
estat graph lr      // Graphs LR test across thresholds

Examples

Download data from the GitHub repository.

Estimate Threshold

xtthreshold gdppcgr govspend khanvar | open popgr grosscap, threshold(khanvar) grid(400) csa(govspend khanvar open popgr grosscap)

Split Thresholded Variables

estat split

Estimate Final Model (using xtdcce2)

xtdcce2 gdppcgr govspend_0 khanvar_0 govspend_1 khanvar_1 open popgr grosscap, cr(govspend khanvar open popgr grosscap)

Plot Likelihood Ratio Test

estat graph lr

References


About, Authors and Version History

Jan Ditzen
Free University of Bozen-Bolzano
📧 jan.ditzen@unibz.it
🌐 Webpage

Yiannis Karavias
Brunel University
📧 yiannis.karavias@brunel.ac.uk
🌐 Webpage

Joakim Westerlund
Lund University
📧 joakim.westerlund@nek.lu.se
🌐 Webpage


Installation

Run the following command in Stata to install:

net from https://github.com/JanDitzen/xtthreshold

Notes


Changelog

Version 0.1 – 24.07.2025