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

Re: st: PCA scores on different data?

From   Maarten buis <>
Subject   Re: st: PCA scores on different data?
Date   Sat, 16 Feb 2008 08:26:22 +0000 (GMT)

--- K Jensen <> 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 )

Hope this helps,

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

Sent from Yahoo! Mail - a smarter inbox

*   For searches and help try:

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