Thanks Martin. As ever--the perfect solution!
Karin
On 16/02/2008, Maarten buis <[email protected]> wrote:
> --- K Jensen <[email protected]> wrote:
> > I would like to calculate the scores derived from a PCA using one
> > Stata data set to the observations in a second data set. How could I
> > go about doing this?
>
> An often very useful feature of -predict- is that it doesn't care
> whether you changed any of the variables or even if you are in the same
> dataset, it just needs the variable names to be the same as in the
> model you estimated. See the example below:
>
> *----------------------- begin example --------------------
> // make two files
> tempfile a b
> sysuse auto, clear
> keep if foreign == 1
> save `a'
> sysuse auto, clear
> keep if foreign == 0
> save `b'
>
> // do pca
> use `a', clear
> pca weight length turn displacement gear_ratio, comp(1)
>
> // calculate scores in file b
> use `b', clear
> predict size, score
> *-------------------- end example -------------------------
> (For more on how to use examples I sent to the Statalist, see
> http://home.fsw.vu.nl/m.buis/stata/exampleFAQ.html )
>
> Hope this helps,
> Maarten
>
> -----------------------------------------
> Maarten L. Buis
> Department of Social Research Methodology
> Vrije Universiteit Amsterdam
> Boelelaan 1081
> 1081 HV Amsterdam
> The Netherlands
>
> visiting address:
> Buitenveldertselaan 3 (Metropolitan), room Z434
>
> +31 20 5986715
>
> http://home.fsw.vu.nl/m.buis/
> -----------------------------------------
>
>
> __________________________________________________________
> Sent from Yahoo! Mail - a smarter inbox http://uk.mail.yahoo.com
>
> *
> * For searches and help try:
> * http://www.stata.com/support/faqs/res/findit.html
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/