Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: problems with e(sample)

From   Richard Williams <>
Subject   Re: st: problems with e(sample)
Date   Fri, 16 Jun 2006 23:21:45 -0500

At 05:33 PM 6/16/2006, Zurab Sajaia wrote:
I found the cause of problem, -restore- works after setting all the ereturns and it clears e(sample) leaving other parameters unchanged.

"esample(varname) specified with ereturn post or repost gives the name of the 0/1 variable indicating the observations involved in the estimation.
The variable is removed from the data but is available for use as

This is what they say in the help so it's still unclear to me why e(sample) disapeares after restoring original data...
I am not sure how e(sample) works but I have always suspected it is really a variable masquerading as a function. If not, it must contain all the rules that would be needed to create such a variable. In any event, it seems to behave pretty much the same way as a variable - restore the data to an earlier point and variables created since then (along with e(sample)) get lost too.

I can see why it would be difficult to keep e(sample) alive after doing a restore. Suppose I preserved the data, then did a collapse, then did a restore. What is e(sample) supposed to identify as 0 and 1? Or, suppose I preserved, gave various commands that deleted or added cases, ran my command, and then restored. How would e(sample) keep track of all the data commands that occurred before I ran my estimation command? Or, how about preserve, reshape, restore?

I suppose if you really wanted/needed to keep e(sample) alive, you could create and save a new dataset before you did you restore, and then merge your original data set with the one that contained e(sample). Alternatively, I suppose it wouldn't be too hard to figure out the commands that would generate e(sample) if you didn't already have it.

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: Richard.A.Williams.5@ND.Edu
WWW (personal):
WWW (department):
* For searches and help try:

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