← 3. Relationships & regression
Crosstab · chi-square
Try this analysis →

Crosstab Analysis and the Chi-Square Test

Crosstab analysis organizes counts and proportions for each combination in a table, and the chi-square test decides whether those differences are statistically significant.

Contingency tableObserved · expected frequenciesχ² test of independenceCramér's V

Men60%40%Women40%60%50%Prefer online shoppingDo not preferχ² = 8.00 · p = .0047

Do men and women prefer different products? Do the shopping channels people mainly use differ by age group? What is the relationship between education level and employment status?

The standard methods for checking how two categorical variables are related, as in these questions, are crosstabulation and the chi-squared test.

Crosstab analysis organizes counts and proportions for each combination of two variables in a table. The chi-square test decides whether the differences that appear are statistically significant. The two methods play different roles, but in real surveys and statistical analyses they are often used together.

They are especially useful for analyzing data divided into categories, such as gender, age group, occupation, product preference or purchase experience. In this article, we look at crosstab analysis and the chi-square test from their basic concepts through a real example, how to interpret the results table, effect sizes and what to check before the analysis.

SECTION 1

What is crosstab analysis?

Crosstab analysis combines two or more categorical variables to check the frequency and proportion of data falling in each category.

The results are usually shown in a form called a crosstab or contingency table. For example, suppose you surveyed 200 customers about their gender and whether they prefer online shopping.

Gender is divided into men and women, and online shopping preference into 'prefer' and 'do not prefer.' Organizing the collected data in a contingency table gives the following.

GenderPrefer online shoppingDo not preferTotal
Men6040100
Women4060100
Total100100200
Prefer online shoppingDo not preferMen60%40%Women40%60%50%
Online shopping preference by gender

The table shows that 60 of 100 men preferred online shopping, while 40 of 100 women preferred it. In other words, the rate of preferring online shopping was 60% for men and 40% for women. Crosstab analysis shows that the response distributions of the two groups differ.

But an important question remains.

Is the observed 20-percentage-point difference statistically significant?

To answer this question, you can use the chi-square test.

SECTION 2

How is crosstab analysis different from frequency analysis?

To understand crosstab analysis, it helps to first know how it differs from frequency analysis.

Frequency analysis checks how often each value appears in a single variable. Crosstab analysis, by contrast, combines two or more variables to compare distributions by category. For example, suppose you surveyed 200 customers about their preferred shopping channel.

Frequency analysis

Shopping channelRespondentsShare
Online10050%
In-store10050%
Total200100%

Frequency analysis shows that half of all customers prefer online shopping. But it cannot tell you which customers prefer online shopping.

Crosstab analysis

GenderOnlineIn-store
Men60%40%
Women40%60%

Crosstab analysis lets you see how shopping channel preferences differ by gender. In other words, if frequency analysis shows the distribution of one variable, crosstab analysis shows the distribution across combinations of several variables.

AspectFrequency analysisCrosstab analysis
Main purposeCheck the distribution of a single variableCompare distributions across variable combinations
Typical outputFrequencies, percentagesContingency table, row and column percentages
Example questionHow many people prefer online shopping?Does the rate of preferring online shopping differ by gender?
Main useUnderstanding overall responsesExploring response differences between groups

Both analyses can be used as descriptive statistical methods for summarizing and understanding data.

SECTION 3

Which percentages should you look at in a contingency table?

One thing to watch in crosstab analysis is the basis on which percentages are calculated.

Even for the same contingency table, what you are describing changes depending on whether you use row or column percentages. Typically you can look at row percentages, column percentages and total percentages.

Row percentage

Row percentages are calculated based on each row's total. If gender is set as the row in the earlier example, they look like this.

GenderPrefer online shoppingDo not prefer
Men60%40%
Women40%60%

This table shows the share preferring online shopping within each gender group. So it suits the question, 'How do men's and women's shopping channel preferences differ?'

Column percentage

Column percentages are calculated based on each column's total.

GenderPrefer online shoppingDo not prefer
Men60%40%
Women40%60%

In this example each column total is also 100, so the numbers come out the same. But the meaning is different: among people who prefer online shopping, 60% are men and 40% are women.

Column percentages are generally used to check the composition of the people who chose a particular response.

Total percentage

Total percentages are calculated based on the whole sample. For example, if 60 of all 200 people are men who prefer online shopping, the total percentage is 30%. Which percentage is more appropriate depends on the analysis question.

To compare differences in preference by gender, it is usually easiest to look at the proportions within each gender group.

