# NOT RUN {
## AHR when there are no ties in phat:
resp <- c(1, 0, 0, 0, 1)
prob <- (1:5)*0.1
AHR(y = resp, phat = prob)
# expect answer: 1/2 * (1 + 0 + 0 + 0 + 2/5)
## (Expected) AHR when there are ties in phat:
resp <- c(1, 1, 0, 0, 0, 0, 0, 1, 0, 0)
prob <- c(1, 1, 1, 0.4, 0.4, 0.3, 0.2, 0.15, 0.1, 0)
AHR(y = resp, phat = prob)
# expect answer: 1/3 * (2/3 + 1/2 * (1/3 + 2/3) + 1/3 * 4/3 +
# 1/8 * (2/3 + 2/3 + 2/3 + 1))
# }
Run the code above in your browser using DataLab