# Meaning of a Residual plot that looks like composition of sawtooth waves

I'm working on a prototype that reads a fixed mass in a loadcell through an 24 bit ADC using a MCU; the device undergoes high temperature amplitudes, therefore the mass readings drift (because of the analog electronics) even though the mass doesn't physically change (it's always 1260 g). I`ve tested the device in a chamber that undergoes cyclic temperature changes. When I did linear regression on the dataset of the test (mass (in grams) vs temperature (in Celsius)), I got a high R^2 but the residual plot looks really weird...

What's the meaning of this? Is it a consequence of the quantization error of the ADC?

the Y axis is the mass residue in grams; the X axis is the (temperature*10) in Celsius, e.g. x=100 <=> 10°C

UPDATE: I've added transparency to the plot, it can be verified that most the parallel left-most line has more opacity (because most of the temperature cycles happened at that temperature, hence more observations). Also, by plotting the histogram we can verify that indeed there are 6 distinctive larger groups plus a small group (the opaque blue plot has 6 lines and one small dot near the -12 g label, therefore 7 groups I suppose)

• Do you have six different masses? Oct 5, 2023 at 17:16
• @mdewey No, but I could find some other masses to test Oct 5, 2023 at 17:18
• @mdewey, Do you mean, if I used 6 different masses on the test or if I have 6 masses at my disposal to test? I only used a single mass on the test, the readings change because the temperature affects the analog electronics. Oct 5, 2023 at 17:20
• This is duplicate, a question that has been posted many times. e.g. see here: stats.stackexchange.com/questions/235449/… ... naturally that's also a duplicate, but I picked that one because it's particularly clear that it's the same problem there. If you search for descriptions like regression diagonal lines residual and similar variations, you turn up relevant hits. Oct 5, 2023 at 22:41

The definition

residual $$=$$ observed response $$-$$ fitted response

means that in a plot of residual (y axis) versus fitted (x axis) points for each distinct observed response plot on a line with intercept that value and gradient $$-1$$. Hence the various distinct observed values plot as a series of parallel lines. That is visible on your plot.

As @mdewey comments, it appears that you have just 6 distinct observed values, which should be easy to check directly.

Some people say unique, not distinct. Similarly some people say predicted, not fitted

• Thanks for the interpretation, I've decided to add transparency to the residuals plot. I could verify that the left-most parallel line had greater opacity than the other lines, i.e. most of the temperature cycles concentrated around -4°C to +2°C. Then I plotted the histogram, breaking the binning into 10g intervals starting from 1200 to 1290, only 6 big groups of masses could be observed. Oct 5, 2023 at 18:24
• But does this great clustering around only 6 groups means my model is broken? (i.e. non-linear) Oct 5, 2023 at 18:26
• I wouldn't say that this alone breaks your model. In principle it's always true that a residual vs fitted plot is a series of parallel lines, but that's not a source of worry if there are many of it. Oct 6, 2023 at 11:49