# Stevens and Anderson-Cook's probability of agreement evaluates whether
# two related populations have reliability curves that are similar enough
# to be treated as practically homogeneous. At each age, the agreement
# hypothesis is that the difference between the two fitted reliabilities
# lies inside the user-specified practical tolerance interval.
set.seed(1)
n <- 160
dat <- data.frame(
age = c(runif(n, 0, 60), runif(n, 0, 45)),
generation = rep(c("Gen1", "Gen2"), each = n)
)
eta <- ifelse(
dat$generation == "Gen1",
4.3 - 0.045 * dat$age,
4.0 - 0.040 * dat$age
)
dat$pass <- rbinom(nrow(dat), size = 1, prob = plogis(eta))
fit_pa <- prob_agree(
dat,
response = "pass",
predictor = "age",
group = "generation",
delta = 0.05,
link = "logit",
ci = TRUE
)
print(fit_pa)
summary(fit_pa)
estimate(fit_pa)
tidy(fit_pa)
confint(fit_pa)
plot(fit_pa)
# Four generations are compared as all pairwise two-generation contrasts.
set.seed(2)
n4 <- 120
dat4 <- data.frame(
age = rep(runif(n4, 0, 55), times = 4),
generation = rep(paste0("Gen", 1:4), each = n4)
)
shifts <- c(4.2, 4.0, 3.8, 3.6)
slopes <- c(-0.040, -0.042, -0.044, -0.046)
gen_id <- match(dat4$generation, paste0("Gen", 1:4))
eta4 <- shifts[gen_id] + slopes[gen_id] * dat4$age
dat4$pass <- rbinom(nrow(dat4), size = 1, prob = plogis(eta4))
fit4 <- prob_agree(
dat4,
response = "pass",
predictor = "age",
group = "generation",
limits = c(-0.03, 0.05),
link = "logit",
ci = FALSE
)
print(fit4)
plot(fit4)
Run the code above in your browser using DataLab