Over a million developers have joined DZone.

R-Square Value Demystified

DZone's Guide to

R-Square Value Demystified

I want to take few steps back to clear the fog with regards to the calculation of the R-Square statistic and kill the confusion around it

· Big Data Zone ·
Free Resource

The open source HPCC Systems platform is a proven, easy to use solution for managing data at scale. Visit our Easy Guide to learn more about this completely free platform, test drive some code in the online Playground, and get started today.

As we all know, in today's world of quick results and insights, nobody wants to spend time on understanding the core concepts of certain statistical terms while performing an analytical routine. One statistical term that is talked about a lot but that does not have very well-understood mechanics is R-Square statistics (AKA coefficient of determination). This statistic helps to measure the closeness of the data to the fitted line of regression.

It is also worth mentioning that by squaring the correlation coefficient statistic, one can calculate the R-Square value. However, I want to take few steps back to clear the fog with regards to the calculation of this statistic and kill the confusion around it (I know this is quite an extreme statement). As they say, the devil is in the details...

So, let's get started.

What Is an R-Square Value?

To simply put it, it is:

Total sum of squares - residual sum of squares / total sum of squares

Quite a mouthful. Let's make it a bit simpler. It can also be defined as:

Error sum of squares / total sum of squares

Some of you might even chuckle and say, "But we don't even know how to calculate the above mumbo-jumbo!" And my answer to you all would be, "No worries; let me explain it with the help of mathematical notations!" Yes, mathematical notations!

Let's make the above calculations more obvious by looking at an example:

  1. Step 1: Calculating the mean value of the Y variable and total sum of squares
  2. Step 2: Calculating the residual sum of squares
  3. Step 3: Calculating the error sum of squares (sum of square error)

Once all the important elements are calculated, you are ready to compute the R-Square value.

Short-Form R Square Calculation Method = ESS / TSS

To prove the above calculations, I created a scatter plot chart in Excel and also cross-validated the information by using regression analysis with Excel's Data Analysis Tool Pack.

The next topic that might be a good candidate for further discussion related to the R-Square value is Adjusted R-Square. We usually use this statistic when we have multiple predictor variables. The standard R-Square value tends to increase with the number of predictor variables, which might not be a good way to look at the model's performance. Therefore, when working with multiple predictor variables, statisticians and analysts prefer to use the Adjusted R-Square.

Calculating this value is pretty simple and straight-forward. Let's look at its notation to understand the mechanics of this statistic.

  • N = Number of points in the data sample
  • P = Number of independent predictor variables or regressors, i.e. the number of variables in your model barring the constant

How does this work in our example?

It's pretty simple.

1-(1-0.04783 (R-Squared value)) * (16 (number of Y data points) - 1) / (16 -1 (predictor variables [if you have >1 predictor variables, you will mention that number here]) -1) = -0.02018

Check the Adjusted R-Square value from the Data Analysis Tool Pack's regression analysis results.

You can download the working file by clicking here.

Managing data at scale doesn’t have to be hard. Find out how the completely free, open source HPCC Systems platform makes it easier to update, easier to program, easier to integrate data, and easier to manage clusters. Download and get started today.

big data ,logistic regression ,data analytics ,data visualization

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}