The Shapiro–Wilk test evaluates whether a sample is consistent with a normal distribution. Its null hypothesis states that the data is normally distributed. Using a 0.05 significance cutoff, a p-value above 0.05 supports assuming normality, while a p-value at or below 0.05 supports rejecting normality. section 5.5
Use the test alongside a density plot rather than relying on visual inspection alone. In regression preparation, normally distributed variables can remain candidates, while variables flagged as non-normal may be withheld because linear regression assumes Gaussian distributions. section 5.5.2 section 14.3
Testing NBA deflections
In R, run `shapiro.test(hustle$deflections)`. The result `W = 0.98557, p-value = 0.4235` exceeds 0.05, so deflections can be treated as normally distributed for this screening step. Pair the result with a density plot to inspect the distribution’s shape. section 5.5.1
A visually deceptive distribution
For NBA points per game, a histogram may appear approximately Gaussian, but `shapiro.test(nba_stats$PTS)` returns `W = 0.99016, p-value = 0.04124`. Because the p-value is below 0.05, assume the distribution is not quite normal. section 14.3
options(scipen = 999)
shapiro.test(hustle$deflections)
##
## Shapiro-Wilk normality test
##
## data: hustle$deflections
## W = 0.98557, p-value = 0.4235
dp1 <- ggplot(hustle, aes(x = deflections)) +
geom_density(alpha = .3, fill = "dodgerblue4") +
labs(title = "Deflections",
subtitle = "Shapiro-Wilk test of normality: p-value = 0.42",
x = "",
y = "Density") +
theme(plot.title = element_text(face = "bold"))
print(dp1)
Inspect the executable R call, reported W statistic, p-value, and matching density plot for the deflections example. section 5.5.1

