**[R] qreg postestimation** -- Postestimation tools for qreg, iqreg, bsqreg, and
sqreg

__Postestimation commands__

The following postestimation commands are available after **qreg**, **iqreg**,
**bsqreg**, and **sqreg**:

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
* **hausman** Hausman's specification test
**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
-------------------------------------------------------------------------
* **hausman** is not appropriate after **bsqreg**, **iqreg**, or **sqreg**.
+ **forecast** is not appropriate with **mi** estimation results.

__Syntax for predict__

For qreg, iqreg, and bsqreg

**predict** [*type*] *newvar* [*if*] [*in*] [**,** [**xb**|**stdp**|__r__**esiduals**]]

For sqreg

**predict** [*type*] *newvar* [*if*] [*in*] [**,** __eq__**uation(***eqno*[**,***eqno*]**)** *statistic*]

*statistic* Description
-------------------------------------------------------------------------
Main
**xb** linear prediction; the default
**stdp** standard error of the linear prediction
**stddp** standard error of the difference in linear predictions
__r__**esiduals** residuals
-------------------------------------------------------------------------
These statistics are available both in and out of sample; type **predict**
*...* **if e(sample)** *...* if wanted only for the estimation sample.

__Menu for predict__

**Statistics > Postestimation**

__Description for predict__

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

__Options for predict__

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

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

**stdp** calculates the standard error of the linear prediction.

**stddp** is allowed only after you have fit a model using **sqreg**. The
standard error of the difference in linear predictions between
equations 1 and 2 is calculated.

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

**equation(***eqno*[**,***eqno*]**)** specifies the equation to which you are making the
calculation.

**equation()** is filled in with one *eqno* for the **xb**, **stdp**, and **residuals**
options. **equation(#1)** would mean that the calculation is to be made
for the first equation, **equation(#2)** would mean the second, and so
on. You could also refer to the equations by their names.
**equation(income)** would refer to the equation named income and
**equation(hours)** to the equation named hours.

If you do not specify **equation()**, results are the same as if you had
specified **equation(#1)**.

To use **stddp**, you must specify two equations. You might specify
**equation(#1, #2)** or **equation(q80, q20)** to indicate the 80th and 20th
quantiles.

__Syntax for margins__

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

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

*statistic* Description
-------------------------------------------------------------------------
**xb** linear prediction; the default
**stdp** not allowed with **margins**
**stddp** 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.

__Examples__

Setup
**. sysuse auto**
**. qreg price weight length foreign**

Obtain predicted values
**. predict hat**

Obtain residuals
**. predict r, resid**