Statistics & Quantitative Methods for Analytics

Chapter 9
Categorical Data and Non-Parametric Methods

Diploma in Business Analytics
Statistics & Quantitative Methods for Analytics   •   Diploma

Categorical Data and Non-Parametric Methods

Introduction

Business analysts frequently work with data that are not measured on a meaningful numerical scale. Customer segment, payment method, complaint type, subscription status, satisfaction category and product choice are categorical variables. Other variables, such as service ratings from 1 to 5, are ordinal: their categories have an order, but the differences between adjacent categories cannot automatically be assumed equal.

Many familiar statistical procedures, including the t-test, analysis of variance and Pearson correlation, rely on assumptions such as numerical measurement, approximate normality, independent observations and equal variances. When these assumptions are inappropriate, contingency-table analysis and non-parametric methods provide useful alternatives. These methods do not mean “assumption-free” statistics. Rather, they make different and often less restrictive assumptions.

This chapter explains how to summarise categorical data, investigate relationships using contingency tables and chi-square tests, and apply selected rank-based procedures to ordinal, skewed or non-normal data. Emphasis is placed on interpretation, practical decision-making and responsible use of statistical evidence.

Learning Objectives

By the end of this chapter, you should be able to:

  1. Distinguish nominal, ordinal, discrete numerical and continuous variables.
  2. Construct and interpret frequency tables, relative frequencies and contingency tables.
  3. Calculate expected frequencies and apply the chi-square goodness-of-fit and independence tests.
  4. Explain standardised residuals, effect size and the assumptions of chi-square analysis.
  5. Select and interpret the sign test, Wilcoxon signed-rank test, Mann–Whitney U test, Kruskal–Wallis test and Spearman’s rank correlation.
  6. Report results without confusing statistical significance with practical importance.
  7. Recognise limitations involving sampling, dependence, sparse cells, ties, multiple testing and ethical interpretation.

1. Measurement Scales and Data Structure

A variable’s measurement scale determines which summaries and tests are defensible.

ScaleMeaningExamplesSuitable summaries
NominalCategories have no inherent orderRegion, browser, payment methodCounts, percentages, mode
OrdinalCategories have an order, but unequal spacing is not establishedSatisfaction level, risk bandCounts, percentages, median, ranks
IntervalEqual numerical intervals, but no true zeroTemperature in °CMean, standard deviation, correlation
RatioEqual intervals and meaningful zeroRevenue, waiting time, units soldAll standard numerical summaries

A categorical variable may be binary, such as churned/not churned, or polytomous, such as product category. Categories should be mutually exclusive and collectively exhaustive for the intended population. If a respondent can select several options, the data are multiple-response data and require a different denominator for each category.

For category i, the sample proportion is:

p̂i = ni / n

where n_i is the number of observations in category i and n is the total number of valid observations. The percentage is 100p̂_i. Missing observations should be reported rather than silently included or excluded.

2. Frequency Tables and Contingency Tables

A frequency table records how often each category occurs. A contingency table cross-classifies two categorical variables. For example, an analyst may examine whether payment method differs between retained and churned customers.

Payment methodRetainedChurnedRow total
Card12030150
Direct debit9020110
Wallet402060
Column total25070320

Counts alone can mislead when group sizes differ. Percentages should be calculated using a denominator that matches the question. Row percentages answer “within this payment method, what percentage churned?” Column percentages answer “among churned customers, what payment methods were used?” A professional report identifies the denominator explicitly.

The table can be viewed as a joint distribution of two variables. Row and column totals are marginal distributions. The question of independence is whether the distribution of one variable changes across the categories of the other.

3. Chi-Square Tests

3.1 Chi-square goodness-of-fit test

The goodness-of-fit test compares observed category counts with hypothesised counts. It can test, for example, whether four delivery options are selected equally often.

χ² = ∑(Oi − Ei)² / Ei

Here O_i is the observed count in category i, E_i is its expected count under the null hypothesis, and the summation covers all k categories. If hypothesised proportions are q_i and the sample size is n, then:

Ei = n qi

The usual hypotheses are H₀: the population category proportions equal the specified proportions, and H₁: at least one proportion differs. When parameters have not been estimated from the same data, the reference degrees of freedom are k − 1. A small p-value indicates inconsistency with H₀, not proof of a particular alternative pattern.

