Residual Sum of Squares is essentially the sum of the squared differences between the actual values of the dependent variable and the values predicted by the model. This metric provides a numerical representation of how well the model fits the data, with smaller values indicating a better fit and larger values suggesting a poorer fit.
For example, for predicting retail store sales based on advertising spend using a linear regression model. Calculate the Residual Sum of Squares (RSS) by finding the squared differences between actual and predicted sales to assess model fit.

Residual Sum of Squares
The scatter plot on the right displays the residuals, which are the differences between actual sales and predicted sales, plotted against advertising spend.
Ideally, we want these residuals to be randomly scattered around the horizontal zero line. If they are, it indicates that our model fits the data well.
However, in this case, we can see some patterns in the residuals, which suggests that our model may not be capturing all the underlying relationships in the data. This could mean we need a more complex model to better understand the relationship between advertising and sales.
Types of Sum of Squares
In regression analysis, RSS is one of the three main types of sum of squares, alongside the Total Sum of Squares (TSS) and the Sum of Squares due to Regression (SSR) or Explained Sum of Squares (ESS).
- Total Sum of Squares measures the total variation in the dependent variable relative to its mean.
- Sum of Squares due to Regression measures the variation explained by the regression model.
- Residual Sum of Squares, on the other hand, measures the variation that is not explained by the model, which is essentially the error or residual component.
How to Calculate the Residual Sum of Squares?
Residual Sum of Squares (RSS) can be calculated using the following formula:
[Tex]{RSS= \Sigma_{i=1}^n(y_i-f(x_i))^2}
[/Tex]
Where,
- [Tex]y_i[/Tex] is the ith value of variable to be predicted,
- [Tex]f(x_i)[/Tex] is the predicted value, and
- n is the number of terms or variables.
Regression Sum of Squares (SSR)
The regression sum of squares measures how well the model is and how close is the predicted value to the expected value.
Consider a set X with n observations. The sum of squares S for this set can be calculated using the below formula:
[Tex]\bold{S = \Sigma_{i=1}^{n} (X_i- \bar{X})^2}
[/Tex]
Where,
- Xi is the ith observation of the set,
- [Tex]\bold{\bar{X}}
[/Tex]is the mean of the dataset, and
- n is the number of observations.
Total Sum of Squares (TSS)
Total sum of squares is used to denote the amount of variation in the dependent variable. The total sum of squares is the sum of the regression sum of squares and the residual sum of squares. It is calculated as:
TSS = RSS + SSR
Where the abbreviations have their usual meaning.
How to Calculate Sum of Squares?
We will discuss steps to calculate the sum of squares for both the residual method and regressive method in the following headings.
How to Calculate Residual Sum of Squares?
To calculate the residual sum of squares, we can use the following steps:
Step 1: Organize the data to find the expected value.
Step 2: Calculate the residual i.e., yi – ŷi.
Step 3: Use the following formula to calculate the Residual Sum of Squares.
[Tex]\bold{RSS= \Sigma_{i=1}^n(y_i-f(x_i))^2}
[/Tex]
Step 4: The result is the required value of the Residual Sum of Squares.
How to Calculate Sum of Squares Due to Regression?
To calculate the sum of squares due to regression we can use the following steps:
- Step 1: Calculate the mean of the given data
- Step 2: Calculate the difference between the mean and each data point.
- Step 3: Calculate the square of the value obtained in step 2.
- Step 4: Sum all the values obtained from Step 3.
Significance and Limitations
Significance of Sum of Squares
The sum of squares formula can be used for various purposes and has great significance in real life such as:
- It can be used to find the variability of data points from the mean value.
- It helps the investors to make a good decision regarding investment by checking the variance of the stock.
- It can also help to compare the stock price of two different companies.
Limitations of Sum of Squares
The sum of squares has the following limitations:
- A higher dataset makes it very difficult to make decisions in real life as the graph of the data is more spread out.
- An investor may need data of many years to make good decisions but this huge data becomes very difficult to handle.
Solved Examples of Residual Sum of Squares
Problem 1: Calculate the sum of squares of the set X = [1,2,3,6] if the mean is found to be 3.
Solution:
Given [Tex]\bar{X} = 3
[/Tex]
X
| [Tex]X-\bar{X}
[/Tex]
|
|---|
|
1
|
-2
|
|
2
|
-1
|
|
3
|
0
|
|
6
|
3
|
Using [Tex]S = \Sigma_{i=1}^{n} (X_i- \bar{X})^2
[/Tex]
[Tex]S = (-2)^2+(-1)^2+0^2+3^2
[/Tex]
S = 4+1+0+9
S = 14
Therefore , The sum of squares of the set is 14.
Problem 2: Calculate the sum of squares of the set X = [3,6,9,12,15] if the mean is found to be 9.
Solution:
Given [Tex]\bar{X} = 9
[/Tex]
X
| [Tex]X-\bar{X}
[/Tex]
|
|---|
|
3
|
-6
|
|
6
|
-3
|
|
9
|
0
|
|
12
|
3
|
|
15
|
6
|
Using [Tex]S = \Sigma_{i=1}^{n} (X_i- \bar{X})^2
[/Tex]
[Tex]S = (-6)^2+(-3)^2+0^2+3^2+6^2
[/Tex]
S = 36+9+0+9+36
S = 90
[Tex]\therefore
[/Tex]The sum of squares of the set is 90.
Problem 3: Calculate the sum of squares of the dataset X = [1,2,3,4,5,6]
Solution:
In this case we need to calculate the mean first.
[Tex]\bar{X} = \frac{1+2+3+4+5+6}{6}
[/Tex]
= 21/6
[Tex]\bar {X} = 3.5
[/Tex]
X
| [Tex]X-\bar{X}
[/Tex]
|
|---|
|
1
|
-2.5
|
|
2
|
-1.5
|
|
3
|
-0.5
|
|
4
|
0.5
|
|
5
|
1.5
|
|
6
|
2.5
|
Using [Tex]S = \Sigma_{i=1}^{n} (X_i- \bar{X})^2
[/Tex]
[Tex]S = (-2.5)^2+(-1.5)^2+(-0.5)^2+(0.5)^2+(1.5)^2+(2.5)^2
[/Tex]
S = 6.25+2.25+0.25+0.25+2.25+6.25
S = 17.50
[Tex]\therefore
[/Tex]The sum of squares of the set is 17.50.
Problem 4: Calculate the sum of squares of the dataset Y = [3,4,5,1,7]
Solution:
In this case we need to calculate the mean first.
[Tex]\bar{X} = \frac{3+4+5+1+7}{5}
[/Tex]
= 20/5
[Tex]\bar {X} = 4
[/Tex]
X
| [Tex]X-\bar{X}
[/Tex]
|
|---|
|
3
|
-1
|
|
4
|
0
|
|
5
|
1
|
|
1
|
-3
|
|
7
|
3
|
Using [Tex]S = \Sigma_{i=1}^{n} (X_i- \bar{X})^2
[/Tex]
[Tex]S = (-1)^2+(0)^2+(1)^2+(-3)^2+(3)^2
[/Tex]
S = 1+0+1+9+9
S = 20
[Tex]\therefore
[/Tex]The sum of squares of the set is 20.
Problem 5: Calculate the sum of squares of the set X = [1,4,6,8] if mean is found to be 4.75.
Solution:
Given [Tex]\bar{X} = 4.75
[/Tex]
X
| [Tex]X-\bar{X}
[/Tex]
|
|---|
|
1
|
-3.75
|
|
4
|
-0.75
|
|
6
|
1.25
|
|
8
|
3.25
|
Using [Tex]S = \Sigma_{i=1}^{n} (X_i- \bar{X})^2
[/Tex]
[Tex]S = (-3.75)^2+(-0.75)^2+(1.25)^2+(3.25)^2
[/Tex]
S = 14.0625+0.5625+1.5625+10.5625
S = 26.75
[Tex]\therefore
[/Tex]The sum of squares of the set is 26.75.
FAQs Of Residual Sum of Squares
What is the Practical Significance of Sum of Squares?
Sum of squares helps investors to determine the variability in the price of the stock and helps them to invest their money wisely.
What is the Desirable Value for Residual Sum of Squares?
We always desire a low value of residual sum of squares as it is calculated by considering the error left after the model is run. So a lower value will mean lesser error as compared to a higher value.
What is Regression?
Regression is a technique in statistics that determines the relationship between a dependent variable and one or more independent variables. It is generally used for prediction purposes.
What are The Types of Sum of Squares used in Regression?
Sum of squares are classified into 3 types which are:
- Regression Sum of Squares
- Residual Sum of Squares
- Total Sum of Squares
Similar Reads
Residual Sum of Squares
Residual Sum of Squares is essentially the sum of the squared differences between the actual values of the dependent variable and the values predicted by the model. This metric provides a numerical representation of how well the model fits the data, with smaller values indicating a better fit and la
7 min read
Sum of Squares
Sum of squares in statistics can be defined as the variation of the data set. Sum of squares can be applied in regression analysis, optimization problems, or error measurement for quantifying how individual elements in a set deviate from the central tendency. In algebra, we can find the sum of squar
11 min read
How to Calculate Residual Sum of Squares in Python
The residual sum of squares (RSS) calculates the degree of variance in a regression model. It estimates the level of error in the model's prediction. The smaller the residual sum of squares, the better your model fits your data; the larger the residual sum of squares, the worse. It is the sum of squ
2 min read
Sum of Squares of n Natural numbers
Sum of Squares of n Natural numbers: The sum of squares of n natural numbers is calculated using the formula [n(n+1)(2n+1)] / 6 where 'n' is a natural number. Examples: n = 1, Sum = (1 x (1 + 1) x (1 x 2 + 1))/6 = 1n = 2, Sum = (2 x (2 + 1) x (2 x 2 + 1))/6 = 5 (Which is sum of 11 + 22)n = 3, Sum =
12 min read
Uses of Square Numbers in Real-life
Square numbers are an essential concept in mathematics, representing the result of multiplying a number by itself. They hold significance not only in mathematical contexts but also in various aspects of our daily lives. This article explores the practical applications of square numbers in everyday s
6 min read
Squares and Square Roots
Squares and Square roots are highly used mathematical concepts which are used for various purposes. Squares are numbers produced by multiplying a number by itself. Conversely, the square root of a number is the value that, when multiplied by itself, results in the original number. Thus, squaring and
13 min read
Squares and Cubes
Squares and Cubes are mathematical operations involving numbers that are essential in various areas of mathematics. Square of a number is obtained by multiplying the number by itself where whereas a cube of a number is obtained by multiplying the number by itself twice. In this article, we will lear
11 min read
Area of Square
The area of a Square is defined as the space enclosed by the boundary of the square. Measurement of the area is done in square units. The unit for measurement of the area is m2. Let's understand the Area of square with the following illustration: To calculate square's area we need to know the length
7 min read
Perfect Squares
A perfect square or square number is a number that can be expressed as the product of an integer with itself. In other words, a perfect square is n raised to the power 2 where n is an integer. Let’s understand Perfect Squares with the following illustration: Examples: 9 is a perfect square as we can
9 min read
Square Pyramid Formula
A square pyramid is a three-dimensional geometric shape with a square base and four triangular faces that meet at a single point called the apex. Several formulas are associated with a square pyramid, including those for the surface area, volume, and slant height. In this article, we will learn abou
7 min read
Square Matrix
Square Matrix: A matrix is defined as a rectangular array of numbers that are arranged in rows and columns. A square matrix is characterized by having the same number of rows as columns. It's referred to as an m x m matrix, indicating that it is a square matrix of order ?m. When two square matrices
9 min read
Difference of Two Squares
The difference of Two Squares is an algebraic expression that takes the form a2 − b2. This expression is unique because it can be factored into the product of two binomials: (a + b)(a - b). The formula works due to the cancellation of the middle terms when expanding the product of these binomials. I
6 min read
Good R Squared Value in R
In the world of numbers and models, the R-squared value plays a key role in telling us how well our models fit the data. In R Programming Language this article is a quick guide to why a solid R-squared matters and how it helps us understand if our models are doing a good job. What is R-squared?R-squ
6 min read
Sum of Squares of First N Natural Numbers in JavaScript
The sum of squares of the first n natural numbers is a mathematical problem of finding the sum of squares of each number up to a given positive number n. We can find the sum of squares of first n natural numbers in JavaScript using the approaches listed below. Table of Content Sum of Square of First
3 min read
Square 1 to 50
The concept of the square of a number is important in mathematics. It is important to learn squares of numbers from 1 to 50. Squares is not limited to mathematics, it is used in various real-life applications such as geometry, engineering, construction, designing, etc. In this article, we will learn
8 min read
Square Numbers
Square Numbers are the product of a number multiplied by itself. These are fundamental to mathematics. In this article, we will explain Square Numbers, Give Examples, List of Square Numbers from 1 to 100, Why are they called Square Numbers and others in detail. Table of Content What is a Square Numb
7 min read
Square 1 to 30
Square 1 to 30 is the square of all the natural numbers from 1 to 30. The square of a number is the multiple of the number with itself. Learning these squares helps students to easily solve various arithmetic problems and helps them to solve complex calculations with ease. The value of the square of
7 min read
Perfect Square Formula
Perfect Square Formula: A polynomial or number which when multiplied by itself is called a perfect square. The perfect square is calculated by two algebraic expressions that include: (a + b)² = a² + 2ab + b² and (a - b)² = a² - 2ab + b². In this article, we have covered the perfect square definition
7 min read
Find the square of: 2a+b
In the Number system, there are various questions in which squares and square roots of the numbers are used to get the desired goal or to make the question convenient to solve. It is not only square and square roots, there are cubes and cube roots, and so on. There are direct methods of finding out
3 min read
How to calculate the sum of squares?
The number system includes different types of numbers for example prime numbers, odd numbers, even numbers, rational numbers, whole numbers, etc. These numbers can be expressed in the form of figures as well as words accordingly. For example, numbers like 40 and 65 expressed in the form of figures c
5 min read