[R] Bootstrapping with Kendall's tau
Therneau, Terry M., Ph.D.
therneau at mayo.edu
Fri Mar 7 15:50:53 CET 2014
With respect to question 2, I use the wild bootstrap for tau.
Wu, C.F.J. (1986). Jackknife, bootstrap and other
resampling methods in regression analysis (with discussions).
Annals of Statistics, 14, 1261-1350.
-- begin included message ----------
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