[SciPy-User] Trouble getting R^2 value

Sturla Molden sturla.molden at gmail.com
Tue May 19 09:01:31 EDT 2015


abhisek Mondal <abhisek.mndl at gmail.com> wrote:

>   I'm working with a 3D data-set aiming to best-fit the points in a 3D
> surface.
> So far, I have successfully fitted the surface using *scipy.linalg.lstsq*.

>   But, I would like to express the significance of the results in terms of
> R^2 value, which I'm not being able to perform with this particular
> function.


scipy.linalg.lstsq is a linear algebra solver, it is basically an interface
to the lapack *gelss subroutines. It does not do linear regression analysis
as such. (That is why it is not in scipy.stats.*)

If you want to fit a linear regression model and get all the diagnostics
and probablility computations, statsmodels is an excellent package. 

Apart from that, R2 is easy to compute: 

http://en.m.wikipedia.org/wiki/Coefficient_of_determination


Sturla




More information about the SciPy-User mailing list