I have data with a starting (y) value that sequentially increments/decrements as (x) time measured in days passes.

I found this link for creating a linear regression of the data

http://www.easycalculation.com/statistics/regression.phpI would like to automate the slope calculation in excel. Does anyone have an idea of how to do it? I see the math formula at the bottom of the page

N∑XY−∑X∑YN∑X2−(∑X)2

but i don’t know how to translate it to an excel formula. The problem is mainly the ∑XY and ∑X2. The others are easy with the

`count`

,`sum`

and`pow`

function.

My x coordinates and y coordinates are in rows such that`C1`

is`x1`

and`D1`

is`x2`

.

**Answer**

First, note that your link links to a worked example that will probably help.

To implement the equation in Excel:

- make a new column labeled “XY” in E
- enter the number of rows in cell “F2” (this will be N)
- label column F “X^2”
- enter
`=C2^2`

into F2 to caclulate X^2, highlight F2:FN and hit`ctrl+D`

to fill this equation down - enter the equation
`=(G2*sum(E:E) - sum(C:C)*sum(D:D))/(G2*sum(F:F) - sum(C:C)^2)`

into an empty cell. This will be your R^2 - enter the equation
`=slope(D:D, C:C)`

into another empty cell, this should match your calculation.

Finished result is shown in an example google doc that can be downloaded in Excel format here.

**Attribution***Source : Link , Question Author : Community , Answer Author : David LeBauer*