Lesson 13 of 16 · Level 4: Expert
Correlation, Trends and A/B Testing
- ⏱ 14 min read
- ❓ 4 review questions
- ✍️ Exercise with solution
- 📥 Downloadable template
In this lesson
- How to measure the relationship between two numeric variables with the correlation coefficient (r).
- Why correlation is not causation, with a confounding example hidden in the practice data.
- How to describe a trend with a trend line and a moving average, and when not to trust a forecast.
- How an A/B test works, from hypothesis to sample size.
- How to read A/B results correctly: conversion rates, lift, p-values and confidence intervals.
Use Sales Clean for the correlations (columns H, I and J) and the monthly revenue table on the Summary sheet for trends. The A/B test example uses its own numbers, given in the lesson.
- sales-practice-data.xlsx · sheets Sales Clean and Summary
Descriptive statistics tell you what one column looks like. The next step is relationships: do bigger orders mean more revenue? Are sales trending up? Did the new checkout page actually increase conversions, or was it luck? This lesson covers the three tools analysts use for those questions (correlation, trends and A/B tests) and the reasoning traps that come with each one. All correlation and trend figures come from the practice data.
Correlation: do two numbers move together?
The Pearson correlation coefficient, written r, measures how strongly two numeric variables follow a straight-line relationship. It ranges from −1 to +1:
- +1: perfect positive relationship (when one goes up, the other always goes up proportionally).
- 0: no linear relationship.
- −1: perfect negative relationship.
In Excel or Google Sheets, =CORREL(range1, range2) calculates it. On the 200 clean orders:
| Variables | Formula | r | Reading |
|---|---|---|---|
| Units and revenue | =CORREL(H2:H201,J2:J201) | 0.76 | Strong positive |
| Unit price and revenue | =CORREL(I2:I201,J2:J201) | 0.37 | Moderate positive |
| Unit price and units | =CORREL(I2:I201,H2:H201) | −0.01 | No linear relationship |
A rough rule of thumb: |r| below 0.3 is weak, 0.3 to 0.7 moderate and above 0.7 strong, but context matters more than labels. Squaring r gives r², the share of the variation in one variable that a straight line on the other explains: 0.76² ≈ 0.58, so units explain about 58% of the variation in revenue. The rest comes mostly from price differences between products.
1. The correlation between unit price and units per order is −0.01. What does that mean?
An r this close to zero means price doesn't predict order quantity in a straight-line way. In this data, order size depends on the channel (wholesale vs. consumer), not on price. And no correlation value, by itself, proves causation.
Correlation is not causation
A correlation tells you two things move together. It doesn't tell you why. There are four common explanations, and only one of them is "A causes B":
Confounding variable
A third factor drives both. Ice cream sales and drownings both rise in summer; heat drives both.
Check: split the data by the suspected third factor.Reverse causation
B causes A. Stores with more staff sell more, but busy stores hire more staff.
Check: which happened first?Coincidence
Test enough variable pairs and some will correlate by pure chance.
Check: is there a plausible mechanism? Does it hold in new data?Built-in relationship
Revenue = units × price, so units and revenue must correlate. It's arithmetic, not insight.
Check: is one variable calculated from the other?A confounder hiding in our data
The West's average order is $572.28, while the South's is $316.68. It's tempting to conclude "Western customers spend more." Split by channel and the story changes:
| Average order | West | South |
|---|---|---|
| All orders | $572.28 | $316.68 |
| Online orders | $186.43 | $166.69 |
| Retail orders | $145.10 | $187.38 |
| Wholesale orders | $2,009.36 | $1,094.78 |
| Wholesale share of orders | 21.9% (14 of 64) | 15.3% (9 of 59) |
Consumer orders are similar in both regions (retail is even higher in the South). The gap comes from channel mix: the West has a larger share of wholesale orders, and its wholesale orders are bigger. Channel is the confounder. The right conclusion is "the West has more and bigger business buyers," which leads to a very different action than "Western shoppers spend more."
2. A manager says: "Regions with more wholesale orders have higher average orders, so let's push wholesale buyers to place more orders and our averages will rise." What's the best response?
The average order is a mix effect: more large orders raise the average automatically. Optimizing an average can mislead (you could raise it by losing small customers). Focus on the business outcome, total revenue and profit, and analyze channels separately.
Trends: is it going up?
A linear trend line fits the straight line that best follows the data over time. With months numbered 1 to 12 in column A and monthly revenue in column B of a small table:
Slope (change per month): =SLOPE(B2:B13, A2:A13) → +$610.72
Intercept: =INTERCEPT(B2:B13, A2:A13) → $3,508.21
Fit (R²): =RSQ(B2:B13, A2:A13) → 0.21
"Forecast" for month 13: =FORECAST.LINEAR(13, B2:B13, A2:A13) → $11,447.62
The slope says revenue rose about $611 per month on average, but an R² of 0.21 means the line explains only 21% of the month-to-month variation. The April and December wholesale spikes dominate. A January 2026 "forecast" of $11,448 would be nearly four times January 2025 ($3,025) and almost certainly wrong. With noisy data and one year of history, a trend line describes the past; it's not a reliable forecast.
A moving average smooths noise by averaging each month with the previous ones. For a 3-month moving average, type =AVERAGE(B2:B4) next to March and copy it down. It runs from $3,029 in March to $9,819.67 in December, a smoother picture than the raw $2,945-to-$18,319 swings. Separating the series helps even more: online and retail revenue alone rose about $103 per month, with no giant spikes.
December is high in 2025, but you can't call it "seasonal" from a single year: it could be a one-time event. To claim seasonality, compare the same months across at least two or three years.
A/B testing: proving cause and effect
If correlation can't prove causation, what can? A controlled experiment. In an A/B test you randomly split users into two groups, show group A the current version and group B a changed version, and compare an outcome. Because assignment is random, the groups are alike in everything except the change, so a big enough difference can be attributed to it.
- Write a hypothesis
- Pick one primary metric
- Calculate the sample size
- Randomize and run
- Analyze once, then decide
Example: a one-page checkout
The retailer tests a new one-page checkout on its website. Hypothesis: "The one-page checkout will increase the conversion rate (orders ÷ visitors)." Before starting, the analyst calculates that detecting an increase from about 4.8% to 5.8% with 95% confidence and 80% power needs roughly 7,900 visitors per group, so the test runs until each group has 8,000 visitors.
| Group | Visitors | Orders | Conversion rate |
|---|---|---|---|
| A: current checkout | 8,000 | 384 | 4.8% |
| B: one-page checkout | 8,000 | 464 | 5.8% |
The difference is 1.0 percentage point, a relative lift of 20.8% (1.0 ÷ 4.8). Is it real or luck? A two-proportion z-test answers that:
Pooled rate p = (384 + 464) / (8,000 + 8,000) = 0.053
Standard error = √( p × (1 − p) × (1/8,000 + 1/8,000) ) = 0.00354
z = (0.058 − 0.048) / 0.00354 = 2.82
p-value (two-sided) = 2 × (1 − NORM.S.DIST(2.82, TRUE)) ≈ 0.005
95% confidence interval for the difference: +0.31 to +1.69 points
The p-value is the probability of seeing a difference at least this large if the two checkouts truly performed the same. At 0.005 it's well below the usual 0.05 threshold, so the result is statistically significant. The confidence interval says the true improvement is plausibly anywhere from 0.31 to 1.69 points: positive, but with a wide range, which is worth mentioning when you estimate the revenue impact.
Now imagine the same rates with only 800 visitors per group: 38 vs. 46 orders (4.75% vs. 5.75%). The z-score drops to 0.90 and the p-value rises to 0.37. Same lift, but far too little data to tell it apart from chance. That's why you calculate the sample size before the test.
3. An A/B test reports p = 0.005. Which interpretation is correct?
A p-value is calculated assuming no real difference. It is not the probability that B is better, and it says nothing about the size of the effect. For size, look at the lift and the confidence interval.
A/B testing checklist
4. On day 3 of a planned 14-day test, the p-value is 0.03 and the team wants to stop and launch version B. What's the risk?
If you check repeatedly and stop at the first significant result, the real false-positive rate climbs well above 5%. Stick to the planned sample size (or use a method designed for sequential testing).
Practice exercise
The marketing team tests a new product-page photo. Group A: 6,000 visitors and 300 orders. Group B: 6,000 visitors and 345 orders.
- Calculate both conversion rates and the relative lift.
- Calculate the z-score (pooled method) and say whether the result is significant at the 0.05 level.
- What would you tell the team?
See solution
1. A: 300 ÷ 6,000 = 5.0%. B: 345 ÷ 6,000 = 5.75%. Lift = 0.75 ÷ 5.0 = 15%.
2. Pooled rate = 645 ÷ 12,000 = 0.05375. Standard error = √(0.05375 × 0.94625 × (1/6,000 + 1/6,000)) ≈ 0.00412. z = 0.0075 ÷ 0.00412 ≈ 1.82. Two-sided p-value = 2 × (1 − NORM.S.DIST(1.82, TRUE)) ≈ 0.069, which is above 0.05: not statistically significant.
3. "The new photo looks promising (+15%), but with this sample we can't rule out chance (p ≈ 0.07). If the test hasn't reached its planned sample size, keep it running; if it has, treat the result as inconclusive and don't claim a 15% gain." Never round a p of 0.069 down to "basically significant."
Summary
- Pearson's r (=CORREL) measures linear relationships from −1 to +1; units and revenue have r = 0.76 in our data.
- Always plot the data: one r can hide separate groups, like consumer and wholesale orders.
- Correlation is not causation: check for confounders, reverse causation, coincidence and built-in relationships.
- The West's higher average order is explained by channel mix, not by bigger consumer purchases.
- Trend lines and moving averages describe the past; with R² = 0.21 and one year of data, don't sell the line as a forecast.
- A/B tests establish cause and effect: plan the sample size, randomize, don't peek and report lift, confidence interval and p-value.
Next lesson: Python for Data Analysis with pandas. You'll repeat the whole workflow in code, from loading the raw CSV to charts.
Create your account in 30 seconds, mark your lessons and download your certificate at the end.