Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I do regression analysis in Sage?

Tags:

math

sage

I tried this unsuccessfully:

find_fit(data, quadratic_residues)

I am trying to find the best-fit for data about water flow rates: http://dl.getdropbox.com/u/175564/rate.png

---edit after the comment---

The new code:

var('x')
model(x) = x**2
find_fit((xlist, reqlist), model)

The error message:

Traceback (click to the left for traceback)
...
TypeError: data has to be a list of lists, a matrix, or a numpy array

---edit

The error message is now:

Traceback (click to the left for traceback)
...
ValueError: each row of data needs 2 entries, only 5 entries given

The same here as a picture: http://dl.getdropbox.com/u/175564/sage.png

like image 299
Léo Léopold Hertz 준영 Avatar asked Jan 18 '09 03:01

Léo Léopold Hertz 준영


People also ask

How do you perform a regression analysis?

It consists of 3 stages – (1) analyzing the correlation and directionality of the data, (2) estimating the model, i.e., fitting the line, and (3) evaluating the validity and usefulness of the model. First, a scatter plot should be used to analyze the data and check for directionality and correlation of data.

Which tool can be used to conduct a regression analysis?

You can use SPSS software to perform regression analysis, it is simple and efficient software.

How do you create a regression report?

Select Tools->Regression Test from the main menu or use the right-click menus of the Regression Folder in the Project Explorer to launch the Regression Test Wizard that allows you to create and edit Regression Command/Script files. To run an existing Regression Test Script, select Execute.


1 Answers

mydata = [[1,3],[2,7],[3,13],[4,24]]
var('a,b,c')
mymodel(x) = a*x^2 + b*x + c 
myfit = find_fit(mydata,mymodel,solution_dict=True)
points(mydata,color='purple') + plot(
  mymodel(
    a=myfit[a],
    b=myfit[b],
    c=myfit[c]
    ), 
    (x,0,4,),
    color='red'
  )
like image 199
Andre Mikulec Avatar answered Sep 29 '22 20:09

Andre Mikulec