Optimal two variable linear regression calculation
- by Dave Jarvis
Problem
Am looking to apply the y = mx + b equation (where m is SLOPE, b is INTERCEPT) to a data set, which is retrieved as shown in the SQL code. The values from the (MySQL) query are:
SLOPE = 0.0276653965651912
INTERCEPT = -57.2338357550468
SQL Code
SELECT
((sum(t.YEAR) * sum(t.AMOUNT)) - (count(1) * sum(t.YEAR * t.AMOUNT))) /
…