Tutorials › Exam PA - Predictive Analytics › Association Measures for Mixed Predictor Types

Exam PA · Screening and Dimension Reduction · Tutorial 268 of 966

Association Measures for Mixed Predictor Types

Select and calculate an association measure that matches the types of two predictors, while interpreting its limitations.

Intermediate 12 min read

What You'll Learn

  • Match association summaries to numeric, binary, and categorical predictor pairs.
  • Calculate point-biserial correlation for a numeric predictor and a binary indicator.
  • Interpret the correlation between two binary indicators and how coding affects its sign.
  • Calculate Cramer's V from a categorical contingency table.
  • Use eta squared to summarize numeric differences across multiple categories.
  • Recognize how coding, sparsity, and nonlinear patterns limit association summaries.

Why Predictor Types Matter

A predictor correlation matrix is useful only when its entries have a meaningful interpretation. Pearson correlation is appropriate for a pair of numeric predictors when linear association is the target, but a factor or binary indicator requires care: assigning numbers to nominal categories does not make them quantitative. Screening a mixed predictor set therefore begins by identifying each variable's type and choosing a measure suited to the pair.

These measures summarize different features of association. A correlation has a sign and is scaled from \(-1\) to \(1\); Cramer's V and eta are nonnegative measures of strength. None, by itself, establishes causation or proves that two predictors are redundant for a particular predictive model.

Definition: A binary indicator \(B\) takes values 0 and 1. A point-biserial correlation is the Pearson correlation between a numeric variable \(X\) and a binary indicator \(B\). For two binary indicators, their Pearson correlation is also called the phi coefficient. For two nominal categorical variables, Cramer's V summarizes association using a contingency table. For a numeric variable grouped by a categorical variable, eta summarizes how much of the numeric variable's variation is between the groups.

Choose a Measure for the Pair

The number of categories matters. A two-level factor can be represented as a 0/1 indicator, so correlation gives a signed association with another numeric or binary variable. With three or more nominal levels, correlations based on arbitrary numeric codes are generally not meaningful. Use a measure that treats the levels as categories instead.

Predictor pairUseful summaryWhat it summarizes
Numeric and binaryPoint-biserial correlationDifference in numeric means between the two indicator groups, scaled by overall variation
Binary and binaryPhi coefficient (Pearson correlation of 0/1 indicators)Direction and strength of association for the chosen coding
Nominal categorical and nominal categoricalCramer's VStrength of association in a contingency table, without a direction
Numeric and categorical with multiple levelsEta or eta squaredShare of numeric variation associated with differences between category means

For numeric-numeric pairs, Pearson correlation describes linear association, while rank correlation can capture monotone association. Those measures should not be replaced by a category-based measure simply because the numeric variables have been divided into groups. Binning discards information and may hide patterns within each bin.

Numeric and Binary: Point-Biserial Correlation

Let \(B=1\) identify one group and \(B=0\) the other. Write \(p\) for the proportion with \(B=1\), \(q=1-p\), and \(\bar{x}_1,\bar{x}_0\) for the group means of \(X\). Define \(\bar{x}\) as the overall mean and \(\sigma_X\) as the empirical standard deviation using divisor \(n\). Then the point-biserial correlation is

$$ r_{XB}=\frac{\sqrt{pq}\,(\bar{x}_1-\bar{x}_0)}{\sigma_X}. $$

The sign depends on which group is coded 1. If the mean in the \(B=1\) group is larger, the correlation is positive; swapping the 0/1 coding reverses the sign but not its magnitude. The formula uses the overall standard deviation of \(X\), not a within-group standard deviation. Software such as R's cor() returns the same Pearson correlation when both variables are coded numerically as described.

Why the formula holds: The overall mean is \(\bar{x}=p\bar{x}_1+q\bar{x}_0\). With empirical covariance defined using divisor \(n\), the \(B=1\) observations contribute \(pq(\bar{x}_1-\bar{x})\) to the covariance, and the \(B=0\) observations contribute \(-pq(\bar{x}_0-\bar{x})\). Their sum is \(pq(\bar{x}_1-\bar{x}_0)\). Since the empirical variance of \(B\) is \(pq\), dividing the covariance by \(\sigma_X\sqrt{pq}\) gives the stated formula.

Worked Example: Numeric Score and a Binary Flag

In a hypothetical screening exercise, a numeric score \(X\) is recorded for eight applications. A flag \(B=1\) identifies four applications that received an additional review. The observed scores are 10, 12, 14, and 16 for \(B=1\), and 4, 6, 8, and 10 for \(B=0\). Calculate the point-biserial correlation and interpret its sign.

Method. Find the group proportions and means, then use the point-biserial formula. There are four records in each group, so \(p=q=4/8=0.5\). The means are \( \bar{x}_1=(10+12+14+16)/4=52/4=13 \) and \( \bar{x}_0=(4+6+8+10)/4=28/4=7 \).

