Stata 15 help for _estimates

[P] _estimates -- Manage estimation results


Move estimation results into holdname

_estimates hold holdname [, copy restore nullok varname(newvar)]

Restore estimation results

_estimates unhold holdname [, not]

List names holding estimation results

_estimates dir

Eliminate estimation results

_estimates clear

Eliminate specified estimation results

_estimates drop { holdnames | _all }

where holdname is the name under which estimation results will be held.


_estimates hold, _estimates unhold, _estimates dir, _estimates clear, and _estimates drop provide a low-level mechanism for setting aside and later restoring up to 300 estimation results.

_estimates hold moves, or copies if the copy option is specified, all information associated with the last estimation command into holdname. If holdname is a temporary name, it will automatically be deleted when you exit from the current program.

_estimates unhold restores the information from the estimation command previously moved into holdname and eliminates holdname.

_estimates dir lists the holdnames under which estimation results are currently held.

_estimates clear eliminates all set aside results. Also, if the restore option is specified when the estimates are held, those estimates will be automatically restored when the program concludes. It is not necessary to perform an _estimates unhold in that case.

_estimates drop eliminates the estimation results stored under the specified holdnames.

_estimates is a programmer's command designed to be used within programs. estimates is a user's command to manage multiple estimation results. estimates uses _estimates to hold and unhold results, and it adds features such as model-selection indices and looping over results. Postestimation commands, such as suest and lrtest, assume that estimation results are stored using estimates rather than _estimates.


copy requests that all information associated with the last estimation command be copied into holdname. By default, it is moved, meaning that the estimation results temporarily disappear. The default action is faster and uses less memory.

restore requests that the information in holdname be automatically restored when the program ends, regardless of whether that occurred because the program exited normally, the user pressed Break, or there was an error.

nullok specifies that it is valid to store null results. After restoring a null result, no estimation results are active.

varname(newvar) specifies the variable name under which esample() will be held. If varname() is not specified, holdname is used. If the variable already exists in the data, an error message is shown. This variable is visible to users. If it is dropped, _estimates unhold will not be able to restore the estimation sample e(sample) and sets e(sample) to 1.

not specifies that the previous _estimates hold, restore request for automatic restoration be canceled. The previously held estimation results are discarded from memory without restoration, now or later.


. regress y x1 x2 x3 (fit first model)

. _estimates hold model1 (and hold on to it)

. regress y x1 x2 x3 x4 (fit the second model)

. _estimates hold model2 (and hold on to it, too)

. use newdata (use another dataset)

. _estimates dir (see what models are currently held)

. _estimates unhold model1 (get the first model)

. predict yhat1 (predict using first regression)

. _estimates unhold model2 (get the second model)

. predict yhat2 (predict using second regression)

Stored results

_estimates hold removes the estimation results -- e() items.

_estimates unhold restores the previously held e() results.

_estimates clear permanently removes all held e() results.

_estimates dir returns the names of the held estimation results in the local r(names), separated by single spaces.

_estimates dir also returns r(varnames), which has the corresponding variable names for esample().

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index