What is a Standardized Residuals Calculator?

A Standardized Residuals Calculator is a statistical tool used to determine how closely a set of data points fit a given curve or line. It calculates the difference between the observed value and the expected value of a given data point, and then standardizes the residuals by dividing them by the standard deviation of the data set. This allows the data points to be compared across different datasets, and helps to identify outliers and other patterns that may indicate a problem with the data.

@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;
}

A is a residual that has been divided by its standard deviation. It is calculated as:

ri = ei / RSE√1-hii

where:

  • ei: The ith residual
  • RSE: The residual standard error of the model
  • hii: The leverage of the ith observation

This calculator finds the standardized residuals for each observation in a simple linear regression model.

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:

Linear Regression Equation:

ŷ = 29.6309 + (0.7553)*x

List of Standardized Residuals:

-0.143
-3.104
1.896
-0.064
1.975
-0.906
1.133
-0.787

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 = ”;

function linearRegression(y,x){
var lr = {};
var n = y.length;
var sum_x = 0;
var sum_y = 0;
var sum_xy = 0;
var sum_xx = 0;
var sum_yy = 0;

for (var i = 0; i < y.length; i++) {
sum_x += x[i];
sum_y += y[i];
sum_xy += (x[i]*y[i]);
sum_xx += (x[i]*x[i]);
sum_yy += (y[i]*y[i]);
}

lr['slope'] = (n * sum_xy – sum_x * sum_y) / (n*sum_xx – sum_x * sum_x);
lr['intercept'] = (sum_y – lr.slope * sum_x)/n;
return lr;
}

var lr = linearRegression(y, x);
var a = lr.slope;
var b = lr.intercept;

//calculate residuals
residuals = [];

for (var obs = 0; obs < y.length; obs++) {
this_resid = (y[obs] – (b – (-1*a*x[obs]))).toFixed(3);
residuals.push(this_resid);
}

//calculate leverage
lev_n = x.length;
lev_mean = math.mean(x);
lev_ss = 0;

for (var i = 0; i < x.length; i++) {
lev_ss += (x[i]-lev_mean)*(x[i]-lev_mean);
}

leverages = [];
for (var j = 0; j < x.length; j++) {
this_leverage = 1/lev_n-(-1*(Math.pow(x[j] -lev_mean, 2)))/lev_ss;
leverages.push(this_leverage);
}

//calculate RSE
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 sst = syy;
var ssr = (sxy/sxx)*sxy;
var sse = sst-ssr;

var RSE = Math.sqrt(sse / (x.length – 2));

//calculate standardized residuals
stand_resids = [];
for (var k = 0; k < x.length; k++) {
this_sr = (residuals[k]/(RSE*Math.sqrt(1-leverages[k]))).toFixed(4);
stand_resids.push(this_sr);
}

//output results
document.getElementById('a').innerHTML = a.toFixed(4);
document.getElementById('b').innerHTML = b.toFixed(4);
document.getElementById('resids_out').innerHTML = stand_resids.toString().split(',').join("
“);
}

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

} //end calc function

x