## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Time for action – calculating the correlation coefficient

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.

## What just happened?

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 ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required