Worked example: goodness of fit

A retailer records 100 delivery choices: standard 46, next-day 29 and collection 25. Management’s model predicts proportions 0.50, 0.30 and 0.20. Expected counts are 50, 30 and 20.

χ² = (46−50)²/50 + (29−30)²/30 + (25−20)²/20
= 0.32 + 0.0333 + 1.25
= 1.6033

There are 3 − 1 = 2 degrees of freedom. At the 5% level, the critical value is approximately 5.991. Since 1.6033 is smaller, the result is not statistically significant at that level. The sample does not provide sufficient evidence that the stated proportions are incorrect. This does not establish that the model is exactly true.

3.2 Chi-square test of independence

The independence test examines whether two categorical variables are associated. The hypotheses are H₀: the variables are independent in the population, and H₁: they are associated.

For a table with r rows and c columns, the expected count in cell (i, j), assuming independence, is:

Eij = (Ri × Cj) / n

where R_i is row i’s total, C_j is column j’s total and n is the grand total. The test statistic is:

χ² = ∑∑(Oij − Eij)² / Eij

The degrees of freedom are:

df = (r − 1)(c − 1)

Worked example: independence

Using the payment table above, the expected count for Card and Churned is:

E = (150 × 70) / 320 = 32.8125

The expected counts for the six cells are approximately 117.188, 32.813, 85.938, 24.063, 46.875 and 13.125. Substituting all six observed and expected counts gives approximately χ² = 7.77, with df = (3 − 1)(2 − 1) = 2. The result would be statistically significant at the 5% level because 7.77 exceeds 5.991. The analyst may conclude that payment method and churn status are associated in this sample, while avoiding the claim that payment method causes churn.

3.3 Interpreting cells and residuals

A significant overall chi-square statistic does not identify which cells create the association. A Pearson residual is:

rij = (Oij − Eij) / √Eij

Positive values indicate more observations than expected; negative values indicate fewer. Large absolute residuals highlight cells requiring investigation. Adjusted residuals may be preferable when making approximate cell-level significance assessments, but analysts should account for multiple comparisons and should not treat residuals as automatic proof of a business explanation.

For a 2 × 2 table, the phi coefficient is an effect-size measure:

φ = √(χ² / n)

For larger tables, Cramér’s V is commonly used:

V = √[χ² / (n × min(r − 1, c − 1))]

Both measures range from 0 to 1 for the usual non-negative interpretation, although the meaning of a “small” or “large” value depends on context, table size and field conventions. Statistical significance is influenced by sample size; effect size and confidence intervals are therefore important.

4. Assumptions and Practical Decisions in Chi-Square Analysis

Chi-square procedures require independent observations. A person, account or transaction should not be counted repeatedly unless the design and analysis explicitly accommodate dependence. Categories must be clearly defined, and expected counts should not be excessively small. A common practical guideline is that expected counts should generally be at least 5, although rules differ and the exact sampling distribution may still be adequate in some settings.

When expected counts are sparse, combine substantively similar categories only when this is defensible, collect more data, use an exact method, or apply a model designed for sparse data. For a small 2 × 2 table, Fisher’s exact test may be appropriate. It evaluates the table using the exact hypergeometric distribution under a fixed-margin framework; it is not simply a correction to chi-square.

A chi-square test also does not establish causation, temporal direction or practical value. Large datasets can produce very small p-values for trivial differences. Conversely, a non-significant result may reflect low power, poor measurement or a genuinely small association.

5. Non-Parametric Methods and Ranks

Non-parametric methods are useful when measurement is ordinal, distributions are strongly skewed, outliers are influential, or parametric assumptions are not credible. Many compare ranks rather than raw values. Ranking replaces the smallest observation with rank 1, the next with rank 2 and so on. Tied values receive average ranks.

These methods are not automatically superior. They may test a different parameter or require their own assumptions. For example, a rank test may be interpreted as a location comparison only when group distributions have broadly similar shapes. Otherwise, a significant result may reflect differences in spread or shape rather than a simple shift in central tendency.

5.1 Sign test

The sign test examines paired differences while using only their direction. For each pair, zero differences are omitted. Under H₀ of no directional tendency, the number of positive differences follows a binomial distribution with probability 0.5:

