skip to content

Salary varies across 12 departments — how do you quantify how much of salary variation department accounts for?

level: seniorimportance: should knowfreq 38%

answer

  1. no ordering, so no correlation coefficient
  2. split the variance in two
  3. between-group over total sum of squares
  4. share of variation accounted for by group membership
  5. many levels on few rows inflates it

basics

~10 s

Use the correlation ratio eta. Eta-squared is the between-group sum of squares over the total sum of squares: the share of salary variance accounted for by department membership. It runs 0 to 1.

solid answer

~50 s

A correlation coefficient is not available here because department is nominal, so the right summary is the correlation ratio eta. Compute `eta^2 = SS_between / SS_total`, where SS_total sums squared deviations of every salary from the grand mean and SS_between sums n_d x (department mean - grand mean)^2 over departments. That is literally the fraction of salary variance accounted for by department membership, running from 0 when all department means coincide to 1 when salary is constant within each department. Two cautions. Eta-squared is biased upward: with no real differences at all its expected value is roughly (k - 1) / (n - 1), so 12 departments across 60 people gives about 0.19 from noise alone, and bias-adjusted variants exist. And it sees only differences in means, so departments with equal means but very different pay spreads score near 0.

go deeper

for a junior

Know that a nominal column with many levels cannot go into a correlation, and that the alternative summarises how much of the outcome's variation sits between groups rather than inside them.

for a middle

Write out the decomposition SS_total = SS_between + SS_within and explain that eta-squared is the between share, bounded in 0 to 1, sensitive only to differences in group means.

for a senior

Show the diagnostic instincts: check level counts and group sizes, compare against the (k - 1)/(n - 1) noise baseline, inspect individual group means and spreads, and refuse a causal reading.

for a principal

Decide how high-cardinality categorical columns are screened and reported across the org, including whether bias-adjusted measures are the default and how such numbers may be used in sensitive discussions like pay.

## Why a correlation coefficient does not apply Department is a nominal variable with 12 unordered levels. A correlation coefficient needs a direction to be positive or negative about, and there is no meaningful ordering of departments to supply one. What you can still ask is a question about explained variation: if I know which department someone is in, how much of the spread in salary have I accounted for? The correlation ratio, written eta, answers exactly that. ## The variance decomposition Let the grand mean be the mean salary of all n employees, and let department d have n_d employees with mean salary M_d. - SS_total = sum over all employees of (salary - grand mean)^2 - SS_between = sum over departments of n_d x (M_d - grand mean)^2 - SS_within = sum over all employees of (salary - own department mean)^2 These satisfy SS_total = SS_between + SS_within: total variation splits cleanly into variation between department averages and variation among individuals inside a department. `eta^2 = SS_between / SS_total = 1 - SS_within / SS_total` and eta is its square root. Eta-squared = 0.30 means 30 percent of the observed variation in salary is attributable to department membership and 70 percent lives inside departments. Eta-squared = 0 means every department pays the same on average; eta-squared = 1 means every employee within a department earns exactly the department mean, so department determines salary completely. ## Properties worth stating Eta imposes no ordering and no linearity. It does not care whether the department means rise or fall in any pattern, only that they differ, so it detects any arrangement of group means that a straight-line summary would miss. It is scale-invariant in the sense that a linear rescaling of salary leaves it unchanged, and it is bounded in 0 to 1 with no sign. With exactly two groups it reduces to a familiar quantity: eta equals the absolute value of the point-biserial correlation between the binary group flag and the outcome, and eta-squared equals its square. So the correlation ratio is the natural many-level generalisation of the binary-flag case. ## The upward bias, and why 12 levels makes it worse Eta-squared is a descriptive statistic of the sample, and it is biased upward as an estimate of any population quantity. Even with identical pay policies everywhere, random variation makes 12 sample department means differ, so SS_between is never 0. Under no real association its expected value is approximately (k - 1) / (n - 1) with k groups and n observations. With k = 12 and n = 60, that is 11/59, about 0.19, purely from noise. With n = 6,000 the same expression gives about 0.002, negligible. The lesson is that a many-level categorical variable will always look somewhat explanatory on a small sample: high-cardinality columns manufacture apparent explanatory power. Compare any eta-squared against that (k - 1)/(n - 1) baseline, watch out for departments with only a handful of employees, and prefer a bias-adjusted variant such as epsilon-squared or omega-squared when the number of levels is large relative to n. ## What eta misses Eta looks only at means. Two departments with the same average pay but one tightly clustered and one wildly dispersed contribute nothing to SS_between, so eta says nothing while the pay structures differ dramatically. It also says nothing about which departments are unusual, so follow it with a look at the individual department means and spreads. Salary distributions are typically right-skewed, and a small number of very high earners can move a department mean noticeably, so check whether one person is doing the work. Finally, eta is a description of association within this sample, not an attribution of cause. Department is entangled with role seniority, tenure, location and hiring market. An eta-squared of 0.30 says department membership tracks 30 percent of pay variation; it does not say department is why people are paid what they are paid, and using it that way in a pay-equity discussion is the mistake an interviewer is watching for.

  • How does the correlation ratio relate to the point-biserial correlation?
    With exactly two groups they coincide: eta equals the absolute value of the point-biserial correlation, and eta-squared equals its square. The correlation ratio is the generalisation to any number of unordered categories, keeping the explained-variation reading while giving up the sign, since more than two unordered levels have no direction to report.
  • What does eta fail to tell you about the department-salary relationship?
    Everything except differences in means. Departments with identical averages but very different pay dispersion contribute nothing, and eta never names which departments are unusual. It is also purely descriptive of the sample: department is confounded with role, tenure and location, so a high value is not an attribution of cause.
  • Why does a high-cardinality categorical column tend to look explanatory even when it is not?
    Because each extra level adds a group mean free to wander with sampling noise. Under no real association eta-squared runs around (k - 1) / (n - 1), so 50 levels on 200 rows yields roughly 0.25 from noise alone. Judge any value against that baseline, or use a bias-adjusted variant, before concluding the column carries signal.

saying these in an interview costs you the question

  • Correlates arbitrary department code numbers with salary
  • Reads eta-squared as a causal share of pay
  • Ignores the upward bias with many levels and few rows
  • Expects eta to detect equal means with different spreads
  • Thinks eta carries a sign or direction

context