*! version 1.0.0 08jul2026

Title

totimpact -- Total impact effects in time series regressions
(Pesaran & Smith, 2014)

Syntax

Standalone form

totimpact
depvar
indepvars
[if] [in]
[, options]

Postestimation form (uses the regress results in memory)

totimpact
[if] [in]
[, options]

Main
focus(varlist) report only these regressors; default is all of
them

level(#) confidence level for the total effect; default
level(95)

Reporting
gamma also display the co-movement matrix
gamma_ji = cov(x_j,x_i)/var(x_i)

noheader suppress the results table (still stores r())

Graphs
graph draw the full dashboard (compare + decompose + gamma)

plots(types) draw only the named plot(s); see
plot types below

name(name) name of the resulting graph in memory; default
name(totimpact)

saving(filename) save the resulting graph to
filename.gph

types in plots() is one or more of:

compare direct coefficient vs total impact effect, with a
confidence spike on the total effect

decompose each total effect split into its direct and indirect
parts (stacked bars)

gamma heatmap of the co-movement coefficients
gamma_ji

all all three of the above, combined into one dashboard (this is
what bare graph does)

depvar and indepvars must be continuous numeric variables. The
command may be used with time series data; specify lagged or
differenced regressors as generated variables.

Description

totimpact estimates the total impact effect of each regressor in a
linear time series regression, following Pesaran and Smith (2014). In an
experiment the inputs are made orthogonal, so the effect of one input is
unambiguous. In observational time series the regressors are realisations of
correlated stochastic processes that cannot be held fixed, and the
ordinary multiple-regression coefficient beta_i — the ceteris paribus
(other things equal) effect — is often not the quantity of interest.

The total impact effect lambda_i instead lets the other regressors adjust
as their historical correlation with the focus regressor dictates
(mutatis mutandis, "other things changing as they must"). Because those
induced movements can outweigh the direct channel, lambda_i can differ in
magnitude from beta_i and even carry the opposite sign.
totimpact reports, for every regressor:

Direct the multiple-regression coefficient beta_i

Indirect the induced part, lambda_i - beta_i

Total the total impact effect lambda_i

Std.Err. its standard error, built from the full-model error
variance

t, P>|t| the corrected test of lambda_i = 0

and flags any regressor whose total effect reverses the sign of its
coefficient. See Methods and formulas for the
exact estimator.

totimpact runs standalone, or as a postestimation command after
regress: typed with no varlist it reads the dependent variable, the
regressors and the estimation sample from the fit in memory. See
totimpact postestimation.

Options

Main

focus(varlist) restricts the report to a subset of the regressors. The
full model is still fitted with every regressor — the corrected standard
errors require it (see Methods) — but only the listed variables appear in
the table, the returned r(table), and any graph. The default is to report
every regressor. A variable listed in focus() that is not one of the
regressors is an error.

level(#) sets the confidence level, as a percentage, for the confidence
interval of the total impact effect that is stored in r(table) and drawn
by the compare plot. The default is level(95) or as set by
set level.

Reporting

gamma additionally displays the matrix of co-movement coefficients
gamma_ji = cov(x_j,x_i)/var(x_i). Column i of this matrix shows how
every regressor moves, on average, with a one-unit shift in x_i; the
diagonal is 1. The total impact effect is the beta-weighted sum of a
column, lambda_i = sum_j beta_j gamma_ji, so the gamma
matrix shows exactly which regressors drive each indirect effect.

noheader suppresses the printed table. The results are still computed and
stored in r(); use this when calling totimpact programmatically.

Graphs

graph draws the full dashboard: the compare, decompose and
gamma plots combined into a single figure. It is a synonym for
plots(all).

plots(types) draws only the requested plot(s). types is one or more
of compare, decompose, gamma, or all (see the list
under Syntax). When more than one plot is
requested they are combined into one figure; a single plot is drawn on its own.
All plots use built-in twoway graphics — no third-party graph command
is required.

name(name) sets the name under which the resulting graph is stored in
memory (see name_option). The default is name(totimpact), replaced
if it already exists.

saving(filename) saves the resulting graph to disk as
filename.gph. Combine with graph export to write a PNG, PDF
or other image format.

Methods and formulas

Write the linear model as

y_t = beta_0 + sum_j beta_j x_jt + u_t, t = 1,...,T,

with the classical assumptions (u_t independent and identically
distributed, mean zero, uncorrelated with the regressors). The total impact
effect of x_it is defined as the expected change in y_t that
accompanies an incremental change in x_it once the other regressors are
allowed to move with it:

lambda_i = sum_j beta_j gamma_ji, with gamma_ii = 1,

where gamma_ji = cov(x_j,x_i)/var(x_i) is the (population) regression slope
of x_j on x_i. This reduces to beta_i only when x_it is
orthogonal to every other regressor.

Point estimate. Pesaran and Smith show (their equation 19) that the sample
total impact effect equals the ordinary least squares slope of the simple
regression of y_t on x_it alone:

lambda-hat_i = sum_t (y_t - ybar)(x_it - xbar_i) / sum_t (x_it - xbar_i)^2.

Equivalently, with S the sample covariance matrix of the regressors and
b the vector of full-model coefficients, lambda-hat = diag(S)^-1
S b. The indirect effect is lambda-hat_i - b_i.

Standard error (the key point). The point estimate comes from the simple
regression, but its standard error must not. The correct variance (their
equation 21) uses omega, the residual standard deviation of the full
multiple regression:

Var(lambda-hat_i) = omega^2 / sum_t (x_it - xbar_i)^2,

with omega^2 estimated by the full-model residual sum of squares
divided by T - k - 1 (k = number of regressors). Inference uses Student's t with
T - k - 1 degrees of freedom.

Because the full model explains at least as much as the simple regression,
omega is never larger than the simple-regression residual standard
deviation omega_i. Hence the naive simple-regression t statistic
understates significance: the correct t is the naive one scaled up by
omega_i/omega >= 1. totimpact always reports the corrected
t; running regress y x_i on its own would give the same
point estimate but a too-small t.

The analysis treats S as constant over the sample. As Pesaran and Smith
note, this is an approximation when the covariance structure varies over time,
but it is adequate for checking the sign of an impact effect against prior
expectations — the paper's main purpose.

Remarks

The distinction matters most when regressors are strongly correlated. If a
control variable x_1 has a large positive effect and moves closely with the
focus variable x_2, then x_2 can carry a negative coefficient in the
multiple regression yet a positive total impact — the "wrong sign" puzzle
discussed by Leamer (1975), McAleer et al. (1986) and Kennedy (2005). A sign
reversal is flagged in red beneath the table.

The procedure of orthogonalising the control variables with respect to the
focus variable, and reading the total effect from the focus variable alone, has
been criticised in other fields (for example Freckleton 2002) because it is a
biased and inconsistent estimator of beta_i. That criticism is correct if
the parameter of interest is beta_i; it is irrelevant when the parameter of
interest is lambda_i, as argued here.

Stored results

totimpact stores the following in r():

Scalars

r(N) number of observations

r(k) number of regressors in the full model

r(df) residual degrees of freedom, T - k - 1

r(rmse) root mean squared error omega of the full model

Macros

r(cmd) totimpact

r(depvar) name of the dependent variable

r(focus) the regressors reported (and returned in r(table))

Matrices

r(table) reported regressors (rows) by
direct, indirect, total, se, t, p, ll,
ul (columns)

r(direct) 1 x k row vector of direct coefficients beta

r(lambda) 1 x k row vector of total impact effects
lambda

r(gamma) k x k co-movement matrix gamma_ji

Examples

Setup: two strongly correlated regressors, with a sign reversal.
The coefficient on x2 is negative, but its total impact is positive
because x1 — which raises y — moves with x2.

. clear

. set seed 12345

. set obs 200

. gen x1 = rnormal()

. gen x2 = 0.9*x1 + 0.4*rnormal()

. gen y = 1.0*x1 - 0.2*x2 + rnormal()

Basic use — full table with the sign-reversal flag:

. totimpact y x1 x2

Focus on one regressor at a 90% level:

. totimpact y x1 x2, focus(x2) level(90)

Co-movement matrix alongside the table:

. totimpact y x1 x2, gamma

Graphs — the full dashboard, then a single plot:

. totimpact y x1 x2, graph

. totimpact y x1 x2, plots(compare)

. totimpact y x1 x2, plots(decompose gamma) name(mydash)

Save a graph and export it to PNG:

. totimpact y x1 x2, graph saving(impact)

. graph export impact.png, replace width(1200)

Postestimation after regress:

. regress y x1 x2

. totimpact, plots(compare)

Programmatic use — grab the total effects, print nothing:

. totimpact y x1 x2, noheader

. matrix list r(lambda)

References

Freckleton, R. P. 2002. On the misuse of residuals in ecology: regression of
residuals vs. multiple regression. Journal of Animal Ecology 71(3):
542-545.

Kennedy, P. E. 2005. Oh no! I got the wrong sign! What should I do?
Journal of Economic Education 36(1): 77-92.

Leamer, E. E. 1975. A result on the sign of restricted least-squares estimates.
Journal of Econometrics 3(4): 387-390.

McAleer, M., G. Fisher, and P. Volker. 1982. Separate misspecified regressions
and the U.S. long-run demand for money function. Review of Economics and
Statistics 64(4): 572-583.

Pesaran, M. H., and R. P. Smith. 2014. Signs of impact effects in time series
regression models. Economics Letters 122(1): 150-153.
doi:10.1016/j.econlet.2013.11.015.

Author

Merwan Roudane

merwanroudane920@gmail.com

https://github.com/merwanroudane

Please report issues or suggestions by email.