**[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
__rf__**orm** reduced-form mean; the default
**direct** direct mean
**indirect** indirect mean
__li__**mited** limited-information mean
**full** full-information mean
__na__**ive** naive-form prediction
**xb** linear prediction
__r__**esiduals** residuals
__ucr__**esiduals** uncorrelated residuals
-------------------------------------------------------------------------
These statistics are only available in a subset of the estimation sample.

__Menu for predict__

**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*] **,** __pr__**edict(***statistic *...**)** [__pr__**edict(***statistic *...**)**
...] [*options*]

*statistic* Description
-------------------------------------------------------------------------
__rf__**orm** reduced-form mean; the default
**direct** direct mean
**indirect** indirect mean
**xb** linear prediction
__li__**mited** not allowed with **margins**
**full** not allowed with **margins**
__na__**ive** not allowed with **margins**
__r__**esiduals** not allowed with **margins**
__ucr__**esiduals** 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**.

__Menu for 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