Correlation and regression: how two measurements move together
Do older people tend to have higher blood pressure? Put one dot per person, with the two measurements as its position, and you get a cloud. Drag the dots to see how close that cloud is to a straight line, how well one measurement guesses the other, and how much you can trust that guess. All data on this page is made up, and the page explains statistics ideas only.
Short answer. The correlation coefficient r is one number between −1 and 1 that says how closely two measurements move together along a straight line. At 1 they rise together along one line, at −1 one goes down as the other goes up along one line, and at 0 there is no straight-line relationship. Regression finds the line (slope and intercept) that guesses one measurement from the other, and asks whether that slope can be told apart from 0. Correlation does not mean one thing causes the other.
Drag a blue dot, or pick a point and change its age and blood pressure. "Remove point" removes the picked point (the black ring); you can have 3 to 40 points. "Draw new data" draws 20 made-up people using the value on the target r slider. Each press moves the seed to 1, 2, 3 and so on, and the same seed always gives the same cloud. Moving the slider redraws with the same seed and only changes r. The green line is the regression line, dashed outside the range of ages in the data. The green band is the 95% range for "the average blood pressure of people this age", and the purple band is the 95% range for "one new person this age".
Try this. ① The first five points are the hand example in section 3. r = 0.7, r² = 0.49, the regression line is blood pressure = 112.5 + 0.35 × age, the 95% confidence interval for the slope is −0.31 to 1.01, and p = 0.188. Even with r = 0.7, five points are not enough to tell the slope apart from 0. ② Drag point 2 down from (40, 134) to (40, 120). Now r = 0.9, the slope is 0.49, the interval is 0.06 to 0.92 and p = 0.036. With few points, one person can change the conclusion. ③ Press "First data", then "Draw new data". This draws 20 people with target r 0.7 (seed 1): r = 0.7, slope 0.81, interval 0.4 to 1.23, p < 0.001. Same r, but with more points the interval is narrow and does not include 0. ④ Now move the target r to 0.3: r = 0.29, interval −0.21 to 0.9, p = 0.208. Twenty people are not enough to tell a relationship this weak apart from 0. ⑤ Move the target r back to 0.7 and turn on both bands. At age 50 the band for the mean is 130.1 to 139.8, but the band for one new person is 112.9 to 157, more than four times as wide. Both bands are narrowest in the middle and widen toward the ends.
Definitions
The page below explains with age and blood pressure. The definitions use n pairs of data , the means , and the standard deviations found by dividing by n − 1.
- covariance
- The average of the product of how far each value is from its own mean. The sample covariance divides by n − 1.
- Pearson correlation coefficient
- The covariance divided by the product of the two standard deviations (when ). It always satisfies , and ±1 happens only when every point lies on one straight line.
- least-squares regression line
- The line that makes the sum of squared residuals as small as possible. b is the slope and a is the intercept.
- residual
- The difference between an observed value and the value the regression line predicts.
- coefficient of determination
- The share of the variation in y (the sum of squared distances from the mean) that the regression line explains. In simple linear regression it equals the square of the correlation coefficient, so it is written .
- t statistic for the slope
- With β the true slope, the statistic for testing . If the errors are independent and follow a normal distribution with mean 0 and the same variance, it follows the t distribution with n − 2 degrees of freedom under the null hypothesis.
1. The correlation coefficient r: one number for moving together
Measure two things for each person (age and blood pressure) and put one dot per person: across for one, up for the other. This picture is a scatter plot. If the cloud tilts up to the right, a higher value of one tends to go with a higher value of the other (positive correlation). If it tilts down to the right, it is the other way round (negative correlation). The correlation coefficient r is not how steep the cloud is. It says, with a sign, how tightly the cloud gathers around one straight line. It is often called the Pearson correlation coefficient.
x̄ ("x bar") and ȳ are the means, s_x and s_y are the standard deviations (dividing by n − 1), z is the z-score ("how many standard deviations from the mean"), Σ means "add them all up", and n is the number of people. Written out, it is the same as r = Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²). Why it looks like this is shown step by step in "How the formula is built" below.
| Property | Meaning | In the lab |
|---|---|---|
| Between −1 and 1 | The ends (±1) only happen when every point is on one straight line | Set target r to 1 |
| The sign is the direction | + means they rise together, − means one goes down as the other goes up | Set target r to −0.5 |
| Units do not matter | Age in months or blood pressure in kPa gives the same r. Multiplying one by −1 only flips the sign | Steps ③ and ⑤ of how the formula is built |
| Swapping x and y changes nothing | "Correlation of age with blood pressure" is the same number as the other way round | Table in section 4 |
| Only measures straight lines | Misses curved relationships, and one stray point can move it a lot | Lab 2 (section 6) |
2. Reading the size of r, and r²
There is no fixed answer to how big r must be to call it "strong". Where weak, moderate and strong begin is a convention that differs between fields, and different books give different numbers. In a precise physical measurement, 0.9 might count as low. In health data, where everyone lives differently, 0.3 might be worth a close look. Rather than putting a label on one number, compare with other studies in the same field and look at r² and the slope as well.
r and the slope are different things. If blood pressure rises only a little with age but very evenly, r is close to 1 and the slope is small. If it rises a lot but varies widely from person to person, the slope is large and r is small.
r² (the coefficient of determination) is the share of the spread that the line explains. Measure how much blood pressure differs between people as "the sum of squared distances from the mean". The part explained by the line on age is r², and the part the line leaves over (the residuals) is 1 − r².
For the hand example (section 3) it is 1 − 127.5 ÷ 250 = 0.49, which is 0.7². The line on age explains 49% of the spread in blood pressure and 51% is left over. If r = 0.5, then r² = 0.25: half the r, but only a quarter of the spread explained. Reading it as "49% of blood pressure is caused by age" is wrong. It is a share of the spread, and it says nothing about causes (section 10).
3. Work it out by hand: five points
The ages and systolic blood pressures of five made-up people. This is the first data in the lab above.
| Person | Age x | Blood pressure y | x − x̄ | y − ȳ | (x − x̄)(y − ȳ) | (x − x̄)² | (y − ȳ)² |
|---|---|---|---|---|---|---|---|
| 1 | 30 | 120 | −20 | −10 | 200 | 400 | 100 |
| 2 | 40 | 134 | −10 | 4 | −40 | 100 | 16 |
| 3 | 50 | 128 | 0 | −2 | 0 | 0 | 4 |
| 4 | 60 | 127 | 10 | −3 | −30 | 100 | 9 |
| 5 | 70 | 141 | 20 | 11 | 220 | 400 | 121 |
| Sum | 250 | 650 | 0 | 0 | 350 | 1000 | 250 |
- Means: x̄ = 250 ÷ 5 = 50, ȳ = 650 ÷ 5 = 130
- Column sums: Σ(x − x̄)(y − ȳ) = 350, Σ(x − x̄)² = 1000, Σ(y − ȳ)² = 250
- Correlation:
r = 350 ÷ √(1000 × 250) = 350 ÷ 500 = 0.7, r² = 0.49 - Slope:
b = 350 ÷ 1000 = 0.35. One year older, and the guess for blood pressure goes up by 0.35 mmHg on average. - Intercept:
a = ȳ − b × x̄ = 130 − 0.35 × 50 = 112.5 - Regression line: blood pressure ≈ 112.5 + 0.35 × age
- Check with standard deviations: s_x = √(1000 ÷ 4) = 15.81, s_y = √(250 ÷ 4) = 7.91, and s_y ÷ s_x = 0.5, so
b = r × (s_y ÷ s_x) = 0.7 × 0.5 = 0.35
The same working, written as formulas:
The intercept 112.5 is not "the blood pressure at age 0". The data only covers ages 30 to 70, so age 0 is outside the range (section 7). Read the intercept only as the number that sets the height of the line.
How the formula is built: the correlation coefficient r
Let's build r = Σ(z_x × z_y) ÷ (n − 1) one step at a time, using the same five people as the hand example. The picture draws one unit of age and one unit of blood pressure at the same size, so the cloud keeps its true shape. Press "Next" and a piece is added to the formula above (the orange background marks the new piece), the picture changes by that much, and the reason appears below. The standardizing in step ④ can be watched on its own, as a cloud that moves and shrinks, on the normalization and standardization page.
Green rectangles count +, orange rectangles count −. The number inside each rectangle is its area. In steps ④ and ⑤ the points move to z-score units, and in step ⑥ they go back to the original units.
Written only as formulas, the steps above look like this. The numbers are from the hand example.
Why divide by n − 1? To match the standard deviations s_x and s_y, which were also found by dividing by n − 1. If you found the standard deviations by dividing by n, you would divide by n at the end too. Either way r comes out the same, and the written-out form Σ(x − x̄)(y − ȳ) ÷ √(Σ(x − x̄)² × Σ(y − ȳ)²) has no n in it at all.
The line in the last step is the least squares line. That page finds the line with the smallest sum of squared residuals using projection, and gets the slope Σ(x − x̄)(y − ȳ) ÷ Σ(x − x̄)². Divide the top and the bottom by n − 1 and you get covariance ÷ s_x². The covariance is r × s_x × s_y, so this becomes r × (s_y ÷ s_x).
4. Regression: a line that guesses one measurement from the other
Regression finds a formula that guesses one measurement (y, here blood pressure) from another (x, here age). The simplest kind uses one straight line and is called simple linear regression.
b (the slope) is "how much the average y goes up when x goes up by 1", and it has units (mmHg per year). a (the intercept) is the height of the line at x = 0. The line always passes through the mean point (x̄, ȳ). How to fit the line and why it uses squares is covered on the projection and least squares page. This page reads that line with a statistician's eye.
| Correlation | Regression | |
|---|---|---|
| The question | How closely do the two move together along a line? | If I know x, what do I guess for y? |
| Swap x and y | Same answer (symmetric) | A different line |
| Units | None (−1 to 1) | The slope is units of y per unit of x |
| What you get | One number, r | Slope, intercept, guesses, residuals |
Swapping x and y gives a different line. In the hand example, guessing age from blood pressure gives the slope r × (s_x ÷ s_y) = 0.7 × 2 = 1.4 years per mmHg. Drawn in the same picture (age across, blood pressure up), that line has slope 1 ÷ 1.4 ≈ 0.71, steeper than the line guessing blood pressure from age (0.35). The two lines cross at the mean point and only lie on top of each other when r is ±1. So first decide what you are guessing from what.
5. Can the slope be told apart from 0? Confidence interval and p-value
The slope 0.35 in the hand example comes from these five people. Five other people would have given a different slope. The standard error estimates how much the slope would wobble from sample to sample, and the confidence interval and p-value come from it. These calculations assume the data follows the assumptions in section 6.
It is n − 2 because two numbers of the line (slope and intercept) were set from the same data. t* is the value that keeps the middle 95% of a t distribution with n − 2 degrees of freedom: 3.18 for 3 degrees of freedom, 2.10 for 18, and it approaches the normal distribution's 1.96 as the degrees of freedom grow. The t distribution is covered on the t-test page. The lab on this page does not read t tables; it computes the areas directly with the incomplete beta function.
- Residuals (actual − guess): 120 − 123 = −3, 134 − 126.5 = 7.5, −2, −6.5, 4. Sum of squares 127.5
s = √(127.5 ÷ 3) = 6.52SE = 6.52 ÷ √1000 = 0.206t = 0.35 ÷ 0.206 = 1.70, 3 degrees of freedom, two-sided p = 0.188- Confidence interval:
0.35 ± 3.18 × 0.206 = 0.35 ± 0.66, so −0.31 to 1.01
Even though r = 0.7 looks big, with five points data tilted this much is not unusual even when the true slope is 0. The interval including 0 says the same thing. With the same r = 0.7 and 20 people, p < 0.001 and the interval is 0.4 to 1.23 (lab 1, "Try this" ③).
Testing whether r is 0 and testing whether the slope is 0 are the same test. You can get t straight from r: t = r × √(n − 2) ÷ √(1 − r²). For the hand example, 0.7 × √3 ÷ √0.51 = 1.70, the same.
- "p = 0.188, so there is an 18.8% chance the slope is 0." No. p is "the chance of data tilted at least this much, assuming the slope is 0". It is not the chance that the assumption is true (hypothesis testing and p-values).
- "p is above 0.05, so age and blood pressure are unrelated." No. It only means this data could not tell the slope apart from 0. The interval −0.31 to 1.01 also includes quite large positive slopes. This is common when there are few points (statistical power).
- "p is tiny, so the relationship is strong." No. With many points even a weak correlation gets a small p. With 1,000 people, r = 0.1 gives p ≈ 0.002, but r² is 0.01: the line explains 1% of the spread.
- "There is a 95% chance the true slope is between −0.31 and 1.01." Strictly, no. The 95% is a score for the method. If you drew data many times and built an interval the same way each time, about 95% of those intervals would contain the true slope. This one interval either contains it or does not (confidence intervals).
The band for the mean and the band for one new person
You can draw two kinds of band around the line. They answer different questions.
The band for the mean (confidence band) is where "the average blood pressure of people aged x" is likely to be. It keeps getting narrower as you add points. The band for one new person (prediction band) is where "the blood pressure of one new person aged x" is likely to be. It adds each person's own scatter (the 1 under the square root), so it is always wider, and no amount of data makes it narrower than that scatter. At age 50 in the hand example, the band for the mean is 120.7 to 139.3 and the band for one new person is 107.3 to 152.7. Both bands are narrowest at x̄ and widen further away. The band for the mean is 32.1 wide at age 30, 18.6 at 50 and 43.5 at 80. Reading "most people fall inside the band for the mean" is wrong. To talk about one person, use the band for one new person.
6. What r cannot see: draw the picture first
The same summary numbers can hide very different data. In a 1973 paper the statistician Anscombe showed four data sets with the same means, variances, correlation and regression line but completely different pictures, and argued that you should look at graphs, not only numbers. Below are four new data sets made up for this page with the same idea: ten made-up measurements each of hours in culture and number of cells (in units of 10,000).
| Data | x̄ | ȳ | s_x | s_y | r | Regression line | Spearman |
|---|---|---|---|---|---|---|---|
| A straight cloud | 6.00 | 7.00 | 3.16 | 1.98 | 0.80 | y = 4.00 + 0.50x | 0.73 |
| B curve | 6.00 | 7.00 | 3.16 | 1.98 | 0.80 | y = 4.00 + 0.50x | 0.71 |
| C one stray point | 6.00 | 7.00 | 3.16 | 1.98 | 0.80 | y = 4.00 + 0.50x | 0.96 |
| D one point makes the line | 6.00 | 7.00 | 3.16 | 1.98 | 0.80 | y = 4.00 + 0.50x | 0.52 |
Use the buttons to change the view. "Four data sets" draws all four at the same scale, with each set's regression line in green (dashed outside the range of the data). "Residual plots" draws each point's distance from the line for the same data. "U-shaped curve" is made-up data on temperature and enzyme activity. On a narrow screen such as a phone, the four pictures stack one per row.
- A straight cloud. The points scatter evenly around the line. Here the line and r sum up the data well.
- B curve. The cell count rises, then bends and falls. The relationship is clear but not straight. You need to fit a curve instead of a line.
- C one stray point. The other nine points form an almost perfect line (r 0.999, slope 0.39), but one point at 8.5 hours pulls the line up, raising the slope to 0.5 and lowering r to 0.8. First check whether that point was measured wrong.
- D one point makes the line. Nine measurements were taken at 5 hours and only one at 15 hours. Remove that one point and every x is the same, so a slope cannot even be worked out. In practice that one point set the line.
Try this. ① "Four data sets": as in the table, all four have r = 0.8, the line y = 4 + 0.5x, and p = 0.006 for the slope. ② "Residual plots": only A scatters around 0 with no pattern. B makes an arch, in C one point has a lone large residual of 3.25, and in D the point at 15 hours has a residual of exactly 0. ③ "U-shaped curve": r = 0, slope 0, Spearman 0.04. The numbers say "no relationship", but the picture is a clear hill.
Assumptions, and how to read a residual plot
A residual plot puts x (or the guess) across and the residual (actual y − y on the line) up. A good residual plot scatters inside a band centred on 0, with no pattern. The confidence interval and p-value in section 5 rest on the assumptions below. When they break, the numbers are hard to trust.
| Assumption | What breaking it looks like in the residual plot | If it breaks |
|---|---|---|
| The relationship is straight | An arch or a U (B) | Fit a curve, or change the values (for example with a log) and look again |
| The points are independent of each other | Joined in time order they make waves. One person appears several times | Data with repeated measurements of the same person needs a method made for it (repeated measures) |
| The spread is even | It opens up like a trumpet toward one side | The standard error and p are wrong. Change the values or use a method that allows for uneven spread |
| The residuals are roughly normal | A long tail on one side, points far away | Matters most with few points. With many points it matters less |
| One or two points do not decide the result | One point far off (C), one x on its own (D) | Run it again without that point and see if the conclusion changes. Do not delete points without a reason |
r = 0 does not mean "no relationship". In the "U-shaped curve", enzyme activity is highest at a middle temperature and falls on both sides, a very clear relationship, yet r is 0. The climb on the left half and the drop on the right half cancel out. r only measures straight-line relationships.
7. Do not stretch the line beyond the data
A line has only been checked where there is data. Put age 0 into the hand example's line 112.5 + 0.35 × age and you get 112.5; put in 200 and you get 182.5. Neither means anything. The data only covers ages 30 to 70. Outside that range the relationship may bend or stop (stretch B's line to 15 hours and it guesses 11.5, while the curve is already on its way down), and the bands widen the further you go from x̄. That is why the lines in labs 1 and 2 are dashed outside the range of the data. If you need to know about ages outside the range, collect data there.
8. Rank correlation (Spearman): ranks instead of values
Spearman's rank correlation replaces the values with their ranks (1, 2, 3 and so on, from smallest) and then works out r. Equal values share their ranks (if 3rd and 4th place are tied, both get 3.5). So it measures not "is it straight?" but "when one goes up, does the other always go up (or always go down)?".
In the hand example the age ranks are 1, 2, 3, 4, 5 and the blood pressure ranks are 1, 4, 3, 2, 5. The rank differences 0, −2, 0, 2, 0 have squares adding up to 8, and the shortcut formula for data without ties gives 1 − 6 × Σdifference² ÷ (n × (n² − 1)) = 1 − 48 ÷ 120 = 0.6. The Pearson r was 0.7.
- Curved but one-way relationships. Even a curve gives Spearman 1 if it only ever goes up (for example x = 1, 2, 3, 4 and y = 1, 8, 27, 64).
- When there are stray values. In C, Pearson is 0.80 and Spearman is 0.96. As a rank, the stray value 11.5 is just "the largest" (10th), so it does not stray far.
- Values that only have an order. Like a pain score from 1 to 5, where you cannot say the steps are equal in size.
A relationship that goes up and then down (a U) is invisible to rank correlation too (0.04). Other tests based on ranks are on the nonparametric tests page.
9. Regression to the mean
In z-score units the slope of the regression line is r (how the formula is built, step ⑥). Because r is below 1, someone 2 standard deviations above the mean on one test is guessed to be only 2 × r standard deviations above the mean on the other. With r = 0.6, that is 1.2. People who were extreme once tend to come out closer to the mean next time. This is regression to the mean. In an 1886 paper Galton compared the heights of parents and their children and called this "regression towards mediocrity", which is where the statistical word "regression" comes from.
Two scores on the same test from 200 made-up people. Score = true skill (mean 50, standard deviation 8) + a new random wobble each time (standard deviation 6). In theory the two scores correlate at 64 ÷ (64 + 36) = 0.64; in this made-up sample it is 0.6 (fixed seed). The orange points are the picked group. With "High on test 2" the purple line guessing test 1 from test 2 is drawn too.
Try this. ① At the start (top 10% on test 1, 20 people): test 1 mean 67.5 → test 2 mean 60.9. Nothing was done to them, yet they came down by 6.6, almost exactly the regression line's guess (60.8). ② "Low on test 1": 34.4 → 41.4, up by 7. ③ "High on test 2": test 2 mean 67.4, the same people's test 1 mean 61.9. Looking backward in time, they still come back toward the mean. ④ For "High on test 1", shrink the share to 5%: 70.4 → 61.5 (down 8.9). Widen it to 30%: 61.8 → 57.1 (down 4.7). The more extreme the group you pick, the further it comes back.
Why it happens. Among people who scored very high on test 1, many have high skill, but many also had a wobble that went up that day. On test 2 the wobble is drawn fresh, so the skill stays and the luck goes back toward average. Picking people who were high on test 2 works exactly the same way. The cause is not the passing of time but how the group was picked.
Easy to mistake for an effect. Take only the people whose blood pressure came out high on a first measurement, do something, and measure again: the average comes down even if what you did had no effect at all. That is why people picked by the same rule are split at random, one group gets it and the other does not (a control group), and the changes in the two groups are compared. Both groups come back toward the mean by the same amount, so only the real difference is left (clinical trial design).
10. Correlation is not causation
Below is made-up data on the share of gray hair and the systolic blood pressure of 60 people in three age groups (30s, 50s, 70s). Both were made higher for older groups, and within one age group the two were made completely unrelated.
Try this. ① At the start, all 60 people together give r = 0.82, slope 0.55, p < 0.001. It looks as if gray hair raises blood pressure. ② Press "Split by age group": inside the 30s, the 50s and the 70s, r is 0. The overall correlation appears because age raises both gray hair and blood pressure.
A hidden variable that affects both and creates a false relationship like this is called a confounder (confounding and bias). There are several ways a correlation between two measurements can arise.
- x changes y (a cause).
- y changes x (the cause runs the other way).
- A hidden third variable changes both (confounding). Age above is this.
- Chance. It happens with few points, or when you compare many pairs (multiple comparisons).
- How the people were picked. Gathering only certain people can create a correlation that was not there, or hide one that was.
The most direct way to find out about causes is an experiment with random assignment. Splitting people as if by coin toss spreads hidden variables evenly over both groups. With observed data, people measure the hidden variables and put them in as well, for example with multiple regression (section 11), but that cannot protect against hidden variables nobody measured.
11. Multiple regression: more than one x
With several x values the guess is y ≈ a + b₁ × x₁ + b₂ × x₂ + …. This is multiple regression, and the numbers are picked with the same least squares. Here b₁ is read as "holding the other x values fixed, how much the average y changes when x₁ goes up by 1". Put the age group into the section 10 data as well, and the slope for gray hair becomes 0, because only comparisons within the same age group are left. But "holding fixed" is a statement about the calculation. Variables you did not put in are not held fixed, the slopes wobble a lot when the x values are strongly correlated with each other, and it only means something if people with the combinations you are holding fixed are really in the data. Putting in too many variables can also give a model that fits only this data (overfitting).
When the result is yes or no. If the result is one of two, like "has the disease or not", a straight line gives nonsense values below 0 or above 1. Then you use logistic regression, which guesses the probability with an S-shaped curve, and its results are often written as odds ratios. If the result is "time until an event happens", you use survival analysis.
Where it is used
- First look at two measurements. Draw the scatter plot first. If it looks straight, report r, the regression line and the slope's confidence interval together.
- Calibration curves (standard curves). In a lab you measure standard samples of known concentration, fit a line between the reading and the concentration, and then guess the concentration of an unknown sample from its reading. Do not guess outside the range of the standards (section 7).
- Do not use r to check whether two measuring methods agree. A machine that always reads 10 higher still gives r = 1. r only checks whether they move together, not whether they give the same values. To check agreement, look at the differences between the two.
- A starting point for prediction models. Linear regression is the simplest prediction model in machine learning, and is also used as a baseline to compare more complex models against.
# The hand example with only the Python standard library (3.12 or later)
import statistics as st
age = [30, 40, 50, 60, 70]
bp = [120, 134, 128, 127, 141]
st.correlation(age, bp) # 0.7: Pearson r
st.correlation(age, bp, method="ranked") # 0.6: Spearman
st.linear_regression(age, bp) # slope 0.35, intercept 112.5
To get the slope's standard error and p-value in one go, use SciPy's scipy.stats.linregress.
Frequently asked questions
If the correlation coefficient r is 0, are the two measurements unrelated?
It means there is no straight-line relationship. A curved relationship, like a hill or a U shape, can be very clear even when r is close to 0. That is why you draw the scatter plot before you trust the number.
How big does r have to be to count as a strong correlation?
There is no rule everyone follows. Where weak, moderate and strong begin is a convention that differs between fields, and different books give different numbers. Look at r² for the share the line explains, and compare with other studies in the same field.
What is the difference between correlation and regression?
Correlation is one number with no units for how closely two measurements move together, and it stays the same if you swap x and y. Regression finds a line that guesses one measurement from the other. The slope has units, and swapping x and y gives a different line.
Does a small p-value mean a strong correlation?
No. The p-value depends heavily on how many points you have. With 1,000 people a weak correlation like r = 0.1 gives p ≈ 0.002, while with 10 people even r = 0.6 gives p ≈ 0.07. Read the size of the relationship from r, r², and the slope with its confidence interval.
If two things are correlated, does one cause the other?
You cannot say that. A hidden third variable may move both, the cause may run the other way, or it may be chance. The most direct way to find out about causes is an experiment where people are split at random.
Words
| Plain words used here | Textbook term |
|---|---|
| A picture with one dot per person for two measurements | Scatter plot |
| How much they move together (has units) | Covariance |
| How closely they move together (−1 to 1) | Pearson correlation coefficient, r |
| The share of the spread the line explains | Coefficient of determination, r² or R² |
| Correlation of ranks | Spearman's rank correlation, ρ (rho) |
| A line that guesses one measurement from the other | Regression line, simple linear regression |
| Slope / intercept | Regression coefficient (slope) / intercept |
| What you guess / what you guess from | Response or dependent variable / predictor, explanatory or independent variable |
| Actual minus the line's guess | Residual |
| How much the slope wobbles from sample to sample | Standard error (SE) |
| n − 2 | Degrees of freedom (df) |
| Band for the mean / band for one new person | Confidence band / prediction band, prediction interval |
| A plot of the residuals | Residual plot |
| The spread is even | Homoscedasticity |
| A stray point / a point alone that sets the line | Outlier / high-leverage point, influential point |
| Stretching beyond the data | Extrapolation |
| Coming back toward the mean | Regression to the mean |
| A hidden third variable | Confounder, confounding variable |
| Regression with several x values / the slope holding the others fixed | Multiple regression / partial regression coefficient |
Sources
- F. J. Anscombe, Graphs in Statistical Analysis, The American Statistician 27(1), 17–21 (1973). Four data sets with the same summary numbers. The four data sets on this page are new ones made up with the same idea.
- Francis Galton, Regression Towards Mediocrity in Hereditary Stature, The Journal of the Anthropological Institute of Great Britain and Ireland 15 (1886). Regression to the mean.
- NIST/SEMATECH e-Handbook of Statistical Methods: 1.3.3.26 Scatter Plot, 4.4.4 How can I tell if a model fits my data? (residual plots).
- Python statistics module documentation (correlation, linear_regression).
- SciPy scipy.stats.linregress documentation.