So when reporting crosstab results, you should clearly indicate which group the percentages were calculated on.

SECTION 4

What is the chi-square test?

The chi-square test compares the observed frequencies by category with the frequencies expected under a statistical hypothesis.

When used with crosstab analysis, it mainly means the chi-squared test of independence. The chi-squared test of independence checks whether two categorical variables are independent of each other, that is, whether they are statistically related.

For example, if gender and shopping channel preference are independent, you would expect shopping channel preference rates not to differ systematically by gender. Conversely, if the two variables are related, the actually observed frequencies may differ from the frequencies expected under independence.

The chi-squared test of independence evaluates these differences statistically.

Hypotheses of the chi-square test

The following hypotheses are usually set.

Null hypothesis (H₀): The two categorical variables are independent.

Alternative hypothesis (H₁): The two categorical variables are not independent.

The chi-square test computes a test statistic based on the differences between observed and expected frequencies. The chi-square statistic is written as follows. χ² = Σ (O - E)² / E

Here O is the observed frequency and E is the expected frequency. The larger the differences between observed and expected frequencies, the larger the chi-square statistic generally becomes. Statistical significance, however, is judged with the p-value calculated from the chi-square statistic and the degrees of freedom.

SECTION 5

How do observed and expected frequencies differ?

To understand the chi-square test, you need to know the difference between observed and expected frequencies.

The observed frequency is the count found in the actual data. The expected frequency is the count expected under the assumption that the two variables are independent.

Let's use the gender and online shopping preference example from earlier again.

Actual observed frequencies

GenderPrefer onlineDo not prefer
Men6040
Women4060

There are 100 men and 100 women in total. Also, 100 people prefer online shopping and 100 do not. If the two variables are independent, you would expect the share preferring online shopping to be the same in each gender, based on the overall distribution.

Expected frequencies are calculated as follows.

Expected frequency = (row total × column total) ÷ total sample size

So the expected frequency for men who prefer online shopping is (100 × 100) ÷ 200 = 50.

Calculating the expected frequency of every cell the same way gives the following.

Expected frequencies under independence

GenderPrefer onlineDo not prefer
Men5050
Women5050
ObservedPreferNot preferMen6040Women4060ExpectedPreferNot preferMen5050Women5050Compare
Observed and expected frequencies

The observed frequencies differed between 60 and 40, but in the expected frequencies every cell was 50. The chi-square test evaluates whether such differences can be explained by chance sampling variation.

SECTION 6

Real-world example: are gender and online shopping preference related?

Let's look again at the case of surveying 200 customers about gender and whether they prefer online shopping.

The research question is as follows.

"Is there a statistically significant association between gender and online shopping preference?"

Crosstab results

GenderPreferNot preferTotal
Men60 (60%)40 (40%)100
Women40 (40%)60 (60%)100
Total100100200

Values in parentheses are row percentages calculated within each gender group.

Chi-square test results

IndicatorResult
Sample size (N)200
Pearson chi-square (χ²)8.00
Degrees of freedom (df)1
p-value0.0047
Phi coefficient (φ)0.20

No continuity correction was applied.

Men · prefer(60 − 50)² ÷ 502.0Men · not prefer(40 − 50)² ÷ 502.0Women · prefer(40 − 50)² ÷ 502.0Women · not prefer(60 − 50)² ÷ 502.0Totalχ²8.00df 1 · p = .0047
Calculating the chi-square statistic

How do you interpret the results?

While 60% of male respondents preferred online shopping, 40% of female respondents did. The two groups differed by 20 percentage points. The chi-square test gave χ²(1) = 8.00, p = .0047.

Because the p-value is smaller than the usual significance level of 0.05, you can reject the null hypothesis that gender and online shopping preference are independent. So you can interpret that there is a statistically significant association between gender and online shopping preference.

However, a statistically significant association does not let you conclude that gender directly causes shopping channel preference.

That is because other factors, such as age, occupation and purchase experience, may also be involved.

SECTION 7

How do you interpret the p-value of a chi-square test?

In a chi-square test, the p-value is the probability, under the null hypothesis that the two variables are independent, of getting a chi-square statistic as large as the one actually observed or more extreme.

If the significance level is set at the usual 0.05, decisions are made as follows.

p-valueUsual decision
p < .05Reject the null hypothesis; statistically significant association
p ≥ .05Not enough evidence to reject the null hypothesis