X ~ Binomial(m, 0.5)

where m is the number of non-zero pairs. It is robust and suitable for ordinal data, but it discards magnitude and is usually less powerful than the Wilcoxon signed-rank test.

5.2 Wilcoxon signed-rank test

For paired or one-sample data, calculate non-zero differences, rank their absolute values, restore their signs and sum positive and negative ranks. The test examines whether the distribution of differences is symmetrically centred on zero. It assumes independent pairs, an ordinal-or-better outcome and, for the usual location interpretation, a roughly symmetric difference distribution. Ties and zero differences require appropriate software procedures.

5.3 Mann–Whitney U test

The Mann–Whitney U test compares two independent groups. Pool observations, rank them, and calculate rank sums. One common form is:

U₁ = n₁n₂ + [n₁(n₁ + 1)]/2 − R₁

where n₁ and n₂ are group sizes and R₁ is the rank sum for group 1. The alternative statistic is U₂ = n₁n₂ − U₁; software usually reports the smaller value. Under H₀, the groups have the same distribution. With similar distribution shapes, it is often described as a test of location or median difference, but that description is unsafe when shapes differ.

5.4 Kruskal–Wallis test

The Kruskal–Wallis test extends rank comparison to k ≥ 3 independent groups. If group j has size n_j and rank sum R_j, then the uncorrected statistic is:

H = [12 / (N(N + 1))] × ∑(Rj² / nj) − 3(N + 1)

where N is the total sample size. Under suitable conditions and the null hypothesis, H is approximately chi-square distributed with k − 1 degrees of freedom. Ties require a correction, normally supplied by statistical software. A significant result indicates that at least one group differs; it does not identify which groups. Post-hoc pairwise tests, such as Dunn’s procedure with multiplicity adjustment, are required for detailed comparisons.

5.5 Spearman’s rank correlation

Spearman’s correlation assesses monotonic association between two variables by correlating their ranks. When there are no ties, a computational formula is:

ρs = 1 − [6∑di² / (n(n² − 1))]

where d_i is the difference between the two ranks for observation i and n is the number of paired observations. With ties, compute Pearson correlation on the assigned ranks rather than relying on the no-ties shortcut. Values range from −1 to +1. A positive value indicates that higher values of one variable tend to accompany higher values of the other; it does not imply linearity, causation or absence of confounding.

6. Choosing an Appropriate Method

A disciplined selection process begins with the research question and study design, not with the software menu.

Question and data structureSuitable method
One categorical variable versus specified proportionsChi-square goodness of fit
Association between two categorical variablesChi-square independence test; exact alternative if needed
One paired ordinal measure before and afterSign test or Wilcoxon signed-rank
Two independent ordinal or non-normal groupsMann–Whitney U
Three or more independent ordinal or non-normal groupsKruskal–Wallis, followed by adjusted post-hoc tests
Monotonic association between two ordinal variablesSpearman’s rank correlation

The analyst should inspect the data first. Frequency counts, missingness, plots, group sizes, outliers and category definitions often reveal problems that a test cannot repair. The chosen method should be documented together with the null hypothesis, assumptions, effect size, confidence interval where available, p-value and substantive interpretation.

7. Illustrative Case: Customer Service Ratings

Background and problem

A fictional online retailer wants to know whether service ratings differ among three support channels: live chat, email and telephone. Customers rate service from 1 (very poor) to 5 (excellent). Because ratings are ordinal and show ceiling effects, management does not want to rely solely on a normal-theory ANOVA.

Analysis

A sample contains 45 independent customers: 15 per channel. The analyst first reports category percentages and medians, then examines the distributions. Telephone ratings have a median of 4, chat a median of 4 and email a median of 3. A Kruskal–Wallis test is selected because there are three independent groups and the outcome is ordinal.

The null hypothesis is that the rating distributions are the same across channels. Suppose the software output gives H = 8.42, df = 2 and p = 0.015. At α = 0.05, the overall result is statistically significant. The analyst then performs Dunn pairwise comparisons with a familywise adjustment. Suppose only email versus telephone remains significant after adjustment, while chat does not differ clearly from either channel.

Approach and outcome

