The average and median residuals from the linear model

I was just starting to study R and needed some help finding the average and median residues for my data. I calculated lm and in the summary I get leftovers as shown below:

min 1Q median 3Q Max -111.86 -34.90 -7.6 33.46 182.58 

Question : therefore, the median of the residuals is -7.6, but is this my value? Or is there a calculation to find the average and median residuals? I was going to do this (remainder (trees.lm) or should be entered as an average value (tree.lm $))

Please clarify, because my classmates get different answers for the same dataset.

+7
source share
1 answer

The answer to one specific question is here:

 mean(resid(trees.lm)) 

You should not delve into model objects such as this and cut out arbitrary components. Doing this on something more complicated, like GLM, will bite off your hand when you realize that you just pulled work leftovers through:

 glm.mod.obj$residuals 

which are unlikely to be useful to you.

Even for simple things like lm() objects, using resid() or accessing $residuals can be different depending on how the model was installed (what was the setting for the na.action argument, for example?).

In addition, the linear model assumes that iid residues are Gaussian (or normal) random variables with an average value of 0 and a variance of $ \ hat {\ sigma} ^ 2} $, so the average should be very close to 0 (i.e., very, very, very close to 0, but not exactly, because it is a computer and floating point arithmetic).

+6
source

All Articles