# Generate fake data
set.seed(4)
x <- runif(20, 0, 1)
# Find quantiles
quant <- quantile(x, c(.2, .4, .5, .6, .8))
# Theoretical calibration
x_cal <- NA
x_cal[x <= quant[1]] <- 0
x_cal[x > quant[1] & x <= quant[2]] <- .2
x_cal[x > quant[2] & x <= quant[3]] <- .4
x_cal[x > quant[3] & x <= quant[4]] <- .6
x_cal[x > quant[4] & x <= quant[5]] <- .8
x_cal[x > quant[5]] <- 1
x_cal
# Indirect calibration (binomial)
a <- indirectCalibration(x, x_cal, binom = TRUE)
# Indirect calibration (beta regression)
b <- indirectCalibration(x, x_cal, binom = FALSE)
# Correlation
cor(a, b)
# Plot
plot(x, a); points(x, b, col = "red")
Run the code above in your browser using DataLab