seegongsik
probability and statistics explained

linear regression and correlation

The correlation coefficient measures the strength of a linear relationship, and least squares finds the line that minimizes the sum of squared residuals. R-squared is the fraction of variance explained. As noise grows, correlation drops toward zero and the confidence interval on the slope widens.

Measured pairs never sit on a perfect line. Height and weight, hours of study and a test score, temperature and ice-cream sales: the points spread into a cloud, and still a tilted trend hides inside it. A correlation number says how tightly those points hug one straight line, and least squares picks the single line that makes the sum of squared vertical misses as small as it can be. From that line we read a slope, ask what share of the scatter the line explains through R², and then ask whether the slope is a real trend or only noise. The algebra is the same one used when a vector is projected onto a column space in engineering mathematics. The lens is different here. We fit a line to noisy observations and ask what that line lets us say. The points scatter, and the line we choose is still one.

Move one point and the correlation r is computed again at once. When the points rise together in a line, r sits near +1. When a larger x comes with a smaller y, r leans toward -1. When the cloud is round and has no direction, r stays near 0. It measures only a straight association, it ignores units, and it does not leave the span from -1 to +1. A bent curve is something this number misses.

On a fixed cloud, place a line yourself. Moving the slope and the intercept turns the line. The meter is SSE, the sum of the squared vertical gaps from each point to the line. Push the line the wrong way and that sum grows. Only one slope and one intercept bring the sum all the way down. That floor is the least-squares line, and the fit control jumps straight there. A good fit does not mean the error is 0. It means the squared error is as small as it can be.

A residual is the vertical gap that is left. Square the length from the real y to the prediction and add them, and you get SSres, the amount the line still misses. Set that next to the miss of a flat mean line, SStot, and the ratio is R² = 1 - SSres / SStot. That is the share of the up-and-down wobble that the line takes. Switch the mean line and the fitted line and the leftover shrinks in front of you. The leftover is the share the line does not explain.

Start from a clean line and pour noise onto it. As the scatter grows, the same underlying trend gets buried, and r slides from near 1 toward 0. The relationship itself has not changed. What changed is how clearly the eye can still see it. A strong correlation is not a steep slope. It is points that stray only a little from the line.

A slope read from the data is only an estimate, so a confidence interval wraps it. With few points or heavy noise the interval widens and can cross 0, and then the trend might be an accident. Gather more points and the interval narrows. Once the interval leaves 0 completely, that slope is called statistically significant. Push the sample and the interval tightens toward the true slope. A narrower interval is the answer.

In PracticeThe correlation r says how tightly a cloud of points hugs a line, on the span from -1 to +1. Least squares picks the one line whose squared vertical misses add up to the smallest total, and R² tells the share of the wobble that line explains. A confidence interval on the slope says whether the trend is clear enough to trust or whether it is noise. Fit the line, read R², and look at the interval before you trust the slope.
← probability and statistics explained
Was this helpful? Support seegongsik