For example, p = .003 means that, assuming the two variables are independent, the probability of a difference at least as large as the one observed is about 0.3%. But a small p-value does not mean the relationship between the two variables is strong. With a very large sample, even a small association can be statistically significant.

Conversely, with a small sample, even a relatively large difference in proportions may not be statistically significant. So in a chi-square test it is important to look not only at the p-value but also at the proportions in the actual contingency table and the effect size.

SECTION 8

What are the phi coefficient and Cramér's V?

In a chi-square test, it matters not only whether the result is statistically significant but also how strong the association between the two variables is.

For this you can use effect size measures such as the phi coefficient and Cramér's V.

Phi coefficient

The phi coefficient is an association measure used mainly for 2×2 contingency tables, where each variable has two categories. In the earlier gender and online shopping preference example, the phi coefficient was 0.20. This indicates how strong the association between the two variables is.

However, when interpreting the size of the value, consider the research field and the purpose of the analysis.

Cramér's V

Cramér's V is an effect size measure that can be used not only for 2×2 tables but also for tables with more categories. For example, dividing age into 20s, 30s, 40s and 50s and preferred brand into A, B and C produces a 4×3 contingency table.

Here too, you can use Cramér's V to check the size of the association between the two variables.

IndicatorMain useRange of values
Phi coefficientMainly 2×2 tables−1 to 1 under the signed definition for 2×2 tables
Cramér's VTables of various sizes0~1

A Cramér's V close to 0 indicates a weak association, and values closer to 1 indicate a stronger association. However, interpretation criteria can vary with the number of categories in the two variables, the sample size and the research context, so it is best to avoid applying a one-size-fits-all standard.

SECTION 9

If the chi-square test is significant, in which categories did the differences arise?

The chi-square test checks whether there is an overall association between two variables.

But in a table with many categories, it can be hard to see which specific cells had more or fewer responses than expected. For example, suppose you compared four age groups and three brands.

Even if the chi-square test is significant, it does not tell you directly which age group chose which brand relatively often. In such cases you can check the standardized residuals or adjusted standardized residuals.

Brand ABrand BBrand C20s+2.4−1.1−1.330s+0.9+0.2−1.040s−1.2+1.8−0.650s−2.1−0.8+2.6More than expectedFewer than expectedSolid circle = |residual| ≥ 1.96
Residuals by cell

What is residual analysis?

A residual is the difference between the actually observed frequency and the expected frequency.

Standardized or adjusted standardized residuals let you compare how large the difference is in each cell. However, if you examine many cells at once, consider the multiple comparisons problem, and do not interpret a large residual as evidence of a causal relationship.

SECTION 10

What kinds of chi-square tests are there?

There are several types of chi-square tests.

The main ones are the goodness-of-fit test, the test of independence and the test of homogeneity.

TestPurposeExample use
Chi-square goodness-of-fit testTests whether the observed distribution across categories matches a specified expected distributionAre the selection rates for each product color equal?
Chi-square test of independenceTests whether two categorical variables are associatedAre gender and brand preference related?
Chi-square test of homogeneityTests whether the categorical distributions of different populations or groups are the sameAre product preference rates the same across regions?

Chi-square goodness-of-fit test

Checks whether the observed distribution of one categorical variable matches a distribution set in advance. For example, you can test whether four product colors are chosen in equal proportions.

Chi-square test of independence

Checks whether two categorical variables are independent. It is used to analyze the relationship between two variables, such as gender and brand preference, or age group and service use.

Chi-square test of homogeneity

Compares whether the categorical response distributions of different groups are the same. For example, you can check whether the brand preference distributions of customers sampled separately in New York, Chicago and Houston are the same. The test of independence and the test of homogeneity use similar calculations on a contingency table, but they differ in the research question and the sampling design.

The chi-square test examined in this article alongside crosstab analysis is mainly the test of independence.

SECTION 11

Assumptions to check before a chi-square test

The chi-square test is useful for analyzing categorical data, but it must be used under appropriate conditions.

Check that the data are frequency data.

The chi-square test of independence generally uses observed frequencies for each combination of categories. It is not appropriate to enter means or percentages as if they were frequencies. Check that the analysis data represent frequencies of actual observations.

Check that observations are independent.

In the usual chi-square test of independence, observations must be independent of each other. For example, treating the same person's responses before and after using a service as two independent observations can cause problems. To compare the same subjects' before-and-after binary responses, McNemar's test or similar may be more appropriate.

Check that expected frequencies are not too small.