Management should conclude that service ratings are not distributed identically across channels, with evidence of lower ratings for email than telephone. The result does not prove that telephone causes higher satisfaction. Differences in issue complexity, customer urgency, staffing or customer characteristics may confound the comparison. The practical decision should consider the size of the rating difference, response times, cost and the distribution of low ratings—not p-value alone.

Learning points

  1. The measurement scale and design guided method selection.
  2. An overall test was followed by multiplicity-controlled comparisons.
  3. Medians and distributions complemented inferential results.
  4. Association and group difference were not presented as causation.
  5. Operational decisions require effect size, cost and process knowledge.

8. Technology, Reproducibility and Ethical Practice

Spreadsheet tools and statistical packages can produce contingency tables, exact tests, rank tests, residuals and effect sizes quickly. Automation does not remove the need for data validation. Analysts should verify category labels, missing-value codes, duplicate records, expected frequencies and the definition of the observational unit. Reproducible scripts or documented workflows should preserve the data-cleaning decisions and software versions.

AI-assisted analytics can suggest a method or generate code, but its output must be independently checked. AI may misclassify ordinal data as continuous, overlook dependence, use an inappropriate asymptotic approximation or interpret association causally. Sensitive categories such as ethnicity, disability, health status or financial vulnerability require strict access controls, lawful processing, purpose limitation and fairness assessment.

Category construction can create or hide inequality. Combining minority categories may make a chi-square test feasible but erase important differences. Suppressing small cells may protect privacy but also affect interpretation. Analysts should disclose exclusions, missingness, recoding and uncertainty, and should avoid using statistically significant associations to justify discriminatory decisions.

9. Limitations and Best Practices

Important limitations include:

  • Dependence: repeated observations from the same person violate ordinary independence assumptions.
  • Sparse data: very small expected counts make asymptotic p-values unreliable.
  • Ties: ordinal scales commonly contain ties and require corrected rank calculations.
  • Multiple testing: many comparisons increase the chance of false positives.
  • Low power: non-significance does not demonstrate equality.
  • Confounding: observational associations may reflect other variables.
  • Loss of information: ranking or categorising numerical data can reduce precision.
  • Ambiguous interpretation: rank tests may detect distributional differences, not only median shifts.

A strong professional workflow is to define the estimand, inspect and document the data, select a method based on design and scale, check assumptions, report effect size and uncertainty, conduct justified sensitivity analyses, and translate results into decisions cautiously. Where possible, report the actual group percentages, medians or rank summaries rather than only a p-value.

Chapter Summary

Categorical and ordinal data are central to business analytics. Frequency tables describe category distributions, while contingency tables examine joint patterns. The chi-square goodness-of-fit test compares observed counts with specified proportions; the chi-square independence test compares observed counts with counts expected under independence. Expected counts are determined by marginal totals, and effect sizes such as φ and Cramér’s V help assess practical importance.

Non-parametric methods provide alternatives when data are ordinal, skewed, outlier-prone or unsuitable for standard parametric procedures. The sign test uses directions, the Wilcoxon signed-rank test uses signed ranks for paired data, the Mann–Whitney U test compares two independent groups, the Kruskal–Wallis test compares three or more groups, and Spearman’s correlation measures monotonic association through ranks. These methods still require design and distributional assumptions.

Sound analysis depends on correct denominators, independent observations, adequate expected counts, appropriate treatment of ties and missing data, multiplicity control and cautious interpretation. Statistical significance should be combined with effect size, uncertainty, subject-matter knowledge, ethical safeguards and business relevance.

Key Terms

Categorical variable: A variable whose values are categories rather than measured numerical quantities.

Nominal scale: A measurement scale with categories that have no natural order.

Ordinal scale: A scale with ordered categories but not necessarily equal intervals.

Frequency: The number of observations in a category.

Relative frequency: A category count divided by the total valid count.

Contingency table: A table showing the joint frequencies of categorical variables.

Marginal total: A row or column total in a contingency table.

Expected frequency: The count predicted under a specified null hypothesis.

Chi-square goodness-of-fit test: A test comparing observed counts with hypothesised category counts.

Chi-square independence test: A test of association between two categorical variables.

Degrees of freedom: The number of independent quantities that determine a reference distribution.

Pearson residual: The difference between observed and expected count divided by the square root of expected count.

