Dataset

This report uses the attached games.csv dataset, It contains historical NBA game results and team statistics. My research question is whether a team’s rebounding advantage is related to its point differential. I hypothesize that teams with a higher rebound differential will also have a higher point differential.

https://www.kaggle.com/datasets/nathanlauga/nba-games?select=games.csv

nba <- read.csv("games.csv")

head(nba)
##   GAME_DATE_EST  GAME_ID GAME_STATUS_TEXT HOME_TEAM_ID VISITOR_TEAM_ID SEASON
## 1    2022-12-22 22200477            Final   1610612740      1610612759   2022
## 2    2022-12-22 22200478            Final   1610612762      1610612764   2022
## 3    2022-12-21 22200466            Final   1610612739      1610612749   2022
## 4    2022-12-21 22200467            Final   1610612755      1610612765   2022
## 5    2022-12-21 22200468            Final   1610612737      1610612741   2022
## 6    2022-12-21 22200469            Final   1610612738      1610612754   2022
##   TEAM_ID_home PTS_home FG_PCT_home FT_PCT_home FG3_PCT_home AST_home REB_home
## 1   1610612740      126       0.484       0.926        0.382       25       46
## 2   1610612762      120       0.488       0.952        0.457       16       40
## 3   1610612739      114       0.482       0.786        0.313       22       37
## 4   1610612755      113       0.441       0.909        0.297       27       49
## 5   1610612737      108       0.429       1.000        0.378       22       47
## 6   1610612738      112       0.386       0.840        0.317       26       62
##   TEAM_ID_away PTS_away FG_PCT_away FT_PCT_away FG3_PCT_away AST_away REB_away
## 1   1610612759      117       0.478       0.815        0.321       23       44
## 2   1610612764      112       0.561       0.765        0.333       20       37
## 3   1610612749      106       0.470       0.682        0.433       20       46
## 4   1610612765       93       0.392       0.735        0.261       15       46
## 5   1610612741      110       0.500       0.773        0.292       20       47
## 6   1610612754      117       0.469       0.778        0.462       27       47
##   HOME_TEAM_WINS
## 1              1
## 2              1
## 3              1
## 4              1
## 5              0
## 6              0

Q1: Plotting a Graph

average_points <- c(
  mean(nba$PTS_home, na.rm = TRUE),
  mean(nba$PTS_away, na.rm = TRUE)
)

barplot(
  average_points,
  names.arg = c("Home Teams", "Away Teams"),
  col = c("blue", "orange"),
  main = "Average Points Scored by Home and Away Teams",
  xlab = "Team Location",
  ylab = "Average Points Scored",
  ylim = c(0, 120)
)

This bar plot compares the average points scored by home and away teams. The home team scored approximately 103 points per game, while away teams scored 101 points. This suggest home teams score more on average than away teams.

Q2: Statistical Calculation

nba$REB_DIFF <- nba$REB_home - nba$REB_away
nba$POINT_DIFF <- nba$PTS_home - nba$PTS_away

rebound_statistics <- c(
  Mean = mean(nba$REB_DIFF, na.rm = TRUE),
  Median = median(nba$REB_DIFF, na.rm = TRUE),
  Standard_Deviation = sd(nba$REB_DIFF, na.rm = TRUE)
)

round(rebound_statistics, 2)
##               Mean             Median Standard_Deviation 
##               1.26               1.00               8.98

The mean rebound differential was 1.26, meaning home teams collected about 1.26 more rebounds than away teams per game on average. The median was 1 rebound, while the standard deviation was 8.98 rebounds. This shows that the typical rebound difference was small, but the amount of variation between games was much larger.

Q3: Correlation Between Rebound and Point Differential

analysis_data <- nba[
  complete.cases(nba$REB_DIFF, nba$POINT_DIFF),
]

correlation_result <- cor.test(
  analysis_data$REB_DIFF,
  analysis_data$POINT_DIFF
)

correlation_result
## 
##  Pearson's product-moment correlation
## 
## data:  analysis_data$REB_DIFF and analysis_data$POINT_DIFF
## t = 83.518, df = 26550, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.4465560 0.4656079
## sample estimates:
##       cor 
## 0.4561342
rebound_model <- lm(
  POINT_DIFF ~ REB_DIFF,
  data = analysis_data
)

summary(rebound_model)
## 
## Call:
## lm(formula = POINT_DIFF ~ REB_DIFF, data = analysis_data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -58.970  -8.029   0.069   7.991  52.519 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.950574   0.074556   26.16   <2e-16 ***
## REB_DIFF    0.686300   0.008217   83.52   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 12.03 on 26550 degrees of freedom
## Multiple R-squared:  0.2081, Adjusted R-squared:  0.208 
## F-statistic:  6975 on 1 and 26550 DF,  p-value: < 2.2e-16
plot(
  analysis_data$REB_DIFF,
  analysis_data$POINT_DIFF,
  main = "Rebound Differential and Point Differential",
  xlab = "Rebound Differential",
  ylab = "Point Differential",
  pch = 16,
  col = rgb(0, 0, 1, 0.2)
)

abline(
  rebound_model,
  col = "orange",
  lwd = 2
)

The correlation was 0.456, which denotes a moderates positive relationship between the rebound differential and the point differential. The R-squared was 0.208, meaning that the rebound differential could explain 20.8% of the differences in the scoring margin. The p-value is less than 2.2e-16, and hence the relationship is statistically significant. From the slope of the regression line above, one would conclude that the point differentials were higher where the team had higher rebounds compared to its opponent team.

Q4: Distribution of Point Differential

point_diff_data <- na.omit(nba$POINT_DIFF)

hist(
  point_diff_data,
  breaks = 30,
  main = "Distribution of Home-Team Point Differential",
  xlab = "Point Differential",
  ylab = "Number of Games",
  col = "steelblue",
  border = "white"
)

abline(
  v = mean(point_diff_data),
  col = "red",
  lwd = 2,
  lty = 2
)

legend(
  "topright",
  legend = "Mean",
  col = "red",
  lwd = 2,
  lty = 2
)

The histogram is roughly bell-shaped and centered slightly above zero. Most games had point differentials near the center, while very large wins or losses were less common. The red dashed line shows that the mean point differential was approximately 2.82 points, meaning home teams scored about 2.82 more points than away teams on average. Since the distribution is roughly symmetric and the dataset contains many observations, a t-test was used in the next analysis.

Q5: T-Test by Rebounding Advantage

nba$REB_GROUP <- ifelse(
  nba$REB_DIFF > 0,
  "Rebound Advantage",
  "No Rebound Advantage"
)

t_test_result <- t.test(
  POINT_DIFF ~ REB_GROUP,
  data = nba
)

t_test_result
## 
##  Welch Two Sample t-test
## 
## data:  POINT_DIFF by REB_GROUP
## t = -61.901, df = 25988, p-value < 2.2e-16
## alternative hypothesis: true difference in means between group No Rebound Advantage and group Rebound Advantage is not equal to 0
## 95 percent confidence interval:
##  -9.935803 -9.325898
## sample estimates:
## mean in group No Rebound Advantage    mean in group Rebound Advantage 
##                          -2.320045                           7.310805

In the case of the t-test, it indicated that there exists a significant difference between the two groups. In this case, the value of p was less than 2.2e-16. The mean of the point difference for home teams without a rebounding advantage was -2.32, while that of the home teams with rebounding advantage was 7.31. In this case, the difference was approximately 9.63 points. Since the value of p was less than 0.05, the results support my hypothesis.