Let us try to calculate the correlation coefficient for the fit of the leaf length for tree A. We just need to follow Equation (7.9):
octave:21> denom = (length(yA) - 1)*var(yA); octave:22> rcor = 1 – sA.normr^2/denom rcor = 0.96801
This gives an indication that the fit is good as we expected.
In Command 21, we calculated the denominator in Equation (7.9). Notice that instead of calculating the square of the standard deviation, we simply use the variance found with
var. From Equation (7.9), we see that the 2-norm of the residuals enters the nominator. This is already calculated in
polyfit and stored in the structure field
normr, so we use this in the evaluation of the ...