Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to get coefficient of determination (r^2) in sagemath?

I know that I can do regression with the find_fit function:

sage: R = [[1,2],[3.45,4],[6,5],[4,3]]
sage: var('a,b')
(a, b)
sage: model(x) = a*x+b
sage: find_fit(R,model)
[a == 0.56881365890949054, b == 1.445160655902004]

but it does not provide the coefficient of determination (r^2). How would i find the r^2 value in sagemath?