[Rd] Using option na.rm=True in function SD does not work for matrix with complete columns of NAs (PR#11364)

From: <m.tschiedel_at_innovest.at>
Date: Fri, 02 May 2008 13:00:17 +0200 (CEST)


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_MONETA= RY=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



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 03 May 2008 - 17:37:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 03 May 2008 - 18:31:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive