what is r squared in linear regression
R-squared in linear regression is a statistic that tells you what fraction of the variation in the dependent variable is explained by your regression line or model.
Quick Scoop: Core Idea
- R-squared (also called the coefficient of determination) measures how well your regression line fits the data.
- It is usually between 0 and 1 in standard linear regression setups.
- Closer to 1 â the model captures most of the variability in the outcome; closer to 0 â it captures very little.
In simple linear regression with one predictor, R-squared is literally the square of the correlation between X and Y, which is where the name comes from.
How R-squared Is Calculated
Conceptually, R-squared compares how much error your model makes vs. a naive model that always predicts the mean of Y.
- Total variation in Y is measured by the total sum of squares (TSS), the squared deviations of Y from its mean.
- Unexplained variation is measured by the residual sum of squares (RSS), the squared differences between actual and predicted values.
- R-squared is the fraction of total variation that is âexplainedâ by the model (1 â RSS/TSS).
So if R-squared = 0.80, youâd say âthe model explains about 80% of the variance in the dependent variable.â
Interpreting R-squared in Practice
R-squared is a goodness-of-fit measure, but âgoodâ depends on context.
- High R-squared (e.g., 0.9) often appears in physical or engineered systems where relationships are tight and noise is low.
- Moderate or low R-squared can be normal in fields like social science or finance, where outcomes are noisy.
- A higher R-squared means the fitted values lie closer to the regression line, i.e., smaller residuals on average.
R-squared does not prove causality; it only measures how strongly the modelâs predictions move with the observed data.
Limitations and Pitfalls
Even though R-squared is popular, it has some important limitations.
- Adding more predictors will never decrease R-squared; it usually goes up, even if the new variables are useless.
- A very high R-squared can still come from a badly specified model (e.g., missing nonlinearity, overfitting, or omitted variables).
- R-squared alone does not tell you whether coefficients are statistically significant or whether assumptions (linearity, homoscedasticity, etc.) hold.
Thatâs why adjusted R-squared, residual diagnostics, and domain knowledge are typically used alongside plain R-squared.
Simple Example (Story Style)
Imagine you are trying to predict house prices from square footage in a single city.
- Model A: You just draw a flat line at the average house price. This is the âno modelâ baseline.
- Model B: You fit a linear regression: price = a + b¡(square footage).
If Model Bâs R-squared is 0.75, it means that, compared to Model A, the regression explains about 75% of the variation in prices across houses just by using square footage.
In other words: R-squared is a score from 0 to 1 that tells you âhow much better than just predicting the averageâ your regression line really is.
TL;DR: R-squared in linear regression is the proportion of variance in the dependent variable that your model explains, comparing it to a baseline that always predicts the mean; higher values mean a tighter fit, but it doesnât guarantee a correct or causal model.
Information gathered from public forums or data available on the internet and portrayed here.