Cramér’s V: An effect-size measure for association in a contingency table.

Non-parametric method: A method that does not require the usual normal-population assumptions of many parametric tests.

Rank: The ordered position assigned to an observation.

Sign test: A paired or one-sample test based on the direction of non-zero differences.

Wilcoxon signed-rank test: A paired test based on ranked absolute differences and their signs.

Mann–Whitney U test: A rank-based comparison of two independent groups.

Kruskal–Wallis test: A rank-based comparison of three or more independent groups.

Spearman’s rank correlation: A measure of monotonic association based on ranks.

Review Questions

Short Answer Questions

  1. What is the difference between nominal and ordinal data?
  2. Why can row percentages and column percentages lead to different interpretations?
  3. How are expected frequencies calculated in a chi-square independence test?
  4. State two assumptions of the chi-square test.
  5. Why does a significant Kruskal–Wallis result require follow-up comparisons?

Long Answer Questions

  1. Explain the chi-square goodness-of-fit test, including its hypotheses, statistic, degrees of freedom and interpretation.
  2. Describe how a contingency table can be used to investigate customer churn and payment method.
  3. Compare the sign test and Wilcoxon signed-rank test for paired ordinal data.
  4. Explain the assumptions and interpretation of the Mann–Whitney U test.
  5. Discuss why statistical significance should be reported alongside effect size and practical context.

Analytical / Application Questions

  1. A company observes 80 purchases across four product categories. Explain how you would test whether the categories are equally popular, including the expected counts and degrees of freedom.
  2. A survey compares satisfaction ratings across three independent service channels. Propose an analysis plan using descriptive summaries, an appropriate rank-based test and a post-hoc strategy.
  3. A 2 × 2 table produces a statistically significant chi-square result in a very large dataset, but Cramér’s V is very small. Explain how you would communicate this finding to a manager.

Multiple Choice Questions with Answers

Question 1

Which measurement scale has ordered categories but does not guarantee equal distances between categories?

A. Nominal

B. Ordinal

C. Interval

D. Ratio

Correct Answer: B. Ordinal

Question 2

In a chi-square independence test, the expected count for a cell is calculated as:

A. Observed count divided by the grand total

B. Row total multiplied by column total, divided by the grand total

C. Row total plus column total

D. Grand total divided by the number of cells

Correct Answer: B. Row total multiplied by column total, divided by the grand total

Question 3

A goodness-of-fit test has five categories and no parameters estimated from the data. What are its degrees of freedom?

A. 4

B. 5

C. 6

D. 25

Correct Answer: A. 4

Question 4

A positive Pearson residual indicates that a cell contains:

A. Fewer observations than expected

B. Exactly the expected number of observations

C. More observations than expected

D. A negative association by definition

Correct Answer: C. More observations than expected

Question 5

Which method is most appropriate for comparing three independent groups on an ordinal outcome?

A. Paired t-test

B. Mann–Whitney U test

C. Kruskal–Wallis test

D. Sign test

Correct Answer: C. Kruskal–Wallis test

Question 6

The Mann–Whitney U test is designed primarily for:

A. Two independent groups

B. Two paired measurements only

C. One categorical variable and specified proportions

D. Three or more paired measurements

Correct Answer: A. Two independent groups

Question 7

Spearman’s rank correlation measures:

A. Causation between two variables

B. Monotonic association based on ranks

C. Difference between two category proportions only

D. Equality of several variances

Correct Answer: B. Monotonic association based on ranks

Question 8

For the payment table in the chapter, the expected count for Card and Churned is approximately:

A. 13.125

B. 24.063

C. 32.813

D. 46.875

Correct Answer: C. 32.813

Question 9

If expected counts are very small in a 2 × 2 table, which alternative may be appropriate?

A. Fisher’s exact test

B. Pearson correlation

C. One-sample z-test for a mean

D. Linear regression without checking data

Correct Answer: A. Fisher’s exact test

Question 10

A significant Kruskal–Wallis test directly establishes that:

A. Every group differs from every other group

B. At least one group differs in distribution

C. The largest group causes the difference

D. All group medians are unequal

Correct Answer: B. At least one group differs in distribution

Statistics & Quantitative Methods for Analytics
Chapter 9 of 14