In R, using the 'geyser'
dataset from the MASS
library, we are building a nonparametric tolerance interval cont. 90% of geyser eruptions w/ 99% CI
Please, find below the equation I am using:
no_param_pi <- function(x, conf.level = 0.90) {
n <- length(x)
x <- sort(x)
j <- max(floor((n + 1) * (1 - conf.level) / 2), 1)
conf.level <- (n + 1 - 2 * j)/(n + 1)
interval <- c(x[j], x[n + 1 - j])
attr(interval, "conf.level") <- conf.level
interval
}
Here is the code I am playing with, and in which I am missing something... :
library(MASS)
library(tolerance)
head(geyser)
eruptions = subset(geyser, select = waiting:duration, increasing)
nptol.int(eruptions, alpha = 1 - 0.99, P = 0.9)
Looking for both