liveBook · Manning

Correlation matrix

As explained in Statistics Slam Dunk

A correlation matrix is a square tabular arrangement containing pairwise correlation coefficients for a set of variables.

A correlation matrix is a square table that records the pairwise correlation coefficient for every selected variable combination. Coefficients range from -1 to +1: positive values indicate positive association, negative values indicate negative association, and values near zero indicate little meaningful association. section 2.5.4 section 5.6

Build and interpret a matrix in R with this workflow:

  • Select continuous variables before computing correlations; the example uses Age, G, MP, WS, and WS48. section 2.5.4
  • Pass the selected data to cor() to create the tabular matrix. Each variable correlates perfectly with itself, producing 1.00 on the diagonal. section 2.5.4
  • Notice that each pair appears twice because the matrix is symmetric; melt() can stack the combinations into Var1, Var2, and value columns for plotting. section 2.5.4
  • Map the reshaped values to a ggplot2 tile heat map, using color and labels to display coefficient strength. section 2.5.4

Choosing regression predictors

After checking outliers and normality, compare wins with candidate hustle variables. The matrix helps identify promising predictors rather than adding every available variable to a regression model. In the example, deflections, contested_2pt, and screen_assists_pts emerge as comparatively stronger candidates, while other hustle measures show weaker relationships with wins. section 5.6 section 5.6.2

cor_matrix <- cor(cor_draft)
print(cor_matrix)
##             Age          G         MP         WS       WS48
## Age   1.0000000 -0.2189601 -0.2327846 -0.2509647 -0.1801535
## G    -0.2189601  1.0000000  0.7921621  0.8004797  0.6165429
## MP   -0.2327846  0.7921621  1.0000000  0.7758876  0.6597869
## WS   -0.2509647  0.8004797  0.7758876  1.0000000  0.6942061
## WS48 -0.1801535  0.6165429  0.6597869  0.6942061  1.0000000

Inspect the printed R matrix to see diagonal self-correlations, duplicated pairwise values, and relationships such as MP with WS48. section 2.5.4

How Statistics Slam Dunk covers it

How deep it goes
Explains coefficient interpretation, continuous-variable selection, matrix symmetry, reshaping, and heat-map construction, but does not develop correlation theory.
Examples
Uses NBA draft variables and hustle statistics, including Age, MP, WS48, wins, contested shots, and screen assists.
What it assumes
Assumes basic R data selection and plotting, while defining coefficient interpretation and demonstrating the matrix workflow.
What you can do after
Apply it via R to compute coefficients, reshape results, create a heat map, and shortlist regression predictors.
How it connects
Connects correlation coefficients with data visualization, outliers, normality testing, and linear regression.

Also explained in

Compare how 5 books explain correlation matrix →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Slam Dunk. The section links point to the parts of the book it draws on.