For enquiries call:



April flash sale-mobile

HomeBlogData ScienceHow to Interpret R Squared and Goodness of Fit in Regression Analysis

How to Interpret R Squared and Goodness of Fit in Regression Analysis

18th Jan, 2024
view count loader
Read it in
10 Mins
In this article
    How to Interpret R Squared and Goodness of Fit in Regression Analysis

    Regression Analysis is a set of statistical processes that are at the core of data science. In the field of numerical simulation, it represents the most well-understood models and helps in interpreting machine learning algorithms. 

    In my exploration of linear regression models across diverse fields such as ads, medical research, farming, and sports, I've marveled at their versatility. There's this handy measure called R-squared that tells us how well the model and the thing we're studying are connected. It's on a scale from 0 to 100%, which makes it easy to figure out how good the model is. 

    In linear regression models, R-squared is a goodness-fit-measure. It takes into account the strength of the relationship between the model and the dependent variable. Its convenience is measured on a scale of 0 – 100%.. 

    Once you have a fit linear regression model, there are few considerations that you need to address: 

    • How well does the model fit the data? 
    • How well does it explain the changes in the dependent variable? 

    In this article, we will learn about R-squared (R2 ), r squared interpretation, limitations, and few miscellaneous insights about it. We will also cover Machine Learning with Python fundamentals and more.

    Let us first understand the fundamentals of Regression Analysis and its necessity. 

    What is Regression Analysis? 

    Regression Analysis is a well-known statistical learning technique that allows you to examine the relationship between the independent variables (or explanatory variables) and the dependent variables (or response variables). It requires you to formulate a mathematical model that can be used to determine an estimated value that is nearly close to the actual value. 

    The two terms essential to understanding Regression Analysis: 

    • Dependent variables - The factors that you want to understand or predict. 
    • Independent variables - The factors that influence the dependent variable. 

    Imagine having data on students, including how much they study, their attendance, and their exam scores. Regression analysis helps you figure out which factors really matter, which ones you can ignore, and how these factors relate to each other. 

    Using regression, I can see which aspects, like study hours or attendance, have a big impact on exam scores. It's like a tool that highlights what truly influences success in exams. At the same time, it helps me identify things that don't really affect the scores, making my analysis more focused. 

    So, when I dive into this student data, I'm not just looking at each factor in isolation. Regression lets me uncover the connections between study hours, attendance, and exam scores. It's a simple yet powerful way to understand the complex web of influences on student performance. 

    There are mainly two objectives of a Regression Analysis technique: 

    • Explanatory analysis - This analysis understands and identifies the influence of the explanatory variable on the response variable concerning a certain model. 
    • Predictive analysis - This analysis is used to predict the value assumed by the dependent variable.  

    Why use Regression Analysis? 

    The technique generates a regression equation where the relationship between the explanatory variable and the response variable is represented by the parameters of the technique. 

    You can use the Regression Analysis to perform the following: 

    • To model different independent variables. 
    • To add continuous and categorical variables having numerous distinct groups based on a characteristic. 
    • To model the curvature using polynomial terms. 
    • To determine the effect of a certain independent variable on another variable by assessing the interaction terms.  

    What are Residuals? 

    Residuals identify the deviation of observed values from the expected values. They are also referred to as error or noise terms. A residual gives an insight into how good our model is against the actual value but there are no real-life representations of residual values. 

    How To Interpret R squared and Goodness of Fit in Regression Analysis  


    Regression Line and residual plots

    The calculation of the real values of intercept, slope, and residual terms can be a complicated task. However, the Ordinary Least Square (OLS) regression technique can help us to speculate on an efficient model.  The technique minimizes the sum of the squared residuals. With the help of the residual plots, you can check whether the observed error is consistent with the stochastic error (differences between the expected and observed values must be random and unpredictable).  

    What is Goodness-of-Fit?  

    The Regression Analysis is a part of the linear regression technique. It examines an equation that reduces the distance between the fitted line and all of the data points. Determining how well the model fits the data is crucial in a linear model. 

    A general idea is that if the deviations between the observed values and the predicted values of the linear model are small and unbiased, the model has a well-fit data.  

    In technical terms, “Goodness-of-fit” is a mathematical model that describes the differences between the observed values and the expected values or how well the model fits a set of observations. This measure can be used in statistical hypothesis testing. 

    How to assess Goodness-of-fit in a regression model? 

    According to my understanding as a statistician, if I observe that the differences between the predicted values and the actual observations are consistently small and unbiased, it indicates a well-fitted model. In this context, unbiasedness means that the predicted values don't veer too high or too low compared to the actual observations. 

    As I've explored earlier, a linear regression model provides an equation that minimizes the differences between observed and predicted values. In simpler terms, it seeks the smallest sum of squared residuals for the given dataset. 

    In the process of assessing a regression model, it's crucial to examine residual plots before delving into numerical measures of goodness-of-fit, such as R-squared. These plots play a vital role in identifying potential biases in the model by revealing any problematic patterns. 

    If there's evidence of a biased model based on the residual plots, it's a red flag. In such cases, relying on the model results becomes questionable. On the flip side, if the residual plots look good and don't show problematic patterns, then it's appropriate to proceed with evaluating numerical metrics like R-squared and other outputs..

    What is R-squared? 

    R squared (R2  value in machine learning is referred to as the coefficient of determination or the coefficient of multiple determination in case of multiple regression.  

    R squared in regression acts as an evaluation metric to evaluate the scatter of the data points around the fitted regression line. It recognizes the percentage of variation of the dependent variable.  

    R-squared and the Goodness-of-fit 

    R-squared is the proportion of variance in the dependent variable that can be explained by the independent variable.

    How To Interpret R squared and Goodness of Fit in Regression Analysis  

    The value of R-squared stays between 0 and 100%: 

    • 0% corresponds to a model that does not explain the variability of the response data around its mean. The mean of the dependent variable helps to predict the dependent variable and also the regression model. 
    • On the other hand, 100% corresponds to a model that explains the variability of the response variable around its mean. 

    If your value of R2  is large, you have a better chance of your regression model fitting the observations. 

    Although you can get essential insights about the regression model in this statistical measure, you should not depend on it for the complete assessment of the model. It does not give information about the relationship between the dependent and the independent variables.  

    It also does not inform about the quality of the regression model. Hence, as a user, you should always analyze R2  along with other variables and then derive conclusions about the regression model. 

    Visual Representation of R-squared 

    You can have a visual demonstration of the plots of fitted values by observed values in a graphical manner. It illustrates how R-squared values represent the scatter around the regression line. 

    How To Interpret R squared and Goodness of Fit in Regression Analysis  

    As observed in the pictures above, the value of R-squared for the regression model on the left side is 17%, and for the model on the right is 83%. In a regression model, when the variance accounts to be high, the data points tend to fall closer to the fitted regression line.  

    However, a regression model with an R2  of 100% is an ideal scenario which is actually not possible. In such a case, the predicted values equal the observed values and it causes all the data points to fall exactly on the regression line.  

    How to Interpret R squared

    The simplest r squared interpretation is how well the regression model fits the observed data values. Let us take an example to understand this.

    Consider a model where the  R2   value is 70%. Here r squared meaning would be that the model explains 70% of the fitted data in the regression model. Usually, when the R2   value is high, it suggests a better fit for the model.  

    The correctness of the statistical measure does not only depend on R2   but can depend on other several factors like the nature of the variables, the units on which the variables are measured, etc. So, a high R-squared value is not always likely for the regression model and can indicate problems too. 

    A low R-squared value is a negative indicator for a model in general. However, if we consider the other factors, a low R2  value can also end up in a good predictive model. 

    Calculation of R-squared 

    R- squared can be evaluated using the following formula: 

    How To Interpret R squared and Goodness of Fit in Regression Analysis  


    • SSregression – Explained sum of squares due to the regression model. 
    • SStotal  The total sum of squares. 

    The sum of squares due to regression assesses how well the model represents the fitted data and the total sum of squares measures the variability in the data used in the regression model. 

    Now let me come back to the earlier situation where we have two factors: number of hours of study per day and the score in a particular exam to understand the calculation of R-squared more effectively. Here, the target variable is represented by the score and the independent variable by the number of hours of study per day.

    How To Interpret R squared and Goodness of Fit in Regression Analysis  
    In this case, we will need a simple linear regression model and the equation of the model will be as follows:  

    ŷ = w1x1 + b

    The parameters w1  and b can be calculated by reducing the squared error over all the data points. The following equation is called the least square function:

    minimize ∑(yi –  w1x1i – b)2

    How To Interpret R squared and Goodness of Fit in Regression Analysis  

    Now, to calculate the goodness-of-fit, we need to calculate the variance:

    var(u) = 1/n∑(ui – ū)2

    where, n represents the number of data points. 

    Now, R-squared calculates the amount of variance of the target variable explained by the model, i.e. function of the independent variable. 

    However, in order to achieve that, we need to calculate two things: 

    • Variance of the target variable: 

    var(avg) = ∑(yi – Ӯ)2

    • Variance of the target variable around the best-fit line:

    var(model) = ∑(yi – ŷ)2

    How To Interpret R squared and Goodness of Fit in Regression Analysis  

    Finally, we can calculate the equation of R-squared as follows:

    R2  = 1 – [var(model)/var(avg)] = 1 -[∑(yi – ŷ)2/∑(yi – Ӯ)2] 

    Limitations of R-squared 

    Some of the limitations of R-squared are: 

    • R-squared cannot be used to check if the coefficient estimates and predictions are biased or not. 
    • R-squared does not inform if the regression model has an adequate fit or not. 

    To determine the biasedness of the model, you need to assess the residuals plots. A good model can have a low R-squared value whereas you can have a high R-squared value for a model that does not have proper goodness-of-fit.  

    Low R-squared and High R-squared values 

    Regression models with low R2  do not always pose a problem. There are some areas where you are bound to have low R2  values. One such case is when you study human behavior. They tend to have R2   values less than 50%. The reason behind this is that predicting people is a more difficult task than predicting a physical process. 

    You can draw essential conclusions about your model having a low R2  value when the independent variables of the model have some statistical significance. They represent the mean change in the dependent variable when the independent variable shifts by one unit. 

    However, if you are working on a model to generate precise predictions, low R-squared values can cause problems. 

    Now, let us look at the other side of the coin. A regression model with high R2   value can lead to – as the statisticians call it – specification bias. This type of situation arises when the linear model is underspecified due to missing important independent variables, polynomial terms, and interaction terms.  

    To overcome this situation, you can produce random residuals by adding the appropriate terms or by fitting a non-linear model. 

    Model overfitting and data mining techniques can also inflate the value of R2 . The model they generate might provide an excellent fit to the data but actually, the results tend to be completely deceptive. 

    Supercharge your career elevating your skills with business analyst courses online  designed to boost your career. Join the elite league today!


    Let us summarize what we have covered in this article so far: 

    • Regression Analysis and its importance 
    • Residuals and Goodness-of-fit 
    • R-squared: Representation, how to interpret r squared, Calculation, Limitations 
    • Low and High R2  values 

    Although R-squared is a very intuitive measure to determine how well a regression model fits a dataset, it does not narrate the complete story. If you want to get the full picture, you need to have an in-depth knowledge of R2  along with other statistical measures and residual plots.

    For gaining more information on the limitations of the R-squared, you can learn about adjusted r squared interpretation and Predicted R-squared which provide different insights to assess a model’s goodness-of-fit. You can also take a look at a different type of goodness-of-fit measure, i.e. Standard Error of the Regression. Learn more about linear regression applications with KnowledgeHut Machine Learning with Python and other allied courses.

    Frequently Asked Questions (FAQs)

    1How do you tell if a regression model is a good fit in R?

    In R, you can assess the goodness of fit by checking the residual plots. If the residuals show a random pattern and are evenly spread, it indicates a good fit. Also, consider metrics like R-squared and see if it's close to 1.

    2Does higher R2 mean better fit?

    Yes, a higher R-squared generally means a better fit. R-squared measures the proportion of the variation in the dependent variable that the model explains. So, the closer R-squared is to 1, the better the model is at explaining the variability in the data.

    3What R-squared value is a good fit?

    A good rule of thumb is that an R-squared value above 0.70 is often considered good, but it depends on the context. It's essential to consider the nature of the data and the specific field, as what's considered good can vary.

    4How do you interpret regression results?

    To interpret regression results, focus on the coefficients of the variables. A positive coefficient means an increase in the independent variable relates to an increase in the dependent variable. Conversely, a negative coefficient implies a decrease. Also, look at p-values; lower p-values suggest more significant effects.


    Ashish Gulati

    Data Science Expert

    Ashish is a techology consultant with 13+ years of experience and specializes in Data Science, the Python ecosystem and Django, DevOps and automation. He specializes in the design and delivery of key, impactful programs.

    Share This Article
    Ready to Master the Skills that Drive Your Career?

    Avail your free 1:1 mentorship session.

    Your Message (Optional)

    Upcoming Data Science Batches & Dates

    NameDateFeeKnow more
    Course advisor icon
    Course Advisor
    Whatsapp/Chat icon