31 Case Study: The Tips Dataset
By the end of this chapter you will be able to:
- Explore an open-ended dataset and pose your own answerable questions.
- Move between test families (regression, group comparison, multiple regression) as each question demands.
- Evaluate generalizability when all the data come from one restaurant and one waiter.
The Tips dataset is small, real, and open-ended. It contains data from a restaurant — every meal’s total bill, the tip left, the day, the time, the size of the party. There’s no single “right question” attached to it; that’s part of what makes it useful as a teaching case.
This chapter walks through what students typically do with it.
31.1 The dataset
| Variable | Description | Type |
|---|---|---|
total_bill |
Bill amount in dollars | Numeric (continuous) |
tip |
Tip amount in dollars | Numeric (continuous) |
sex |
Server’s reported gender of the bill-payer | Factor (M/F) |
smoker |
Whether the party included a smoker | Factor (Y/N) |
day |
Day of the week | Factor (Thu/Fri/Sat/Sun) |
time |
Time of day | Factor (Lunch/Dinner) |
size |
Number of people in the party | Integer |
A few hundred observations. Real data, lightly cleaned.
The Tips data were collected by a single waiter at one restaurant over several months. The customers whose tipping behavior is recorded likely did not consent to being research participants — naturalistic observation in a public commercial setting is an ethically gray area (no participant harm, but no explicit consent either).
More consequentially for analysis: one waiter, one restaurant is a severe constraint on generalizability. Any finding here about smoker status, party size, day of week, or bill-payer gender applies first and foremost to this waiter’s experience in this specific setting. Replication across multiple servers, restaurants, and geographic regions would be required before drawing broader conclusions about tipping behavior.
Note also that the smoker variable records whether anyone in the party was a smoker — it does not indicate that the bill-payer smoked, or that smoking behavior during the meal was directly observed.
31.2 Question 1: How big are bills and tips?
Always start with descriptives.
data <- reshape2::tips # load the dataset as `data`
summary(data[, c("total_bill", "tip", "size")])
hist(data$total_bill)
hist(data$tip)
plot(data$total_bill, data$tip,
main = "Tip vs. total bill",
xlab = "Total bill ($)",
ylab = "Tip ($)")Bills and tips both look right-skewed — most are modest, with a long tail of big spenders. This is the textbook situation where a log transformation might help, but for the analyses below the t-test and regression results are essentially the same on raw and log scales.
31.3 Question 2: Does the bill predict the tip?
Obvious question, but worth checking.
# Correlation
cor.test(data$total_bill, data$tip)
# Simple regression
model <- lm(tip ~ total_bill, data = data)
summary(model)You’ll find a strong positive correlation, around r = .68, and the simple regression confirms that for each $1 increase in bill, the tip goes up by roughly 10 cents. The slope is highly significant, and \(R^2\) is around .46.
A Pearson correlation indicated a strong positive relationship between total bill and tip, r(242) = .68, p < .001. A simple linear regression confirmed that bill amount significantly predicted tip, F(1, 242) = 203.4, p < .001, \(R^2\) = .46. Each $1 increase in bill was associated with a $0.11 increase in tip, b = 0.11, SE = 0.007, t(242) = 14.26, p < .001.
31.4 Question 3: Does tip percentage differ by group?
A more interesting question is whether percentage tips (not absolute) differ between groups.
# Compute tip percentage
data$tip_pct <- 100 * data$tip / data$total_bill
# By day of week
boxplot(tip_pct ~ day, data = data)
# One-way ANOVA on tip_pct by day
model <- aov(tip_pct ~ day, data = data)
summary(model)
# By smoker status (independent t-test)
t.test(tip_pct ~ smoker, data = data)
# Effect sizes, reported whether or not the tests are significant
effectsize::eta_squared(model, partial = FALSE)
effsize::cohen.d(tip_pct ~ smoker, data = data)Typical findings:
- The day-of-week ANOVA is often not significant — average tip percentages are similar across days.
- The smoker vs. non-smoker t-test is also typically non-significant.
- Report the effect sizes anyway: η² = .01 for day and Cohen’s d = −0.06 (negligible) for smoker.
These are useful pedagogically because they illustrate that not every test is significant, and that knowing how to interpret a non-significant result is part of the work.
31.5 Question 4: Multiple regression — what predicts tip?
A natural follow-up: what combination of variables best predicts the tip?
data$smoker <- as.factor(data$smoker)
data$sex <- as.factor(data$sex)
data$day <- as.factor(data$day)
data$time <- as.factor(data$time)
model <- lm(tip ~ total_bill + size + sex + smoker + day + time,
data = data)
summary(model)
library(car)
vif(model)
# Check why day and time overlap in this sample
with(data, table(day, time))For this model on reshape2::tips:
total_billis the dominant predictor, b = 0.094, SE = 0.010, t(235) = 9.84, p < .001.sizehas a small positive coefficient, b = 0.176, but narrowly misses the course’s α = .05 threshold, SE = 0.090, t(235) = 1.97, p = .0505. Describe this result as borderline but not statistically significant in the specified model.sex,smoker,day, andtimeare also non-significant after controlling for bill and party size (ps ≥ .556).- The generalized VIF output exposes structural overlap between
day(GVIF = 10.65 with 3 df; adjusted GVIF = 1.48) andtime(GVIF = 9.24 with 1 df; adjusted GVIF = 3.04). Use the adjusted values when comparing terms with different degrees of freedom. All Saturday and Sunday observations are dinner, while 61 of 62 Thursday observations are lunch, so the separatedayandtimecoefficients are less stable than they first appear.
The model explains 47.0% of tip variance, only 1.35 percentage points more than total_bill alone (45.7%). That small gain is informative: bill amount captures nearly all of the explanatory power contributed by this predictor set, and the remaining predictors collectively add little.
31.6 Question 5: Open-ended exploration
The Tips dataset is also a great place to practice exploratory analysis without a hypothesis. Open-ended questions students can pursue:
- Are weekend dinners different from weekday lunches in any systematic way?
- Does party size interact with day of week?
- Are there clear outliers, and what happens if you remove them?
These questions don’t have textbook answers, which is the point. The dataset rewards careful EDA and clear thinking about what can and cannot be inferred.
For an open-ended exploration of this dataset:
- EDA: histograms of
total_bill,tip,size - Visualize the bill-tip relationship
- Compute
tip_pctand explore by group - Pick one substantive question, run the appropriate test
- Run a multi-variable regression to see what predicts tip
- Write up the most defensible 2–3 findings
The student-facing worksheet for this dataset — EDA, correlation, simple and multiple regression, t-test, ANOVA, and open-ended exploration — is available here:
The next case study takes a more complex within-subjects design.
Core idea: An open-ended dataset with no pre-assigned question. You choose what to ask; the variable types then determine the test. Judgment — not recipe-following — is the skill being practiced.
You should understand:
- How the same dataset supports regression (bill → tip), group comparison (tip percentage by smoking status), and multiple regression (what predicts tip)
- Why data from one waiter at one restaurant limit generalization, no matter how clean the analysis
- Why a non-significant result here is a finding, not a failure
You should be able to do in R:
- Load
reshape2::tips, computetip_pct, and explore it by group - Pick one question, run the matching test, and defend the choice
- Write up the most defensible findings rather than every test you ran
Plain-language check: You found three significant results and four non-significant ones. What belongs in the write-up, and why isn’t the answer “just the significant ones”?
The one mistake to avoid: Running every possible test and reporting whatever came out significant — that’s the p-hacking pattern from Chapter 29, in miniature.
Practice: Does party size predict tip percentage? Decide which analysis answers that, run it, and state your conclusion with its limits.
Key terms from this chapter are defined in the Glossary.