## What is R Squared (R2) in Regression?

R-squared (R

^{2}) is an important statistical measure which is a regression model that represents the proportion of the difference or variance in statistical terms for a dependent variable which can be explained by an independent variable or variables. In short, it determines how well data will fit the regression model.

### R Squared Formula

For the calculation of R squared, you need to determine the Correlation coefficient, and then you need to square the result.

**R Squared Formula = r ^{2}**

Where r the correlation coefficient can be calculated per below:

**r = n (∑xy) – ∑x ∑y / √ [n* (∑x**

^{2}– (∑x)^{2})] * [n* (∑y^{2}– (∑y)^{2})] 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

### Explanation

If there is any relationship or correlation which may be linear or non-linear between those two variables, then it shall indicate if there is a change in the independent variable in value, then the other dependent variable will likely change in value, say linearly or non-linearly.

The numerator part of the formula conducts a test whether they move together and removes their individual movements and relative strength of both of them moving together, and the denominator part of the formula scales the numerator by taking the square root of the product of the differences of the variables from their squared variables. And when you squared this result, we get R squared, which is nothing but the coefficient of determinationThe Coefficient Of DeterminationCoefficient of determination, also known as R Squared determines the extent of the variance of the dependent variable which can be explained by the independent variable. Therefore, the higher the coefficient, the better the regression equation is, as it implies that the independent variable is chosen wisely.read more.

### Examples

#### Example #1

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

**Solution:**

Using the above-mentioned formula, we need to first calculate the correlation coefficientCalculate The Correlation CoefficientCorrelation Coefficient, sometimes known as cross-correlation coefficient, is a statistical measure used to evaluate the strength of a relationship between 2 variables. Its values range from -1.0 (negative correlation) to +1.0 (positive correlation). read more.

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

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

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 = 0.99932480

So, the calculation will be as follows,

r^{2 }= (0.99932480)^{2}

**R Squared Formula in Regression**

r^{2} = 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 per below.

RBI, the central bank of India, has approached you to provide a presentation on the same in the next meeting. Determine whether the movements in crude oil affects movements in Rupee per dollar?

**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.

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.

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

**The Correlation Coefficient will be-**

r = -0.3614

So, the calculation will be as follows,

r^{2 }= (-0.3614)^{2}

**R Squared Formula in Regression**

r^{2 }= 0.1306

**Analysis:** It appears that there is a minor relationship between changes in crude oil prices and changes in the price of the Indian rupee. As Crude oil price increases, the changes in the Indian rupee also affects. But since R squared is only 13%, then the changes in crude oil price explain very less about changes in the Indian rupee, and the Indian rupee is subject to changes in other variables as well, which needs to be accounted for.

#### Example #3

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

Below are the details that they have gathered.

You are required to calculate R Squared and conclude if this model explains the variances in height affects variances in weight.

**Solution:**

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

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.

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-**

Correlation Coefficient (r) = 0.9301

So, the calculation will be as follows,

r^{2 }= 0.8651

**Analysis:** The correlation is positive, and it appears there is some relationship between height and weight. As the height increases, the weight of the person also appears to be increased. While R2 suggests that 86% of changes in height attributes to changes in weight, and 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, then the coefficient would show the likelihood or the probability of a new point or the new dataset falling on the line. Even if both the variables have a strong connection, the determination does not prove causality.

Some of the spaces where R squared is mostly used is for tracking mutual fundMutual FundA mutual fund is a professionally managed investment product in which a pool of money from a group of investors is invested across assets such as equities, bonds, etcread more performance, for tracking risk in hedge funds, to determine how well is stock moving with the market, where R2 would suggest how much of the movements in the stock can be explained by the movements in the market.

### Recommended Articles

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