set.seed(42)
N <- 6; I <- 10
alpha <- rnorm(N)
beta <- rnorm(I, sd = 0.7)
dist <- abs(matrix(rnorm(N * I, sd = 0.8), N, I)) # fake distances
# Basic waterfall plot for the first respondent
pip_waterfall(alpha, beta, gamma = 1.5, dist, focal_id = 2)
# Add grouping and uncertainty bands
groups <- rep(c("A", "B"), length.out = I)
d_low <- dist * 0.9; d_up <- dist * 1.1
a_l <- alpha - 0.25; a_u <- alpha + 0.25
pip_waterfall(alpha, beta, gamma = 1, dist,
alpha_lower = a_l, alpha_upper = a_u,
distance_low = d_low, distance_up = d_up,
item_group = groups, focal_id = 3)
Run the code above in your browser using DataLab