computing r-squared?

hi all,

i managed to do linear regression on two vectors x, and y using linalg.lstsq. what i can’t figure out is how to compute the R-squared value - the correlation of the two vectors - in matplotlib. can someone please point me to the right function? thank you.

You should use numpy rather than matplotlib. R-squared is the square of the correlation coefficient, so

In [162]: c = np.corrcoef(x, y)[0,1]

In [163]: r2 = c**2

···

On Wed, Mar 4, 2009 at 10:54 AM, per freem <perfreem@…83…287…> wrote:

hi all,

i managed to do linear regression on two vectors x, and y using linalg.lstsq. what i can’t figure out is how to compute the R-squared value - the correlation of the two vectors - in matplotlib. can someone please point me to the right function? thank you.