The overall mean is \(\bar{x}=(52+28)/8=10\). The squared deviations from 10 are 36, 16, 4, 0, 0, 4, 16, and 36, whose sum is 112. Thus \( \sigma_X=\sqrt{112/8}=\sqrt{14} \).

Substitute the values: \( r_{XB}=\sqrt{0.5(0.5)}(13-7)/\sqrt{14}=0.5(6)/\sqrt{14}=3/\sqrt{14}=0.8018 \), rounded to four decimal places. The positive sign means the reviewed group has the higher mean score. As a check, the covariance is \(pq(13-7)=0.25(6)=1.5\); dividing by \(\sigma_X\sigma_B=\sqrt{14}(0.5)\) also gives \(3/\sqrt{14}\).

Common mistake avoided. The factor is \(\sqrt{pq}=0.5\), not \(pq=0.25\). Multiplying the mean difference divided by \(\sigma_X\) by \(pq\) would incorrectly give 0.4009.

Two Binary Predictors: The Phi Coefficient

For two 0/1 indicators, the Pearson correlation is the phi coefficient. Arrange the observations in a \(2\times2\) table, where \(a,b,c,d\) are the cell counts in row order. Then

$$ \phi=\frac{ad-bc}{\sqrt{(a+b)(c+d)(a+c)(b+d)}}. $$

This is a signed measure: the sign reflects whether the coded 1s tend to occur together or in opposite combinations. Reversing the coding of either indicator changes the sign; reversing both preserves it. Thus the sign is meaningful only when the indicator definitions and coding are stated. The magnitude is unchanged by swapping either indicator's coding.

Worked Example: Association Between Two Binary Flags

A hypothetical service team records whether each of 100 cases has flag \(B=1\) and flag \(C=1\). The table gives 30 cases with both flags, 10 with \(B=1,C=0\), 20 with \(B=0,C=1\), and 40 with neither flag. Calculate their phi coefficient.

Method. Set \(a=30\), \(b=10\), \(c=20\), and \(d=40\). The numerator is \(ad-bc=30(40)-10(20)=1200-200=1000\). The denominator is \( \sqrt{(30+10)(20+40)(30+20)(10+40)} =\sqrt{40(60)(50)(50)}=\sqrt{6{,}000{,}000}=2449.4897 \).

Therefore \( \phi=1000/2449.4897=0.4082 \), rounded to four decimal places. The positive value indicates that the two indicators occur together more often than would be expected from a negative association under these codings. As a check, the margins are 40 and 60 for \(B\), and 50 and 50 for \(C\); the formula's four denominator factors are exactly those row and column totals.

Common mistake avoided. The numerator is the cross-product difference \(ad-bc\), not the difference between the two diagonal cell counts alone. The margins are also essential: a raw difference in counts is not a standardized association measure.

Two Categorical Predictors: Cramer's V

For nominal variables with \(r\) and \(c\) levels, form an \(r\times c\) contingency table. Let \(n_{ij}\) be the observed count in cell \((i,j)\), and let \(E_{ij}\) be its independence expected count, computed as row total times column total divided by the overall total \(n\). The Pearson chi-square statistic is

$$ \chi^2=\sum_{i=1}^{r}\sum_{j=1}^{c}\frac{(n_{ij}-E_{ij})^2}{E_{ij}}, \qquad V=\sqrt{\frac{\chi^2}{n\min(r-1,c-1)}}. $$

Cramer's V ranges from 0 to 1 and has no sign: it measures strength, not which category is associated with which. It is unchanged by relabeling the categories. V equals 0 when the observed counts match the independence expected counts, though in a finite sample a value near zero does not establish independence in the population.

Worked Example: Comparing Two Nominal Factors

A hypothetical operations review classifies 100 records by a three-level process type and a two-level routing status. The counts by process type are \((20,10)\), \((10,20)\), and \((20,20)\). Calculate Cramer's V.

Method. The row totals are 30, 30, and 40; the two column totals are 50 and 50. Under independence, the expected counts are \((15,15)\), \((15,15)\), and \((20,20)\), because each expected value is its row total multiplied by its column total and divided by 100.

The first row contributes \( (20-15)^2/15+(10-15)^2/15=25/15+25/15=10/3 \). The second row contributes the same \(10/3\); the third contributes zero. Thus \(\chi^2=20/3=6.6667\). Here \(\min(r-1,c-1)=\min(2,1)=1\), so \( V=\sqrt{(20/3)/(100(1))}=\sqrt{1/15}=0.2582 \), rounded to four decimal places.

Common mistake avoided. The denominator uses \(n\) times the smaller of \(r-1\) and \(c-1\). Using the larger dimension's adjustment would give a different and incorrect value for this table.

Numeric and Multi-Level Categorical: Eta

