**[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
__rf__**orm** 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.

__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, 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*] **,** __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
-------------------------------------------------------------------------

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**]

*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