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: apply predict to a different dataset


From   David Kantor <kantor.d@att.net>
To   Statalist <statalist@hsphsun2.harvard.edu>
Subject   st: apply predict to a different dataset
Date   Thu, 16 Aug 2012 17:17:48 -0400

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/


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