help xtgets_plot version 1.0.0

Title

xtgets_plot -- Postestimation visualizations for xtgets

Syntax

xtgets_plot [, options]

type(string) Plot type: breaks, heatmap, grid (default), counter, residuals

saving(filename) Save graph to disk

scheme(schemename) Stata graph scheme

title(string) Custom title for the graph

plust(#) Extra periods for counterfactual projection; default 0

combine Combine subgraphs into a single graph

Description

xtgets_plot produces postestimation graphs after running xtgets. It
replicates the plotting functions of the R getspanel package. The command
must be called immediately after xtgets (it reads from e()).

Five plot types are available, each serving a different diagnostic purpose.

Plot Types

type(breaks) — Break Detection Timeline

Scatter plot showing detected break dates by panel unit. Each retained indicator
is plotted as a point on a unit (y-axis) vs time (x-axis) grid. Different marker
shapes distinguish indicator types: circle = FESIS, diamond = IIS, triangle = CSIS,
square = TIS.

Use for: Quick overview of which units had breaks and when.

R equivalent: plot(is1)

. xtgets_plot, type(breaks)

type(heatmap) — Effect Heatmap

Heatmap showing the magnitude and sign of break effects over time for each unit.
Blue shading = positive effects (increase in dependent variable); red shading =
negative effects (decrease). Darker colours = larger magnitude. For FESIS,
shading extends from the break date to the end of the sample.

Use for: Visualizing the direction and strength of detected breaks across
the full panel.

R equivalent: plot(is1) (heatmap view)

. xtgets_plot, type(heatmap)

type(grid) — Fitted vs Actual Grid

Small-multiple grid with one panel per unit. Each panel shows:

Black line (+): Actual values of the dependent variable.

Blue line: Fitted values from the final model (with break indicators).

Red vertical lines: Dates of detected breaks.

Use for: Assessing model fit and checking whether breaks align with visible
changes in the data.

R equivalent: plot_grid(is1)

. xtgets_plot, type(grid) saving(mygrid)

type(counter) — Counterfactual Analysis

Shows actual vs counterfactual trajectories for units with detected breaks.
Only units that have at least one break are shown.

Black line (+): Actual values.

Red dashed line: Counterfactual (predicted without break indicators).

Blue line: Fitted values (with break indicators).

Red shaded area: Difference = estimated break effect.

Use for: Estimating "what would have happened" in the absence of the
break/treatment. The gap between actual and counterfactual is the treatment
effect.

R equivalent: plot_counterfactual(is1)

. xtgets_plot, type(counter)

type(residuals) — Residual Analysis

Small-multiple grid showing residuals from the final model for each unit.
A horizontal red dashed line at zero is shown for reference.

Use for: Diagnosing model adequacy. Well-behaved residuals should be
centred around zero with no visible patterns, trends, or heteroscedasticity.

R equivalent: plot_residuals(is1)

. xtgets_plot, type(residuals)

Examples

Full estimation and plotting workflow:

. xtset country year

. xtgets emissions lgdp lpop, fesis effect(twoways) t_pval(0.01)

. xtgets_plot, type(breaks) saving(breaks_plot)

. xtgets_plot, type(heatmap) saving(heatmap_plot)

. xtgets_plot, type(grid) saving(grid_plot)

. xtgets_plot, type(counter) saving(counterfactual_plot)

. xtgets_plot, type(residuals) saving(residuals_plot)

Remarks

xtgets_plot requires that xtgets was the last estimation command
run. It reads all information from e() results. If you run another
estimation command between xtgets and xtgets_plot, the plot command
will fail.

For large panels (many units), the grid, counterfactual, and residual plots
may be crowded. Consider using saving() to save the graph and viewing
it at full size in the Graph Editor, or restrict the sample to a subset of units.

Author

Dr Merwan Roudane

merwanroudane920@gmail.com

Also see

xtgets