Depending on sample size and expected frequencies, the approximation using the chi-square distribution can become inaccurate. The traditional rule of checking whether expected frequencies are 5 or more is often used, but actual adequacy depends on the size of the table and the share of small expected frequencies.

So you should not judge solely by the simple rule that every cell's expected frequency must be 5 or more. When expected frequencies are small, you can consider Fisher's exact test or other exact or simulation-based methods.

Check that the categories are defined appropriately.

For example, dividing age groups too finely can leave very few observations in each cell. Conversely, forcibly merging categories with different meanings can make important differences disappear. So the criteria for dividing categories should be decided based on the research purpose and the characteristics of the data.

Check for missing values.

If survey responses are missing, the sample size used in the crosstab analysis can change. Before the analysis, decide whether to exclude missing values or treat them as a separate category. However, treating missing values as a response category is not always appropriate. Consider why the data are missing and the research purpose.

SECTION 12

How do the chi-square test and correlation analysis differ?

The chi-square test and correlation analysis both look at relationships between variables, but they differ in the data they mainly use and the meaning of their results.

AspectCrosstab · chi-square testCorrelation analysis
Main purposeCheck association between categorical variablesAnalyze the direction and strength of a relationship between two variables
Typical dataGender, occupation, purchase (yes/no), preferred brandStudy time, test scores, income, satisfaction rank
Main indicatorsχ², p-value, Cramér's VPearson r, Spearman ρ, etc.
Direction of relationshipThe usual χ² statistic does not indicate directionThe sign of the correlation coefficient can show direction
Main resultDistribution by category and test of independenceDirection and strength of the relationship

For example, to analyze the relationship between gender and brand preference, you could consider crosstab analysis and the chi-square test. To check the linear relationship between study time and test scores, on the other hand, you could consider Pearson correlation analysis.

Of course, there are also association measures for categorical variables that can carry a sign, such as the phi coefficient, and other association methods may be used depending on the measurement level of the data. So when choosing an analysis, consider both the measurement level of the variables and the research question.

SECTION 13

How do you report crosstab and chi-square test results?

In a research paper or analysis report, it is good to report not only the frequencies and percentages in the contingency table but also the chi-square statistic, degrees of freedom, p-value and effect size.

Using the earlier gender and online shopping preference example, you could write it as follows.

Example of reporting results

Crosstab analysis and a Pearson chi-square test of independence were conducted to examine the association between gender and online shopping preference. In the crosstab analysis, the rate of preferring online shopping was 60.0% for men and 40.0% for women. The chi-square test showed a statistically significant association between the two variables, χ²(1, N = 200) = 8.00, p = .005, φ = .20.

Reporting results this way lets readers see not only the response distribution in each group but also whether there is a statistically significant association and how strong it is. In real research, it is also good to state, as needed, the sample size in each group, the basis for calculating percentages and how missing values were handled.

SECTION 14

Where can crosstab analysis and the chi-square test be used?

Crosstab analysis and the chi-square test are used in many fields that want to check relationships between categorical variables.

Marketing and management

You can analyze brand preference by age group, purchase experience by gender, service use by customer type and more.

Surveys and social science research

You can look at differences in the distribution of attitudes or choices by respondent characteristics such as gender, occupation and education level.

Education research

You can analyze preferred learning styles by grade, participation in and completion of educational programs, learning types by student characteristics and more.

Health and medical research

You can compare the association between lifestyle habits and particular health conditions, whether symptoms occur by group, categorical outcomes by treatment group and more.

HR and organizational research

You can analyze turnover intentions by department, training participation by job level, and the relationship between work arrangements and preferences for benefit programs.

Market research

You can check differences in product choice, ad awareness, purchase experience and brand preference across consumer groups. It is a basic analysis method especially for checking whether response rates in a survey differ by respondent characteristics.

✓Wrap-up

Crosstab analysis shows differences, and the chi-square test judges association.

Crosstab analysis compares response distributions between groups by checking the frequencies and proportions for each combination of two categorical variables.


The chi-square test of independence decides whether there is a statistically significant association between such categorical variables. Using the two methods together lets you see not only which responses appeared most in which group, but also how statistically distinct the observed differences in distribution are.

However, a significant chi-square test does not prove a causal relationship between the two variables. It is also important to look not only at the p-value but also at the actual frequencies and percentages and effect sizes such as the phi coefficient or Cramér's V.

KEY TAKEAWAY

The purpose of crosstab analysis and the chi-square test is not simply to compare response counts by group, but to understand statistically the differences and associations that appear in categorical data.