[R] Bootstrapping with Kendall's tau

David Parkhurst parkhurs at imap.iu.edu
Thu Mar 6 16:53:35 CET 2014


I want to bootstrap Kendall's tau correlation with data that have many 
NAs.  I tried this example:

x <- 1:15
y <- c(2,4,1,3,5, 7,6, 9,10,8, 14, 13, 11, 15, 12)
x[3] <- NA; x[11] <- NA; x[8] <- NA
y[2] <- NA; y[8] <- NA; y[12] <- NA
cor(x,y,use="complete.obs",method="kendall")
library(boot)
tmpdf <- data.frame(x,y)
corboot <- boot(tmpdf, cor(x,y,use="complete.obs",method="kendall"), R=999)

When I run that, I get this error:
Error in boot(tmpdf, cor(x, y, use = "complete.obs", method = 
"kendall"),  :
could not find function "statistic"

So my first question is, how do I tell boot that I want to use cor with 
those options to produce the statistic to be bootstrapped?

A second question is this.  My real data have lots of ties, in both the 
x and y variables, so I want to jitter the data before calculating tau.
Is there a way to jitter x and y at each of the bootstrap calls, as I 
would do for the call with the original data.  How would I specify that 
action?



More information about the R-help mailing list