5.4: Bivariate Analysis Techniques
- Page ID
- 48060
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\dsum}{\displaystyle\sum\limits} \)
\( \newcommand{\dint}{\displaystyle\int\limits} \)
\( \newcommand{\dlim}{\displaystyle\lim\limits} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\(\newcommand{\longvect}{\overrightarrow}\)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\ket}[1]{\left| #1 \right>}\)
\(\newcommand{\bra}[1]{\left< #1 \right|}\)
\(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
\(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
\(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
\(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
\(\newcommand{\expect}[1]{\langle #1 \rangle}\)
\(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)
Overview
After examining variables individually, EDA proceeds to bivariate analysis, which looks at relationships between pairs of variables. This step helps answer questions like: Are two variables correlated? Do certain groups differ with respect to a variable? Could one variable help explain or predict another? Just as with univariate analysis, the approach depends on the types of variables involved (numeric or categorical), and there are standard techniques for each case.

Numeric vs. Numeric (Continuous-Continuous)
When both variables are numeric, the primary tool is the scatter plot. A scatter plot places one variable on the x-axis and the other on the y-axis, plotting each observation as a point. This reveals the form of association: is it linear, nonlinear, or null? Is it positive (both increase together) or negative (one increases while other decreases)? How strong or tight is the relationship versus how scattered? One may also compute the correlation coefficient (e.g., Pearson’s r) to quantify the linear relationship: values near +1 or –1 indicate strong correlation, whereas values near 0 indicate little linear relationship. However, the scatter plot can reveal nuances beyond what a single number can – for example, it can show if the relationship is non-linear (where Pearson r might be low, but there's a clear curved trend), or if the variance changes (heteroscedasticity), or if there are subgroups/clusters within the data.
Additionally, scatter plots might reveal outliers or subgroups. For example, a scatter of height vs. weight might show a cluster of points separated from the rest, perhaps indicating a separate group (maybe data from children vs adults combined, or an error in units for some records). If points are labeled or colored by a third variable (like gender, year, etc.), a scatter can start to become a multivariate plot, which we discuss later.
To complement scatter plots, EDA might include calculating the correlation matrix for many numeric variables at once. A correlation matrix is a table showing correlation coefficients for every pair of variables. Heatmaps are a visual way to depict this matrix: each cell is colored according to the correlation value (for example, blue for high positive correlation, red for high negative in one scheme). This allows the analyst to quickly scan for any strong relationships among numerous variables. If we have, say, 10 variables, a correlation heatmap can highlight that maybe 2 of them are highly collinear (redundant) or that one variable correlates with many others, etc. In EDA, finding that two predictors are 0.99 correlated would be a big red flag (perhaps they are essentially the same thing measured twice), often leading us to decide to drop one of them in modeling. We’ll revisit using EDA for feature selection shortly.
Categorical vs. Numeric (Discrete-Continuous)
Often we want to compare a numeric outcome across different categories or groups. For example, do males and females have different average incomes? Or how do product sales differ by region? For these cases, a common approach is to use grouped summary statistics and corresponding charts. One might compute the mean or median of the numeric variable for each category of the categorical variable, and perhaps the spread as well (standard deviation or IQR). Visualization options include side-by-side box plots for each category, or a violin plot (which shows the distribution shape for each group), or a bar chart of means with error bars. These methods help assess whether there are differences between groups and how variable each group is. For instance, a set of box plots could quickly show that Group A’s values are consistently higher than Group B’s, and also whether Group A’s data is more variable or has more outliers, etc.
If the categorical variable has only two levels, a simple comparison of means (and possibly a t-test, if doing a quick check for significance) might be done as part of EDA. If more levels, analysis of variance (ANOVA) could be an exploratory step (though it borders confirmatory analysis). In exploratory mode, one might not formally report p-values yet, but it’s not uncommon to do a quick test to see if an observed difference might be statistically meaningful or just due to noise.
Categorical vs. Categorical
For completeness, if both variables are categorical, EDA would involve looking at contingency tables (cross-tabulations) to see how the categories interact. For example, a dataset might have variables "Smoking (Yes/No)" and "Payer Gender (Male/Female)" for restaurant bills. A contingency table would count how many observations fall into each combination (Male smoker, Male non-smoker, Female smoker, Female non-smoker). This can reveal any associations (maybe the proportion of smokers differs by gender, etc.). A stacked bar chart or grouped bar chart can visualize the joint distribution of two categorical variables. One might also use a chi-square test to see if the categories are independent or not as an exploratory step.
In summary, bivariate analysis in EDA is about examining pairwise relationships: correlations, differences, and associations. Typical steps include making scatter plots for every interesting pair of continuous variables, and making comparison plots for continuous vs categorical combos. One helpful exploratory technique is the scatter plot matrix (SPLOM) or pair plot, which shows scatter plots for many variable pairs in a grid (with histograms on the diagonal). This can be generated easily with tools (e.g., Seaborn’s pairplot in Python) and is a quick way to spot any standout relationships among multiple variables at once. Another useful approach is computing the correlation matrix and visualizing it via a heatmap, as mentioned, to see all pairwise correlations in one view.


