how to calculate the sum of squares
you can see why the measurement is called the sum of squared deviations or the sum of squares for short you can use the following steps to calculate the sum of squares in statistics the mean is the average of a set of numbers which is calculated by adding the values in the data set together and dividing by the number of values however knowing the mean may not be enough to understand your data and draw conclusions as such it helps to know the variation in a set of measurements how far individual values are from the mean may provide insight into how much variation exists and how well the values fit a regression line types of sum of squaresthe formula we highlighted earlier is used to calculate the total sum of squares the total sum of squares is used to arrive at other types the following are the other types of sum of squares as noted above if the line in the linear model created does not pass through all the measurements of value then some of the variability that has been observed in the share prices is unexplained the sum of squares is used to calculate whether a linear relationship exists between two variables and any unexplained variability is referred to as the residual sum of squares the rss allows you to determine the amount of error left between a regression function and the data set after the model has been run you can interpret a smaller rss figure as a regression function that is well fit to the data while the opposite is true of a larger rss figure here is the formula for calculating the residual sum of squares sse i 1 n y i y i 2 where y i observed value y i value estimated by regression line begin aligned text sse sum i 1 n y i hat y i 2 textbf where y i text observed value hat y i text value estimated by regression line end aligned sse i 1 n yi y i 2where yi observed valuey i value estimated by regression line the regression sum of squares is used to denote the relationship between the modeled data and a regression model a regression model establishes whether there is a relationship between one or multiple variables having a low regression sum of squares indicates a better fit with the data a higher regression sum of squares though means the model and the data aren t a good fit together here is the formula for calculating the regression sum of squares ssr i 1 n y i y 2 where y i value estimated by regression line y mean value of a sample begin aligned text ssr sum i 1 n hat y i bar y 2 textbf where hat y i text value estimated by regression line bar y text mean value of a sample end aligned ssr i 1 n y i y 2where y i value estimated by regression liney mean value of a sample adding the sum of the deviations alone without squaring them results in a number equal to or close to zero since the negative deviations will almost perfectly offset the positive deviations to get a more realistic number the sum of deviations must be squared the sum of squares will always be a positive number because the square of any number whether positive or negative is always positive limitations of using the sum of squaresmaking an investment decision on what stock to purchase requires many more observations than the ones listed here an analyst may have to work with years of data to know with a higher certainty how high or low the variability of an asset is as more data points are added to the set the sum of squares becomes larger as the values will be more spread out the most widely used measurements of variation are the standard deviation and variance however to calculate either of the two metrics the sum of squares must first be calculated the variance is the average of the sum of squares i e the sum of squares divided by the number of observations the standard deviation is the square root of the variance there are two methods of regression analysis that use the sum of squares the least squares method refers to the fact that the regression function minimizes the sum of the squares of the variance from the actual data points in this way it is possible to draw a function which statistically provides the best fit for the data note that a regression function can either be linear a straight line or non linear a curving line example of sum of squareslet s use microsoft as an example to show how you can arrive at the sum of squares using the steps listed above we gather the data so if we re looking at the company s performance over a five year period we ll need the closing prices for that time frame now let s figure out the average price the sum of the total prices is 369 73 and the mean or average price is 369 73 5 73 95 then figure out the sum of squares we find the difference of each price from the average square the differences and add them together in the example above 1 0942 shows that the variability in the stock price of msft over five days is very low and investors looking to invest in stocks characterized by price stability and low volatility may opt for microsoft 