Moodle - Statistics - Block III - Lesson 1
Table of contents
- Association and correlation
- Crosstabs
- Coefficients that can be obtained from crosstabs
- Covariance between two variables
- Correlation between numerical variables
1. Association and correlation
1.1 Association between variables
An association between variables exists when information about one variable provides insight into the other. This can occur with either categorical or quantitative variables 2.
- Association: when knowing the value or category of one variable provides information about another.
- Example: an association might exist between a tourist's country of origin and their chosen accommodation type (e.g., hotel, apartment, camping) 2.
1.2 Correlation between variables
Correlation is a specific type of association that applies to two quantitative variables, describing how they change together. Linear correlation quantifies the strength and direction of the linear relationship between these variables 3.
- Correlation: a type of association between two quantitative variables that describes their joint variation.
- Linear correlation: measures the strength and direction of the linear relationship between two quantitative variables.
- Example: a positive correlation between tourists' income and their average travel spending suggests that higher-income tourists generally spend more 3.
1.3 Association does not imply causation
The presence of an association or linear correlation between two variables does not automatically mean that one causes the other. A causal relationship implies that changes in one variable directly produce changes in another 4.
- Causation: a relationship where changes in one variable directly influence or produce changes in another.
- Confounding variable: an association or correlation may be explained by a third, unmeasured variable that influences both observed variables.
- Example: higher temperatures can increase both ice cream sales and swimming pool attendance, potentially leading to more pool accidents. In this case, temperature is a confounding variable 4.



