Linear Regression of Trend Data

The best fit line (using least squares regression) for the n points (X1,Y1), (X2,Y2),...(Xn,Yn) has the form: $$y = mx+b$$

Where

Slope:

$$m = \frac{n\Bigg(\displaystyle\sum_{i=1}^{n}x_iy_i\Bigg)-\Bigg(\displaystyle\sum_{i=1}^{n}x_i\Bigg)\Bigg(\displaystyle\sum_{i=1}^{n}y_i\Bigg)}{n\Bigg(\displaystyle\sum_{i=1}^{n}{x_i}^2\Bigg)-\Bigg(\displaystyle\sum_{i=1}^{n}x_i\Bigg)^2}$$

Y-Intercept:

$$b = \frac{\Bigg(\displaystyle\sum_{i=1}^{n}y_i\Bigg)-m\Bigg(\displaystyle\sum_{i=1}^{n}x_i\Bigg)}{n}$$

\(x_i\) is the time of the \(i\)th data point

\(y_i\)is the value of the \(i\)th data point

The correlation coefficient quantifies the strength of the linear relationship and is calculated by: $$r = \frac{SSXY}{\sqrt{SSX*SSY}}$$

Where $$SSX = \frac{\displaystyle\sum_{i=1}^{n}{x_i}^2}{n}-\frac{\Bigg(\displaystyle\sum_{i=1}^{n}x_i\Bigg)^2}{n^2}$$

$$SSY =  \frac{\displaystyle\sum_{i=1}^{n}{y_i}^2}{n}-\frac{\Bigg(\displaystyle\sum_{i=1}^{n}y_i\Bigg)^2}{n^2}$$

$$SSXY = \frac{\displaystyle\sum_{i=1}^{n}x_iy_i}{n}-\frac{\Bigg(\displaystyle\sum_{i=1}^{n}x_i\Bigg)\Bigg(\displaystyle\sum_{i=1}^{n}y_i\Bigg)}{n^2}$$