How to calculate Regression Sum of Squares (SSR)

Regression Sum of Squares (SSR) is a measure of how well a regression line fits the data. It is calculated by taking the sum of the squared difference between each data point and the mean of the data, and then summing these squares. SSR is used to measure the accuracy of a regression line and can be used to compare different models.

@import url(‘https://fonts.googleapis.com/css?family=Droid+Serif|Raleway’);

h1 {
text-align: center;
font-size: 50px;
margin-bottom: 0px;
font-family: ‘Raleway’, serif;
}

p {
color: black;
margin-bottom: 15px;
margin-top: 15px;
font-family: ‘Raleway’, sans-serif;
}

#words {
padding-left: 30px;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_summary {
padding-left: 70px;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_text {
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_text_area {
display:inline-block;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
padding-left: 100px;
}

#calcTitle {
text-align: center;
font-size: 20px;
margin-bottom: 0px;
font-family: ‘Raleway’, serif;
}

#hr_top {
width: 30%;
margin-bottom: 0px;
border: none;
height: 2px;
color: black;
background-color: black;
}

#hr_bottom {
width: 30%;
margin-top: 15px;
border: none;
height: 2px;
color: black;
background-color: black;
}

#words_table label, #words_table input {
display: inline-block;
vertical-align: baseline;
width: 350px;
}

#buttonCalc {
border: 1px solid;
border-radius: 10px;
margin-top: 20px;

cursor: pointer;
outline: none;
background-color: white;
color: black;
font-family: ‘Work Sans’, sans-serif;
border: 1px solid grey;
/* Green */
}

#buttonCalc:hover {
background-color: #f6f6f6;
border: 1px solid black;
}

#words_table {
color: black;
font-family: Raleway;
max-width: 350px;
margin: 25px auto;
line-height: 1.75;
}

#summary_table {
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
padding-left: 20px;
}

.label_radio {
text-align: center;
}

td, tr, th {
border: 1px solid black;
}
table {
border-collapse: collapse;
}
td, th {
min-width: 50px;
height: 21px;
}
.label_radio {
text-align: center;
}

#text_area_input {
padding-left: 35%;
float: left;
}

svg:not(:root) {
overflow: visible;
}

This calculator finds the regression sum of squares of a regression equation based on values for a predictor variable and a response variable.

Simply enter a list of values for a predictor variable and a response variable in the boxes below, then click the “Calculate” button:

Predictor values:

Response values:

Regression Sum of Squares (SSR): 19.6122

function calc() {

//get input data
var x = document.getElementById(‘x’).value.split(‘,’).map(Number);
var y = document.getElementById(‘y’).value.split(‘,’).map(Number);

//check that both lists are equal length
if (x.length – y.length == 0) {
document.getElementById(‘error_msg’).innerHTML = ”;

var xbar = math.mean(x);
var ybar = math.mean(y);

let xbar2_hold = 0
for (let i = 0; i < x.length; i++) {
xbar2_hold += Math.pow(x[i], 2);
}

var xbar2 = xbar2_hold / x.length;

let sxx = 0
for (let i = 0; i < x.length; i++) {
sxx += Math.pow(x[i] – xbar, 2);
}

let syy = 0
for (let i = 0; i < y.length; i++) {
syy += Math.pow(y[i] – ybar, 2);
}

let sxy = 0
for (let i = 0; i < x.length; i++) {
sxy += (x[i] – xbar)*(y[i]-ybar);
}

let sxx2 = 0
for (let i = 0; i < x.length; i++) {
sxx2 += (x[i] – xbar)*(Math.pow(x[i], 2)-xbar2);
}

let sx2x2 = 0
for (let i = 0; i < x.length; i++) {
sx2x2 += Math.pow((Math.pow(x[i], 2)-xbar2), 2);
}

let sx2y = 0
for (let i = 0; i < x.length; i++) {
sx2y += (Math.pow(x[i], 2)-xbar2)*(y[i]-ybar);
}

var b = ((sxy*sx2x2)-(sx2y*sxx2)) / ((sxx*sx2x2)-Math.pow(sxx2, 2));
var c = ((sx2y*sxx)-(sxy*sxx2)) / ((sxx*sx2x2)-Math.pow(sxx2, 2));
var a = ybar – (b*xbar) – (c*xbar2);

var sst = syy;
var ssr = (sxy/sxx)*sxy;
var sse = sst-ssr;

document.getElementById('ssr').innerHTML = ssr.toFixed(4);
}

//output error message if boths lists are not equal
else {
//document.getElementById('out').innerHTML = '';
document.getElementById('error_msg').innerHTML = 'The two lists must be of equal length.';
}

} //end calc function

x