Correlation tells you how closely two variables move together. Regression goes one step further and answers a question economists ask all the time: if x is this much higher, how much higher do we expect y to be? This lesson builds the least-squares line from scratch, shows how it connects to r and to R², and ends with what a fitted line can and cannot tell you. It is a primer; the detailed treatment comes in the econometrics module.
Ashanagar is an invented district. The statistics lessons use it for every worked example, so you meet the same households again as the ideas build: first as a list of numbers, then as a spread, then as a population to sample from.
It has 60 households, each with a monthly income in rupees. Unless a page says otherwise, those 60 are the whole population, and a “sample” means a few of them drawn at random. Where a page needs two variables, it uses a smaller set of 12 households with the head’s years of schooling beside income.
The figures are illustrative, made up once and fixed. They are not official statistics.
Lesson 6 left a question open. The twelve Ashanagar households showed a correlation of 0.87 between years of schooling and monthly income. That says the two rise together. It does not say how much extra income one more year of schooling goes with, and that is usually what we want to know. A regression line answers it: it is the straight line that comes closest to the points, written as
Here x is the variable we start from (the independent or explanatory variable), y is the one we want to explain (the dependent variable), b is the slope and a is the intercept, the predicted y when x is zero. The hat over y means a predicted value, as opposed to an observed one.
This is a different job from correlation. Correlation treats the two variables alike. Regression picks a side: it predicts y from x, and the line you get changes if you swap them, as the fourth section shows.
Any line leaves a gap between what it predicts and what actually happened. That gap is the residual: actual minus estimated, ê = y − ŷ (CUET 2020, CUET 2023). If the fitted line is Ŷ = −15 + 0.75X, then at X = 30 the line predicts −15 + 22.5 = 7.5. A household with Y = 50 there has a residual of 50 − 7.5 = 42.5 (CUET 2018): the line badly underestimates it.
Which line is the best? Residuals above and below the line would cancel if you just added them, so we square them first, exactly as we did for the variance. The least-squares line is the one that makes the sum of the squared residuals as small as possible. It is the only line that does.
Try it yourself. The two sliders set a line through the twelve households. The red segments are the residuals, and the box on the left adds up their squares. Slide until you think you have the smallest total, then snap to the real least-squares line to see how close you came.
Your line leaves 205.4 more squared miss than the best line. Tilt it and move it up or down until the red segments are as short as you can make them together. A bad line can even give a negative R², because it fits worse than a flat line at the mean income.
Squaring does three jobs. It stops positive and negative misses cancelling, it punishes one big miss more than several small ones, and it gives formulas for the best a and b that can be written down exactly, with no trial and error. It is the same square that built the variance.
Minimising the squared residuals gives two clean formulas:
Three things follow, and each appears in the exams:
For the twelve households, the covariance is 21.83 and the variance of schooling is 3.33² = 11.08, so b = 1.97 and a = 23 − 1.97 × 10.42 = 2.47. The line is income ≈ 2.47 + 1.97 × schooling, in ₹ thousand. Read it as: households whose head has one more year of schooling have, on average in this sample, about ₹1,970 a month more.
Take any line ŷ = a + bx. Household i misses by . Misses above and below would cancel, so square them and add:
S depends on two numbers, a and b. Drawn against both it is a bowl, and the lowest point is where the bowl stops sloping in either direction. So we look for the place where both slopes are zero.
Dividing by n says the average miss is zero, which is the same as saying the line passes through the point of means (x̄, ȳ). Whatever slope we end up with, the intercept is a = ȳ − b x̄. For the twelve households, x̄ = 125 ÷ 12 = 10.42 and ȳ = 23.
Write ui = xi − x̄ and vi = yi − ȳ. With a = ȳ − b x̄ the miss at household i is vi − b ui, so
For the twelve households Sxx = 132.92, Sxy = 262 and Syy = 684, so S(b) = 684 − 524b + 132.92b². Slide b along the bowl and watch the line it stands for.
It is a minimum, not a maximum, because the second derivative 2Sxx is positive. There is also a way to see it without calculus. Complete the square:
The first term is never negative and is zero at exactly one slope. The second term does not involve b at all, so nothing can beat it.
b = Sxy ÷ Sxx = 262 ÷ 132.92 = 1.971 and a = 23 − 1.971 × 10.42 = 2.47. Divide the top and bottom by n and the slope becomes covariance over variance, 21.83 ÷ 11.08, the form the lesson uses. Since Sxy = r √(SxxSyy), it is also .
The smallest possible total miss is the second bracket: 684 − 262² ÷ 132.92 = 167.56, which is Syy(1 − r²). That small fact is where R² comes from, in the last derivation of this lesson.
Regression slopes carry units, so they respond to changes of units in a pattern worth learning once. Suppose the fitted line is y = 10 + 3x.
Models that are linear in the parameters are linear regressions even when they are not linear in the variables: y = a + b ln x, or y = a + bx + cx² (CUET 2023, CUET 2025). A model such as y = a·xb is not, until you take logarithms to turn it into ln y = ln a + b ln x.
A regression of ln Y on time t, ln Yt = a + bt, says Y grows by a roughly constant percentage each year. The slope is the growth rate in logs, so the compound annual rate is eb − 1. With b = 0.1512 that is e0.1512 − 1 = 16.32% (JAM 2026). The slope read as a percentage, 15.12%, is only an approximation, and it gets worse as b grows. This is the same continuous-versus-compound point as in Lesson 9.
You can regress y on x, minimising vertical misses, or x on y, minimising horizontal misses. These are different lines. Their slopes are
Multiply them and the standard deviations cancel, leaving r². So r = ±√(byx bxy), with the sign taken from the slopes, and byx and bxy always have the same sign. If byx = 1.6 and bxy = 0.4, then r = √0.64 = 0.8, positive because both are (CUET 2021). Use the sliders to see how the two lines behave as r changes.
The weaker the correlation, the further apart the lines swing. Both slopes carry the sign of r, and both lines pass through the point of means. Change the spread of y and both slopes change, since they depend on units, while the picture and the product of the slopes do not.
The facts the exams ask, all visible in the picture:
Why two lines? Because the predictions differ. Take very tall parents: their children tend to be tall, but on average not as tall as the parents. Predicting child from parent pulls the prediction back toward the average. That pull, called regression to the mean, is what the weaker slope shows. Francis Galton noticed it in heights in the 1880s, and the word “regression” comes from it.
A question that hands you the two lines and asks for r needs one decision first: which line is y on x, and which is x on y? Try an assignment and multiply the two slopes. If the product exceeds 1 the assignment was wrong, because r² cannot. The opening question works through exactly this, at the end of the lesson.
A line can be the best possible and still fit badly. The coefficient of determination, R², measures how well it fits. The total variation in y is SST, the sum of squared deviations of y from its mean. The line explains part of it, SSR, and leaves the rest as residual, SSE:
A small worked case: the line Y = −2.5 + 2X is fitted to Y = 2, 5, 9, 14 and X = 2, 4, 6, 8. It predicts 1.5, 5.5, 9.5, 13.5, so the residuals are 0.5, −0.5, −0.5, 0.5 and SSE = 1. The mean of Y is 7.5, so SST = 30.25 + 6.25 + 2.25 + 42.25 = 81. Then R² = 1 − 1 ÷ 81 = 0.988 (JAM 2024).
For the schooling data R² = 0.87² = 0.755: about three-quarters of the variation in income among these households is accounted for by schooling in a straight-line fit. It does not say the other quarter is noise; it says schooling alone does not account for it.
If you regress x on y instead, the slope changes (it is bxy, not 1 ÷ byx) and so does the sum of squared errors, since it now measures horizontal misses in different units. But r and R² do not change, and the slope keeps its sign (UGC NET 2024).
The line predicts ŷi. The distance of the actual income from the mean income splits into a part the line accounts for and a part it misses:
Explained plus left over, drawn as the blue and red strokes in the picture below.
The last term has to go if the pieces are to add up. Does it?
With a = ȳ − b x̄ we have ŷi − ȳ = b ui, and the miss is ei = vi − b ui (u and v as in the slope derivation). So
because b = Sxy ÷ Sxx. Try it in the picture. At the least-squares slope SSR + SSE equals SST exactly. Tilt the line and the pieces stop adding up, by the amount 2b(bSxx − Sxy).
It also follows that SSE = SST − SSR = SST(1 − r²), the smallest total miss found in the slope derivation.
SST = 684, SSR = 262² ÷ 132.92 = 516.4 and SSE = 167.6, and 516.4 + 167.6 = 684. The explained share is 516.4 ÷ 684 = 0.755, which is 0.869². About three quarters of the variation in income across these households goes with differences in schooling.
A regression line is a summary of how y moves with x in the data. It does not, on its own, say that x causes y. Regression analysis does not necessarily imply causation (Hyderabad 2015), and the line represents a quantitative relationship between variables, not causality and not an economic identity (Hyderabad 2011). It is the tool used when we have a reason to treat one variable as depending on another, which is why CUET 2019 names regression as the method for analysing a dependence between two variables. Whether the dependence is causal is a question about the data and the design of the study, which the line cannot answer.
Some cautions that apply every time you read a fitted line:
Definitions, one-step arithmetic and which-measure questions. Most CUET and Hyderabad questions sit here.
Grouped data, combined means, effects of shifting and scaling, and statement questions, up to JNU level.
This topic’s hardest questions, from the DSE entrance, are worked through in Lesson 10: Regression.
These are questions from the TestStop bank. A free account answers 10 a day, each with its worked solution; All-Access opens every set with no daily limit.