## Stata 15 help for spivregress_postestimation

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

Postestimation commands

The following postestimation command is of special interest after
spivregress:

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 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
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
limited          limited-information mean
full             full-information mean
naive            naive-form prediction
xb               linear prediction
residuals        residuals
ucresiduals      uncorrelated residuals
-------------------------------------------------------------------------
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, the
limited-information mean, the full-information mean, the naive-form
prediction, the linear prediction, the residuals, or the uncorrelated
residuals.

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.

limited calculates the limited-information mean.  It is the predicted
mean of the dependent variable conditional on the independent
variables, any spatial lags of the independent variables, and any
spatial lags of the dependent variable.  limited is not available
when the heteroskedastic option is used with spivregress.

full calculates the full-information mean.  It is the predicted mean of
the dependent variable conditional on the independent variables, any
spatial lags of the independent variables, and the other units'
values of the dependent variable.  full is not available when the
heteroskedastic option is used with spivregress.

naive calculates the naive-form prediction.  It is the predicted linear
combination of the independent variables, any spatial lags of the
independent variables, and any spatial lags of the dependent
variable.  It is not a consistent estimator of an expectation. See
Methods and formulas.

xb calculates the predicted linear combination of the independent
variables.

residuals calculates the residuals, including any autoregressive error
term.

ucresiduals calculates the uncorrelated residuals, which are estimates of
the uncorrelated error term.

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
limited            not allowed with margins
full               not allowed with margins
naive              not allowed with margins
residuals          not allowed with margins
ucresiduals        not allowed with margins
-------------------------------------------------------------------------

Statistics not allowed with margins are functions of stochastic
quantities other than e(b).

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 vce(vcetype)]

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.

+-----+
----+ VCE +--------------------------------------------------------------

vce(vcetype) specifies how the standard errors of the impacts are
calculated.

vce(delta), the default, is the delta method and treats the
independent variables as fixed.

vce(unconditional) specifies that standard errors account for
sampling variance in the independent variables.  This option is
not available when if or in is specified with estat impact.

Examples

Setup
. copy http://www.stata-press.com/data/r15/dui_southern.dta .
. copy http://www.stata-press.com/data/r15/dui_southern_shp.dta .
. use dui_southern
. spset

Create a contiguity weighting matrix with the default spectral
normalization
. spmatrix create contiguity W

Fit a generalized spatial two-stage least-squares regression
. spivregress dui nondui vehicles i.dry (police = elect), dvarlag(W)
errorlag(W)

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

Same as above estimation but add a spatial lag of the covariate dry
. spivregress dui nondui vehicles i.dry (police = elect), dvarlag(W)
errorlag(W) ivarlag(W: i.dry)

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

Stored results

estat impact stores the following in r():

Scalars
r(N)                    number of observations

Macros
r(vce)                  vcetype specified in vce()
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

```