Author: Kirill Kushnarev
Reference: McCloskey (Biometrika, 2024)
The hysi package implements the Hybrid Confidence Intervals (HySI) method in Stata for valid inference after LASSO-based model selection. The HySI method, proposed by McCloskey (2024), combines the PoSI framework with a selective intervals approach by Lee et al. (2016) to construct confidence intervals that remain valid regardless of the model selected.
This implementation supports:
- LASSO with a fixed, user-chosen lambda
- Confidence intervals from:
- Naive (frequentist) method
- PoSI
- Selective inference (Lee et al., 2016)
- HySI
An upcoming update will support data-driven lambda selection.
A guide to post-selection inference theory and applications to LASSO will also be published soon.
. net install hysi, replace from("https://raw.githubusercontent.com/kkushnarev/hysi/main/")First, install the GitHub installer (if not already installed):
. net install github, from("https://haghish.github.io/github/")Then install the hysi package:
. github install kkushnarev/hysiThe package provides five commands:
Prepares a dataset for post-selection inference:
- Standardizes variable names
- Destrings variables of interest
- Maps user-specified variables to generic names (
x1,x2, ...,xn) - Generates a mapping file to restore original variable names during export
- Checks dimensional consistency
- Suggest a range of suitable a LASSO penalty and an Adjustment parameter based on data dimensionality
begin_hysi using filename, vars(varlist) y(depvar)using(filename)– Path to the Stata dataset (.dta)vars(varlist)– List of predictorsy(depvar)– Outcome variable
Example:
begin_hysi using Monte_Carlo.dta, vars(Age Education Parents_Income) y(Income)This command creates two temporary files with the suffix _XS:
- One file contains the dataset with renamed and destringed variables.
- The other is a mapping file that links generic variable names (e.g.,
x1,x2, ...) to the original variable names.
Use the _XS dataset for all subsequent commands.
These temporary files will be automatically deleted after export.
Runs LASSO-based variable selection and computes confidence intervals using four methods.
hysi varlist, outcome(varname) lambda(real) delta(real) [level(real)]outcome(varname)– Dependent variablelambda(real)– LASSO penaltydelta(real)– Adjustment parameterlevel(real)– Confidence level (default: 90)
Example:
hysi x1 x2 x3 x4, outcome(Y) lambda(0.1) delta(0.05) level(90)Generates a table summarizing the confidence intervals and compares widths of Naive and HySI intervals. Also flags significance and out-of-interval results.
hsci_table x1 x2 x3 x4 [, level(real)]Example:
hsci_table x1 x2 x3 x4Plots confidence intervals for selected methods.
ci_graphs [, vars(varlist) method(string) save(string)]vars(varlist)– Variables to include in the plot (auto-detects if omitted)method(string)– Methods to include (e.g.,"naive posi hysi")save(string)– File path to save CI data
Example:
ci_graphs, method("naive hysi")Exports results from hsci_table or ci_graphs to various formats. Automatically remaps generic variable names (e.g., x1, x2) to original names.
export_results, type(string) format(string)type(string)–"table"or"graph"format(string)– File format:- For tables:
latex,csv,excel,dta - For graphs:
png
- For tables:
Example:
export_results, type(graph) format(png)If you use this package, please cite:
McCloskey, A. (2024). Hybrid Confidence Intervals after Model Selection. Biometrika.
arXiv:2011.12873
Best wishes to Adam McCloskey, and many thanks for his kind permission to implement his method in Stata.