[R] boot package

Duncan Murdoch murdoch at stats.uwo.ca
Sun Dec 5 13:02:32 CET 2004


On Sat, 4 Dec 2004 18:37:43 -0700, "Nathan Leon Pace, MD, MStat"
<n.l.pace at utah.edu> wrote:

>Hi,
>
>I using the boot package 1.2-20 on R 2.0.1.
>
>My statistics function estimates 6 parameters.
>
>In a small percentage of resampled data sets my statistics function 
>doesn't produce an estimate for one parameter and the boot function 
>stops with an error.
>
>I can write an ifelse(exists('parameter.estimate'), parameter.estimate, 
>NA) statement within the statistic function to substitute an NA for the 
>missing estimate value.
>
>However, the boot.ci function to generate CIs from the boot object 
>won't accept NAs.
>
>My problem is writing code to impute a numeric value for the missing 
>estimate. ifelse won't generate a numeric value if the test is mode 
>logical.

The test in ifelse is always logical or is coerced to be logical, so
this isn't right.  For example,

x <- c(1,2,NA)
ifelse(is.na(x), 0, x)

I suspect the problem has to do with the fact that a bare "NA" is mode
logical, but without sample code, I can't see exactly where you're
going wrong.  Perhaps you got the arguments to ifelse in the wrong
order?

x <- NA
ifelse(is.na(x), 0, x)  # Gives numeric result
ifelse(is.na(x), x, 0)  # Gives logical result

Duncan Murdoch




More information about the R-help mailing list