A correlation coefficient describes the strength and direction of association between two numeric variables, but a nonzero coefficient is not automatically statistically meaningful. A correlation test evaluates whether the observed relationship differs from zero, using a null hypothesis of no correlation and a p-value to decide whether to reject or fail to reject that hypothesis. section 14.4.2 section 20.2
For numeric interval data, Pearson correlation is the default choice in R. Pearson and Spearman coefficients both range from -1 to +1, but Spearman uses ranked values rather than raw values. Missing values can be excluded when computing correlations with `use = "complete.obs"`. section 10.4.1
Run a correlation test as a practical sequence:
- State the null hypothesis: the variables have no meaningful correlation. section 14.4.2
- Use `cor.test()` on the two numeric variables to obtain the correlation estimate, test statistic, degrees of freedom, p-value, and confidence interval. section 10.4.1 section 14.4.2
- Choose a significance threshold before interpreting the result; a 5% threshold rejects the null when the p-value is at or below 0.05 and otherwise fails to reject it. section 14.4.2 section 20.2
- Compare tests carefully when answering a relative question, such as whether points allowed or points scored has a stronger relationship with wins. section 14.4 section 14.4.2
Payrolls and regular-season wins
Testing team payroll against regular-season wins across the combined data returns a Pearson correlation of about 0.21, with a p-value of 0.0000008417 and a 95% confidence interval from about 0.13 to 0.29. At a 5% threshold, reject the no-correlation null hypothesis: payroll and wins show a statistically significant positive association in these observations. Computing the coefficient separately by season also reveals that the association varies, from 0.02 in 2006 to 0.57 in 2000. section 10.4.1
Does defense matter more than offense?
Standardize wins, points allowed, and points scored, then test wins against each scoring measure. The points-allowed correlation is about -0.58 and the points-scored correlation about 0.53; both tests have p-values below the 5% threshold. Because the p-values are alike, these results alone do not establish that points allowed matter more than points scored for regular-season wins. section 14.4 section 14.4.2
options(scipen = 999) cor.test(nba_stats$z_wins, nba_stats$z_o_pts) ## ## Pearson's product-moment correlation ## ## data: nba_stats$z_wins and nba_stats$z_o_pts ## t = -12.434, df = 298, p-value < 0.00000000000000022 ## alternative hypothesis: true correlation is not equal to 0 ## 95 percent confidence interval: ## -0.6543987 -0.5046282 ## sample estimates: ## cor ## -0.5844698 cor.test(nba_stats$z_wins, nba_stats$z_pts) ## ## Pearson's product-moment correlation ## ## data: nba_stats$z_wins and nba_stats$z_pts ## t = 10.74, df = 298, p-value < 0.00000000000000022 ## alternative hypothesis: true correlation is not equal to 0 ## 95 percent confidence interval: ## 0.4414140 0.6052828 ## sample estimates: ## cor ## 0.5282497
Inspect two `cor.test()` outputs side by side: each reports a Pearson estimate, confidence interval, test statistic, and extremely small p-value for wins paired with points allowed or points scored. section 14.4.2
