You are a guest. Restricted access. Read more.
 [2]   LinReg problem ID: 2 Project: scavis Severity: Query Product: SCaVis Status: Solved Version: 1.0 Creator: Marshall Donneley Created: 2013-08-10 10:23:16 Assigned to: Modified: 2013-08-10 20:31:48 [Status history]
 Creator Details Name: Marshall Donneley Add contact: (Follower: 0)
 Initial description I'm pretty new to Scavis, so maybe I just made a dumb error. But I tried a linear regression on a simple function (x^2), and the slope and intercept were wrong. (I was trying to do a Durbin-Watson test just as experiment.) I loaded the data to Excel and the regression looked correct. The data was the same, but the answer was different, and it's obvious the answer I'm getting from my Scavis program is wrong (the slope and intercept from LinReg don't minimize the sum of the squares of the residuals). Again, probably just a dumb error on my part, but I've looked the program over fairly carefully.
 Links to symptom files 1. 2.
 Comments (work log) [1]     2013-08-10 10:27:11     (Creator) Sorry, looks like I couldn't upload the file. Here's the code. Clumsy code, granted. from jhplot.io.csv import * from java.io import * from java.util import * from jhplot import * from java.awt import * from java.awt.event import * from javax.swing import * from java.lang import * from jhplot import * from java.lang import Math from jhplot.stat import * from jarray import * from random import * from jhplot.stat import * from jarray import * from java.util import * from random import * import csv dumfile=CSVWriter('whatever.csv') c1=HPlot('Canvas') c1.visible() c1.setAutoRange() f1=F1D('x^2') p1=P0D() p1.fill(50,1,3) d=p1.getArray() p2=P0D() p2.fill(f1.eval(d)) # this next bit is to remove the extra zeros that get put in at the end of the array for some reason for x in range(p2.size()-1,0,-1): if p2.get(x)==0: p2.removeAll(x,x) p3=P1D() p3.fill(p1,p2) c1.draw(p3) c1.visible() r=LinReg(p3) p4=P0D() a=r.getIntercept() b=r.getSlope() p10=r.getResiduals() # again, removing the extra zeros that crop up for some reason for x in range(p10.size()-1,0,-1): if p10.getX(x)==0: p10.removeAt(x) System.out.println('this is the intercept ' + str(a)) System.out.println('and this is the slope ' + str(b)) System.out.println(p10) System.out.println('that were the resids') for x in range(0,p1.size()): p4.add(a+b*p1.get(x)) p5=P1D() p5.fill(p1,p4) c1.draw(p5) c1.draw(p10) System.out.println(p3) System.out.println('hi') p20=P0D() # attempt at doing a Durbin-Watson test a=0 for x in range(0,p10.size()): a= a + p10.getY(x)*p10.getY(x) b=0 for x in range(1,p10.size()): b=b+(p10.getY(x)-p10.getY(x-1))*(p10.getY(x)-p10.getY(x-1)) System.out.println('DurbinWatson ' + str(b/a)) System.out.println('ok') #writing out the data to a CSV file to export to Excel dumfile.writeNext([str(p3)]) dumfile.close() [2]     2013-08-10 20:31:47     (Assignee) Can you try to use HFitter? The example work OK: http://jwork.org/scavis/wikidoc/doku.php?id=man:data:fitting#linear_regression_with_hfitter
 Resolution Was solved for version 1.2