2. Crosstabs
2.1 Introduction to Crosstabulations
A crosstabulation, also known as a contingency table, is a statistical tool used to display the joint distribution of two or more categorical variables. It organizes the categories of these variables into rows and columns, with each cell representing the frequency of observations that fall into a specific combination of categories.
This method is fundamental for bivariate analysis, allowing for the examination of relationships between variables 6 7 8 13.
The structure of a crosstabulation involves:
- Rows: Represent the categories of one variable.
- Columns: Represent the categories of another variable.
- Cells: Contain the absolute frequencies (counts) of observations for each combination of row and column categories 6 8 13.
For two categorical variables, X and Y, with r categories for X and k categories for Y, the table will have r rows and k columns. The total number of observations in the sample is denoted by n 6.
The table can be represented as:
-: y1*, y2*,..., yj*,..., yk*, Row Total
- X1*: n11, n12,..., n1j,..., n1k, n1.
- X2*: n21, n22,..., n2j,..., n2k, n2. -...:...,...,...,...,...,...,...
- Xi*: ni1, ni2,..., nij,..., nik, ni. -...:...,...,...,...,...,...,...
- Xr*: nr1, nr2,..., nrj,..., nrk, nr.
- Column Total: n.1, n.2,..., n.j,..., n.k, n 6 7 8 11 12 13.
2.2 Absolute Frequencies
Absolute frequencies in a crosstabulation represent the raw count of observations that fall into each specific cell, indicating how many times a particular combination of categories occurs in the sample. These counts are essential for understanding the raw distribution of data 6 8.
The notation nij denotes the absolute frequency for the cell at the intersection of row i and column j. The sum of all absolute frequencies across all cells equals the total number of observations, n 6.
📝 For a cell at the intersection of row i and column j, the absolute frequency nij represents the raw count of observations that fall into that specific combination of categories 6.
2.3 Marginal Distributions
Marginal distributions are the frequency distributions of a single variable within a crosstabulation, calculated independently of the other variable. They are found in the margins of the table, either in the row totals or the column totals 7 8 13.
- Row marginals (ni.): Represent the total frequency for each category of the variable displayed in the rows. They are calculated by summing the frequencies across each row.
- Column marginals (n.j): Represent the total frequency for each category of the variable displayed in the columns. They are calculated by summing the frequencies down each column 7 8 12 13.
The sum of all row marginals equals the total number of observations (n), as does the sum of all column marginals 7 8.
2.4 Relative Frequencies
Relative frequencies express the absolute frequencies as proportions or percentages of the total number of observations. They are calculated by dividing the absolute frequency of each cell by the total number of observations (n) 11 12 13.
The formula for calculating the relative frequency (fij) for a cell at row i and column j is: fij=nnij 11 12 13.
Relative frequencies are useful for comparing distributions across different sample sizes and for understanding the proportion of observations within each category combination 11 12 13.
Similar to absolute frequencies, relative frequencies can also be calculated for marginal distributions:
2.5 Exercise 3.1: Marital Status and Gender
This exercise requires constructing a crosstabulation from raw data on marital status and gender for 15 individuals. The goal is to organize these paired observations into a table showing the joint distribution of the two categorical variables 9.
2.6 Exercise 3.2: Marital Status and Gender (Different Sample)
Similar to Exercise 3.1, this problem involves creating a crosstabulation from a new set of 15 individuals' marital status and gender data. It reinforces the process of organizing paired categorical data 10.
2.7 Exercise 3.3: Marital Status and Gender with Relative Frequencies
This exercise builds upon the previous ones by asking for both the construction of a crosstabulation and the calculation of relative frequencies from the provided data on marital status and gender for 15 individuals 14.
2.8 Exercise 3.4: Tourist Spending and Stay Length
This exercise involves creating a crosstabulation from grouped data for 150 tourists. The variables are daily spending (grouped into intervals) and length of stay (grouped into intervals).
After constructing the table, the task is to calculate the relative frequencies for each cell 15.
📝 For 150 tourists, a crosstabulation of daily spending (grouped into intervals) and length of stay (grouped into intervals) is constructed, and then relative frequencies for each cell are calculated 15.
2.9 Exercise 3.5: Job Role and Work Arrangement
This exercise requires generating a crosstabulation from data on job roles (Sales, Administration, IT) and work arrangements (On-site, Remote, Hybrid) for 15 individuals. The task includes calculating the relative frequencies for the resulting table 16.
2.10 Exercise 3.6: Customer Spending and Shopping Time
This exercise involves creating a crosstabulation for 15 customers based on their total spending (grouped into intervals) and shopping time (grouped into intervals). The final step is to calculate the relative frequencies for the cells in the crosstab 17.
3. Coefficients that can be obtained from crosstabs
3.1 Pearson's chi-square coefficient (χ2)
The Pearson's chi-square (χ2) coefficient quantifies the discrepancy between observed frequencies in a contingency table and the frequencies expected if two categorical variables were statistically independent. It is calculated by summing the squared differences between observed and expected frequencies, divided by the expected frequencies, across all cells in the table.
The theoretical range for χ2 is from 0 to n⋅t, where n is the total number of observations and t is the minimum of (r−1) and (k−1), with r being the number of rows and k being the number of columns.
- Observed values: These are the actual counts recorded in the data for each category combination 19.
- Expected values: These are the frequencies that would be observed if the two variables were independent. They are calculated using the formula feij=nni⋅nj, where ni is the marginal total for row i, nj is the marginal total for column j, and n is the grand total 20 21 22.
- Residual values: These are the differences between the observed and expected frequencies (nij−feij). They indicate the direction and magnitude of the deviation from independence for each cell 24 25.
19.
25.
- Calculation of χ2: The formula is χ2=∑i=1r∑j=1kfeij(nij−feij)2 23 26 27.
- Interpretation: A higher χ2 value indicates a greater discrepancy between observed and expected frequencies, suggesting a stronger association between the variables. A χ2 of 0 implies perfect independence 25 28.
3.2 Limitations of Pearson's χ2
The theoretical range of the Pearson's χ2 statistic depends on the sample size and the dimensions of the contingency table. This dependency means that χ2 values from tables with different sizes or from samples of different sizes cannot be directly compared.
📝 For a 2x2 table, the phi coefficient is calculated as ϕ=nχ2. If χ2=7.4 and n=20, then ϕ=207.4=0.6124 31.
3.3 Phi coefficient (ϕ)
The phi coefficient (ϕ) is a measure of association specifically designed for two dichotomous (2x2) categorical variables. It is derived from Pearson's chi-square statistic and is calculated as the square root of χ2 divided by the total sample size (n).
- Formula: ϕ=nχ2 29 31.
- Interpretation: The strength of association indicated by the phi coefficient is typically interpreted as follows:
- 0 - 0.1: Negligible association
- 0.1 - 0.3: Weak association
- 0.3 - 0.5: Moderate association
- 0.5 - 1.0: Strong association 30.
31.
📝 The contingency coefficient is calculated as C=χ2+nχ2. For a table with χ2=13.9662 and n=60, C=13.9662+6013.9662=0.4345 35.
3.4 Contingency coefficient (C)
The contingency coefficient (C) measures the strength of association between two categorical variables and is derived from Pearson's chi-square statistic, adjusting for sample size. Its maximum possible value, however, still depends on the dimensions of the contingency table, meaning that C values obtained from tables of different sizes cannot be directly compared.
- Formula: C=χ2+nχ2.
- Maximum value: The maximum value of C (Cmax) is related to the table dimensions (t=min{(r−1),(k−1)}) by the formula Cmax=t+1t.
- Interpretation: The value of C ranges from 0 to a maximum value (Cmax) that depends on the dimensions of the contingency table. The strength of association is typically interpreted as follows:
- Values closer to 0 indicate a weak association.
- Values closer to Cmax indicate a strong association 34 35.
34.
3.5 Limitations of the Contingency Coefficient
Similar to Pearson's χ2, the contingency coefficient's theoretical range is dependent on the dimensions of the contingency table. Consequently, C values calculated from tables of different sizes cannot be directly compared.
3.6 Cramer's V coefficient
Cramer's V is an improved and more robust measure of association than the contingency coefficient, offering a standardized value that ranges between 0 and 1, regardless of the table's size. This standardization allows for the comparison of associations between variables with different numbers of categories.
- Formula: V=n⋅tχ2, where t=min{(r−1),(k−1)}39.
- Consistency with Phi: For 2x2 tables, Cramer's V is equal to the absolute value of the phi coefficient (V=∣ϕ∣), ensuring consistency between the measures.
- Interpretation: The strength of association is typically interpreted as follows:
- ≥0.1: Weak association
- ≥0.3: Moderate association
- ≥0.5: Strong association 38.
39.
3.7 Comparability of Cramer's V
Cramer's V provides a fixed theoretical range making it suitable for comparing the strength of association across contingency tables of different dimensions. This allows for direct comparison of association strengths between variables with varying numbers of categories 1.
37.
3.8 Exercise 3.7: Association between educational attainment and employment category
This exercise investigates the association between employees' educational attainment and their employment category within The Williams Corporation. It requires constructing a contingency table, calculating expected frequencies, and then computing Pearson's chi-square (χ2), the Contingency coefficient (C), and Cramer's V 40.
3.9 Exercise 3.8: Association between sex and ulcer status
This exercise examines the relationship between sex and ulcer status using data from a healthcare center. It involves constructing a contingency table, calculating Pearson's chi-square (χ2), and assessing the strength of association by calculating and interpreting Cramer's V 41.
3.10 Exercise 3.9: Association between previous visits and recommendation
This exercise assesses the strength of association between tourists who have visited a destination before and their willingness to recommend it. It specifically requires the calculation of the Phi coefficient (ϕ) for the given 2x2 contingency table 42.
3.11 Exercise 3.10: Association between exhibition preference and museum visit frequency
This exercise explores the relationship between visitors' preferred exhibition type and their museum visit frequency. Given a Pearson's chi-square statistic (χ2=24.6), the task is to calculate Cramer's V and interpret its value to conclude on the strength of the association 43.
4. Covariance between two variables
4.1 Covariance definition
Covariance is a statistical measure used in bivariate analysis to quantify how two quantitative variables change together. It indicates the direction of their linear association 44.
- Positive covariance: suggests that both variables tend to increase or decrease simultaneously.
- Negative covariance: indicates that as one variable increases, the other tends to decrease.
- Zero covariance: implies no linear relationship between the variables 44.
4.2 Covariance formulas
Covariance can be calculated using different formulas, depending on the available data. The formulas provide a way to numerically assess the relationship between two variables 44.
| Formula Name | Formula |
|---|---|
| Covariance (using deviations from mean) | Sxy=n1∑i=1n(xi−xˉ)(yi−yˉ) |
| Covariance (using raw data) | Sxy=n1∑i=1nxiyi−xˉyˉ |
| Covariance (alternative raw data form) | Sxy=n1∑i=1jnijxiyi−xˉyˉ |
5. Correlation between numerical variables
5.1 Pearson's correlation coefficient
Pearson's correlation coefficient, denoted as rxy, quantifies the strength and direction of the linear relationship between two quantitative variables. It is important to note that correlation does not imply causation; the relationship may be causal or non-causal.
The absolute value of the coefficient indicates the strength of the linear association, while its sign reveals the direction of the relationship (positive or negative). The coefficient ranges from -1 to 1 45.
The formula for Pearson's correlation coefficient is: rxy=SxSySxy where Sxy is the covariance between variables x and y, Sx is the standard deviation of variable x, and Sy is the standard deviation of variable y 45.
5.2 Interpretation of Pearson's correlation coefficient
The interpretation of Pearson's correlation coefficient (rxy) is based on its value, indicating the strength and direction of the linear relationship between two variables. A value close to 1 indicates a strong positive linear relationship, while a value close to -1 indicates a strong negative linear relationship.
A value close to 0 suggests a very weak or no linear relationship 45 48.
| Range of | rxy | — | Strength of Linear Relationship |
|---|---|---|---|
| 0 < rxy ≤ 0.2 | Very Low | — | — |
| 0.2 ≤ | rxy | ≤ 0.4 | Low |
| 0.4 ≤ | rxy | ≤ 0.7 | Medium |
| 0.7 ≤ rxy ≤ 0.9 | High | — | — |
| 0.9 ≤ rxy ≤ 1 | Very High | — | — |
5.3 Scatter plots and correlation
Scatter plots are graphical representations used to visualize the relationship between two numerical variables. The pattern of points on a scatter plot can provide a visual indication of the strength and direction of the linear association, which can then be quantified by Pearson's correlation coefficient 46 47.
- Positive correlation: Points tend to rise from left to right, indicating that as one variable increases, the other tends to increase.
- Negative correlation: Points tend to fall from left to right, indicating that as one variable increases, the other tends to decrease.
- No linear correlation: Points are scattered randomly with no discernible pattern, suggesting no linear relationship between the variables 46 47.
5.4 Exercise 3.11: Tourist stay and expenditure
This exercise involves calculating Pearson's correlation coefficient (rxy) to assess the linear relationship between the average length of stay for tourists and their average daily expenditure. The data provided includes monthly figures for both variables 49.
5.5 Exercise 3.12: Advertising expenditure and sales revenue
This exercise requires calculating Pearson's correlation coefficient (rxy) to examine the linear relationship between advertising expenditure and sales revenue for a furniture company. Data for four months, expressed in millions of euros, are provided 50.
© 2026 Maeve. All rights reserved. This content is protected by copyright.