Compare (group
differences and categorical tests)
Table 3.2 asks whether waiting times really differ between three or
more groups: crowding levels, visit times and what students do after
eating. The Kruskal–Wallis test is used because the times are not normal
(Section 1.2) and some groups are small (6 to 12 students), with
epsilon-squared as the effect size and the ANOVA p-value as a check;
p-values are adjusted for 7 tests with the Holm method. The waiting time
has the same distribution in all groups.
kw_specs <- tribble(
~key, ~var, ~grp, ~outcome, ~factor_label,
"total~fullness", "total_min", "fullness", "Total time", "Crowding on arrival",
"seat~fullness", "seat_min", "fullness", "Seat search time", "Crowding on arrival",
"queue~fullness", "queue_min", "fullness", "Queuing time", "Crowding on arrival",
"total~visit", "total_min", "visit_time", "Total time", "Usual visit time",
"queue~visit", "queue_min", "visit_time", "Queuing time", "Usual visit time",
"seat~visit", "seat_min", "visit_time", "Seat search time", "Usual visit time",
"total~stay", "total_min", "StayReason", "Total time", "What students do after eating"
)
kw_tbl <- pmap_dfr(kw_specs, function(key, var, grp, outcome, factor_label) {
x <- df[[var]]; f <- factor(df[[grp]]); k <- kruskal.test(x ~ f)
tibble(key = key, Outcome = outcome, Factor = factor_label, groups = nlevels(f),
H = unname(k$statistic), df = unname(k$parameter), p = k$p.value,
epsilon2 = unname(k$statistic) / (length(x) - 1),
p_anova = summary(aov(x ~ f))[[1]][["Pr(>F)"]][1])
}) %>% mutate(p_holm = p.adjust(p, "holm"))
kwv <- function(key, col) kw_tbl[[col]][kw_tbl$key == key]
kw_tbl %>% transmute(Outcome, Factor, Groups = groups, H = num(H, 2), df, `p-value` = p_txt(p),
`p (Holm)` = p_txt(p_holm), `Effect size (ε²)` = num(epsilon2, 3), `ANOVA p` = p_txt(p_anova)) %>%
show_dt(caption = "Table 3.2 — Kruskal–Wallis tests of waiting time across groups")
Crowding clearly matters: total time differs across crowding levels
(H = 24.6, p < 0.001, ε² = 0.28, so we reject H0), and the same holds
for seat search and queuing time after the Holm adjustment. Visit time
does not matter for total time (p = 0.522, ε² = 0.025, so we cannot
reject H0), and what students do after eating gives a borderline raw p =
0.049 that is not significant once adjusted (Holm p = 0.196). An effect
of ε² = 0.28 is large (benchmarks: 0.01 small, 0.08 medium, 0.26 large),
so crowding explains a real share of why waits differ, whereas the clock
time and lingering at the tables do not show reliable effects.
Differences between crowding levels do not say that crowding causes
waiting, since long queues may themselves make the canteen look full,
and the 100% group has only 6 students; Table 3.6 measures the strength
of the link.
Table 3.3 checks the common belief that non-IU students (n = 20) slow
the canteen down, by comparing them with IU students (n = 70) on waiting
times and satisfaction. The Mann–Whitney U test (Wilcoxon rank-sum)
suits two unequal groups of non-normal data; it is reported with the
Hodges–Lehmann shift (IU minus non-IU) and its 95% CI, the effect size
r, and Holm-adjusted p-values across 7 measures. The measure has the
same distribution for IU and non-IU students.
mw_specs <- c(queue_min = "Queuing time (min)", food_min = "Waiting for food (min)",
seat_min = "Seat search time (min)", total_min = "Total time (min)",
SatSeating = "Satisfaction: seats (1–5)", SatCleanliness = "Satisfaction: cleanliness (1–5)",
SatOverall = "Satisfaction: overall (1–5)")
mw_row <- function(var, label) {
x <- df[[var]]; g <- df$IUStudent
w <- wilcox.test(x ~ g, conf.int = TRUE, exact = FALSE)
z <- qnorm(w$p.value / 2, lower.tail = FALSE)
tibble(Measure = label, median_IU = median(x[g == "IU student"]), median_nonIU = median(x[g == "Non-IU student"]),
shift = unname(w$estimate), ci_lo = w$conf.int[1], ci_hi = w$conf.int[2],
W = unname(w$statistic), p = w$p.value, r = z / sqrt(length(x)))
}
mw_tbl <- map2_dfr(names(mw_specs), unname(mw_specs), mw_row) %>% mutate(p_holm = p.adjust(p, "holm"))
mw_tbl %>% transmute(Measure, `Median IU` = median_IU, `Median non-IU` = median_nonIU,
`Shift IU − non-IU` = num(shift), `95% CI` = paste0(num(ci_lo), " – ", num(ci_hi)),
`p-value` = p_txt(p), `p (Holm)` = p_txt(p_holm), `Effect size r` = num(r)) %>%
show_dt(caption = "Table 3.3 — IU (n = 70) vs. non-IU (n = 20) students")
For total time the typical difference is 0.00 (95% CI -3.00 to 4.00)
minutes (IU minus non-IU, p = 0.622, so we cannot reject H0), and 0 of
the 7 measures reaches p < 0.05 (smallest raw p = 0.155). The largest
effect size is r = 0.15, which is small (below 0.3). The data give no
evidence that non-IU students wait longer or are less satisfied, so
blaming outsiders is not supported empirically. With only 20 non-IU
students the intervals are wide and a real but modest difference could
be missed (absence of evidence is not evidence of absence); Tables
3.4–3.5 look at what each group believes.
Table 3.4 shows what IU and non-IU students believe is the main cause
of overcrowding and how clear they find the canteen rules, because
perceptions shape which fixes students will accept. Counts with row
percentages within each group are used because the groups differ in size
and both variables are categories. No test is run here; Table 3.5 tests
it.
perc <- bind_rows(
df %>% count(IUStudent, level = OvercrowdCauses) %>% mutate(variable = "Main cause of overcrowding"),
df %>% count(IUStudent, level = RuleClarity) %>% mutate(variable = "Clarity of canteen-use rules")
) %>%
group_by(variable, IUStudent) %>% mutate(share = n / sum(n)) %>% ungroup() %>%
mutate(cell = paste0(n, " (", pct(share), ")")) %>%
select(variable, level, IUStudent, cell) %>%
pivot_wider(names_from = IUStudent, values_from = cell, values_fill = "0 (0.0%)") %>%
arrange(variable, level)
show_dt(perc, caption = "Table 3.4 — Perceptions by student group: n (row %)",
colnames = c("Question", "Answer", "IU students (n = 70)", "Non-IU students (n = 20)"), n = nrow(perc))
Both groups mostly blame the large number of users, including
students from other universities (38 of 70 IU students, 54.3%; 10 of 20
non-IU students, 50.0%), so the two groups give a similar picture of the
cause. The rules are called “not clear yet” by 20 of 70 IU students
(28.6%) but only 1 of 20 non-IU students (5.0%). No p-value is attached
to percentages in a descriptive table. IU students themselves, who are
the majority of users, are the group that finds the rules unclear, which
matters for any plan based on rules or zones. Some answer cells hold 1
to 3 people, so chi-square assumptions are not met; Table 3.5 uses a
test that suits small counts.
Table 3.5 tests whether the differences between IU and non-IU
students in Table 3.4 are larger than chance. Several cells have fewer
than 5 expected students, so Fisher’s exact test (Monte Carlo version
for tables larger than 2×2, 20,000 draws) is the main test, with the
chi-square p-value and Cramér’s V (effect size) shown for comparison;
p-values are Holm-adjusted for the 2 tests. Student group and the answer
are independent (no association).
cat_row <- function(var, label) {
tb <- table(df$IUStudent, df[[var]])
chi <- suppressWarnings(chisq.test(tb, correct = FALSE))
set.seed(2026)
fe <- fisher.test(tb, simulate.p.value = TRUE, B = 20000)
tibble(Variable = label, chi2 = unname(chi$statistic), df = unname(chi$parameter), p_chi = chi$p.value,
p_fisher = fe$p.value,
cramers_V = sqrt(unname(chi$statistic) / (sum(tb) * (min(dim(tb)) - 1))),
min_expected = min(chi$expected))
}
cat_tbl <- bind_rows(cat_row("OvercrowdCauses", "Main cause of overcrowding"),
cat_row("RuleClarity", "Clarity of canteen-use rules")) %>%
mutate(p_holm = p.adjust(p_fisher, "holm"))
cat_tbl %>% transmute(Variable, `Chi-square` = num(chi2, 2), df, `p (chi-square)` = p_txt(p_chi),
`p (Fisher)` = p_txt(p_fisher), `p (Fisher, Holm)` = p_txt(p_holm),
`Cramér's V` = num(cramers_V), `Smallest expected count` = num(min_expected, 1)) %>%
show_dt(caption = "Table 3.5 — IU vs. non-IU: association with perceptions")
The main cause of overcrowding is unrelated to student group (Fisher
p = 0.953, Cramér’s V = 0.09, so we cannot reject H0). Rule clarity is
borderline: Fisher p = 0.042 (we reject H0) but chi-square p = 0.057 and
Holm-adjusted p = 0.085, with V = 0.29 (medium). Students of both groups
agree on the cause, and the sign that IU students find the rules less
clear is worth acting on cheaply (publish the rules) but should not be
treated as firm evidence. The result depends on one non-IU student
saying “not clear yet”, and several smallest expected counts are below
5, so it is fragile.
Find a relationship
(correlation)
Figures 3.2 and 3.3 look at the shape of two relationships before any
coefficient is computed: whether finding a seat takes longer when the
canteen is crowded, and whether students who notice more outside
students also report longer seat searches. A boxplot per level of an
ordered variable shows whether the trend is steadily rising (suited to
Spearman’s rank correlation) or bent. No test is run.
hcboxplot(x = df$seat_min, var = df$fullness, outliers = TRUE) %>%
hc_chart(type = "column", zoomType = "xy") %>%
hc_title(text = "Finding a seat takes longer as the canteen fills up") %>%
hc_xAxis(title = list(text = "Crowding on arrival")) %>%
hc_yAxis(title = list(text = "Seat search time (minutes)"))
The median seat-search time is 1 minute when the canteen is under 50%
full and 10.25 minutes when it is full, rising in steps. This is a
picture, so no p-value yet. The trend is steady, so a rank-based
correlation is appropriate. The seat-search times come from only four
ranges, so many students tie at the same value; Table 3.6 gives the
strength of the link.
Figure 3.3 asks whether noticing outside students goes with longer
seat searches, the other half of the common explanation for the
bottleneck. A boxplot by how often the student notices outsiders (Never
to Always). No test is run.
hcboxplot(x = df$seat_min, var = df$ext_f, outliers = TRUE) %>%
hc_chart(type = "column", zoomType = "xy") %>%
hc_title(text = "Noticing outside students shows no clear link to seat search time") %>%
hc_xAxis(title = list(text = "How often the student notices students from other universities")) %>%
hc_yAxis(title = list(text = "Seat search time (minutes)"))
The boxes are at similar heights across the five answers with no
steady upward trend, which suggests no link between noticing outsiders
and the real seat-search time. This is a picture, so Table 3.6 gives the
p-value. The perceived presence of outsiders does not line up with
longer actual searches for a seat. Some answers (“Never”, “Always”) hold
few students, so the boxes are uneven; the correlations follow.
Table 3.6 measures how strong and in which direction crowding and the
noticing of outsiders are related to waiting times and seat
satisfaction. Spearman’s rho is used because crowding and the notice
score are ordered categories and times are skewed; the 95% CI uses the
Bonett–Wright approximation; correlation does not prove causation. There
is no monotonic association (rho = 0).
cor_specs <- tribble(
~key, ~x, ~y, ~label,
"full~queue", "full_score", "queue_min", "Crowding vs. queuing time",
"full~seat", "full_score", "seat_min", "Crowding vs. seat search time",
"full~total", "full_score", "total_min", "Crowding vs. total time",
"ext~seat", "ext_score", "seat_min", "Noticing outsiders vs. seat search time",
"ext~total", "ext_score", "total_min", "Noticing outsiders vs. total time",
"ext~satseat", "ext_score", "SatSeating", "Noticing outsiders vs. seat satisfaction"
)
cor_tbl <- pmap_dfr(cor_specs, function(key, x, y, label) {
spearman_ci(df[[x]], df[[y]]) %>% mutate(key = key, label = label, .before = 1)
}) %>% mutate(p_holm = p.adjust(p, "holm"))
cor_tbl %>% transmute(Pair = label, n, `Spearman rho` = num(rho), `95% CI` = paste0(num(lo), " – ", num(hi)),
`p-value` = p_txt(p), `p (Holm)` = p_txt(p_holm)) %>%
show_dt(caption = "Table 3.6 — Spearman correlations")
Crowding is moderately related to total time (rho = 0.45 (95% CI 0.26
to 0.61), p < 0.001, so we reject H0) and to seat search time (rho =
0.38 (95% CI 0.18 to 0.55), p < 0.001). Noticing outsiders is
unrelated to seat search time (rho = -0.08 (95% CI -0.28 to 0.13), p =
0.473) but goes with lower seat satisfaction (rho = -0.30 (95% CI -0.48
to -0.10), Holm p = 0.012). Crowding goes with a medium-sized increase
in every stage of the wait, while the sense that “outsiders are here” is
a feeling about seats rather than a longer actual search. These are
associations, and perception and satisfaction are both self-reported,
which can inflate their link; the regression in Table 3.8 asks which
service stage matters most for overall satisfaction.
Predict (multiple
regression)
Table 3.7 checks that the five service ratings, which will be used
together to predict overall satisfaction, are not so closely related
that their effects cannot be told apart. The variance inflation factor
(VIF) of each predictor; values below 5 are usually acceptable and below
10 tolerable. No test is run.
preds <- c("SatQueueing", "SatFoodPickup", "SatSeating", "SatCleanliness", "SatTotalTime")
vif_tbl <- tibble(
predictor = unname(sat_lab[preds]),
VIF = map_dbl(preds, ~ 1 / (1 - summary(lm(reformulate(setdiff(preds, .x), .x), data = df))$r.squared))
)
show_dt(vif_tbl, caption = "Table 3.7 — Variance inflation factors", colnames = c("Predictor", "VIF"))
The VIFs range from 1.78 to 2.87, all well below 5. No p-value
applies. The service ratings overlap somewhat (they are rated by the
same people) but not so much that the model cannot separate them. VIF
only checks overlap, not whether the linear model fits; Table 3.8 fits
the model and Figure 3.4 checks its residuals.
Table 3.8 estimates how much overall satisfaction changes when the
rating of one service stage rises by one point, holding the other four
fixed, to find which stage matters most. An ordinary least squares
multiple regression, reporting the slope (point estimate) with its 95%
CI and p-value, a standardised coefficient to compare stages, and a
bootstrap 95% CI (2,000 resamples) as a check because the residuals may
not be normal. For each stage the slope is 0 (no effect after
controlling for the others).
m <- lm(SatOverall ~ SatQueueing + SatFoodPickup + SatSeating + SatCleanliness + SatTotalTime, data = df)
gl <- broom::glance(m)
sd_y <- sd(df$SatOverall)
set.seed(2026)
boot <- replicate(2000, coef(lm(SatOverall ~ ., data = df[sample(nrow(df), replace = TRUE), c("SatOverall", preds)]))[preds])
boot_ci <- t(apply(boot, 1, quantile, probs = c(0.025, 0.975)))
coef_tbl <- broom::tidy(m, conf.int = TRUE) %>%
filter(term != "(Intercept)") %>%
mutate(std_beta = estimate * map_dbl(term, ~ sd(df[[.x]])) / sd_y,
boot_lo = boot_ci[term, 1], boot_hi = boot_ci[term, 2],
predictor = unname(sat_lab[term]))
coef_tbl %>% transmute(Predictor = predictor, `Slope` = num(estimate), `95% CI (OLS)` = paste0(num(conf.low), " – ", num(conf.high)),
`95% CI (bootstrap)` = paste0(num(boot_lo), " – ", num(boot_hi)),
`p-value` = p_txt(p.value), `Standardised β` = num(std_beta)) %>%
show_dt(caption = paste0("Table 3.8 — Regression of overall satisfaction on five service ratings (R² = ",
num(gl$r.squared), ", adjusted R² = ", num(gl$adj.r.squared), ")"))
The model explains 59% of the variation in overall satisfaction
(adjusted R² = 0.57, F-test p < 0.001). The largest slopes are for
food pickup and availability (0.39 (95% CI 0.16 to 0.62), p < 0.001)
and total time acceptable (0.31 (95% CI 0.14 to 0.47), p < 0.001), so
we reject H0 for both; the other three slopes have CIs that include 0
and the queuing slope is slightly negative because of overlap with the
other ratings (VIF 2.9). One extra point on food pickup raises overall
satisfaction by about 0.4 points, so pickup and perceived total time are
the stages where improvement is most likely to lift the overall
experience. This is an association between ratings given by the same
students, not proof that fixing a stage causes higher satisfaction;
Figure 3.4 checks whether the model assumptions hold.
Figure 3.4 checks the linear model’s assumptions by plotting
residuals against fitted values, together with a normality test of the
residuals. A residual plot shows whether the spread is even and whether
any pattern is left; Shapiro–Wilk tests normality. The residuals are
normally distributed.
sw_res <- shapiro.test(resid(m))
resid_df <- tibble(fitted = fitted(m), residual = resid(m))
hchart(resid_df, "scatter", hcaes(x = fitted, y = residual)) %>%
hc_title(text = "Residuals show no strong pattern, but they are not perfectly normal") %>%
hc_xAxis(title = list(text = "Fitted overall satisfaction")) %>%
hc_yAxis(title = list(text = "Residual"),
plotLines = list(list(value = 0, color = "#d62728", width = 1, dashStyle = "Dash"))) %>%
hc_legend(enabled = FALSE) %>%
hc_chart(zoomType = "xy")
The residuals are centred on 0 with no clear curve, but the
Shapiro–Wilk test gives W = 0.946, p < 0.001, so we reject H0: the
residuals are not normal. The lines of dots come from whole-number
satisfaction scores and a ceiling at 5, which explains the departure;
the bootstrap intervals in Table 3.8, which do not rely on normal
residuals, still exclude 0 for food pickup and total time, so the main
conclusion stands. With ordinal 1–5 scores a linear model is an
approximation, and the model is one of several possible; Section 5.1
repeats key results under other assumptions.