Skip to main content
v2026.11,858 entries · CC-BY 4.0

Bivariate Data: Definition, Examples, and How to Analyze It

What bivariate data is, how to plot it, and a step-by-step correlation and regression example with Excel, R and Python code.

Written and maintained by CASRAI Editorial Board

Last updated

Bivariate data are observations recorded on two variables for the same set of cases, so every case contributes one (x, y) pair. Height and weight measured on each of 30 people is bivariate data; so is hours of study and exam score for each student. The point of collecting two variables together is to ask how they relate, which is what bivariate analysis does. A common mistake is to treat the two columns as separate samples; the pairing is what makes the data bivariate.

What is bivariate data?

Each row of a bivariate data set is one case (a person, a sample, a site) with a value for variable X and a value for variable Y. Univariate data records one variable per case and is summarised with a mean, a spread and a histogram (see descriptive statistics). Multivariate data records three or more variables per case. Bivariate sits between the two: the smallest data structure in which a relationship can be examined at all.

In the pairing used by OpenStax Introductory Statistics, x is the independent (explanatory) variable and y is the dependent (response) variable, and the scatter plot shows the direction of the relationship between them. NIST/SEMATECH likewise puts the response variable on the vertical axis and a variable suspected of being related to it on the horizontal axis. Choosing which variable plays which role is a design decision, covered in explanatory vs response variable.

Bivariate data examples

  • Child’s age (x) and vocabulary size (y), the pairing OpenStax uses to introduce scatter plots.
  • Hours studied (x) and exam score (y) for each student.
  • Dose of a reagent (x) and measured absorbance (y) for each sample.
  • Grant size (x) and number of publications (y) for each funded project.

In each case the two values belong to the same unit. Two unrelated lists of numbers of equal length are not bivariate data until they are paired by case.

Bivariate data vs univariate data

Type Variables per case Typical question
Univariate 1 What is the centre and spread of this variable?
Bivariate 2 Are X and Y related, and how strongly?
Multivariate 3 or more How do several variables relate at once?

How to display bivariate data (scatter plot)

Plot the data before computing anything. NIST defines a scatter plot as a plot of the values of Y versus the corresponding values of X, and lists the questions it answers: whether X and Y are related, whether the relationship is linear or non-linear, whether the spread of Y changes with X, and whether outliers are present. OpenStax calls it the most common and easiest way to display the relation between two variables. For how to read the pattern, see scatterplot interpretation.

Formula: the correlation coefficient r

The usual numerical summary of a linear relationship in bivariate data is the Pearson correlation coefficient. In the computational form printed by OpenStax:

r = [ n·Σxy − (Σx)(Σy) ] / √( [ n·Σx² − (Σx)² ] · [ n·Σy² − (Σy)² ] )

  • n: the number of (x, y) pairs.
  • Σx, Σy: the sum of the x values and of the y values.
  • Σxy: the sum of each x multiplied by its own y.
  • Σx², Σy²: the sums of the squared values.

The least-squares line through the same data is ŷ = a + bx, where b = [nΣxy − (Σx)(Σy)] / [nΣx² − (Σx)²] and a = (Σy − bΣx) / n.

Worked example with the arithmetic shown

The six pairs below are invented for illustration: hours studied (x) and exam score (y).

Student x y xy x² y²
1 1 52 52 1 2704
2 2 55 110 4 3025
3 3 61 183 9 3721
4 4 64 256 16 4096
5 5 70 350 25 4900
6 6 74 444 36 5476
Sum 21 376 1395 91 23922
  1. Numerator: 6 × 1395 − 21 × 376 = 8370 − 7896 = 474.
  2. First bracket: 6 × 91 − 21² = 546 − 441 = 105.
  3. Second bracket: 6 × 23922 − 376² = 143532 − 141376 = 2156.
  4. Denominator: √(105 × 2156) = √226380 ≈ 475.79.
  5. r = 474 / 475.79 ≈ 0.996.

