coefficient of determination (R^2) on polyfit

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

coefficient of determination (R^2) on polyfit

Octave - General mailing list
Hey guys,

reading polyfit's help i wander how to calculate r-squared
(coefficient of determination).
Could u pls exemplify in a simple linear fit?

Thx!


Reply | Threaded
Open this post in threaded view
|

Re: coefficient of determination (R^2) on polyfit

Doug Stewart-4


On Mon, Dec 16, 2019 at 10:14 AM oxy via Help list for GNU Octave <[hidden email]> wrote:
Hey guys,

reading polyfit's help i wander how to calculate r-squared
(coefficient of determination).
Could u pls exemplify in a simple linear fit?

Thx!




x=[  1 2 3];
y=[2 3 5];
q=polyfit(x,y,1)
R=corr(x,y)
r2=R^2

this agrees  with a sample on



--
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: coefficient of determination (R^2) on polyfit

Nir Krakauer-3
or corr(q, y) to find the correlation between the fitted and original values.


Reply | Threaded
Open this post in threaded view
|

Re: coefficient of determination (R^2) on polyfit

Doug Stewart-4


On Mon, Dec 16, 2019 at 3:23 PM Nir Krakauer <[hidden email]> wrote:
or corr(q, y) to find the correlation between the fitted and original values.
@nir to do that you need:

x=[1 2 3];
y=[2 3 5];
[q s]=polyfit(x,y,1);
R=corr(x,y)
r2=R^2
yy=s.yf
RR=corr(y,yy)
plot(x,y,x,yy)

and RR is equal to R
  --
DASCertificate for 206392



Reply | Threaded
Open this post in threaded view
|

Re: coefficient of determination (R^2) on polyfit

Nir Krakauer-3
Yes, thanks for the correction.