Tips Dataset: Case Study Worksheet

Companion to Chapter 30 (Case Study: The Tips Dataset). This assignment threads one open-ended, real dataset through exploratory analysis, correlation, simple and multiple regression, a t-test, and a one-way ANOVA — the same set of tools the chapter walks through, applied by you.

Why We Are Using This Dataset

The Tips dataset records real restaurant transactions collected by a single waiter over several months: the bill, the tip, the day, the time, the size of the party. Unlike the baby dataset sequence, there’s no single research question attached to this one — that’s the point. Part of the skill this assignment builds is choosing which question a given pair of variables can actually answer, then picking the test that matches.

Before you start: re-read the “Data collection and generalizability” box in Ch 30. These data come from one waiter at one restaurant, and the customers involved did not consent to being research subjects. Keep both limitations in mind when you write your conclusions — a strong effect size here is still a claim about this restaurant, not restaurants in general.

A Note on AI Tools

You may use AI assistants (ChatGPT, Claude, etc.) to help debug your R code — that’s a realistic professional skill. You may not use AI to generate your interpretations. Every write-up sentence must reflect your own reading of the output. If you use AI for any part of this assignment, note where at the end.

Dataset Variables

Variable Description Type
total_bill Total bill amount (\() | Numeric | | `tip` | Tip amount (\)) Numeric
sex Server’s reported gender of the bill-payer Factor (Male/Female)
smoker Whether the party included a smoker Factor (Yes/No)
day Day of the week Factor (Thur/Fri/Sat/Sun)
time Meal period Factor (Lunch/Dinner)
size Number of people in the party Integer

Standard Setup

library(reshape2)
data(tips)

head(tips)
str(tips)
nrow(tips)

No file upload needed — tips is built into the reshape2 package.

Section 1: Exploratory Data Analysis

1a. Descriptives. Calculate descriptive statistics for total_bill, tip, and size.

summary(tips[, c("total_bill", "tip", "size")])
sd(tips$total_bill)
sd(tips$tip)
sd(tips$size)

1b. Visualization.

hist(tips$tip, main = "Distribution of Tips", xlab = "Tip ($)")

plot(tips$total_bill, tips$tip,
     main = "Tip vs. Total Bill",
     xlab = "Total Bill ($)", ylab = "Tip ($)")

boxplot(tip ~ day, data = tips,
        main = "Tips by Day", ylab = "Tip ($)")

Describe what you observe in each plot. What relationship between bill and tip does the scatter plot suggest?

1c. Potential confound. The scatter plot shows a positive relationship between total bill and tip amount. What is one potential confound or third variable that could be driving both higher at the same time? Explain why it matters for how you’d interpret a correlation between them.

Section 2: Correlation

cor(tips[, c("total_bill", "tip", "size")])
cor.test(tips$total_bill, tips$tip)
cor.test(tips$size, tips$tip)

Report both correlations in APA format (r, df, p, and the 95% CI from cor.test), then answer:

Section 3: Simple Regression

Predict tip from total_bill.

model_simple <- lm(tip ~ total_bill, data = tips)
summary(model_simple)
confint(model_simple)

Section 4: Multiple Regression

Predict tip from all the other variables.

tips$smoker <- as.factor(tips$smoker)
tips$sex    <- as.factor(tips$sex)
tips$day    <- as.factor(tips$day)
tips$time   <- as.factor(tips$time)

model_multi <- lm(tip ~ total_bill + size + sex + smoker + day + time, data = tips)
summary(model_multi)

library(car)
vif(model_multi)

Section 5: Independent-Samples t-Test

Do smokers and non-smokers differ in tip percentage? (Percentage, not raw tip, controls for the fact that smoker and non-smoker parties may have different bill sizes.)

tips$tip_pct <- 100 * tips$tip / tips$total_bill

tapply(tips$tip_pct, tips$smoker, mean)
tapply(tips$tip_pct, tips$smoker, sd)

shapiro.test(tips$tip_pct[tips$smoker == "Yes"])
shapiro.test(tips$tip_pct[tips$smoker == "No"])

t.test(tip_pct ~ smoker, data = tips)

library(effectsize)
cohens_d(tip_pct ~ smoker, data = tips)

Section 6: One-Way ANOVA

Does tip percentage differ across days of the week?

model_anova <- aov(tip_pct ~ day, data = tips)
summary(model_anova)

library(effectsize)
eta_squared(model_anova)

tapply(tips$tip_pct, tips$day, mean)
tapply(tips$tip_pct, tips$day, sd)

Section 7: Open-Ended Exploration

Pick one of the following (or propose your own, with instructor approval), and answer it with an appropriate test:

State the question, the test you chose and why it fits the variable types involved, and your conclusion with its limits.

Section 8: Synthesis

Reflection

Submission Guidelines