Skip to content
Prev 65239 / 398506 Next

Reconstructing Datasets

On Wed, 2005-03-02 at 08:30 +0200, Jari Oksanen wrote:
Naturally, I forgot the transposition:

xfull <- pc$x %*% t(pc$rotation)

and the check:

range(x - xfull) 

which should be something in magnitude 1e-12 or better (6e-15 in the
test I run).
and the same here:

x3 <- pc$x[,1:3] %*% t(pc$rotation[,1:3])

The moral: cut-and-paste.
And here you need to close the parentheses: 

x3 <- sweep(x3, 2, attr(x, "scaled:scale", "*"))
x3 <- sweep(x3, 2, attr(x, "scaled:center", "+"))

The moral #1: cut-and-paste.
and #2: drink coffee in the morning.
cheers, jari oksanen