## Stata 15 help for spxtregress_postestimation

```
[SP] spxtregress postestimation -- Postestimation tools for spxtregress

Postestimation commands

The following postestimation command is of special interest after
spxtregress:

Command            Description
-------------------------------------------------------------------------
estat impact       direct, indirect, and total impacts
-------------------------------------------------------------------------

The following postestimation commands are also available:

Command            Description
-------------------------------------------------------------------------
contrast           contrasts and ANOVA-style joint tests of estimates
estat ic           Akaike's and Schwarz's Bayesian information criteria
(AIC and BIC)
estat summarize    summary statistics for the estimation sample
estat vce          variance-covariance matrix of the estimators (VCE)
estimates          cataloging estimation results
lincom             point estimates, standard errors, testing, and
inference for linear combinations of coefficients
lrtest             likelihood-ratio test
margins            marginal means, predictive margins, marginal effects,
and average marginal effects
marginsplot        graph the results from margins (profile plots,
interaction plots, etc.)
nlcom              point estimates, standard errors, testing, and
inference for nonlinear combinations of coefficients
predict            predictions, residuals, influence statistics, and
other diagnostic measures
predictnl          point estimates, standard errors, testing, and
inference for generalized predictions
pwcompare          pairwise comparisons of estimates
test               Wald tests of simple and composite linear hypotheses
testnl             Wald tests of nonlinear hypotheses
-------------------------------------------------------------------------

Syntax for predict

predict [type] newvar [if] [in] [, statistic]

statistic          Description
-------------------------------------------------------------------------
Main
rform            reduced-form mean; the default
direct           direct mean
indirect         indirect mean
xb               linear prediction
-------------------------------------------------------------------------
These statistics are only available in a subset of the estimation sample.

Statistics > Postestimation

Description for predict

predict creates a new variable containing predictions such as the
reduced-form mean, the direct mean, the indirect mean, or the linear
prediction.

Options for predict

+------+
----+ Main +-------------------------------------------------------------

rform, the default, calculates the reduced-form mean.  It is the
predicted mean of the dependent variable conditional on the
independent variables and any spatial lags of the independent
variables.  See Methods and formulas.

direct calculates the direct mean.  It is a unit's predicted contribution
to its own reduced-form mean.  The direct and indirect means sum to
the reduced-form mean.

indirect calculates the indirect mean.  It is the predicted sum of the
other units' contributions to a unit's reduced-form mean.

xb calculates the predicted linear combination of the independent
variables.

Syntax for margins

margins [marginlist] [, options]

margins [marginlist] , predict(statistic ...) [predict(statistic ...)
...] [options]

statistic          Description
-------------------------------------------------------------------------
rform              reduced-form mean; the default
direct             direct mean
indirect           indirect mean
xb                 linear prediction
-------------------------------------------------------------------------

For the full syntax, see [R] margins.

Statistics > Postestimation

Description for margins

margins estimates margins of response for reduced-form mean, direct mean,
indirect mean, and linear predictions.

Syntax for estat impact

estat impact [varlist] [if] [in] [, nolog]

varlist is a list of independent variables, including factor variables,
taken from the fitted model.  By default, all independent variables
from the fitted model are used.

Description for estat impact

estat impact estimates the mean of the direct, indirect, and total
impacts of independent variables on the reduced-form mean of the
dependent variable.

Options for estat impact

+------+
----+ Main +-------------------------------------------------------------

nolog suppresses the calculation progress log that shows the percentage
completed.  By default, the log is displayed.

Examples

Setup
. copy http://www.stata-press.com/data/r15/homicide_1960_1990.dta .
. copy http://www.stata-press.com/data/r15/homicide_1960_1990_shp.dta
.
. use homicide_1960_1990
. xtset _ID year
. spset

Create a contiguity weighting matrix with the default spectral
normalization
. spmatrix create contiguity W if year == 1990

Fit a spatial autoregressive random-effects model
. spxtregress hrate ln_population ln_pdensity gini i.year, re
dvarlag(W)

Obtain direct, indirect, and total effects of the covariates
. estat impact

Obtain the averages of the effects of gini
. estat impact gini

Create an inverse-distance weighting matrix with the default spectral
normalization
. spmatrix create idistance M if year == 1990

Refit the model above but specify the interaction of gini and year
. spxtregress hrate ln_population ln_pdensity c.gini##i.year, re
dvarlag(M) errorlag(M)

Test the significance of the gini and year interaction
. contrasts c.gini#year

Obtain the effect of gini by year based on year 1960
. estat impact gini if year == 1960

Stored results

estat impact stores the following in r():

Scalars
r(N)                    number of observations

Macros
r(xvars)                names of independent variables

Matrices
r(b_direct)             vector of estimated direct impacts
r(Jacobian_direct)      Jacobian matrix for direct impacts
r(V_direct)             estimated variance-covariance matrix of direct
impacts
r(b_indirect)           vector of estimated indirect impacts
r(Jacobian_indirect)    Jacobian matrix for indirect impacts
r(V_indirect)           estimated variance-covariance matrix of
indirect impacts
r(b_total)              vector of estimated total impacts
r(Jacobian_total)       Jacobian matrix for total impacts
r(V_total)              estimated variance-covariance matrix of total
impacts

```