[R] PCA error: svd(x, nu=0) infinite or missing values

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Jan 5 07:25:26 CET 2008


Please read the help page:

      ## S3 method for class 'formula':
      prcomp(formula, data = NULL, subset, na.action, ...)

      ## Default S3 method:
      prcomp(x, retx = TRUE, center = TRUE, scale. = FALSE, tol = NULL, ...)

So there is no na.action argument for the form you used, and your 
'na.omit' matches 'retx'.  Try

prcomp(~ ., data=ot, na.action=na.omit, scale=TRUE)

or

prcomp(na.omit(ot), scale=TRUE)


On Fri, 4 Jan 2008, Silvia Lomascolo wrote:

>
> Hi,
> I am trying to do a PCA on my data but I keep getting the error message
>
> svd(x, nu=0) infinite or missing values
>
>> From the messages posted on the subject, I understand that the NAs in my
> data might be the problem, but I thought na.omit would take care of that.
> Less than 5% of my cells are missing data. However, the NAs are not
> regularly distributed across my matrix: certain cases and variables have
> most of the NAs in the data set. Might that be the problem?  Any hints as to
> how to resolve this without having to get rid of those cases and variables?
> Code is pasted below.
>
> Any help is greatly appreciated!
>
> Silvia.
>
> CODE:
>
> ot = read.table('C:\\Documents and Settings\\...\\matrix.txt', header=T)
> ot.pca = prcomp(ot, scale.=T, na.omit)#this is as far as I got. I have also
> tried princomp but I get a very similar error message
>
> I use Windows, and R version 2.6.0.
>

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list