# Example with simulated multi-level precision data
set.seed(42)
# Generate data for 6 concentration levels
conc_levels <- c(5, 10, 25, 50, 100, 200)
n_levels <- length(conc_levels)
prec_data <- data.frame()
for (i in seq_along(conc_levels)) {
level_data <- expand.grid(
level = conc_levels[i],
day = 1:5,
replicate = 1:5
)
# Simulate CV that decreases with concentration
true_cv <- sqrt(3^2 + (20/conc_levels[i])^2)
level_data$value <- conc_levels[i] * rnorm(
nrow(level_data),
mean = 1,
sd = true_cv/100
)
prec_data <- rbind(prec_data, level_data)
}
# Run precision study
prec <- precision_study(
data = prec_data,
value = "value",
sample = "level",
day = "day"
)
# Generate precision profile
profile <- precision_profile(prec)
print(profile)
summary(profile)
# Hyperbolic model with bootstrap CIs
profile_boot <- precision_profile(
prec,
model = "hyperbolic",
cv_targets = c(10, 20),
bootstrap = TRUE,
boot_n = 499
)
# Linear model
profile_linear <- precision_profile(prec, model = "linear")
Run the code above in your browser using DataLab