Open R180 opened 2 years ago
I don't see how this is a bug. myFunction
is under your control and you've hardwired a constant into the index vector (k[1:25]
). Nowhere is a guarantee made about length(x)
; indeed, for the jack-knife calculations, the length is n-1
, but best not to assume that either. Also, the documentation for bcajack
states that func(x) should return a real value
.
Thanks. I had not realized that the element numbers (e.g., row numbers) corresponded to the element numbers in the original data set rather than the bootstrapped (or jackknifed) data set. S I have included the following note my self in the following R code (which does indeed work):
myData <- cbind(c(4,8,2,5,4,6,7,7,1,8,5,2,3,5,8,2),c(1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2))
myFunction <- function(k) {
# Note. The function should not refer to element numbers (row numbers, column numbers,
# or vector element numbers) within the function's input data, since bcajack controls
# which element numbers are utilized at any given point in time.
myStat <- mean(k[k[,2] == 1, 1]) - mean(k[k[,2] == 2 ,1])
return(myStat)
}
set.seed(5)
myBcaResult <- bcajack(x = myData, B = 5000, func = myFunction,
verbose = FALSE, alpha = c(0.001,0.01,0.05))
myBcaResult
@bnaras