Slope b = 474 / 105 ≈ 4.514 and intercept a = (376 − 4.514 × 21) / 6 ≈ 46.87, so ŷ = 46.87 + 4.514x. At x = 4 the line gives 64.92, against an observed 64. The coefficient of determination is r² ≈ 0.992.

Interpretation: what the result means

OpenStax states that r is always between −1 and +1 and that values close to −1 or +1 indicate a stronger linear relationship between x and y. Here r ≈ 0.996 is very close to +1: in these six students, more hours go with higher scores along an almost perfectly straight line. It does not say the extra hours caused the higher scores.

Value of r What OpenStax says
r = 1 Perfect positive linear relationship
r = −1 Perfect negative linear relationship
r = 0 Likely no linear correlation
Curved or horizontal pattern May have a correlation of 0 even though the variables are related

For a fuller treatment of r see the correlation coefficient guide.

Assumptions and common mistakes

  • Skipping the plot. Because a curved pattern can give r near 0, always look at the scatter plot first; NIST notes it shows whether a relationship is linear or non-linear.
  • Reading r as causation. r measures linear association between x and y; it does not establish that either variable influences the other.
  • Breaking the pairs. Sorting one column independently of the other destroys the data. Sort or filter whole rows only.
  • Ignoring outliers and changing spread. Both are things NIST says a scatter plot reveals; check them before trusting a single summary number.
  • Predicting far outside the observed x range. The fitted line describes the range you measured; with x from 1 to 6 hours it says nothing reliable about 20 hours.

How to report bivariate results (APA example)

The APA numbers-and-statistics guide says to italicise letters used as statistical symbols, to leave out the zero before the decimal point for a statistic that cannot exceed 1 (it names correlations and p values), to report correlations to two decimals, and to write p values below .001 as p < .001. The common way to write a correlation sentence adds the degrees of freedom (n − 2) in parentheses after r. For the worked example (n = 6, so 4 degrees of freedom):

Hours studied and exam score were strongly positively correlated, r(4) = .99, p < .001.

With six invented points this is a demonstration of the format, not a finding; real reports state n, the variables and units, and show the scatter plot.

How to calculate it in Excel, R or Python

Excel

=CORREL(A2:A7, B2:B7)     returns 0.9962
=SLOPE(B2:B7, A2:A7)      returns 4.5143
=INTERCEPT(B2:B7, A2:A7)  returns 46.8667

R

x <- c(1, 2, 3, 4, 5, 6)
y <- c(52, 55, 61, 64, 70, 74)
cor(x, y)          # 0.9962293
coef(lm(y ~ x))    # intercept 46.87, slope 4.514
plot(x, y)

More on plotting in R: scatterplots in R.

Python (3.10 or later)

import statistics as st
x = [1, 2, 3, 4, 5, 6]
y = [52, 55, 61, 64, 70, 74]
print(st.correlation(x, y))            # 0.9962293
print(st.linear_regression(x, y))      # slope 4.514, intercept 46.87

Python plotting is covered in scatter plot in Python.

FAQ

What is bivariate analysis?

Bivariate analysis examines two variables measured on the same cases to see whether and how they are related, typically starting with a scatter plot and then a correlation coefficient or a regression line.

Is bivariate data the same as a scatter plot?

No. A scatter plot is a way to display bivariate data. The data are the paired values; the plot is one picture of them.

What is the difference between bivariate and multivariate data?

Bivariate data has exactly two variables per case. Multivariate data has three or more.

Which variable goes on the x-axis?

The explanatory (independent) variable goes on the x-axis and the response (dependent) variable on the y-axis, as in both OpenStax and NIST.

Can r be 0 when the variables are related?

Yes. OpenStax notes that data with a curved or horizontal pattern may have a correlation of 0, which is why the plot comes first.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Bivariate Data: Definition, Examples, and How to Analyze It

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →

Ask CASRAI · Regulatory Radar

Research-admin question? Get an answer that links its sources.

An AI assistant specialized in research administration. Every answer links its sources to check before you act. 2 questions free, no account. $29/month after.

  • Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.
  • Every answer numbers its sources and links each one, so you can check the source yourself.