If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

# Calculating residual example

AP.STATS:
DAT‑1 (EU)
,
DAT‑1.E (LO)
,
DAT‑1.E.1 (EK)

## Video transcript

he rents bicycles to tourists she recorded the height in centimeters of each customer and the frame size in centimeters of the bicycle that customer rented after plotting her results viewer noticed that the relationship between the two variables was fairly linear so she used the data to calculate the following least squares regression equation for predicting bicycle frame size from the height of the customers of the equation so before I even look at this question let's just think about what she did so she had a bunch of customers and she recorded given the height of the customer what size frame that person rented and so she might have had something like this where in the horizontal axis you have height measured in centimeters and the vertical axis you have frame size that's also measured in centimeters and so there might have been someone who it measures 100 centimeters in height who gets a 25 centimeter frame I don't know if that's reasonable or not for you bicycle experts but let's just go with it and so she would have plotted it there maybe there's another person of 100 centimeters in height who got a frame that was slightly larger and she applied it there and then she did a least squares regression and a least squares regression is trying to fit a line to this data oftentimes you would use a spreadsheet or to use a computer and that line is trying to minimize the square of the distance between these between these points and so the least squares regression maybe it would look something like this and this is just a rough estimate of it it might look as some things so let me get my ruler tool it might look something like it might look something like this let me plot it so this that would be the line so our regression line y hat is equal to 1/3 plus 1/3 X and so this you could view this as a way of predicting or either modeling the relationship or predicting that hey if I get a new person I could take their height and put it to X and figure out what frame size they're likely to rent but they ask us what is the residual of a customer with a frame with a height of 1 155 centimeters who rent a bike with a 51 centimetre frame so how do we think about this well the residual is going to be the difference between what they actually produce and what the line what our regression line would have predicted so we could say a residual let me write it this way residual is going to be actual actual minus predicted so if predicted is larger than actual this is actually going to be a negative numbers predicted is smaller than actual there's going to be a positive number well we know the actual they tell us that they tell us that they rent it's a 155 centimeter person rents a bike with a 51 centimetre frame so this is 51 centimeters but what is the predicted well that's where we can use our regression equation that V R came up with the predicted under that in orange the predicted is going to be equal to 1/3 plus 1/3 times the person's height their height is 155 that's the predicted Y hat is what our linear regression predicts are our line predicts so what is this going to be this is going to be equal to 1/3 plus 155 over 3 which is equal to 156 over 3 which comes out nicely to 52 so the predicted on our line is 52 and so here so this person is 155 we can plot them right over here 155 they're coming in slightly below the line so they're coming in slightly below the line right there in that distance which is and we can see that they are below the line so that distance is going to be or in this case the residual is going to be negative so this is going to be negative one and so if we were to zoom in right over here you can't see it that well but let me draw it so if we zoom in let's say we were to zoom in the line and it looks like this and our data point is right my data point is right over here we know we're below the line and this was going to be a negative residual and the magnitude of that residual is how far we are below the line and in this case it is negative 1 and so that is our residual this is what actual the actual data - what was predicted by our regression line