[R] prcomp

David Winsemius dwinsemius at comcast.net
Thu Aug 18 00:02:33 CEST 2011


On Aug 17, 2011, at 5:47 PM, David Winsemius wrote:

>
> On Aug 17, 2011, at 5:19 PM, Rosario Garcia Gil wrote:
>
>> Hello
>>
>> I am trying to run a PCA on the attached file, but I get this error  
>> message:
>>
>> pc<-prcomp(data[,-(1:2)],scale=T)$x
>> Error in svd(x, nu = 0) : infinite or missing values in 'x'
>
> What part of "missing values in 'x'" is unclear in that error message?

After looking further at the prcomp defaults I see that na.action  
defaults to na.omit so it may not be the missing data, but rather  
collinearity. Do these plotting and descriptive steps to see that your  
data is extremely clustered:

matplot(dat[,-(1:2)] )
  pairs(dat[-(1:2)])
summary(dat[-(1:2)])

So the effort to invert the data matrix is probably failing due to the  
application of inappropriate data reduction to variables which, though  
nominally numeric, are really categorical, and fairly strangely  
distributed ones at that. Also not this advice in ?prcomp:

"Note that scale = TRUE cannot be used if there are zero or constant  
(for center = TRUE) variables." I cpunt four variables that violate  
that restriction. But removing scale=T still does not fix the problem.

-- 

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list