Skip to content

nomanarshed/regproject

Repository files navigation

regproject

Post-estimation projection and boundary analysis for Stata

regproject is a post-estimation command that projects the effect of a chosen independent variable (IV) on the dependent variable (DV), while holding all other regressors at their median values. It automatically detects whether the active dataset is cross-sectional, time-series, or panel, and produces a mode-appropriate set of publication-quality graphs.


Installation

From SSC (once published)

ssc install regproject

From GitHub (development version)

net install regproject, from("https://raw.githubusercontent.com/nomanarshed/regproject/main/") replace

Or manually: download all .ado and .sthlp files and place them in your personal ado directory (adopath).


Syntax

regproject varname [, ivmin(#) ivmax(#)
                      ivmins(numlist) ivmaxs(numlist)
                      ymin(#) ymax(#)
                      saving(stub) combine nodisplay]
Option Description
varname Focal independent variable to project
ivmin(#) / ivmax(#) Lower / upper bound for focal IV only
ivmins(numlist) / ivmaxs(numlist) Bounds for all IVs in regression order (positional)
ymin(#) / ymax(#) DV limits for shading and crossing detection
saving(stub) Save graphs as stub_1.gph, stub_2.gph, ...
combine Combine all mode graphs into a single 2×2 figure
nodisplay Suppress screen display (useful in batch scripts)

Note: ivmin/ivmax and ivmins/ivmaxs are mutually exclusive. Use the scalar form for the focal variable only; use the list form to set bounds for every regressor simultaneously.


Data mode detection

regproject reads xtset and tsset status automatically:

Condition Mode detected Graphs produced
No xtset / tsset active Cross-sectional 4 graphs
tsset or xtset with time variable only Time series 3 graphs
xtset with panel and time variable Panel data 4 graphs

Graphs by mode

Cross-sectional (4 graphs)

Graph Type What it shows
1 Bar chart Predicted ŷ per entity using own covariate values, sorted by focal IV; four horizontal reference lines; DV shading
2 Horizontal bar Sensitivity ranking — all IVs ranked by |coef × (upper − lower)|; focal IV highlighted
3 Diverging bar Gap-to-boundary — headroom to DV upper limit or depth below DV lower limit per entity
4 Grouped bar Actual ŷ vs counterfactual ŷ (focal IV replaced with its median)

Panel data (4 graphs)

Graph Type What it shows
1 Dot chart Predicted ŷ per entity at latest observed period, sorted by focal IV; four reference lines; DV shading
2 Spaghetti Entity ŷ trajectories over time; median trajectory in red
3 Scatter Δ focal IV (first to last period) vs Δ ŷ per entity; theoretical regression slope as dashed reference
4 Heat map Entities × time periods, cell colour = predicted ŷ (requires heatplot from SSC; fallback bubble scatter otherwise)

Time series (3 graphs, displayed in a 2×2 grid)

Graph Type What it shows
1 Line + ribbon Static sweep of focal IV from lower to upper bound; 95% CI ribbon; red diamond at latest observed value
2 Line 25-period forward projection; focal IV trended linearly, others held at median; DV crossing annotated
3 Line 25-period full-system projection; all covariates trended simultaneously; inhibitor dynamics reflected

Specification summary table

Every call prints a table to the results window before any graph is drawn, documenting:

  • Detected data mode and model command
  • DV bounds and their source
  • Every regressor with its coefficient, lower bound, upper bound, and source label (data range / ivmin/ivmax / ivmins/ivmaxs)

This provides a reproducible audit trail of all assumptions embedded in the graphs.


Examples

Cross-sectional

sysuse auto, clear
regress price mpg weight length
regproject weight, ivmins(10 1500 140) ivmaxs(41 5000 233) ymin(3000) ymax(16000) combine

Time series

sysuse uslifeexp, clear
tsset year
regress le_wmale le_wfemale le_bmale
regproject le_wfemale, ivmin(55) ivmax(95) ymin(55) ymax(85) combine

Panel data

* Generate a 10-country 5-period panel
clear
set obs 50
generate cid  = ceil(_n / 5)
generate year = 2010 + mod(_n-1, 5) * 2
generate str15 cname = ""
replace cname = "Malaysia"    if cid==1
replace cname = "Thailand"    if cid==2
replace cname = "Indonesia"   if cid==3
replace cname = "Philippines" if cid==4
replace cname = "Vietnam"     if cid==5
replace cname = "Cambodia"    if cid==6
replace cname = "Bangladesh"  if cid==7
replace cname = "Pakistan"    if cid==8
replace cname = "SriLanka"    if cid==9
replace cname = "India"       if cid==10
generate gdp    = 3 + 4*runiform() + 0.2*(year-2010)/2
generate trade  = 40 + 80*runiform()
generate govexp = 15 + 10*runiform()
generate poverty = 35 - 1.8*gdp - 0.05*trade - 0.3*govexp + rnormal(0,1.5)
xtset cid year
xtreg poverty gdp trade govexp, fe
regproject gdp, ivmins(-2 25 10) ivmaxs(10 150 35) ymin(0) ymax(40) combine

A complete self-contained example do-file covering all three modes is included in the package as regproject_example.do.


Supported estimation commands

regress, xtreg, qreg, iqreg, xtregar, newey, arima, ardl, ivregress

Any command that stores results in e(b), e(V), and e(depvar) and supports predict, xb should work in practice.


Optional dependency

heatplot (Jann, SSC) is used for Panel Graph 4. If not installed, regproject falls back to a bubble scatter automatically.

ssc install heatplot

Citation

If you use regproject in published work, please cite:

Arshed, N. (2026). regproject: Post-estimation projection and boundary analysis for Stata. Statistical Software Components, Boston College Department of Economics.


Author

Dr Noman Arshed
Senior Lecturer, Department of Business Analytics
Sunway Business School, Sunway University
📧 nouman.arshed@gmail.com
🐙 github.com/nomanarshed/regproject

Bug reports and feature requests are welcome via GitHub Issues.


Version history

Version Date Notes
1.0.0 April 2026 Initial release

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors