Skip to content

BUG: Apparently, bcajack loses the final element of a vector when that final element has been included in a subset. #7

Description

@R180

@bnaras

# BUG: Apparently, bcajack loses the final element of a vector when that final element has been included in a subset.
#
# ----------------------------------------------------------------------------
# This does NOT work (produces NAs for the BCA confidence interval limits).
# ----------------------------------------------------------------------------
myData <- c(4,8,2,5,4,6,7,7,1,8,2,2,5,3,6,7,3,6,2,2,1,9,3,2,335)
myFunction <- function(k) {
    myStat <- mean(k[1:25]) # This causes bcajack to produce NAs for the BCA confidence limits
                            # because the subset includes the final value in the input-vector.
    return(myStat)
}
set.seed(5)
myBcaResult <- bcajack(x = myData, B = 5000, func = myFunction,
verbose = FALSE, alpha = c(0.001,0.01,0.05))
myBcaResult
#
# ----------------------------------------------------------------------------
# This DOES work since the function doesn't use the final value of the input vector.
# ----------------------------------------------------------------------------
myData <- c(4,8,2,5,4,6,7,7,1,8,2,2,5,3,6,7,3,6,2,2,1,9,3,2,335)
myFunction <- function(k) {
    myStat <- mean(k[1:24]) # This produces proper output 
                            # since the subsetting excludes the input-vector's final value.
return(myStat)
}
set.seed(5)
myBcaResult <- bcajack(x = myData, B = 5000, func = myFunction,
verbose = FALSE, alpha = c(0.001,0.01,0.05))
myBcaResult
 
# ----------------------------------------------------------------------------
# This DOES work, since there's no subsetting.
# ----------------------------------------------------------------------------
myData <- c(4,8,2,5,4,6,7,7,1,8,2,2,5,3,6,7,3,6,2,2,1,9,3,2,335)
myFunction <- function(k) {
    myStat <- mean(k) # This produces proper output 
                                   # since there's no subsetting.
return(myStat)
}
set.seed(5)
myBcaResult <- bcajack(x = myData, B = 5000, func = myFunction,
verbose = FALSE, alpha = c(0.001,0.01,0.05))
myBcaResult

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions