Skip to main content

Posts

Showing posts from August, 2017

SQL Table-Valued Function to Find the Best Trend Line Using Linear Regression

Linear regression is probably one of the first regression techniques we run across. It is useful for explaining (and perhaps forecasting) data that has a linear nature, but where the underlying process is unknown.  Linear regression line between New Patient Data and  Marketing Expenses   This solution focuses on the practical aspects of finding the best trend line for a financial time series using SQL function. If you have a large dataset with multiple sets of x and y data points associated with some attribute, you can do a linear regression on each set with one query using GroupID. The great strength of the linear regression line is that it can clarify sometimes ambiguous line charts and quantify the results via the slope of the line.