When a numeric variable \(X\) is compared across a categorical predictor with multiple levels, eta squared measures the fraction of total variation in \(X\) attributable to differences between the observed group means. For \(G\) groups, define the between-group sum of squares \(SS_{\text{between}}=\sum_{g=1}^{G}n_g(\bar{x}_g-\bar{x})^2\) and total sum of squares \(SS_{\text{total}}=\sum_{i=1}^{n}(x_i-\bar{x})^2\). Then \(\eta^2=SS_{\text{between}}/SS_{\text{total}}\), and \(\eta=\sqrt{\eta^2}\). Eta is nonnegative and does not give a direction or describe the ordering of groups. It can detect differences in group means even when no single numeric coding of the categories is justified.

Worked Example: Numeric Values Across Three Categories

For a hypothetical study, numeric measurements in categories A, B, and C are respectively \((1,3)\), \((4,6)\), and \((8,10)\). Calculate eta squared and eta.

Method. The group means are 2, 5, and 9. The overall mean is \((1+3+4+6+8+10)/6=32/6=16/3\). The between-group sum of squares is \(2(2-16/3)^2+2(5-16/3)^2+2(9-16/3)^2 =2(100/9+1/9+121/9)=444/9=148/3\).

The total sum of squares can be calculated from the six observations: \(SS_{\text{total}}=\sum x_i^2-n\bar{x}^2=226-6(16/3)^2=226-512/3=166/3\). Therefore \(\eta^2=(148/3)/(166/3)=74/83=0.8916\), and \(\eta=\sqrt{74/83}=0.9442\), both rounded to four decimal places. The within-group sum of squares is \(SS_{\text{total}}-SS_{\text{between}}=(166-148)/3=6\), which confirms that \(SS_{\text{between}}+SS_{\text{within}}=SS_{\text{total}}\).

Common mistake avoided. Eta squared is a ratio of sums of squares, not the ratio of the largest and smallest group means. A high value here indicates that group means account for much of the observed variation; it does not show that category membership causes the numeric measurements.

Limits and Practical Interpretation

Association summaries are screening tools, not complete descriptions of predictor relationships. A correlation near zero rules out neither a nonlinear pattern nor a relationship that is strong only within certain subgroups. Cramer's V can indicate a strong categorical association without showing which cells drive it, so inspect the table or cell-level residuals when interpretation matters. Eta can conceal differences in group distributions when group means are similar.

Sparse levels require particular caution. A category with very few observations can make estimated associations unstable, and small expected counts can make a chi-square approximation for inferential testing unreliable. Cramer's V can also be larger in tables with many levels, even after its dimension adjustment; compare values in context rather than treating one cutoff as universal. These summaries depend only on the observed pair and do not account for other predictors, outcome relevance, or predictive performance.

  • Use the stated 0/1 coding when reporting a binary correlation, since recoding can reverse its sign.
  • Do not calculate Pearson correlation from arbitrary codes for a nominal factor with more than two levels.
  • Report Cramer's V as nonnegative strength, and inspect the contingency table to understand the pattern.
  • Interpret eta as a descriptive fraction of variation associated with group means, not as a causal effect.

A suitable association measure makes mixed-type screening more coherent, but it does not make different measures directly interchangeable. A point-biserial correlation and Cramer's V have different interpretations, even if both are displayed as numbers between zero and one in magnitude. Use the measure that matches the variable types, preserve the underlying summaries for interpretation, and avoid treating a single association value as a final decision about predictor usefulness.

Check Your Understanding

For each pair, identify the relevant measure and work through the calculation or interpretation requested.

  1. A numeric score has \(\sigma_X=5\). A binary indicator has \(p=0.25\), and the group means are \(\bar{x}_1=18\) and \(\bar{x}_0=12\). Calculate the point-biserial correlation, using the stated coding. (Answer: 0.5196)
  2. Two binary indicators have counts \(a=18\), \(b=12\), \(c=6\), and \(d=24\). Calculate phi using the cross-product formula and state its sign. (Answer: \(0.4082\), positive)
  3. A \(2\times3\) table has rows \((30,10,10)\) and \((10,20,20)\), with \(n=100\). The expected rows under independence are \((20,15,15)\) and \((20,15,15)\). Calculate \(\chi^2\), then Cramer's V. (Answer: \(\chi^2=16.6667\), \(V=0.4082\))
  4. A numeric measurement is compared across three nominal categories. Its total sum of squares is 50 and its between-group sum of squares is 18. Calculate eta squared and eta, and say whether eta indicates direction. (Answer: \(\eta^2=0.3600\), \(\eta=0.6000\); eta does not indicate direction)
  5. A \(4\times3\) categorical table has \(n=120\) and Pearson \(\chi^2=24\). Calculate Cramer's V using the correct dimension adjustment. (Answer: \(V=\sqrt{24/(120\cdot2)}=0.3162\))
Clinical Biostats