Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: apply predict to a different dataset


From   "Sarah Edgington" <sedging@ucla.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: apply predict to a different dataset
Date   Fri, 17 Aug 2012 10:45:22 -0700

David,
Look at -help estimates-
You can either store estimates in memory for later use in the same session,
or save them so they can be loaded for use later.
-Sarah

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of David Kantor
Sent: Thursday, August 16, 2012 2:18 PM
To: Statalist
Subject: st: apply predict to a different dataset

Hi.
This may be a routing matter, but I am attempting this for the first time.
I use Stata 10.

I have two datasets with some of the same variables.
I want to -regress- on the first dataset, then apply the coefficients to run
-predict- on the second dataset.

I am thinking that the thing to do is...

use set1
regress v1 v2 v3 v4
_return hold somename

use set2
_return restore somename, hold
predict newvar

----

Is this the right approach?
I also wonder whether the -_return- operations are necessary. I note that
when I -use- a dataset, the coefficients from the earlier
-regress- are still around.
But I also wonder if the regress coefficients can be stored in a file that I
can reload at a later time -- and then I could proceed to do a -predict-.
Note that my actual task is to apply the -predict- to a multitude of
additional datasets.

Thanks if anyone can help with this.
--David

*
*   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/

*
*   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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index