Hey, thanks a lot. I was able to do it, though for my project the R^2
value constantly came out to .9999....

On Oct 6, 12:39 pm, Jason Grout <[email protected]> wrote:
> Jaasiel Ornelas wrote:
> > Is there any way to calculate regression lines and regression (R^2)
> > for a set of points in sage?
>
> I would probably first look at using scipy.stats.  For example, a linear
> regression line can be found like this 
> (fromhttp://www2.warwick.ac.uk/fac/sci/moac/currentstudents/peter_cock/pyt...)
>
> sage: from scipy import stats
> sage: x = [5.05, 6.75, 3.21, 2.66]
> sage: y = [1.65, 26.5, -5.93, 7.96]
> sage: gradient, intercept, r_value, p_value, std_err = stats.linregress(x,y)
>
> <some deprecation warnings--these won't make a difference with the output>
>
> sage: print "Gradient and intercept", gradient, intercept
> Gradient and intercept 5.3935773612 -16.2811279931
> sage: print "R-squared", r_value**2
> R-squared 0.524806275136
> sage: print "p-value", p_value
> p-value 0.275564857882
>
> See:
>
> http://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.linre...
>
> Jason
>
> --
> Jason Grout
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to