From Robert.McGehee at geodecapital.com  Fri May 16 16:56:54 2008
From: Robert.McGehee at geodecapital.com (McGehee, Robert)
Date: Fri, 16 May 2008 10:56:54 -0400
Subject: [Rd] var/sd and NAs in R2.7.0
Message-ID: <EEBC169715EB8C438D3C9283AF0F201C023E472B@MSGBOSCLM2WIN.DMN1.FMR.COM>

Hello all,
I just upgraded to R 2.7.0 and found that the behavior of 'var' and 'sd'
have changed in the presence NAs (this wasn't explicit in the NEWS file,
though I see it probably has to do with the change for cor/cov). Anyway,
I just want to make sure that it was intentional to produce an error
when there was all NAs and na.rm=TRUE, rather than returning an NA (like
R 2.6.2), or NaN (like the function 'mean' does). That is, isn't the
purpose of 'na.rm=TRUE' to, in part, suppress these error messages.

Specifically,
> var(c(NA, NA, NA), na.rm=TRUE) # R2.6.2
[1] NA  
> var(c(NA, NA, NA), na.rm=TRUE) # R2.7.0
Error during wrapup: no complete observations in cov/cor

I think I can get the old behavior by setting use='p', but the 'sd'
function does not have a 'use' argument and I'd like not to get an error
here. Anyway, I'm a fan of the old behavior (not producing an error),
but if there was a reason to change this when na.rm=TRUE, I would
request that the 'sd' function be updated to be able to revert to the
old behavior as well.

FYI: I 'apply' these functions to large matrices of stock return time
series with missing values, and don't want the whole calculation to fail
just because I'm missing stock returns for one company.

Thanks,
Robert

Robert McGehee, CFA
Geode Capital Management, LLC
One Post Office Square, 28th Floor | Boston, MA | 02109
Tel: 617/392-8396    Fax:617/476-6389
mailto:robert.mcgehee at geodecapital.com



This e-mail, and any attachments hereto, are intended fo...{{dropped:11}}



[Rd] var/sd and NAs in R2.7.0
McGehee, Robert