__Title__

**[U] 20 Estimation and postestimation commands**

__Description__

For a list of Stata's estimation commands, see estimation commands. For
a discussion of postestimation commands, see postest.

Properties shared by all estimation commands are listed.

__Remarks__

Stata commands that fit statistical models -- commands such as **logit**,
**regress**, **logistic**, and **sureg** -- work similarly.

Remarks are presented under the following headings:

1. Common syntax
2. Estimation on subsamples
3. Robust variance estimates
4. Prefix commands
5. Confidence intervals of parameters
6. Format of coefficient table
7. Tests of parameters
8. Point estimates and CIs of linear and nonlinear combinations
9. Predictions
10. Forecasts
11. Generalized predictions
12. Marginal means, predictive margins, marginal effects, and average
marginal effects
13. Plots of margins
14. Contrasts
15. Pairwise comparisons
16. Estimation statistics
17. Variance-covariance matrix of the estimators (VCE)
18. Coefficients and standard errors in expressions
19. Managing and combining estimates
20. Redisplaying estimates
21. Factor rotations
22. Specialized graphs
23. Postestimation Selector

__1. Common syntax__

Single-equation estimation commands usually have syntax

*command* *varlist* [*if*] [*in*] [*weight*] [**,** *options*]

and multiple-equation estimation commands usually have syntax

*command* **(***varlist***)** *...* **(***varlist***)** [*if*] [*in*] [*weight*] [**,** *options*]

In single-equation commands, the first variable in *varlist* is the
dependent variable and the remaining are the independent variables,
although there can be variations. For instance, **anova** allows you to
specify both variables and terms as independent variables.

__2. Estimation on subsamples__

You can use Stata's standard syntax (*if* and *in*) to restrict the sample;
you do not have to make a special dataset.

__3. Robust variance estimates__

Most estimation commands allow option **vce(robust)**, which provides the
Huber/White/sandwich estimator of variance. Those that do also provide
option **vce(cluster** *clustvar***)**, which relaxes the assumption of
independence. See **[U] 20.22 Obtaining robust variance estimates**.

__4. Prefix commands__

Prefix commands may be used to modify or extend what the estimation
command does. The syntax is

*prefix_command* *...* **:** *command* *...*

where

*prefix_command* Description
---------------------------------------------------------------------
**statsby:** collect results across subsets of the data
**rolling:** collect statistics on moving subsets

**bootstrap:** bootstrap estimation
**jackknife:** jackknife estimation

* **svy:** estimation with complex survey data
* **mi estimate:** run command on multiply imputed data and adjust
results for multiple imputation (MI)

* **bayes:** fit model as a Bayesian regression

* **fmm:** fit model using finite mixture modeling

* **nestreg:** run command with accumulated blocks of
regressors and report nested model comparison
tests
* **stepwise:** stepwise estimation

* **fp:** run command with fractional polynomials of one
regressor
* **mfp:** run command with multiple fractional polynomial
regressors
---------------------------------------------------------------------
* Available for most but not all estimation commands.
See help prefix for a full list of *prefix_commands*.

Before using the **bootstrap:** or **jackknife:** prefixes, however, check
whether the estimation command allows option **vce(bootstrap)** or
**vce(jackknife)**. If it does, using the option rather than the prefix is
better. The option is implemented in terms of the prefix command, but
the option automatically knows to pass all the appropriate suboptions for
the specific estimator you are using.

__5. Confidence intervals of parameters__

Estimation commands display confidence intervals of the coefficients.
Estimation-command option **level()** specifies the width of the interval.
The default is **level(95)**, meaning 95% confidence intervals.

You can reset the default with **set level**.

__6. Format of coefficient table__

You can change the formatting of test statistics, p-values, coefficients,
standard errors, and confidence limits in the coefficient table. See **[U]**
**20.9 Formatting the coefficient table**.

__7. Tests of parameters__

You can perform tests on the estimated parameters by using

o **test** -- Wald test of linear hypotheses

o **testnl** -- Wald test of nonlinear hypotheses

o **lrtest** -- likelihood-ratio tests

o **hausman** -- Hausman specification test

o **suest** -- generalization of the Hausman test

__8. Point estimates and CIs of linear and nonlinear combinations__

You can obtain point estimates and confidence intervals of linear
combinations of the estimated parameters by using **lincom**, and those of
nonlinear combinations by using **nlcom**.

__9. Predictions__

You can obtain predictions, residuals, influence statistics, and the
like, either for the data on which you just estimated or for some other
data, by using **predict**.

The help for **predict** is found in two places:

1. help **predict** -- general information

2. help *estimation_command* **postestimation** -- specific information
and special features following estimation by *estimation_command*.
For instance, help **regress postestimation** tells you about **predict**
following **regress**.

The easy way to access the postestimation help is to see **[R] regress** (or
whatever estimation command you are using) and then select
*postestimation*.

__10. Forecasts__

You can combine multiple estimation results and other equations to obtain
time-series forecasts; see **[TS] forecast**.

__11. Generalized predictions__

You can obtain nonlinear predictions, standard errors, Wald test
statistics, significance levels, and confidence intervals, either for the
data on which you just estimated or for some other data, by using
**predictnl**.

One especially useful feature of **predictnl** is that you can obtain
standard errors for most predictions available via **predict**, and you can
obtain standard errors of functions and combinations of these
predictions.

__12. Marginal means, predictive margins, marginal effects, and average__
__marginal effects__

Command **margins** estimates marginal means, adjusted predictions, marginal
effects, partial effects, or other expressions at fixed values for the
regressors; or it estimates averages of means, adjusted predictions,
marginal effects, partial effects, or other expressions at fixed values
of some covariates and averaging over the rest. Averages are based on
the data currently in memory.

__13. Plots of margins__

Command **marginsplot** graphs the results of the immediately preceding
**margins** command.

__14. Contrasts__

The postestimation command **contrast** estimates and tests contrasts.
Included are ANOVA-style tests of main effects, simple effects,
interaction effects, and nested effects. You may use the built-in
contrast operators, or define your own custom contrasts.

The command **margins, contrast** extends **contrast** to margins of linear and
nonlinear responses.

__15. Pairwise comparisons__

The postestimation command **pwcompare** performs pairwise comparisons across
the levels of factor variables. The resulting tests and confidence
intervals may be adjusted for multiple comparisons.

The command **margins, pwcompare** extends **pwcompare** to margins of linear and
nonlinear responses.

To perform pairwise comparisons of means, use **pwmean**.

__16. Estimation statistics__

Command **estat ic** displays scalar- and matrix-valued postestimation
statistics such as AIC and BIC.

__17. Variance-covariance matrix of the estimators (VCE)__

Command **estat vce** displays the VCE -- either as a covariance matrix or as
a correlation matrix.

Estimation commands store coefficients in the matrix **e(b)** and the VCE in
**e(V)**.

You can obtain the coefficients and VCE into Mata matrices by using
**st_matrix("e(b)")** and **st_matrix("e(V)")**; see **[M-5] st_matrix()**.

__18. Coefficients and standard errors in expressions__

You can refer to the coefficients and standard errors in expressions by
using **_b[***name***]** and **_se[***name***]**, such as

. **generate contribution = _b[mpg]*mpg**

See **[U] 13.5 Accessing coefficients and standard errors** and see _b.

__19. Managing and combining estimates__

You can store estimation results with command **estimates store**. These
estimation results may later be restored and replayed, the coefficients
of one or more may be combined in a table, etc.; see **[R] estimates**.

Programmers should also see command **[P] _estimates**, which is a low-level
tool that manages stored estimation results.

__20. Redisplaying estimates__

You can, at any time, review your most recent estimates by typing the
estimation command without arguments.

__21. Factor rotations__

You can rotate loadings after factorlike commands; see **[MV] rotate**.

__22. Specialized graphs__

There are specialized graph commands available after some estimation
commands.

For instance, command **lroc** will graph the ROC curve after **logistic**,
**logit**, **probit**, or **ivprobit**. Command **screeplot** will make scree plots
after **factor** or **pca**, as well as various other multivariate commands.
Command **stcurve** will plot the survivor, hazard, or cumulative hazard
function after **stcox**, **stintreg**, **streg**, **mestreg**, or **xtstreg** and will plot
the cumulative subhazard or cumulative incidence function after **stcrreg**.

What is available can always be found in the postestimation section of
the documentation following the estimator.

__23. Postestimation selector__

Launch the Postestimation Selector window to see a list of all
postestimation features that are available for the currently active
estimation results. You can launch the dialog box for an item in the
list. The list is automatically updated when estimation commands are run
or estimates are restored from memory or disk. See **[R] postest**.