**[R] eivreg postestimation** -- Postestimation tools for eivreg

__Postestimation commands__

The following postestimation commands are available after **eivreg**:

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
**forecast** dynamic forecasts and simulations
**lincom** point estimates, standard errors, testing, and
inference for linear combinations of coefficients
**linktest** link test for model specification
**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
**xb** linear prediction; the default
__r__**esiduals** residuals
**stdp** standard error of the prediction
**stdf** standard error of the forecast
__p__**r(***a***,***b***)** Pr(*a* < y < *b*)
**e(***a***,***b***)** *E*(y | *a* < y < *b*)
__ys__**tar(***a***,***b***)** *E*(y*), y* = max{*a*,min(y,*b*)}
-------------------------------------------------------------------------
These statistics are available both in and out of sample; type **predict**
*...* **if e(sample)** *...* if wanted only for the estimation sample.
where *a* and *b* may be numbers or variables; *a* missing (*a* __>__ **.**) means minus
infinity, and *b* missing (*b* __>__ **.**) means plus infinity; see missing.

__Menu for predict__

**Statistics > Postestimation**

__Description for predict__

**predict** creates a new variable containing predictions such as linear
predictions, residuals, standard errors, probabilities, and expected
values.

__Options for predict__

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

**xb**, the default, calculates the linear prediction.

**residuals** calculates the residuals, that is, y - xb.

**stdp** calculates the standard error of the prediction, which can be
thought of as the standard error of the predicted expected value or
mean for the observation's covariate pattern. The standard error of
the prediction is also referred to as the standard error of the
fitted value.

**stdf** calculates the standard error of the forecast, which is the standard
error of the point prediction for 1 observation and is commonly
referred to as the standard error of the future or forecast value. By
construction, the standard errors produced by **stdf** are always larger
than those produced by **stdp**; see *Methods and formulas* in **[R] regress**.

**pr(***a***,***b***)** calculates Pr(*a* < xb + u < *b*), the probability that y|x would be
observed in the interval (*a*,*b*).

*a* and *b* may be specified as numbers or variable names; *lb* and *ub* are
variable names;
**pr(20,30)** calculates Pr(20 < xb + u < 30);
**pr(***lb***,***ub***)** calculates Pr(*lb* < xb + u < *ub*); and
**pr(20,***ub***)** calculates Pr(20 < xb + u < *ub*).

*a* missing (*a* __>__ .) means minus infinity; **pr(.,30)** calculates
Pr(-infinity < xb + u < 30);
**pr(***lb***,30)** calculates Pr(-infinity < xb + u < 30) in observations for
which *lb* __>__ .
and calculates Pr(*lb* < xb + u < 30) elsewhere.

*b* missing (*b* __>__ .) means plus infinity; **pr(20,.)** calculates
Pr(+infinity > xb + u > 20);
**pr(20,***ub***)** calculates Pr(+infinity > xb + u > 20) in observations for
which *ub* __>__ .
and calculates Pr(20 < xb + u < *ub*) elsewhere.

**e(***a***,***b***)** calculates *E*(xb + u | *a* < xb + u < *b*), the expected value of y|x
conditional on y|x being in the interval (*a*,*b*), meaning that y|x is
truncated. *a* and *b* are specified as they are for **pr()**.

**ystar(***a***,***b***)** calculates *E*(y*), where y* = *a* if xb + u __<__ *a*, y* = *b* if
xb + u __>__ *b*, and y* = xb + u otherwise, meaning that y* is censored.
*a* and *b* are specified as they are for **pr()**.

__Syntax for margins__

**margins** [*marginlist*] [**,** *options*]

**margins** [*marginlist*] **,** __pr__**edict(***statistic *...**)** [__pr__**edict(***statistic *...**)**
...] [*options*]

*statistic* Description
-------------------------------------------------------------------------
**xb** linear prediction; the default
__p__**r(***a***,***b***)** Pr(*a* < y < *b*)
**e(***a***,***b***)** *E*(y | *a* < y < *b*)
__ys__**tar(***a***,***b***)** *E*(y*), y* = max{*a*,min(y,*b*)}
**stdp** not allowed with **margins**
**stdf** not allowed with **margins**
__r__**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 linear predictions,
probabilities, and expected values.

__Examples__

Setup
**. sysuse auto**

Fit regression in which **weight** and **mpg** are measured with reliabilities
.85 and .9
**. eivreg price weight foreign mpg, r(weight .85 mpg .9)**

Calculate fitted values for estimation sample only
**. predict prhat if e(sample)**

Calculate standard errors of fitted values
**. predict stderr if e(sample), stdp**