The following seems to be an bug in prcomp():
> test <- ts( matrix( c(NA, 2:5, NA, 7:10), 5, 2))
> test
Time Series:
Start = 1
End = 5
Frequency = 1
Series 1 Series 2
1 NA NA
2 2 7
3 3 8
4 4 9
5 5 10
> prcomp(test, scale.=TRUE, na.action=na.omit)
Erro en svd(x, nu = 0) : infinite or missing values in 'x'
> prcomp(na.omit(test), scale.=TRUE, na.action=na.omit)
Standard deviations:
[1] 1.414214e+00 3.726778e-17
Rotation:
PC1 PC2
Series 1 0.7071068 -0.7071068
Series 2 0.7071068 0.7071068
>
note that
> is.matrix(test)
[1] TRUE
This is R2.3.1 pre-compiled binary from CRAN on windows XP.
> sessionInfo()
Version 2.3.1 (2006-06-01)
i386-pc-mingw32
attached base packages:
[1] "methods" "stats" "graphics" "grDevices" "utils"
"datasets" "base"
Kjetil
bug in prcomp (PR#8994)
2 messages · KjetilBrinchmannHalvorsen at gmail.com, Peter Dalgaard
KjetilBrinchmannHalvorsen at gmail.com writes:
The following seems to be an bug in prcomp():
...
> prcomp(test, scale.=TRUE, na.action=na.omit)
Erro en svd(x, nu = 0) : infinite or missing values in 'x'
> prcomp(na.omit(test), scale.=TRUE, na.action=na.omit)
Nope. We've been here before: The _formula_method_ for prcomp takes an na.action argument, the default method does not. If you read closely, you'll see that this is in accordance with documentation.
O__ ---- Peter Dalgaard ?ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907