Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Neil Shephard <[email protected]> |

To |
[email protected] |

Subject |
Re: st: Predict in version 11 |

Date |
Wed, 8 Dec 2010 11:06:18 +0000 |

On Wed, Dec 8, 2010 at 9:58 AM, Marnix Zoutenbier <[email protected]> wrote: > Dear all, > > I see a difference in the way predict works between Stata10 and 11. > > Consider the following example > x1 testset y > 1 1 12 > 2 1 13 > 3 1 14 > 4 2 . > > And the commands > anova y x1 if testset==1 > predict yhat > > The following is the result in version 11 > x1 testset y yhat > 1 1 12 12 > 2 1 13 13 > 3 1 14 14 > 4 2 . 12 > > While in version 10 the following dataset results > x1 testset y yhat > 1 1 12 12 > 2 1 13 13 > 3 1 14 14 > 4 2 . . > > I prefer the version 10 way-of-working, because it gives me the opportunity > to identify observations that are in the testset (testset==2) and not in > the trainingset (testset==1). > > Is it possible to obtain the same result in version 11 as in version 10, > other than switching with the version command before and after predict? Yes, see the -man predict- page (http://www.stata.com/help.cgi?predict), items 6 and 7 in the Description section near the top... predict can be used to make in-sample or out-of-sample predictions: 6. predict calculates the requested statistic for all possible observations, whether they were used in fitting the model or not. predict does this for the standard options 1 through 3 and generally does this for estimator-specific options 4. 7. predict newvar if e(sample), ... restricts the prediction to the estimation subsample. So in your above example under Stata 11 you should use... predict yhat if(e(sample)) Neil -- "Our civilization would be pitifully immature without the intellectual revolution led by Darwin" - Motoo Kimura, The Neutral Theory of Molecular Evolution Email - [email protected] Website - http://kimura-no-ip.org/ Photos - http://www.flickr.com/photos/slackline/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Predict in version 11***From:*"Marnix Zoutenbier" <[email protected]>

**References**:**st: Predict in version 11***From:*"Marnix Zoutenbier" <[email protected]>

- Prev by Date:
**Re: st: Testing equality of 2 coefficients after FE regression: How does Stata compute the Pooled SE and test statistic?** - Next by Date:
**RE: st: Uninstalling older versions of stata? / Wish I'd known earlier** - Previous by thread:
**st: Predict in version 11** - Next by thread:
**Re: st: Predict in version 11** - Index(es):