I'm a programmer, and unfortunately not a good statistician. I am trying to apply a linear equation (y=mx+b
) to display a trendline on a graph. Here's a sample of what I'm able to produce:
Where the Y-axis is a percent relative to the goal (not in currency, but in a percent), and the X-axis is the date (represented discreetly in this image). I've tweaked the graph to show the trendline as an extension from the last day (today) as to visually combine 2 lines into 1 (as opposed to 2 lines running together).
From what I understand, we can calculate a trendline using two or more data points. And that's where my question comes in. I'm using the entire current dataset (July 2-24) to calculate my trendline. So in the image, that would be all data points on the blue line. For example, the first point (7/2/13) is represented as {1,0.28}
; the second as {2,0.01}
; and so forth.
Am I correctly applying the trendline equation by using that dataset?
As an additional part to the question: should I be using another form of trendline equation, like the polynomial? And, finally, could my linear equation be derived by using two data points from the same time last year? For example, July 26-27's forecast is solved for by using the same dates' historical data from the year prior.