Talk:Trend line

Latest comment: 17 years ago by Tobacman in topic Merge

Java

edit

Why is there Java code in this article? --Andy M. 05:47, 13 May 2006 (UTC)Reply

I used the logic from the Java code in an ASP project, and it appears to produce incorrect results.

The following URL is the resource I ended up using: http://helios.bto.ed.ac.uk/bto/statistics/tress11.html

The ASP code I came up with was the following:

' Calculate trendline ' y = bx + a dim trend_sumXY dim trend_sumX dim trend_sumY dim trend_sumXsq dim trend_n dim trend_b dim trend_a

Function addPoint(trend_x,trend_y) trend_sumXY = trend_sumXY + (trend_x*trend_y) trend_sumX = trend_sumX + trend_x trend_sumY = trend_sumY + trend_y trend_sumXsq = trend_sumXsq + (trend_x*trend_x) trend_n = trend_n + 1 End Function

Function calcLine() trend_b = (trend_sumXY - ((trend_sumX*trend_sumY)/trend_n)) / (trend_sumXsq - ((trend_sumX*trend_sumX)/trend_n)) trend_a = (trend_sumY/trend_n) - (trend_b*(trend_sumX/trend_n)) 'Response.Write( "
Calculating line formula
gradient (b): " & trend_b & "
intercept (a): " & trend_a ) End Function

Function getY(trend_x) getY = (trend_b*trend_x)+trend_a End Function

Call addPoint() for each point in your graph, then call calcLine to calculate the trend line gradient and intercept.

Finally, use getY to return Y coordinates for your trendline based on an input of the X coordinate.

I'm not a Wikipedia pro, but if anyone wants to incorporate any of this material into the actual article that's fine.

- Jamie C —Preceding unsigned comment added by 212.69.238.251 (talkcontribs)

Merge

edit

This article is pointless and should be moved to linear regression, unless anyone has objections. — Chris53516 (Talk) 23:16, 30 January 2007 (UTC)Reply

By "moved to" I presume you mean "merged into." Agree strongly, and I'll go ahead... Jeremy Tobacman 00:48, 23 February 2007 (UTC)Reply