Advertising Dataset (Kaggle): https://www.kaggle.com/datasets/ashydv/advertising-dataset
Each observation is a market, with the amount spent on TV, radio, and newspaper advertising ($ thousands) and product sales (thousands of units).
ads <- read.csv("https://raw.githubusercontent.com/selva86/datasets/master/Advertising.csv")
ads <- ads[, -1]
set.seed(123)
sample_ads <- ads[sample(nrow(ads), nrow(ads) / 2), ]
nrow(ads)
## [1] 200
nrow(sample_ads)
## [1] 100
The original dataset has 200 observations. I used a random sample of 100 observations (half) for my analysis.
summary(sample_ads$sales)
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 5.30 10.25 12.65 13.90 17.32 26.20
sd(sample_ads$sales)
## [1] 4.861288
hist(sample_ads$sales,
breaks = seq(0, 30, 2.5),
col = "steelblue",
main = "Distribution of Sales",
xlab = "Sales (thousands of units)")
Sales range from 5.3 to 26.2, with a mean of 13.90, a median of 12.65, and a standard deviation of 4.86. The distribution is slightly right-skewed, with most markets selling between 10 and 15 thousand units.
round(cor(sample_ads), 3)
## TV radio newspaper sales
## TV 1.000 0.000 -0.078 0.785
## radio 0.000 1.000 0.346 0.524
## newspaper -0.078 0.346 1.000 0.068
## sales 0.785 0.524 0.068 1.000
plot(sample_ads$TV, sample_ads$sales,
pch = 19, col = "darkorange",
main = "TV Ad Budget vs. Sales",
xlab = "TV ad budget ($ thousands)",
ylab = "Sales (thousands of units)")
abline(lm(sales ~ TV, data = sample_ads), col = "red", lwd = 2)
Sales have a strong positive correlation with TV spending (r = 0.785), a moderate correlation with radio (r = 0.524), and almost no correlation with newspaper (r = 0.068).
Sales were slightly right-skewed, with most markets selling between 10 and 15 thousand units. TV advertising had the strongest relationship with sales (r = 0.785), radio had a moderate relationship (r = 0.524), and newspaper had almost none (r = 0.068). This suggests TV and radio are the better places to spend advertising money, although correlation alone doesn’t prove the ads caused the sales.