Skip to content
Back to formatted view

Raw Message

Message-ID: <49B6D9B6.8030202@gmail.com>
Date: 2009-03-10T21:20:54Z
From: Alain Paquette
Subject: Using napredict in prcomp

Hello all,

I wish to compute site scores using PCA (prcomp) on a matrix with 
missing values, for example:

    Drain    Slope    OrgL
a    4    1    NA
b    2.5    39    6
c    6    8    45
d    3    9    12
e    3    16    4
...

Where a,b... are sites.
The command
 > pca<-prcomp(~ Drain + Slope + OrgL, data = t, center = TRUE, scale = 
TRUE, na.action=na.exclude)
works great, and from
 > pca$x
I can get site scores, e.g.

                       PC1          PC2          PC3
a          NA           NA           NA
b -2.10475208 -2.315128625 -0.885197753
c  5.01177388 -1.778786252 -0.193285051
d  0.28638602  0.298315086  0.386113799
e -0.58861254  0.089498632 -0.434951813
...

Easy enough...
But how do I use the "napredict" argument? Is it intended as an argument 
to be used in the prcomp line (as suggested in ?prcomp), or is it to be 
used by itself, to replace NAs in the above site score matrix (which is 
what I really want to do).

Thank you,
Alain

-- 
Alain Paquette, Ph.D.
alain.paquette at gmail.com

Centre d'?tude de la for?t (CEF)
Universit? du Qu?bec ? Montr?al
www.cef-cfr.ca

Projet TRIADE
www.projettriade.ca
alain.paquette at projettriade.ca