R Squared Formula

Updated on March 14, 2024
Article byHarsh Katara
Edited byAshish Kumar Srivastav
Reviewed byDheeraj Vaidya, CFA, FRM

What is R Squared (R2) in Regression?

R-squared (R2) is an important statistical measure. A regression model represents the proportion of the difference or variance in statistical terms for a dependent variable that an independent variable or variables can explain. In short, it determines how well the data will fit the regression model.

Key Takeaways

  • R-squared (R2) is an essential statistical tool. A regression model shows the difference or variance proportion in statistical terms for a dependent variable that an independent variable or variables can explain. Then, it calculates the data that fits the regression model.
  • For the R-squared calculation, one must estimate the correlation coefficient and then square the result.
  • The R-squared relevance in regression is the capability to search the probability of the future event happening in the forecasted results or the outcomes. 

R Squared Formula

To calculate R-squared, you need to determine the correlation coefficient and then square the result.

R Squared Formula = r2

Where r the correlation coefficient can be calculated per below:

r = n (∑xy) – ∑x ∑y / √ [n* (∑x2 – (∑x)2)] * [n* (∑y2 – (∑y)2)]
R Squared Formula

You are free to use this image on your website, templates, etc, Please provide us with an attribution linkHow to Provide Attribution?Article Link to be Hyperlinked
For eg:
Source: R Squared Formula (wallstreetmojo.com)

Where,

  • r = The Correlation coefficient
  • n = number in the given dataset
  • x = first variable in the context
  • y = second variable
Financial Modeling & Valuation Courses Bundle (25+ Hours Video Series)

–>> If you want to learn Financial Modeling & Valuation professionally , then do check this ​Financial Modeling & Valuation Course Bundle​ (25+ hours of video tutorials with step by step McDonald’s Financial Model). Unlock the art of financial modeling and valuation with a comprehensive course covering McDonald’s forecast methodologies, advanced valuation techniques, and financial statements.

Explanation

Suppose there is any relationship or correlation which may be linear or non-linear between those two variables. In that case, if there is a change in the independent variable in value, the other dependent variable will likely change in value, say linearly or nonlinearly.

The numerator part of the formula tests whether they move together and remove their movements. The relative strength of both of them moving together. The denominator part of the formula scales the numerator taking the square root of the product of the differences between the variables from their squared variables. And when you square this result, we get R-squared, which is nothing but the coefficient of determination.

Examples

You can download this R Squared Formula Excel Template here – R Squared Formula Excel Template

Example #1

Consider the following two variables x and y, you are required to calculate the R Squared in Regression.

r sq Example 1.1

Solution:

Using the formula mentioned above, we need to first calculate the correlation coefficient.

r sq Example 1.2

We have all the values in the above table with n = 4.

Let’s now input the formulas’ values to arrive at the figure.

Example 1.3

r = ( 4 * 26,046.25 ) – ( 265.18 * 326.89 )/ √ [(4 * 21,274.94) – (326.89)2] * [(4 * 31,901.89) – (326.89)2]

r = 17,501.06 / 17,512.88

The Correlation Coefficient will be-

r sq Example 1.4

r = 0.99932480

So, the calculation will be as follows,

r sq Example 1.5

r2 = (0.99932480)2

R Squared Formula in Regression

r sq Example 1.6

r2 = 0.998650052

Example #2

India, a developing country, wants to conduct an independent analysis of whether changes in crude oil prices have affected its rupee value. Following is the history of Brent crude oil price and rupee valuation, both against dollars that prevailed on an average for those years below.

Solution:

Using the formula for the correlation above, we can calculate the correlation coefficient first. Treating average crude oil price as one variable, say x, and treating Rupee per dollar as another variable as y.

r sq Example 2.1

RBI, the Central Bank of India, has approached you to provide a presentation on the same in the next meeting. But, first, determine whether the movements in crude oil affect movements in the rupee per dollar.

Solution:

Using the formula for the correlation above, we can calculate the correlation coefficient first. For example, treating average crude oil price as one variable, say x, and treating rupee per dollar as another as y.

r sq Example 2.3

We have all the values in the above table with n = 6.

Let’s now input the formulas’ values to arrive at the figure.

The Correlation Coefficient will be-

r sq Example 2.4

r = (6 * 23592.83) – (356.70 * 398.59) / √ [(6 * 22829.36) – (356.70)2] * [(6 * 26529.38) – (398.59)2]

r = -620.06 / 1,715.95

r = -0.3614

So, the calculation will be as follows,

Example 2.5

r2 = (-0.3614)2

R Squared Formula in Regression

Example 2.6

r2 = 0.1306

Analysis: There is a minor relationship between changes in crude oil prices and the price of the Indian rupee. As crude oil price increases, the changes in the Indian rupee also affect. But since R-squared is only 13%, the changes in crude oil price explain very little about changes in the Indian rupee. The Indian rupee is also subject to changes in other variables, which must account for.

Example #3

XYZ laboratory is researching height and weight and is interested in knowing if there is any relationship between these variables. After gathering a sample of 5000 people for every category and came up with an average weight and height in that particular group.

Below are the details that they have gathered.

R Squared Formula Example 3.1

You are required to calculate R-squared and conclude if this model explains the variances in height affect variances in weight.

Solution:

Using the formula for the correlation above, we can calculate the correlation coefficient first. For example, treating height as one variable, say x, and weight as another as y.

R Squared Formula Example 3.2

We have all the values in the above table with n = 6.

Let’s now input the values in the formula to arrive at the figure.

Example 3.3

r = ( 7 * 74,058.67 ) – (1031 * 496.44) / √[(7 * 153595 – (1031)2] * [(7 * 35793.59) – (496.44)2]

r = 6,581.05 / 7,075.77

The Correlation Coefficient will be-

R Squared Formula Example 3.4

Correlation Coefficient (r) = 0.9301

So, the calculation will be as follows,

Example 3.5

r2 = 0.8651

Analysis: The correlation is positive. It appears there is some relationship between height and weight. As the height increases, the person’s weight also appears to increase. While R2 suggests that 86% of changes in height attributes to changes in weight, 14% are unexplained.

Relevance and Uses

The relevance of R-squared in regression is its ability to find the probability of future events occurring within the given predicted results or the outcomes. If more samples are added to the model, the coefficient will show the likelihood or the probability of a new point or the new dataset falling on the line. The determination does not prove causality even if both variables have a strong connection.

Some of the spaces where R squared is mostly used is for tracking mutual fund performance, tracking risk in hedge funds, and determining how well stock moves with the market, where R2 would suggest how much of the stock can be explained by the movements in the market.

Frequently Asked Questions (FAQs)

Can the R-squared formula be negative?

The Adjusted R Square will become negative when the R-squared formula is relatively tiny to the parameter’s ratio.

Is the R-squared formula a percentage?

R-squared values range from 0 to 1. It is commonly expressed in percentages from 0% to 100%. An R-squared of 100% means that movements in the index wholely explain security’s all actions.

Why is R- the squared formula essential?

R-squared determines the relationship between the dependent variable movements depending on an independent variable’s movements. Therefore, it does not show whether the selected model is good or bad, nor will it display whether the data and predictions are biased.

Can the R-squared formula decrease with more variables?

The R-squared formula value always stays the same regardless of how many variables we add to our regression model. It is because even though one adds unnecessary variables to the data, the value of the R-squared does not decrease. Instead, it either stays the same or increases with new independent variables.

Recommended Articles

This article has been a guide to R-Squared Formula in Regression. Here, we learn how to calculate R-Square using its formula, examples, and a downloadable Excel template. You can learn more about financial analysis from the following articles: –