m.tschiedel at innovest.at
2008-May-02 11:00 UTC
[Rd] Using option na.rm=True in function SD does not work for matrix with complete columns of NAs (PR#11364)
Dear R-developers, =20 according to the "what's new"-section in version R 2.7.0, there has been a change in the working of co[rv] and so also in sd and var. =20 I am afraid, that the use of function sd with option "na.rm=3DT" has not been changed appropriately. So the following problem exists with missing data: =20> sessionInfo()R version 2.7.0 (2008-04-22)=20 i386-pc-mingw32=20 =20 locale: LC_COLLATE=3DGerman_Austria.1252;LC_CTYPE=3DGerman_Austria.1252;LC_MONETARY=3DGerman_Austria.1252;LC_NUMERIC=3DC;LC_TIME=3DGerman_Austria.1252 =20 attached base packages: [1] stats graphics grDevices utils datasets methods base =20 =20 =20 a<-matrix(rnorm(100),10,10); a[1,]<-NA> sd(a,na.rm=3DT)Fehler in var(x, na.rm =3D na.rm) : keine vollst=E4ndigen Elementpaare this error is clear as "sd" is using "var" and in case of na.rm=3DT "var" uses "na.method=3Dcomplete.obs" which is obviously never the case in this example. =20 So I suggest to set the default.method for na.rm=3DT to "pairwise.complete.obs" to get the same result as in previous versions of R, that is the same as=20> sqrt(diag(var(a,use=3D"pair")))[1] NA 0.9117738 0.5953496 0.9272141 0.8864333 0.8045383 0.4240055 1.0304519 0.9221493 1.2087638 Best regards, =20 Martin --=20 Martin Tschiedel Senior Investment Manager A Siemens Company=09 INNOVEST Kapitalanlage AG Email: m.tschiedel at innovest.at